]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.maps/src/org/simantics/maps/eclipse/MapPainter.java
Some cleaning and fixing of district functionalities
[simantics/district.git] / org.simantics.district.maps / src / org / simantics / maps / eclipse / MapPainter.java
index 3c4a9944fd628a95d979722b7fd2ee62267b9966..ee0c71a6cb54b8767a0aa7acba8ab26decd108c6 100644 (file)
  *******************************************************************************/
 package org.simantics.maps.eclipse;
 
+import java.awt.geom.AffineTransform;
+
 import org.simantics.g2d.canvas.Hints;
 import org.simantics.g2d.canvas.ICanvasContext;
 import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;
 import org.simantics.g2d.canvas.impl.SGNodeReflection.SGCleanup;
 import org.simantics.g2d.canvas.impl.SGNodeReflection.SGInit;
 import org.simantics.maps.sg.MapNode;
+import org.simantics.maps.sg.MapScaleNode;
 import org.simantics.scenegraph.g2d.G2DParentNode;
 import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler;
 import org.simantics.scenegraph.g2d.events.command.CommandEvent;
@@ -57,11 +60,12 @@ public class MapPainter extends AbstractCanvasParticipant {
     };
 
     protected MapNode node = null;
+    protected MapScaleNode scaleNode = null;
 
-    private int scale;
+    private AffineTransform transform;
 
-    public MapPainter(int scale) {
-        this.scale = scale;
+    public MapPainter(AffineTransform transform) {
+        this.transform = transform;
     }
 
     @Override
@@ -100,9 +104,14 @@ public class MapPainter extends AbstractCanvasParticipant {
     @SGInit
     public void initSG(G2DParentNode parent) {
         node = parent.addNode("map", MapNode.class);
-        node.setScale(scale);
+        node.setTransform(transform);
         node.setEnabled(true);
         node.setZIndex(Integer.MIN_VALUE + 999); // Just under the grid
+        
+        scaleNode = parent.addNode("mapScale", MapScaleNode.class);
+        scaleNode.setTransform(transform);
+        scaleNode.setEnabled(true);
+        scaleNode.setZIndex(Integer.MAX_VALUE - 999); // Just under the grid
     }
 
     @SGCleanup