]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoNode.java
Fixed most warnings from district codebase after JavaSE-11 switch
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / nodes / DistrictNetworkStaticInfoNode.java
index 4ce35a27344450de02942cf3607036829f64f20c..a8544a9b1858032e85c293a8f6e62fe1260abda6 100644 (file)
@@ -9,7 +9,6 @@ import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
 
-import org.simantics.district.network.ui.styles.DistrictNetworkStaticInfoStyle;
 import org.simantics.scenegraph.ParentNode;
 import org.simantics.scenegraph.g2d.G2DNode;
 import org.simantics.scenegraph.g2d.nodes.spatial.RTreeNode;
@@ -22,13 +21,13 @@ public class DistrictNetworkStaticInfoNode extends G2DNode implements DeferredNo
 
        private static final Font FONT = new Font(Font.SANS_SERIF, Font.PLAIN, DPIUtil.upscale(10));
 
-       private static final Point2D UNIT_X = new Point2D.Double(1.0, 0.0);
-
        public static final String NODE_KEY = "DISTRICT_NETWORK_STATIC_INFO";
 
+       public static final String STATIC_INFO_DEFERRED = "staticInfo";
+
        String info = null;
        Point2D origin = new Point2D.Double();
-       Point2D direction = UNIT_X;
+       Point2D direction = new Point2D.Double();
 
        private DistrictNetworkEdgeNode edgeNode = null;
 
@@ -37,7 +36,7 @@ public class DistrictNetworkStaticInfoNode extends G2DNode implements DeferredNo
        @Override
        public void render(Graphics2D g) {
                ParentNode<?> root = (ParentNode<?>) NodeUtil.getNearestParentOfType(this, RTreeNode.class);
-               DeferredRenderingNode deferred = root != null ? (DeferredRenderingNode) root.getNode(DistrictNetworkStaticInfoStyle.STATIC_INFO_DEFERRED) : null;
+               DeferredRenderingNode deferred = root != null ? (DeferredRenderingNode) root.getNode(STATIC_INFO_DEFERRED) : null;
                if (deferred != null)
                        deferred.deferNode(g.getTransform(), this);
                else
@@ -86,7 +85,7 @@ public class DistrictNetworkStaticInfoNode extends G2DNode implements DeferredNo
                int ascent = fm.getMaxAscent();
 
                g.transform(AffineTransform.getRotateInstance(direction.getX(), direction.getY()));
-               g.translate(0, ascent);
+               g.translate(0, ascent+2);
 
 //             int height = fm.getHeight();
 //             g.setColor(Color.WHITE);
@@ -103,8 +102,8 @@ public class DistrictNetworkStaticInfoNode extends G2DNode implements DeferredNo
        }
 
        public void setLocation(Point2D origin, Point2D direction) {
-               this.origin = origin;
-               this.direction = direction;
+               this.origin.setLocation(origin);
+               this.direction.setLocation(direction);
        }
 
        public void setInfo(String info) {
@@ -113,5 +112,7 @@ public class DistrictNetworkStaticInfoNode extends G2DNode implements DeferredNo
 
        public void setEdgeNode(DistrictNetworkEdgeNode n) {
                this.edgeNode = n;
+               // Ensure that origin/location are recalculated
+               prevZoomLevel = -1;
        }
 }