package org.simantics.district.network.ui.adapters;
-import java.awt.geom.Path2D;
import java.awt.geom.Point2D;
import org.simantics.db.AsyncReadGraph;
import org.simantics.diagram.synchronization.SynchronizationHints;
import org.simantics.diagram.synchronization.graph.GraphSynchronizationHints;
import org.simantics.diagram.synchronization.graph.layer.GraphLayerManager;
-import org.simantics.district.network.ModelledCRS;
import org.simantics.district.network.ontology.DistrictNetworkResource;
import org.simantics.district.network.ui.DistrictNetworkEdge;
import org.simantics.g2d.canvas.ICanvasContext;
Resource startVertex = graph.getSingleObject(edgeResource, DN.HasStartVertex);
Resource endVertex = graph.getSingleObject(edgeResource, DN.HasEndVertex);
- // TODO: fix scale..
- double scale = 100000;
-
+ // TODO: Find maybe a better way to apply the scaling
double[] startCoords = graph.getRelatedValue2(startVertex, DIA.HasLocation);
-
- double startLon = ModelledCRS.longitudeToX(startCoords[0]) * scale;
- double startLat = ModelledCRS.latitudeToY(startCoords[1]) * scale;
-
double[] endCoords = graph.getRelatedValue2(endVertex, DIA.HasLocation);
-
- double endLon = ModelledCRS.longitudeToX(endCoords[0]) * scale;
- double endLat = ModelledCRS.latitudeToY(endCoords[1]) * scale;
-
- Path2D path = new Path2D.Double();
- path.moveTo(startLon, startLat);
- path.lineTo(endLon, endLat);
-
- DistrictNetworkEdge edge = new DistrictNetworkEdge(path);
+ DistrictNetworkEdge edge = new DistrictNetworkEdge(new Point2D.Double(startCoords[0], startCoords[1]), new Point2D.Double(endCoords[0], endCoords[1]));
Resource mapping = graph.getSingleObject(edgeResource, DistrictNetworkResource.getInstance(graph).HasMapping);
element.setHint(DistrictNetworkAdditionalColor.KEY_DN_MAPPING_RESOURCE, mapping);
element.setHint(DistrictNetworkEdgeElement.KEY_DN_EDGE, edge);
+ // set scaling transform
+ ElementUtils.setTransform(element, MapScalingTransform.INSTANCE);
+
IModifiableSynchronizationContext context = diagram.getHint(SynchronizationHints.CONTEXT);
GraphLayerManager layerManager = context.get(GraphSynchronizationHints.GRAPH_LAYER_MANAGER);