import org.simantics.g2d.element.handler.impl.SimpleElementLayers;
import org.simantics.maps.MapScalingTransform;
import org.simantics.scenegraph.g2d.G2DParentNode;
+import org.simantics.scenegraph.g2d.nodes.SVGNode;
import org.simantics.utils.datastructures.hints.IHintContext.Key;
import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
import org.slf4j.Logger;
public static final Key KEY_DN_EDGE = new KeyOf(DistrictNetworkEdge.class, "DN_EDGE");
public static final Key KEY_DN_EDGE_NODE = new SceneGraphNodeKey(DistrictNetworkEdgeNode.class, "DN_EDGE_NODE");
+ public static final Key KEY_DN_EDGE_SYMBOL_NODE = new SceneGraphNodeKey(DistrictNetworkEdgeNode.class, "DN_EDGE_SYMBOL_NODE");
public static final ElementClass CLASS =
ElementClass.compile(
if (node == null) {
node = parent.addNode(ElementUtils.generateNodeId(edgeElement), DistrictNetworkEdgeNode.class);
edgeElement.setHint(KEY_DN_EDGE_NODE, node);
+
+ SVGNode symbol = node.addNode(ElementUtils.generateNodeId(edgeElement), SVGNode.class);
+ edgeElement.setHint(KEY_DN_EDGE_SYMBOL_NODE, symbol);
}
node.setColor(ElementUtils.getAdditionalColor(edgeElement, Color.BLUE));
@Override
public void cleanup(IElement edge) {
+ ElementUtils.removePossibleNode(edge, KEY_DN_EDGE_SYMBOL_NODE);
ElementUtils.removePossibleNode(edge, KEY_DN_EDGE_NODE);
edge.removeHint(KEY_DN_EDGE_NODE);
+ edge.removeHint(KEY_DN_EDGE_SYMBOL_NODE);
}
}
if (size == null)
size = new Rectangle2D.Double();
if (edge != null)
- size.setFrame(DistrictNetworkEdgeNode.calculatePath(edge, null).getBounds2D());
+ size.setFrame(DistrictNetworkEdgeNode.calculatePath(edge, null, false).getBounds2D());
else
LOGGER.debug("Element {} does not have edge!", e);
public Shape getElementShape(IElement e) {
DistrictNetworkEdge edge = e.getHint(KEY_DN_EDGE);
if (edge != null) {
- return DistrictNetworkEdgeNode.calculatePath(edge, null);
+ return DistrictNetworkEdgeNode.calculatePath(edge, null, false);
} else {
return getBounds(e, null);
}
}
private boolean pickIntersectingObjects(DistrictNetworkEdge edge, Rectangle2D bounds) {
- double tolerance = (bounds.getHeight() + bounds.getHeight()) * 0.25 / MapScalingTransform.getScaleX();
+ double tolerance = (bounds.getHeight() + bounds.getHeight()) * 1 / MapScalingTransform.getScaleX();
Line2D line = new Line2D.Double(edge.getStartPoint(), edge.getEndPoint());
double sx = bounds.getCenterX() / MapScalingTransform.getScaleX();
double sy = bounds.getCenterY() / MapScalingTransform.getScaleY();