From 2cccdfa0ce7351b2a285ae6ee437642f79fb852e Mon Sep 17 00:00:00 2001 From: lehtonen Date: Wed, 30 Dec 2009 23:28:10 +0000 Subject: [PATCH] Adapt to org.simantics.scenegraph changes. git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@13371 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../h2d/editor/impl/SceneGraphManager.java | 54 +++++++++---------- .../simantics/h2d/node/FilledShapeNode.java | 15 +++--- .../src/org/simantics/h2d/node/LineNode.java | 2 +- .../org/simantics/h2d/node/RectangleNode.java | 2 +- .../src/org/simantics/h2d/node/ShapeNode.java | 2 +- .../src/org/simantics/h2d/node/TextNode.java | 2 +- 6 files changed, 38 insertions(+), 39 deletions(-) diff --git a/org.simantics.h2d/src/org/simantics/h2d/editor/impl/SceneGraphManager.java b/org.simantics.h2d/src/org/simantics/h2d/editor/impl/SceneGraphManager.java index 1a67333a..1f9f2cc3 100644 --- a/org.simantics.h2d/src/org/simantics/h2d/editor/impl/SceneGraphManager.java +++ b/org.simantics.h2d/src/org/simantics/h2d/editor/impl/SceneGraphManager.java @@ -11,31 +11,31 @@ import org.simantics.scenegraph.g2d.nodes.PageBorderNode; import org.simantics.scenegraph.g2d.nodes.TransformNode; class SceneGraphManager { - G2DSceneGraph sceneGraph; - TransformNode diagramCoordinatesNode; - G2DParentNode elementsNode; - G2DParentNode selectionNode; - G2DParentNode actionNode; - - public SceneGraphManager(JComponent rootPane) { - sceneGraph = new G2DSceneGraph(); - //sceneGraph.setRootPane(rootPane); - diagramCoordinatesNode = sceneGraph.addNode(TransformNode.class); - - PageBorderNode border = diagramCoordinatesNode.addNode(PageBorderNode.class); - border.init(new Rectangle2D.Double(0.0, 0.0, 297.0, 210.0), Boolean.TRUE); - - elementsNode = diagramCoordinatesNode.addNode(G2DParentNode.class); - elementsNode.setZIndex(0); - - selectionNode = diagramCoordinatesNode.addNode(G2DParentNode.class); - selectionNode.setZIndex(1); - - actionNode = diagramCoordinatesNode.addNode(G2DParentNode.class); - actionNode.setZIndex(2); - } - - void setViewTransform(AffineTransform viewTransform) { - diagramCoordinatesNode.setTransform(viewTransform); - } + G2DSceneGraph sceneGraph; + TransformNode diagramCoordinatesNode; + G2DParentNode elementsNode; + G2DParentNode selectionNode; + G2DParentNode actionNode; + + public SceneGraphManager(JComponent rootPane) { + sceneGraph = new G2DSceneGraph(); + //sceneGraph.setRootPane(rootPane); + diagramCoordinatesNode = sceneGraph.addNode(TransformNode.class); + + PageBorderNode border = diagramCoordinatesNode.addNode(PageBorderNode.class); + 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); + + elementsNode = diagramCoordinatesNode.addNode(G2DParentNode.class); + elementsNode.setZIndex(0); + + selectionNode = diagramCoordinatesNode.addNode(G2DParentNode.class); + selectionNode.setZIndex(1); + + actionNode = diagramCoordinatesNode.addNode(G2DParentNode.class); + actionNode.setZIndex(2); + } + + void setViewTransform(AffineTransform viewTransform) { + diagramCoordinatesNode.setTransform(viewTransform); + } } diff --git a/org.simantics.h2d/src/org/simantics/h2d/node/FilledShapeNode.java b/org.simantics.h2d/src/org/simantics/h2d/node/FilledShapeNode.java index 687c8478..e3d33667 100644 --- a/org.simantics.h2d/src/org/simantics/h2d/node/FilledShapeNode.java +++ b/org.simantics.h2d/src/org/simantics/h2d/node/FilledShapeNode.java @@ -1,6 +1,5 @@ package org.simantics.h2d.node; -import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Shape; @@ -10,16 +9,16 @@ import org.simantics.scenegraph.g2d.G2DNode; 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; @@ -29,13 +28,13 @@ public class FilledShapeNode extends G2DNode { 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(); } - + } diff --git a/org.simantics.h2d/src/org/simantics/h2d/node/LineNode.java b/org.simantics.h2d/src/org/simantics/h2d/node/LineNode.java index 3f608f56..c09ec93b 100644 --- a/org.simantics.h2d/src/org/simantics/h2d/node/LineNode.java +++ b/org.simantics.h2d/src/org/simantics/h2d/node/LineNode.java @@ -40,7 +40,7 @@ public class LineNode extends G2DNode { } @Override - public Rectangle2D getBounds() { + public Rectangle2D getBoundsInLocal() { Rectangle2D bounds = new Rectangle2D.Double(); bounds.setFrameFromDiagonal(begin, end); return bounds; diff --git a/org.simantics.h2d/src/org/simantics/h2d/node/RectangleNode.java b/org.simantics.h2d/src/org/simantics/h2d/node/RectangleNode.java index 5f91df72..d621d9c1 100644 --- a/org.simantics.h2d/src/org/simantics/h2d/node/RectangleNode.java +++ b/org.simantics.h2d/src/org/simantics/h2d/node/RectangleNode.java @@ -29,7 +29,7 @@ public class RectangleNode extends G2DNode { } @Override - public Rectangle2D getBounds() { + public Rectangle2D getBoundsInLocal() { return bounds; } diff --git a/org.simantics.h2d/src/org/simantics/h2d/node/ShapeNode.java b/org.simantics.h2d/src/org/simantics/h2d/node/ShapeNode.java index ba8f13b4..d5af4762 100644 --- a/org.simantics.h2d/src/org/simantics/h2d/node/ShapeNode.java +++ b/org.simantics.h2d/src/org/simantics/h2d/node/ShapeNode.java @@ -86,7 +86,7 @@ public class ShapeNode extends G2DNode { } @Override - public Rectangle2D getBounds() { + public Rectangle2D getBoundsInLocal() { return shape.getBounds2D(); } } diff --git a/org.simantics.h2d/src/org/simantics/h2d/node/TextNode.java b/org.simantics.h2d/src/org/simantics/h2d/node/TextNode.java index 8c3ed909..559e6e4d 100644 --- a/org.simantics.h2d/src/org/simantics/h2d/node/TextNode.java +++ b/org.simantics.h2d/src/org/simantics/h2d/node/TextNode.java @@ -237,7 +237,7 @@ public class TextNode extends G2DNode { } @Override - public Rectangle2D getBounds() { + public Rectangle2D getBoundsInLocal() { return null; } -- 2.47.1