]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Some more fixes to platform for district platform-district-5-2017
authorjsimomaa <jani.simomaa@gmail.com>
Mon, 12 Jun 2017 05:15:35 +0000 (08:15 +0300)
committerjsimomaa <jani.simomaa@gmail.com>
Tue, 13 Jun 2017 05:31:24 +0000 (08:31 +0300)
Change-Id: Ifd718c20d5a98806e93c365b45ce3bdd003b4118

bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java
bundles/org.simantics.g2d/src/org/simantics/g2d/participant/RulerPainter.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/RulerNode.java

index d69ef69c69fadec257a3e07e2fc31a600cd5ed15..eb9e33607d5500197cc7c4fd8d0c061036d835c3 100644 (file)
@@ -1012,8 +1012,9 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos
         Shape shape = ElementUtils.getElementShapeOrBounds(e);
         Rectangle2D bounds = shape.getBounds2D();
         //System.out.println("selection bounds: "+bounds);
-        final double margin = 1;
-        bounds.setFrame(bounds.getMinX() - margin, bounds.getMinY() - margin, bounds.getWidth() + 2*margin, bounds.getHeight() + 2*margin);
+        final double marginX = 1 / selectionTransform.getScaleX();
+        final double marginY = 1 / selectionTransform.getScaleY();
+        bounds.setFrame(bounds.getMinX() - marginX, bounds.getMinY() - marginY, bounds.getWidth() + 2*marginX, bounds.getHeight() + 2*marginY);
 
         List<SelectionSpecification> ss = e.getElementClass().getItemsByClass(SelectionSpecification.class);
         if (!ss.isEmpty()) {
index 74a5f358674009cc44b2ae52ef731c6e579a9997..bffe0c9df4862a160f95ac0e61610dffb1d2a1e1 100644 (file)
@@ -116,7 +116,7 @@ public class RulerPainter extends AbstractCanvasParticipant {
         node.remove();
     }
 
-    void updateNode() {
+    protected void updateNode() {
         node.setEnabled(isPaintingEnabled());
         node.setGridSize(getGridSize());
     }
index daec9e55e2a80c1143426228c098572ad206f89f..27c1c1fd2bae4c1d2469ea24af1d0259647b152c 100644 (file)
@@ -57,7 +57,7 @@ public class RulerNode extends G2DNode {
     public void render(Graphics2D g) {
         if (!enabled)
             return;
-
+        
         AffineTransform tr = g.getTransform();
         double scaleX = Math.abs(tr.getScaleX());
         double scaleY = Math.abs(tr.getScaleY());
@@ -109,7 +109,7 @@ public class RulerNode extends G2DNode {
         // Vertical ruler
         for(double x = offsetX%stepX-stepX; x < bounds.getMaxX(); x+=stepX) {
             if(x > 20) {
-                double val = (x-offsetX)/scaleX;
+                double val = (x-offsetX)/scaleX / getTransform().getScaleX();
                 double modifiedValue = modifyHorizontalValue(val);
                 String str = formatValue(modifiedValue);
                 FontMetrics fm = g.getFontMetrics();
@@ -142,7 +142,7 @@ public class RulerNode extends G2DNode {
         previousText = -100;
         for(double y = offsetY%stepY-stepY; y < bounds.getMaxY(); y+=stepY) {
             if(y > 20) {
-                double val = (y-offsetY)/scaleY;
+                double val = (y-offsetY)/scaleY / getTransform().getScaleY();
                 double modifiedValue = modifyVerticalValue(val);
                 String str = formatValue(modifiedValue);
                 FontMetrics fm = g.getFontMetrics();