package org.simantics.district.network.ui.adapters;
-import java.awt.geom.AffineTransform;
-
import org.simantics.db.AsyncReadGraph;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.g2d.element.IElement;
import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;
import org.simantics.g2d.layers.ILayersEditor;
+import org.simantics.maps.MapScalingTransform;
public class DistrictNetworkVertexElementFactory extends SyncElementFactory {
public static final ElementClass CLASS = DistrictNetworkVertexElement.CLASS;
private DistrictNetworkResource DN;
private DiagramResource DIA;
-
+
public DistrictNetworkVertexElementFactory(ReadGraph graph) {
this.DN = DistrictNetworkResource.getInstance(graph);
this.DIA = DiagramResource.getInstance(graph);
@Override
public void load(ReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource vertexResource, IElement element) throws DatabaseException {
-
+ if (!graph.hasStatement(vertexResource))
+ return; // already deleted
+
double[] coords = graph.getRelatedValue(vertexResource, DIA.HasLocation);
DistrictNetworkVertex vertex = new DistrictNetworkVertex(coords);
+
+ Resource mapping = graph.getSingleObject(vertexResource, DistrictNetworkResource.getInstance(graph).HasMapping);
+ element.setHint(DistrictNetworkAdditionalColor.KEY_DN_MAPPING_RESOURCE, mapping);
element.setHint(DistrictNetworkVertexElement.KEY_DN_VERTEX, vertex);
- // set element transform based on layer SRS and coords
- AffineTransform at = new AffineTransform(1, 0, 0, 1, coords[0], coords[1]);
- ElementUtils.setTransform(element, at);
+ // set scaling transform for vertices
+ ElementUtils.setTransform(element, MapScalingTransform.INSTANCE);
IModifiableSynchronizationContext context = diagram.getHint(SynchronizationHints.CONTEXT);
GraphLayerManager layerManager = context.get(GraphSynchronizationHints.GRAPH_LAYER_MANAGER);