import org.simantics.scenegraph.g2d.nodes.TransformNode;\r
\r
class SceneGraphManager {\r
- G2DSceneGraph sceneGraph;\r
- TransformNode diagramCoordinatesNode;\r
- G2DParentNode elementsNode;\r
- G2DParentNode selectionNode;\r
- G2DParentNode actionNode;\r
- \r
- public SceneGraphManager(JComponent rootPane) {\r
- sceneGraph = new G2DSceneGraph();\r
- //sceneGraph.setRootPane(rootPane);\r
- diagramCoordinatesNode = sceneGraph.addNode(TransformNode.class);\r
- \r
- PageBorderNode border = diagramCoordinatesNode.addNode(PageBorderNode.class);\r
- border.init(new Rectangle2D.Double(0.0, 0.0, 297.0, 210.0), Boolean.TRUE);\r
- \r
- elementsNode = diagramCoordinatesNode.addNode(G2DParentNode.class);\r
- elementsNode.setZIndex(0);\r
- \r
- selectionNode = diagramCoordinatesNode.addNode(G2DParentNode.class);\r
- selectionNode.setZIndex(1);\r
- \r
- actionNode = diagramCoordinatesNode.addNode(G2DParentNode.class);\r
- actionNode.setZIndex(2);\r
- }\r
- \r
- void setViewTransform(AffineTransform viewTransform) {\r
- diagramCoordinatesNode.setTransform(viewTransform);\r
- }\r
+ G2DSceneGraph sceneGraph;\r
+ TransformNode diagramCoordinatesNode;\r
+ G2DParentNode elementsNode;\r
+ G2DParentNode selectionNode;\r
+ G2DParentNode actionNode;\r
+\r
+ public SceneGraphManager(JComponent rootPane) {\r
+ sceneGraph = new G2DSceneGraph();\r
+ //sceneGraph.setRootPane(rootPane);\r
+ diagramCoordinatesNode = sceneGraph.addNode(TransformNode.class);\r
+\r
+ PageBorderNode border = diagramCoordinatesNode.addNode(PageBorderNode.class);\r
+ border.init(new Rectangle2D.Double(0.0, 0.0, 297.0, 210.0), new Rectangle2D.Double(10.0, 10.0, 277.0, 190.0), Boolean.TRUE);\r
+\r
+ elementsNode = diagramCoordinatesNode.addNode(G2DParentNode.class);\r
+ elementsNode.setZIndex(0);\r
+\r
+ selectionNode = diagramCoordinatesNode.addNode(G2DParentNode.class);\r
+ selectionNode.setZIndex(1);\r
+\r
+ actionNode = diagramCoordinatesNode.addNode(G2DParentNode.class);\r
+ actionNode.setZIndex(2);\r
+ }\r
+\r
+ void setViewTransform(AffineTransform viewTransform) {\r
+ diagramCoordinatesNode.setTransform(viewTransform);\r
+ }\r
}\r
package org.simantics.h2d.node;
-import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Shape;
public class FilledShapeNode extends G2DNode {
- private static final long serialVersionUID = -7540487222025677413L;
-
- protected Shape shape = null;
+ private static final long serialVersionUID = -7540487222025677413L;
+
+ protected Shape shape = null;
protected Color color = Color.BLACK;
@SyncField("shape")
public void setShape(Shape shape) {
this.shape = shape;
}
-
+
@SyncField("color")
public void setColor(Color color) {
this.color = color;
public void render(Graphics2D g2d) {
if(shape == null) return;
if(color != null) g2d.setColor(color);
-
+
g2d.fill(shape);
}
@Override
- public Rectangle2D getBounds() {
+ public Rectangle2D getBoundsInLocal() {
return shape.getBounds2D();
}
-
+
}