]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Some fixes for platform for district simantics private/jsimomaa-district
authorjsimomaa <jani.simomaa@gmail.com>
Fri, 28 Apr 2017 13:06:58 +0000 (16:06 +0300)
committerjsimomaa <jani.simomaa@gmail.com>
Fri, 28 Apr 2017 13:32:16 +0000 (16:32 +0300)
Change-Id: I3851e2ea3a50a9bc55f3952d2acdea3f4f8eb5dd

bundles/org.simantics.g2d/src/org/simantics/g2d/participant/RulerPainter.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewer.java
bundles/org.simantics.platform.ui.ontology/graph/PlatformUIViews.pgraph
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/RulerNode.java

index e4f90791e2123b8fa1c01bf1566ae82de90ac0f7..74a5f358674009cc44b2ae52ef731c6e579a9997 100644 (file)
@@ -102,11 +102,15 @@ public class RulerPainter extends AbstractCanvasParticipant {
 
     @SGInit
     public void initSG(G2DParentNode parent) {
-        node = parent.addNode("ruler", RulerNode.class);
+        node = parent.addNode("ruler", getNodeClass());
         node.setZIndex(PAINT_PRIORITY);
         updateNode();
     }
 
+    protected Class<? extends RulerNode> getNodeClass() {
+        return RulerNode.class;
+    }
+
     @SGCleanup
     public void cleanupSG() {
         node.remove();
index b5381917d4b8acd3dd2e03f571b8a334d273e6de..1762dea7f6108d34b0a265731387adc9325cb002 100644 (file)
@@ -727,9 +727,7 @@ public class DiagramViewer
         addKeyBindingParticipants(ctx);
 
         // Grid & Ruler & Background
-        ctx.add(new GridPainter());
-        ctx.add(new RulerPainter());
-        ctx.add(new BackgroundPainter());
+        addGridRulerBackgroundParticipants(ctx);
 
         h.setHint(Hints.KEY_DISPLAY_PAGE, diagramPreferences.get(DiagramPreferences.P_DISPLAY_PAGE_SIZE));
         h.setHint(Hints.KEY_DISPLAY_MARGINS, diagramPreferences.get(DiagramPreferences.P_DISPLAY_MARGINS));
@@ -776,6 +774,12 @@ public class DiagramViewer
         ctx.setLocked(false);
     }
 
+    protected void addGridRulerBackgroundParticipants(CanvasContext ctx) {
+        ctx.add(new GridPainter());
+        ctx.add(new RulerPainter());
+        ctx.add(new BackgroundPainter());
+    }
+
     protected void loadPageSettings(ICanvasContext ctx) {
         DiagramDesc diagramDesc = null;
 
index f14f769020d7c39a13a9af13bad54158e758b1b6..1d62340f7a3800de66e8ec5445f2c29107fcaac2 100644 (file)
@@ -101,7 +101,7 @@ VIEWS.SharedLibraryContribution : SWT.TypedVariableTabContribution
 
 //VIEWS.SharedLibraryContribution2 : SWT.TypedVariableTabContribution
 //    SEL.AbstractVariableTabContribution.HasPriority 1
-//    SEL.AbstractTypedVariableTabContribution.HasType L0.SharedOntology
+//    SEL.AbstractTypedTabContribution.HasType L0.SharedOntology
 //    SWT.TypedVariableTabContribution.HasView SharedLibraries
 //    L0.HasLabel "Shared Libraries"
 
index f7e0d1e5c6b5cb05d280b9a5ae514758723b2370..daec9e55e2a80c1143426228c098572ad206f89f 100644 (file)
@@ -109,7 +109,9 @@ public class RulerNode extends G2DNode {
         // Vertical ruler
         for(double x = offsetX%stepX-stepX; x < bounds.getMaxX(); x+=stepX) {
             if(x > 20) {
-                String str = formatValue((x-offsetX)/scaleX);
+                double val = (x-offsetX)/scaleX;
+                double modifiedValue = modifyHorizontalValue(val);
+                String str = formatValue(modifiedValue);
                 FontMetrics fm = g.getFontMetrics();
                 Rectangle2D r = fm.getStringBounds(str, g);
                 if((x-r.getWidth()/2) > previousText) {
@@ -141,9 +143,8 @@ public class RulerNode extends G2DNode {
         for(double y = offsetY%stepY-stepY; y < bounds.getMaxY(); y+=stepY) {
             if(y > 20) {
                 double val = (y-offsetY)/scaleY;
-                if (MAP_Y_SCALING)
-                    val = Math.toDegrees(Math.atan(Math.sinh(Math.toRadians(val))));
-                String str = formatValue(val);
+                double modifiedValue = modifyVerticalValue(val);
+                String str = formatValue(modifiedValue);
                 FontMetrics fm = g.getFontMetrics();
                 Rectangle2D r = fm.getStringBounds(str, g);
                 if(y-1+r.getHeight()/2 > previousText) {
@@ -175,6 +176,26 @@ public class RulerNode extends G2DNode {
         g.setTransform(tr);
     }
 
+    /**
+     * A method for subclasses to alter the actual X-value of the ruler 
+     * 
+     * @param value
+     * @return possibly modified X-value 
+     */
+    protected double modifyHorizontalValue(double value) {
+        return value;
+    }
+
+    /**
+     * A method for subclasses to alter the actual Y-value of the ruler 
+     * 
+     * @param value
+     * @return possibly modified Y-value 
+     */
+    protected double modifyVerticalValue(double value) {
+        return value;
+    }
+
     private static final transient int    MAX_DIGITS = 5;
     private static final transient double EPSILON    = 0.01;
     private static final transient double TRIM_THRESHOLD_MAX_VALUE = Math.pow(10, 4);