KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > figures > FreeformLayer


1 /**
2  * <p> Project: com.nightlabs.editor2d </p>
3  * <p> Copyright: Copyright (c) 2004 </p>
4  * <p> Company: NightLabs GmbH (Germany) </p>
5  * <p> Creation Date: 19.05.2005 </p>
6  * <p> Author: Daniel Mazurek </p>
7  **/

8 package com.nightlabs.editor2d.figures;
9
10 import java.awt.Graphics2D JavaDoc;
11
12 import org.eclipse.draw2d.Graphics;
13 import org.eclipse.draw2d.J2DGraphics;
14 import org.eclipse.gef.EditPart;
15
16 import com.nightlabs.editor2d.DrawComponent;
17 import com.nightlabs.editor2d.render.Renderer;
18
19
20 public class FreeformLayer
21 extends OversizedBufferFreeformLayer
22 implements RendererFigure
23 {
24     /**
25      * @param editPart
26      */

27     public FreeformLayer() {
28         super();
29     }
30     
31     protected J2DGraphics j2d;
32     protected Graphics2D JavaDoc g2d;
33     public void paint(Graphics graphics)
34     {
35         if (graphics instanceof J2DGraphics) {
36             j2d = (J2DGraphics) graphics;
37             g2d = j2d.createGraphics2D();
38             g2d.setClip(null);
39             renderer.paint(drawComponent, g2d);
40             g2d.dispose();
41         }
42         paintChildren(graphics);
43         // super.paint(graphics);
44
}
45     
46     protected Renderer renderer;
47     public void setRenderer(Renderer renderer) {
48         this.renderer = renderer;
49     }
50     
51     protected DrawComponent drawComponent;
52     public void setDrawComponent(DrawComponent drawComponent) {
53         this.drawComponent = drawComponent;
54     }
55     
56     /**
57      * @see com.nightlabs.editor2d.figures.RendererFigure#paint(java.awt.Graphics2D)
58      */

59     public void paint(Graphics2D JavaDoc graphics) {
60         if (renderer != null && drawComponent != null)
61             renderer.paint(drawComponent, graphics);
62     }
63     
64     // public boolean intersects(Rectangle rect)
65
// {
66
// return super.intersects(rect);
67
// }
68
//
69
// protected Rectangle childrenBounds = new Rectangle(0,0,0,0);
70
// protected Rectangle getChildenBounds()
71
// {
72
// for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
73
// IFigure child = (IFigure) iter.next();
74
// Rectangle childBounds = child.getBounds();
75
// childrenBounds.getUnion(childBounds);
76
// }
77
// return childrenBounds;
78
// }
79
//
80
// public Rectangle getBounds() {
81
// return getChildenBounds();
82
// }
83
}
84
Popular Tags