]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Implement district features to Simantics platform 67/267/1
authorjsimomaa <jani.simomaa@gmail.com>
Fri, 13 Jan 2017 13:19:53 +0000 (15:19 +0200)
committerjsimomaa <jani.simomaa@gmail.com>
Fri, 13 Jan 2017 13:19:53 +0000 (15:19 +0200)
* Fix picking to pick vertex before edge
* Do not create new vertices if one already exists (need to configure
the picking threshold though)
* Add visual aids to drawing before the drawing is persisted to db

Change-Id: I7e1a59e032fcd47f75bd576c96ea3214ba172969

org.simantics.district.network.ui/META-INF/MANIFEST.MF
org.simantics.district.network.ui/src/org/simantics/district/network/ui/DNEdgeBuilder.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/DistrictDiagramViewer.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkVertexNode.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/NetworkDrawingNode.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/participants/DNPointerInteractor.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/participants/DNTranslateMode.java
org.simantics.district.ui.feature/feature.xml

index 267a0dd0a29d06b828200a8423bbfe3042e618b5..1a7ea47d3a5ac75d68edf66e00e3c9e9f98e3866 100644 (file)
@@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.e4.ui.model.workbench;bundle-version="1.1.100.v20150
  org.simantics.district.network.ontology,
  org.simantics.utils.datastructures,
  org.simantics.district.network;bundle-version="1.0.0",
- org.simantics.layer0.utils
+ org.simantics.layer0.utils,
+ org.simantics.district.maps
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Export-Package: org.simantics.district.network.ui.adapters
 Bundle-ActivationPolicy: lazy
index b9b73e542308882d51f0b2c0c925bcedd128f5c6..687ca337b85689f6dd749fcba1fbfde04a9bec7b 100644 (file)
@@ -1,80 +1,93 @@
-package org.simantics.district.network.ui;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.exception.ServiceException;\r
-import org.simantics.db.layer0.util.Layer0Utils;\r
-import org.simantics.diagram.synchronization.IModifiableSynchronizationContext;\r
-import org.simantics.diagram.synchronization.SynchronizationHints;\r
-import org.simantics.diagram.synchronization.graph.AddElement;\r
-import org.simantics.diagram.synchronization.graph.GraphSynchronizationHints;\r
-import org.simantics.diagram.synchronization.graph.layer.GraphLayer;\r
-import org.simantics.diagram.synchronization.graph.layer.GraphLayerManager;\r
-import org.simantics.diagram.ui.DiagramModelHints;\r
-import org.simantics.district.network.DistrictNetworkUtil;\r
-import org.simantics.district.network.ontology.DistrictNetworkResource;\r
-import org.simantics.g2d.diagram.IDiagram;\r
-\r
-public class DNEdgeBuilder {\r
-    \r
-    private Resource diagramResource;\r
-    private IDiagram diagram;\r
-    private GraphLayerManager glm;\r
-\r
-    public DNEdgeBuilder(Resource diagramResource, IDiagram diagram) {\r
-        this.diagramResource = diagramResource;\r
-        this.diagram = diagram;\r
-        \r
-        IModifiableSynchronizationContext context = diagram.getHint(SynchronizationHints.CONTEXT);\r
-        glm = context.get(GraphSynchronizationHints.GRAPH_LAYER_MANAGER);\r
-    }\r
-\r
-    public void create(WriteGraph graph, double[] start, double[] end) throws DatabaseException {\r
-        \r
-        DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);\r
-        \r
-        // 1. Get diagram edge to construct\r
-        Resource edge = getOrCreateEdge(graph);\r
-        \r
-        // 1.1 Give running name to connection and increment the counter attached to the diagram.\r
-        AddElement.claimFreshElementName(graph, diagramResource, edge);\r
-        \r
-        // 2. Add vertices\r
-        Resource startVertex = getOrCreateVertex(graph, start);\r
-        Resource endVertex = getOrCreateVertex(graph, end);\r
-        \r
-        graph.claim(edge, DN.HasStartVertex, startVertex);\r
-        graph.claim(edge, DN.HasEndVertex, endVertex);\r
-        \r
-        // 7. Put the element on all the currently active layers if possible.\r
-        if (glm != null) {\r
-            putOnActiveLayer(graph, edge);\r
-            putOnActiveLayer(graph, startVertex);\r
-            putOnActiveLayer(graph, endVertex);\r
-        }\r
-        \r
-        Layer0Utils.addCommentMetadata(graph, "Added edge " + edge);\r
-        graph.markUndoPoint();\r
-    }\r
-    \r
-    private void putOnActiveLayer(WriteGraph graph, Resource res) throws DatabaseException {\r
-        glm.removeFromAllLayers(graph, res);\r
-        glm.putElementOnVisibleLayers(diagram, graph, res);\r
-    }\r
-\r
-    private Resource getOrCreateVertex(WriteGraph graph, double[] coords) throws DatabaseException {\r
-        // TODO: check if vertex exists already, for now create always new\r
-        Resource vertex = null;\r
-        if (vertex == null) {\r
-            vertex = DistrictNetworkUtil.createVertex(graph, diagramResource, coords); \r
-            AddElement.claimFreshElementName(graph, diagramResource, vertex);\r
-        }\r
-        return vertex;\r
-    }\r
-\r
-    private Resource getOrCreateEdge(WriteGraph graph) throws DatabaseException {\r
-        return DistrictNetworkUtil.createEdge(graph, diagramResource);\r
-    }\r
-\r
-}\r
+package org.simantics.district.network.ui;
+
+import java.awt.geom.Rectangle2D;
+import java.util.Collection;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.ObjectsWithType;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.util.Layer0Utils;
+import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.diagram.synchronization.IModifiableSynchronizationContext;
+import org.simantics.diagram.synchronization.SynchronizationHints;
+import org.simantics.diagram.synchronization.graph.AddElement;
+import org.simantics.diagram.synchronization.graph.GraphSynchronizationHints;
+import org.simantics.diagram.synchronization.graph.layer.GraphLayerManager;
+import org.simantics.district.network.DistrictNetworkUtil;
+import org.simantics.district.network.ontology.DistrictNetworkResource;
+import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.layer0.Layer0;
+
+public class DNEdgeBuilder {
+    
+    private Resource diagramResource;
+    private IDiagram diagram;
+    private GraphLayerManager glm;
+
+    public DNEdgeBuilder(Resource diagramResource, IDiagram diagram) {
+        this.diagramResource = diagramResource;
+        this.diagram = diagram;
+        
+        IModifiableSynchronizationContext context = diagram.getHint(SynchronizationHints.CONTEXT);
+        glm = context.get(GraphSynchronizationHints.GRAPH_LAYER_MANAGER);
+    }
+
+    public void create(WriteGraph graph, double[] start, double[] end) throws DatabaseException {
+        
+        DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+        
+        // 1. Get diagram edge to construct
+        Resource edge = getOrCreateEdge(graph);
+        
+        // 1.1 Give running name to connection and increment the counter attached to the diagram.
+        AddElement.claimFreshElementName(graph, diagramResource, edge);
+        
+        // 2. Add vertices
+        Collection<Resource> vertices = graph.syncRequest(new ObjectsWithType(diagramResource, Layer0.getInstance(graph).ConsistsOf, DistrictNetworkResource.getInstance(graph).Vertex));
+        Resource startVertex = getOrCreateVertex(graph, vertices, start);
+        Resource endVertex = getOrCreateVertex(graph, vertices, end);
+        
+        graph.claim(edge, DN.HasStartVertex, startVertex);
+        graph.claim(edge, DN.HasEndVertex, endVertex);
+        
+        // 7. Put the element on all the currently active layers if possible.
+        if (glm != null) {
+            putOnActiveLayer(graph, edge);
+            putOnActiveLayer(graph, startVertex);
+            putOnActiveLayer(graph, endVertex);
+        }
+        
+        Layer0Utils.addCommentMetadata(graph, "Added edge " + edge);
+        graph.markUndoPoint();
+    }
+    
+    private void putOnActiveLayer(WriteGraph graph, Resource res) throws DatabaseException {
+        glm.removeFromAllLayers(graph, res);
+        glm.putElementOnVisibleLayers(diagram, graph, res);
+    }
+
+    private Resource getOrCreateVertex(WriteGraph graph, Collection<Resource> vertices, double[] coords) throws DatabaseException {
+        Resource vertex = null;
+        for (Resource vertx : vertices) {
+            double[] existingCoords = graph.getRelatedValue2(vertx, DiagramResource.getInstance(graph).HasLocation, Bindings.DOUBLE_ARRAY);
+            Rectangle2D existing = new Rectangle2D.Double(existingCoords[0], existingCoords[1], 1, 1);
+            Rectangle2D tobecreated = new Rectangle2D.Double(coords[0], coords[1], 1, 1);
+            if (existing.intersects(tobecreated)) {
+                vertex = vertx;
+                break;
+            }
+        }
+        if (vertex == null) {
+            vertex = DistrictNetworkUtil.createVertex(graph, diagramResource, coords); 
+            AddElement.claimFreshElementName(graph, diagramResource, vertex);
+        }
+        return vertex;
+    }
+
+    private Resource getOrCreateEdge(WriteGraph graph) throws DatabaseException {
+        return DistrictNetworkUtil.createEdge(graph, diagramResource);
+    }
+
+}
index 9acad52c4b6f11345c9f93767af4853996e7ac82..5155ccd2d54778c434f0d28d6c7462e929423d01 100644 (file)
@@ -1,32 +1,46 @@
-package org.simantics.district.network.ui;\r
-\r
-import java.util.concurrent.TimeUnit;\r
-\r
-import org.simantics.district.network.ui.participants.DNPointerInteractor;\r
-import org.simantics.g2d.canvas.ICanvasContext;\r
-import org.simantics.g2d.diagram.handler.PickRequest.PickFilter;\r
-import org.simantics.g2d.diagram.participant.DelayedBatchElementPainter;\r
-import org.simantics.g2d.diagram.participant.ElementPainter;\r
-import org.simantics.g2d.diagram.participant.Selection;\r
-import org.simantics.g2d.diagram.participant.ZOrderHandler;\r
-import org.simantics.g2d.participant.RenderingQualityInteractor;\r
-import org.simantics.modeling.ui.diagramEditor.DiagramViewer;\r
-\r
-public class DistrictDiagramViewer extends DiagramViewer {\r
-\r
-    @Override\r
-    protected void addDiagramParticipants(ICanvasContext ctx) {\r
-        ctx.add(new ZOrderHandler());\r
-        ctx.add(new Selection());\r
-        ctx.add(new ElementPainter());\r
-        ctx.add(new DNPointerInteractor());\r
-        \r
-        ctx.add(new NetworkDrawingParticipant());\r
-    }\r
-\r
-    @Override\r
-    protected void addPainterParticipants(ICanvasContext ctx) {\r
-        ctx.add(new RenderingQualityInteractor());\r
-        ctx.add(new DelayedBatchElementPainter(PickFilter.FILTER_MONITORS, 500, TimeUnit.MILLISECONDS));\r
-    }\r
-}\r
+package org.simantics.district.network.ui;
+
+import java.util.concurrent.TimeUnit;
+
+import org.simantics.district.network.ui.participants.DNPointerInteractor;
+import org.simantics.g2d.canvas.ICanvasContext;
+import org.simantics.g2d.canvas.impl.CanvasContext;
+import org.simantics.g2d.diagram.handler.PickRequest.PickFilter;
+import org.simantics.g2d.diagram.participant.DelayedBatchElementPainter;
+import org.simantics.g2d.diagram.participant.ElementPainter;
+import org.simantics.g2d.diagram.participant.Selection;
+import org.simantics.g2d.diagram.participant.ZOrderHandler;
+import org.simantics.g2d.participant.PanZoomRotateHandler;
+import org.simantics.g2d.participant.RenderingQualityInteractor;
+import org.simantics.maps.eclipse.MapPainter;
+import org.simantics.modeling.ui.diagramEditor.DiagramViewer;
+import org.simantics.utils.datastructures.hints.IHintContext;
+
+public class DistrictDiagramViewer extends DiagramViewer {
+
+    @Override
+    protected void addDiagramParticipants(ICanvasContext ctx) {
+        ctx.add(new ZOrderHandler());
+        ctx.add(new Selection());
+        ctx.add(new ElementPainter());
+        ctx.add(new DNPointerInteractor());
+        
+        ctx.add(new MapPainter(100000));
+        
+        ctx.add(new NetworkDrawingParticipant());
+    }
+    
+    @Override
+    public void initializeCanvasContext(CanvasContext ctx) {
+        super.initializeCanvasContext(ctx);
+        IHintContext h = ctx.getDefaultHintContext();
+        h.setHint(PanZoomRotateHandler.KEY_ZOOM_IN_LIMIT, 10000.0);
+        h.setHint(PanZoomRotateHandler.KEY_ZOOM_OUT_LIMIT, 0.01);
+    }
+
+    @Override
+    protected void addPainterParticipants(ICanvasContext ctx) {
+        ctx.add(new RenderingQualityInteractor());
+        ctx.add(new DelayedBatchElementPainter(PickFilter.FILTER_MONITORS, 500, TimeUnit.MILLISECONDS));
+    }
+}
index eb1d26eb7359c9983c1183804b93f758bd5261fd..4abeee8b8b8b013fa90da556494dfc0ecb445604 100644 (file)
-package org.simantics.district.network.ui.nodes;\r
-\r
-import java.awt.BasicStroke;\r
-import java.awt.Color;\r
-import java.awt.Graphics2D;\r
-import java.awt.RenderingHints;\r
-import java.awt.Shape;\r
-import java.awt.Stroke;\r
-import java.awt.geom.AffineTransform;\r
-import java.awt.geom.Path2D;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-import org.simantics.district.network.ui.DistrictNetworkEdge;\r
-import org.simantics.scenegraph.g2d.G2DNode;\r
-import org.simantics.scenegraph.utils.NodeUtil;\r
-\r
-public class DistrictNetworkEdgeNode extends G2DNode {\r
-\r
-    private static final long serialVersionUID = 8049769475036519806L;\r
-    \r
-    private static final Stroke     SELECTION_STROKE = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);\r
-    private static final Color      SELECTION_COLOR  = new Color(255, 0, 255, 96);\r
-    \r
-    private DistrictNetworkEdge edge;\r
-    private Rectangle2D bounds;\r
-\r
-    @Override\r
-    public void render(Graphics2D g2d) {\r
-        \r
-        AffineTransform ot = null;\r
-        AffineTransform t = getTransform();\r
-        if (t != null && !t.isIdentity()) {\r
-            ot = g2d.getTransform();\r
-            g2d.transform(getTransform());\r
-        }\r
-        \r
-        Object aaHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);\r
-        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);\r
-\r
-        Color oldColor = g2d.getColor();\r
-//        boolean selected = isSelected();\r
-//        if (selected) {\r
-//            Path2D selectionPath = edge.getPath();\r
-//            Shape selectionShape = SELECTION_STROKE.createStrokedShape(selectionPath);\r
-//            g2d.setColor(SELECTION_COLOR);\r
-//            g2d.fill(selectionShape);\r
-//        }\r
-//        \r
-        g2d.setColor(Color.BLUE);\r
-        // render\r
-        g2d.draw(edge.getPath());\r
-        \r
-        // Reset\r
-        g2d.setColor(oldColor);\r
-        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aaHint);\r
-        \r
-        if (ot != null)\r
-            g2d.setTransform(ot);\r
-    }\r
-\r
-    private boolean isSelected() {\r
-        return NodeUtil.isSelected(this, 1);\r
-    }\r
-\r
-    @Override\r
-    public Rectangle2D getBoundsInLocal() {\r
-        return bounds;\r
-    }\r
-    \r
-    private void updateBounds() {\r
-        Rectangle2D oldBounds = bounds;\r
-        if (oldBounds == null)\r
-            oldBounds = new Rectangle2D.Double();\r
-        bounds = calculateBounds(oldBounds);\r
-    }\r
-\r
-    private Rectangle2D calculateBounds(Rectangle2D rect) {\r
-        return edge.getBounds(rect);\r
-    }\r
-\r
-    public void setDNEdge(DistrictNetworkEdge edge) {\r
-        this.edge = edge;\r
-        updateBounds();\r
-    }\r
-\r
-}\r
+package org.simantics.district.network.ui.nodes;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.Stroke;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import org.simantics.district.network.ui.DistrictNetworkEdge;
+import org.simantics.scenegraph.g2d.G2DNode;
+import org.simantics.scenegraph.utils.GeometryUtils;
+import org.simantics.scenegraph.utils.NodeUtil;
+
+public class DistrictNetworkEdgeNode extends G2DNode {
+
+    private static final long serialVersionUID = 8049769475036519806L;
+    
+    private static final Stroke     SELECTION_STROKE = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
+    private static final Color      SELECTION_COLOR  = new Color(255, 0, 255, 96);
+    
+    private DistrictNetworkEdge edge;
+    private Rectangle2D bounds;
+    
+    private Stroke stroke = new BasicStroke(2);
+    private boolean scaleStroke = true;
+
+    @Override
+    public void init() {
+
+    }
+    
+    @Override
+    public void render(Graphics2D g2d) {
+        
+        AffineTransform ot = null;
+        AffineTransform t = getTransform();
+        if (t != null && !t.isIdentity()) {
+            ot = g2d.getTransform();
+            g2d.transform(getTransform());
+        }
+        
+        Object aaHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+
+        Color oldColor = g2d.getColor();
+        BasicStroke oldStroke = (BasicStroke) g2d.getStroke();
+//        boolean selected = isSelected();
+//        if (selected) {
+//            Path2D selectionPath = edge.getPath();
+//            Shape selectionShape = SELECTION_STROKE.createStrokedShape(selectionPath);
+//            g2d.setColor(SELECTION_COLOR);
+//            g2d.fill(selectionShape);
+//        }
+//        
+        g2d.setColor(Color.BLUE);
+        if (stroke != null) {
+            if (scaleStroke && stroke instanceof BasicStroke) {
+                BasicStroke bs = GeometryUtils.scaleStroke(stroke, (float) (1.0 / GeometryUtils.getScale(g2d.getTransform())));
+                g2d.setStroke(bs);
+            } else {
+                g2d.setStroke(stroke);
+            }
+        }
+        // render
+        g2d.draw(edge.getPath());
+        
+        // Reset
+        g2d.setStroke(oldStroke);
+        g2d.setColor(oldColor);
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aaHint);
+        
+        if (ot != null)
+            g2d.setTransform(ot);
+    }
+
+    private boolean isSelected() {
+        return NodeUtil.isSelected(this, 1);
+    }
+
+    @Override
+    public Rectangle2D getBoundsInLocal() {
+        return bounds;
+    }
+    
+    private void updateBounds() {
+        Rectangle2D oldBounds = bounds;
+        if (oldBounds == null)
+            oldBounds = new Rectangle2D.Double();
+        bounds = calculateBounds(oldBounds);
+    }
+
+    private Rectangle2D calculateBounds(Rectangle2D rect) {
+        return edge.getBounds(rect);
+    }
+
+    public void setDNEdge(DistrictNetworkEdge edge) {
+        this.edge = edge;
+        updateBounds();
+    }
+
+}
index 7365060b0254bc8c6f62d5c4cb4aeef8e1dcd6d5..a126ee5942a841f50a2108684a364a78052a4554 100644 (file)
@@ -1,54 +1,83 @@
-package org.simantics.district.network.ui.nodes;\r
-\r
-import java.awt.Color;\r
-import java.awt.Graphics2D;\r
-import java.awt.RenderingHints;\r
-import java.awt.geom.AffineTransform;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-import org.simantics.district.network.ui.adapters.DistrictNetworkVertex;\r
-import org.simantics.scenegraph.g2d.G2DNode;\r
-\r
-public class DistrictNetworkVertexNode extends G2DNode {\r
-\r
-    private static final long serialVersionUID = -2641639101400236719L;\r
-    private DistrictNetworkVertex vertex;\r
-\r
-    @Override\r
-    public void render(Graphics2D g2d) {\r
-        AffineTransform ot = null;\r
-        AffineTransform t = getTransform();\r
-        if (t != null && !t.isIdentity()) {\r
-            ot = g2d.getTransform();\r
-            g2d.transform(getTransform());\r
-        }\r
-        \r
-        Object aaHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);\r
-        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);\r
-        \r
-        Color oldColor = g2d.getColor();\r
-        g2d.setColor(Color.RED);\r
-        // render\r
-        \r
-        Rectangle2D.Double rect = new Rectangle2D.Double(-0.5, -0.5, 1, 1);\r
-        g2d.draw(rect);\r
-        \r
-        // Reset stats\r
-        g2d.setColor(oldColor);\r
-        \r
-        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aaHint);\r
-        \r
-        if (ot != null)\r
-            g2d.setTransform(ot);\r
-    }\r
-\r
-    @Override\r
-    public Rectangle2D getBoundsInLocal() {\r
-        return new Rectangle2D.Double(-0.5, -0.5, 1, 1);\r
-    }\r
-\r
-    public void setVertex(DistrictNetworkVertex vertex) {\r
-        this.vertex = vertex;\r
-    }\r
-\r
-}\r
+package org.simantics.district.network.ui.nodes;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.Stroke;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import org.simantics.district.network.ui.adapters.DistrictNetworkVertex;
+import org.simantics.scenegraph.g2d.G2DNode;
+import org.simantics.scenegraph.utils.GeometryUtils;
+
+public class DistrictNetworkVertexNode extends G2DNode {
+
+    private static final long serialVersionUID = -2641639101400236719L;
+    private DistrictNetworkVertex vertex;
+    
+    private static final double scale = 1;
+    
+    private double left = -0.5;
+    private double top = -0.5;
+    private double width = 1;
+    private double height = 1;
+    
+    private Stroke stroke = new BasicStroke(2);
+    private boolean scaleStroke = true;
+
+    @Override
+    public void init() {
+        setZIndex(2);
+    }
+    
+    @Override
+    public void render(Graphics2D g2d) {
+        AffineTransform ot = null;
+        AffineTransform t = getTransform();
+        if (t != null && !t.isIdentity()) {
+            ot = g2d.getTransform();
+            g2d.transform(getTransform());
+        }
+        
+        Object aaHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+        
+        Color oldColor = g2d.getColor();
+        Stroke oldStroke = g2d.getStroke();
+        
+        g2d.setColor(Color.RED);
+        if (stroke != null) {
+            if (scaleStroke && stroke instanceof BasicStroke) {
+                BasicStroke bs = GeometryUtils.scaleStroke(stroke, (float) (1.0 / GeometryUtils.getScale(g2d.getTransform())));
+                g2d.setStroke(bs);
+            } else {
+                g2d.setStroke(stroke);
+            }
+        }
+        // render
+        
+        Rectangle2D.Double rect = new Rectangle2D.Double(left / scale, top / scale, width / scale, height / scale);
+        g2d.draw(rect);
+        
+        // Reset stats
+        g2d.setColor(oldColor);
+        g2d.setStroke(oldStroke);
+        
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aaHint);
+        
+        if (ot != null)
+            g2d.setTransform(ot);
+    }
+
+    @Override
+    public Rectangle2D getBoundsInLocal() {
+        return new Rectangle2D.Double(left / scale, top / scale, width / scale, height / scale);
+    }
+
+    public void setVertex(DistrictNetworkVertex vertex) {
+        this.vertex = vertex;
+    }
+
+}
index 486294275aa554289e4f1d65bb2d15ae057e8515..a9c96e9b37c3e295b452c33eb521374079af9f3d 100644 (file)
-package org.simantics.district.network.ui.nodes;\r
-\r
-import java.awt.Color;\r
-import java.awt.Graphics2D;\r
-import java.awt.geom.Path2D;\r
-import java.awt.geom.Point2D;\r
-import java.awt.geom.Rectangle2D;\r
-import java.util.ArrayList;\r
-import java.util.HashSet;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.simantics.Simantics;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.diagram.ui.DiagramModelHints;\r
-import org.simantics.district.network.ui.DNEdgeBuilder;\r
-import org.simantics.district.network.ui.NetworkDrawingParticipant;\r
-import org.simantics.g2d.canvas.Hints;\r
-import org.simantics.g2d.canvas.IToolMode;\r
-import org.simantics.g2d.diagram.IDiagram;\r
-import org.simantics.scenegraph.g2d.G2DNode;\r
-import org.simantics.scenegraph.g2d.events.EventTypes;\r
-import org.simantics.scenegraph.g2d.events.MouseEvent;\r
-import org.simantics.scenegraph.g2d.events.MouseEvent.MouseClickEvent;\r
-import org.simantics.scenegraph.g2d.events.MouseEvent.MouseDoubleClickedEvent;\r
-import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent;\r
-import org.simantics.scenegraph.utils.NodeUtil;\r
-\r
-public class NetworkDrawingNode extends G2DNode {\r
-\r
-    private static final long serialVersionUID = -3475301184009620573L;\r
-    \r
-    private List<Point2D> nodes = new ArrayList<>();\r
-\r
-    private Rectangle2D rect = new Rectangle2D.Double(10, 10, 10, 10);\r
-\r
-    private Set<Path2D> paths = new HashSet<>();\r
-\r
-    private Resource diagramResource;\r
-\r
-    private boolean committed;\r
-\r
-    private NetworkDrawingParticipant participant;\r
-\r
-    private IDiagram diagram;\r
-    \r
-    @Override\r
-    public void init() {\r
-        super.init();\r
-        addEventHandler(this);\r
-    }\r
-    \r
-    public void setNetworkDrawingParticipant(NetworkDrawingParticipant participant) {\r
-        this.participant = participant;\r
-    }\r
-    \r
-    public void setDiagram(IDiagram diagram) {\r
-        if (diagram != null) {\r
-            this.diagram = diagram;\r
-            this.diagramResource = diagram.getHint(DiagramModelHints.KEY_DIAGRAM_RESOURCE);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void render(Graphics2D g2d) {\r
-        Color old = g2d.getColor();\r
-        g2d.setColor(Color.BLUE);\r
-        \r
-        paths.forEach(p -> {\r
-            g2d.draw(p);\r
-        });\r
-        \r
-        g2d.setColor(old);\r
-    }\r
-\r
-    @Override\r
-    public Rectangle2D getBoundsInLocal() {\r
-        return rect.getBounds2D();\r
-    }\r
-    \r
-    @Override\r
-    public int getEventMask() {\r
-        return EventTypes.MouseMask;\r
-    }\r
-    \r
-    @Override\r
-    protected boolean mouseDoubleClicked(MouseDoubleClickedEvent e) {\r
-        // nodes to path2d\r
-        IToolMode mode = getToolMode();\r
-        if (mode == Hints.CONNECTTOOL || e.hasAnyModifier(MouseEvent.ALT_MASK | MouseEvent.ALT_GRAPH_MASK)) {\r
-            Point2D start = null;\r
-            Point2D end = null;\r
-            Iterator<Point2D> nodeIter = nodes.iterator();\r
-            while (nodeIter.hasNext()) {\r
-                if (end == null) {\r
-                    start = nodeIter.next();\r
-                } else {\r
-                    start = end;\r
-                }\r
-                end = nodeIter.next();\r
-                \r
-                createEdge(start, end);\r
-            }\r
-            \r
-            nodes.clear();\r
-            committed = true;\r
-            \r
-            repaint();\r
-            \r
-            return true;\r
-        }\r
-        return super.mouseDoubleClicked(e);\r
-    }\r
-    \r
-    private void createEdge(Point2D start, Point2D end) {\r
-        double[] startCoords = new double[] { start.getX(), start.getY() };\r
-        double[] endCoords = new double[] { end.getX(), end.getY() };\r
-        \r
-        DNEdgeBuilder builder = new DNEdgeBuilder(diagramResource, diagram);\r
-        Simantics.getSession().asyncRequest(new WriteRequest() {\r
-            \r
-            @Override\r
-            public void perform(WriteGraph graph) throws DatabaseException {\r
-                builder.create(graph, startCoords, endCoords);\r
-            }\r
-        });\r
-        \r
-    }\r
-    \r
-    @Override\r
-    protected boolean mouseClicked(MouseClickEvent e) {\r
-        // check ToolMode\r
-        IToolMode mode = getToolMode();\r
-        if (mode == Hints.CONNECTTOOL || e.hasAnyModifier(MouseEvent.ALT_MASK | MouseEvent.ALT_GRAPH_MASK)) {\r
-            if (committed) {\r
-                committed = false;\r
-                return false;\r
-            }\r
-            Point2D localPos = NodeUtil.worldToLocal(this, e.controlPosition, new Point2D.Double());\r
-            nodes.add(new Point2D.Double(localPos.getX(), localPos.getY()));\r
-        }\r
-        return super.mouseClicked(e);\r
-    }\r
-    \r
-    private IToolMode getToolMode() {\r
-        return participant.getHint(Hints.KEY_TOOL);\r
-    }\r
-\r
-    @Override\r
-    protected boolean mouseMoved(MouseMovedEvent e) {\r
-        return super.mouseMoved(e);\r
-    }\r
+package org.simantics.district.network.ui.nodes;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Stroke;
+import java.awt.geom.Path2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.simantics.Simantics;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.diagram.ui.DiagramModelHints;
+import org.simantics.district.network.ui.DNEdgeBuilder;
+import org.simantics.district.network.ui.NetworkDrawingParticipant;
+import org.simantics.g2d.canvas.Hints;
+import org.simantics.g2d.canvas.IToolMode;
+import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.scenegraph.g2d.G2DNode;
+import org.simantics.scenegraph.g2d.events.EventTypes;
+import org.simantics.scenegraph.g2d.events.MouseEvent;
+import org.simantics.scenegraph.g2d.events.MouseEvent.MouseClickEvent;
+import org.simantics.scenegraph.g2d.events.MouseEvent.MouseDoubleClickedEvent;
+import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent;
+import org.simantics.scenegraph.utils.GeometryUtils;
+import org.simantics.scenegraph.utils.NodeUtil;
+
+public class NetworkDrawingNode extends G2DNode {
+
+    private static final long serialVersionUID = -3475301184009620573L;
+    
+    private List<Point2D> nodes = new ArrayList<>();
+
+    private Resource diagramResource;
+
+    private boolean committed;
+
+    private NetworkDrawingParticipant participant;
+
+    private IDiagram diagram;
+
+    private static final Stroke DASHED_STROKE = new BasicStroke(2.0f,
+            BasicStroke.CAP_ROUND,
+            BasicStroke.JOIN_ROUND,
+            4.0f, new float[]{4.0f}, 0.0f);
+
+    private static final Color BLUE_ALPHA = new Color(0, 0, 255, 100);
+
+    private boolean scaleStroke = true;
+    
+    @Override
+    public void init() {
+        super.init();
+        addEventHandler(this);
+    }
+    
+    public void setNetworkDrawingParticipant(NetworkDrawingParticipant participant) {
+        this.participant = participant;
+    }
+    
+    public void setDiagram(IDiagram diagram) {
+        if (diagram != null) {
+            this.diagram = diagram;
+            this.diagramResource = diagram.getHint(DiagramModelHints.KEY_DIAGRAM_RESOURCE);
+        }
+    }
+
+    @Override
+    public void render(Graphics2D g2d) {
+        
+        Path2D path = new Path2D.Double();
+        Iterator<Point2D> nodeIter = nodes.iterator();
+        if (nodeIter.hasNext()) {
+            Point2D node = nodeIter.next();
+            path.moveTo(node.getX(), node.getY());
+        }
+        while (nodeIter.hasNext()) {
+            Point2D node = nodeIter.next();
+            path.lineTo(node.getX(), node.getY());
+        }
+        
+        Color old = g2d.getColor();
+        Stroke oldStroke = g2d.getStroke();
+        
+        if (DASHED_STROKE != null) {
+            if (scaleStroke && DASHED_STROKE instanceof BasicStroke) {
+                BasicStroke bs = GeometryUtils.scaleStroke(DASHED_STROKE, (float) (1.0 / GeometryUtils.getScale(g2d.getTransform())));
+                g2d.setStroke(bs);
+            } else {
+                g2d.setStroke(DASHED_STROKE);
+            }
+        }
+        
+        g2d.setColor(BLUE_ALPHA);
+
+        g2d.draw(path);
+        
+        g2d.setStroke(oldStroke);
+        g2d.setColor(old);
+    }
+
+    @Override
+    public Rectangle2D getBoundsInLocal() {
+        return null;
+    }
+    
+    @Override
+    public int getEventMask() {
+        return EventTypes.MouseMask;
+    }
+    
+    @Override
+    protected boolean mouseDoubleClicked(MouseDoubleClickedEvent e) {
+        // nodes to path2d
+        IToolMode mode = getToolMode();
+        if (mode == Hints.CONNECTTOOL || e.hasAnyModifier(MouseEvent.ALT_MASK | MouseEvent.ALT_GRAPH_MASK)) {
+            Point2D start = null;
+            Point2D end = null;
+            Iterator<Point2D> nodeIter = nodes.iterator();
+            while (nodeIter.hasNext()) {
+                if (end == null) {
+                    start = nodeIter.next();
+                } else {
+                    start = end;
+                }
+                end = nodeIter.next();
+                
+                createEdge(start, end);
+            }
+            
+            nodes.clear();
+            committed = true;
+            
+            repaint();
+            
+            return true;
+        }
+        return super.mouseDoubleClicked(e);
+    }
+    
+    private void createEdge(Point2D start, Point2D end) {
+        double[] startCoords = new double[] { start.getX(), start.getY() };
+        double[] endCoords = new double[] { end.getX(), end.getY() };
+        
+        DNEdgeBuilder builder = new DNEdgeBuilder(diagramResource, diagram);
+        Simantics.getSession().asyncRequest(new WriteRequest() {
+            
+            @Override
+            public void perform(WriteGraph graph) throws DatabaseException {
+                builder.create(graph, startCoords, endCoords);
+            }
+        });
+        
+    }
+    
+    @Override
+    protected boolean mouseClicked(MouseClickEvent e) {
+        // check ToolMode
+        IToolMode mode = getToolMode();
+        if (mode == Hints.CONNECTTOOL || e.hasAnyModifier(MouseEvent.ALT_MASK | MouseEvent.ALT_GRAPH_MASK)) {
+            if (committed) {
+                committed = false;
+                return false;
+            }
+            Point2D localPos = NodeUtil.worldToLocal(this, e.controlPosition, new Point2D.Double());
+            nodes.add(new Point2D.Double(localPos.getX(), localPos.getY()));
+            
+            repaint();
+            return true;
+        }
+        return super.mouseClicked(e);
+    }
+    
+    private IToolMode getToolMode() {
+        return participant.getHint(Hints.KEY_TOOL);
+    }
+
+    @Override
+    protected boolean mouseMoved(MouseMovedEvent e) {
+        return super.mouseMoved(e);
+    }
 }
\ No newline at end of file
index e8b8337b72845aed2b75fa119b34c7483c0c9818..acb0acacba55246f739a174c9d3d850de4835201 100644 (file)
@@ -1,22 +1,56 @@
-package org.simantics.district.network.ui.participants;\r
-\r
-import java.awt.geom.Point2D;\r
-import java.util.Set;\r
-\r
-import org.simantics.g2d.canvas.ICanvasParticipant;\r
-import org.simantics.g2d.diagram.participant.pointertool.PointerInteractor;\r
-import org.simantics.g2d.diagram.participant.pointertool.TerminalUtil.TerminalInfo;\r
-import org.simantics.g2d.element.IElement;\r
-\r
-public class DNPointerInteractor extends PointerInteractor {\r
-\r
-    @Override\r
-    protected ICanvasParticipant createConnectTool(TerminalInfo ti, int mouseId, Point2D startCanvasPos) {\r
-        return super.createConnectTool(ti, mouseId, startCanvasPos);\r
-    }\r
-    \r
-    @Override\r
-    protected ICanvasParticipant createTranslateTool(int mouseId, Point2D startCanvasPos, Point2D curCanvasPos, Set<IElement> elementsToDrag) {\r
-        return new DNTranslateMode(startCanvasPos, curCanvasPos, mouseId, elementsToDrag);\r
-    }\r
-}\r
+package org.simantics.district.network.ui.participants;
+
+import java.awt.geom.Point2D;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.simantics.district.network.ui.adapters.DistrictNetworkEdgeElement;
+import org.simantics.district.network.ui.adapters.DistrictNetworkVertexElement;
+import org.simantics.g2d.canvas.ICanvasParticipant;
+import org.simantics.g2d.diagram.handler.PickRequest.PickSorter;
+import org.simantics.g2d.diagram.participant.pointertool.PointerInteractor;
+import org.simantics.g2d.diagram.participant.pointertool.TerminalUtil.TerminalInfo;
+import org.simantics.g2d.element.IElement;
+import org.simantics.scenegraph.g2d.G2DNode;
+
+public class DNPointerInteractor extends PointerInteractor {
+
+    private static class DNPickSorter implements PickSorter {
+
+        @Override
+        public void sort(List<IElement> elements) {
+            Collections.sort(elements, (e1, e2) -> {
+                G2DNode e1node = getNode(e1);
+                G2DNode e2node = getNode(e2);
+                if (e1node.getZIndex() < e2node.getZIndex())
+                    return -1;
+                else if (e1node.getZIndex() > e2node.getZIndex())
+                    return 1;
+                return 0;
+            });
+        }
+
+        private static G2DNode getNode(IElement element) {
+            G2DNode node = element.getHint(DistrictNetworkEdgeElement.KEY_DN_EDGE_NODE);
+            if (node == null)
+                node = element.getHint(DistrictNetworkVertexElement.KEY_DN_VERTEX_NODE);
+            return node;
+        }
+    }
+
+    public DNPointerInteractor() {
+        super(new DNPickSorter());
+    }
+
+    @Override
+    protected ICanvasParticipant createConnectTool(TerminalInfo ti, int mouseId, Point2D startCanvasPos) {
+        return super.createConnectTool(ti, mouseId, startCanvasPos);
+    }
+
+    @Override
+    protected ICanvasParticipant createTranslateTool(int mouseId, Point2D startCanvasPos, Point2D curCanvasPos,
+            Set<IElement> elementsToDrag) {
+        return new DNTranslateMode(startCanvasPos, curCanvasPos, mouseId, elementsToDrag);
+    }
+}
index 74a464758590f7c91288ed8df749eae454cedc18..7d8af3d67f1103c4bca0db0765f374f19bca101f 100644 (file)
@@ -1,83 +1,82 @@
-package org.simantics.district.network.ui.participants;\r
-\r
-import java.awt.geom.AffineTransform;\r
-import java.awt.geom.Point2D;\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-\r
-import org.simantics.Simantics;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.CommentMetadata;\r
-import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.diagram.elements.ElementTransforms;\r
-import org.simantics.diagram.elements.ElementTransforms.TransformedObject;\r
-import org.simantics.diagram.stubs.DiagramResource;\r
-import org.simantics.district.network.ontology.DistrictNetworkResource;\r
-import org.simantics.g2d.canvas.Hints;\r
-import org.simantics.g2d.diagram.participant.pointertool.TranslateMode;\r
-import org.simantics.g2d.element.ElementUtils;\r
-import org.simantics.g2d.element.IElement;\r
-import org.simantics.g2d.element.handler.Move;\r
-\r
-public class DNTranslateMode extends TranslateMode {\r
-\r
-    public DNTranslateMode(Point2D startingPoint, Point2D currentPoint, int mouseId, Collection<IElement> elements) {\r
-        super(startingPoint, currentPoint, mouseId, elements);\r
-    }\r
-    \r
-    @Override\r
-    protected boolean commit() {\r
-        for (IElement el : elementsToReallyTranslate) {\r
-            Move move = el.getElementClass().getAtMostOneItemOfClass(Move.class);\r
-            if (move != null) {\r
-                Point2D oldPos = move.getPosition(el);\r
-                move.moveTo(el, oldPos.getX() + dx, oldPos.getY() + dy);\r
-            }\r
-        }\r
-        try {\r
-            Simantics.getSession().syncRequest(new WriteRequest() {\r
-                @Override\r
-                public void perform(WriteGraph graph) throws DatabaseException {\r
-                    Collection<TransformedObject> transformed = new ArrayList<TransformedObject>();\r
-                    DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);\r
-                    DiagramResource DIA = DiagramResource.getInstance(graph);\r
-                    for (IElement e : elementsToReallyTranslate) {\r
-                        Object obj = ElementUtils.getObject(e);\r
-                        if (obj instanceof Resource) {\r
-                            Resource res = (Resource) obj;\r
-                            if (graph.isInstanceOf(res, DN.Vertex)) {\r
-                                AffineTransform at = ElementUtils.getLocalTransform(e, new AffineTransform());\r
-                                transformed.add( new TransformedObject((Resource) obj, at) );\r
-                                \r
-                                \r
-                                // write to db\r
-                                double[] coords = new double[] { at.getTranslateX(), at.getTranslateY() };\r
-                                graph.claimLiteral(res, DIA.HasLocation, coords);\r
-                            }\r
-                        }\r
-                    }\r
-                    \r
-                    if (!transformed.isEmpty()) {\r
-                        CommentMetadata cm = graph.getMetadata(CommentMetadata.class);\r
-                        graph.addMetadata(cm.add("Translated " + transformed.size() + " "\r
-                                + (transformed.size() == 1 ? "element" : "elements")\r
-                                + " by (" + dx + "," + dy + ") mm."));\r
-                        graph.markUndoPoint();\r
-                    }\r
-                }\r
-            });\r
-        } catch (DatabaseException e) {\r
-            e.printStackTrace();\r
-        }\r
-        \r
-        for (IElement dirty : elementsToDirty)\r
-            dirty.setHint(Hints.KEY_DIRTY, Hints.VALUE_SG_DIRTY);\r
-\r
-        setDirty();\r
-        remove();\r
-        return false;\r
-    }\r
-\r
-}\r
+package org.simantics.district.network.ui.participants;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.simantics.Simantics;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.CommentMetadata;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.diagram.elements.ElementTransforms.TransformedObject;
+import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.district.network.ontology.DistrictNetworkResource;
+import org.simantics.g2d.canvas.Hints;
+import org.simantics.g2d.diagram.participant.pointertool.TranslateMode;
+import org.simantics.g2d.element.ElementUtils;
+import org.simantics.g2d.element.IElement;
+import org.simantics.g2d.element.handler.Move;
+
+public class DNTranslateMode extends TranslateMode {
+
+    public DNTranslateMode(Point2D startingPoint, Point2D currentPoint, int mouseId, Collection<IElement> elements) {
+        super(startingPoint, currentPoint, mouseId, elements);
+    }
+    
+    @Override
+    protected boolean commit() {
+        for (IElement el : elementsToReallyTranslate) {
+            Move move = el.getElementClass().getAtMostOneItemOfClass(Move.class);
+            if (move != null) {
+                Point2D oldPos = move.getPosition(el);
+                move.moveTo(el, oldPos.getX() + dx, oldPos.getY() + dy);
+            }
+        }
+        try {
+            Simantics.getSession().syncRequest(new WriteRequest() {
+                @Override
+                public void perform(WriteGraph graph) throws DatabaseException {
+                    Collection<TransformedObject> transformed = new ArrayList<TransformedObject>();
+                    DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+                    DiagramResource DIA = DiagramResource.getInstance(graph);
+                    for (IElement e : elementsToReallyTranslate) {
+                        Object obj = ElementUtils.getObject(e);
+                        if (obj instanceof Resource) {
+                            Resource res = (Resource) obj;
+                            if (graph.isInstanceOf(res, DN.Vertex)) {
+                                AffineTransform at = ElementUtils.getLocalTransform(e, new AffineTransform());
+                                transformed.add( new TransformedObject((Resource) obj, at) );
+                                
+                                
+                                // write to db
+                                double[] coords = new double[] { at.getTranslateX(), at.getTranslateY() };
+                                graph.claimLiteral(res, DIA.HasLocation, coords);
+                            }
+                        }
+                    }
+                    
+                    if (!transformed.isEmpty()) {
+                        CommentMetadata cm = graph.getMetadata(CommentMetadata.class);
+                        graph.addMetadata(cm.add("Translated " + transformed.size() + " "
+                                + (transformed.size() == 1 ? "element" : "elements")
+                                + " by (" + dx + "," + dy + ") mm."));
+                        graph.markUndoPoint();
+                    }
+                }
+            });
+        } catch (DatabaseException e) {
+            e.printStackTrace();
+        }
+        
+        for (IElement dirty : elementsToDirty)
+            dirty.setHint(Hints.KEY_DIRTY, Hints.VALUE_SG_DIRTY);
+
+        setDirty();
+        remove();
+        return false;
+    }
+
+}
index 8faefe0ebf75018666486301baf6d4644785011f..8e0633e87d660ffb67e7673666551d3fc66b7c2e 100644 (file)
@@ -1,44 +1,51 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<feature\r
-      id="org.simantics.district.ui.feature"\r
-      label="Simantics District UI Feature"\r
-      version="1.0.0.qualifier">\r
-\r
-   <description url="http://www.example.com/description">\r
-      [Enter Feature Description here.]\r
-   </description>\r
-\r
-   <copyright url="http://www.example.com/copyright">\r
-      [Enter Copyright Description here.]\r
-   </copyright>\r
-\r
-   <license url="http://www.example.com/license">\r
-      [Enter License Description here.]\r
-   </license>\r
-\r
-   <includes\r
-         id="org.simantics.district.feature"\r
-         version="0.0.0"/>\r
-\r
-   <plugin\r
-         id="org.simantics.district.network.ui"\r
-         download-size="0"\r
-         install-size="0"\r
-         version="0.0.0"\r
-         unpack="false"/>\r
-\r
-   <plugin\r
-         id="org.simantics.district.imports.ui"\r
-         download-size="0"\r
-         install-size="0"\r
-         version="0.0.0"\r
-         unpack="false"/>\r
-\r
-   <plugin\r
-         id="org.simantics.district.network.ui.ontology"\r
-         download-size="0"\r
-         install-size="0"\r
-         version="0.0.0"\r
-         unpack="false"/>\r
-\r
-</feature>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+      id="org.simantics.district.ui.feature"
+      label="Simantics District UI Feature"
+      version="1.0.0.qualifier">
+
+   <description url="http://www.example.com/description">
+      [Enter Feature Description here.]
+   </description>
+
+   <copyright url="http://www.example.com/copyright">
+      [Enter Copyright Description here.]
+   </copyright>
+
+   <license url="http://www.example.com/license">
+      [Enter License Description here.]
+   </license>
+
+   <includes
+         id="org.simantics.district.feature"
+         version="0.0.0"/>
+
+   <plugin
+         id="org.simantics.district.network.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.simantics.district.imports.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.simantics.district.network.ui.ontology"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.simantics.district.maps"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+</feature>