From 58b47703830a334d4c2d91576fba3e36972b677d Mon Sep 17 00:00:00 2001 From: lehtonen Date: Thu, 2 Dec 2010 16:29:23 +0000 Subject: [PATCH] Added memory consumption FIXMEs for sysdyn scene graph nodes git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@18919 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/ui/elements2/connections/DependencyNode.java | 9 ++++++--- .../sysdyn/ui/elements2/connections/FlowNode.java | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyNode.java index 844192e5..988b0001 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyNode.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyNode.java @@ -33,6 +33,8 @@ public class DependencyNode extends G2DNode implements ISelectionPainterNode { private static final long serialVersionUID = 1294351381209071074L; + private static final BasicStroke STROKE = new BasicStroke(1.0f); + private Color color; private Stroke stroke; private Rectangle2D beginBounds; @@ -42,7 +44,7 @@ public class DependencyNode extends G2DNode implements ISelectionPainterNode { transient public boolean hover = false; private transient PropertyChangeListener fieldListener = null; - + public void setFieldListener(PropertyChangeListener listener) { this.fieldListener = listener; } @@ -111,12 +113,13 @@ public class DependencyNode extends G2DNode implements ISelectionPainterNode { // NICENESS g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + // FIXME: optimize memory allocations Pair shapes = Dependencies.createArrowShape(beginBounds, endBounds, angle); boolean selected = NodeUtil.isSelected(this, 2); if(selected) { g.setColor(Color.PINK); - g.setStroke(new BasicStroke(1.0f)); + g.setStroke(STROKE); g.draw(shapes.first); g.fill(shapes.second); if(color != null) g.setColor(color); @@ -125,7 +128,7 @@ public class DependencyNode extends G2DNode implements ISelectionPainterNode { g.fill(shapes.second); } else if (hover){ g.setColor(Color.LIGHT_GRAY); - g.setStroke(new BasicStroke(1.0f)); + g.setStroke(STROKE); g.draw(shapes.first); g.fill(shapes.second); if(color != null) g.setColor(color); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/FlowNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/FlowNode.java index b44cacf7..23bace0b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/FlowNode.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/FlowNode.java @@ -27,7 +27,9 @@ import org.simantics.utils.datastructures.Pair; public class FlowNode extends G2DNode implements ISelectionPainterNode { private static final long serialVersionUID = 328942356917631237L; - + + private static final BasicStroke STROKE = new BasicStroke(1.0f); + private Color color; private Stroke stroke; private Rectangle2D beginBounds; @@ -103,10 +105,12 @@ public class FlowNode extends G2DNode implements ISelectionPainterNode { if(toValve) { + // FIXME: optimize memory allocations lines = Flows.createLines(false, endBounds, beginBounds); } else { + // FIXME: optimize memory allocations lines = Flows.createLines(true, beginBounds, endBounds); arrow = Flows.createArrow(beginBounds, endBounds); @@ -115,7 +119,7 @@ public class FlowNode extends G2DNode implements ISelectionPainterNode { boolean selected = NodeUtil.isSelected(this, 2); if(selected) { g.setColor(Color.PINK); - g.setStroke(new BasicStroke(1.0f)); + g.setStroke(STROKE); g.draw(lines.first); g.draw(lines.second); if(color != null) g.setColor(color); -- 2.47.1