From f472708c61928951284317defe74410a952b299b Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Mon, 12 Jun 2017 08:15:35 +0300 Subject: [PATCH] Some more fixes to platform for district Change-Id: Ifd718c20d5a98806e93c365b45ce3bdd003b4118 --- .../simantics/g2d/diagram/participant/ElementPainter.java | 5 +++-- .../src/org/simantics/g2d/participant/RulerPainter.java | 2 +- .../src/org/simantics/scenegraph/g2d/nodes/RulerNode.java | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java index d69ef69c6..eb9e33607 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java @@ -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 ss = e.getElementClass().getItemsByClass(SelectionSpecification.class); if (!ss.isEmpty()) { diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/RulerPainter.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/RulerPainter.java index 74a5f3586..bffe0c9df 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/RulerPainter.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/RulerPainter.java @@ -116,7 +116,7 @@ public class RulerPainter extends AbstractCanvasParticipant { node.remove(); } - void updateNode() { + protected void updateNode() { node.setEnabled(isPaintingEnabled()); node.setGridSize(getGridSize()); } diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/RulerNode.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/RulerNode.java index daec9e55e..27c1c1fd2 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/RulerNode.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/RulerNode.java @@ -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(); -- 2.47.1