throws DatabaseException {
DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
- if (!graph.isInstanceOf(mapElement, DN.Edge))
+ boolean isEdge = graph.isInstanceOf(mapElement, DN.Edge);
+ boolean isVertex = graph.isInstanceOf(mapElement, DN.Vertex);
+ if (!isEdge && !isVertex)
return null;
- Resource diagram = graph.getSingleObject(mapElement, Layer0.getInstance(graph).PartOf);
- Set<Resource> edgesToUse = graph.syncRequest(new MidBranchEdgeSetRequest(diagram), TransientCacheListener.instance());
- if (!edgesToUse.contains(mapElement))
- return null;
+ if (isEdge) {
+ Resource diagram = graph.getSingleObject(mapElement, Layer0.getInstance(graph).PartOf);
+ Set<Resource> edgesToUse = graph.syncRequest(new MidBranchEdgeSetRequest(diagram), TransientCacheListener.instance());
+ if (!edgesToUse.contains(mapElement))
+ return null;
+ }
DiagramResource DIA = DiagramResource.getInstance(graph);
StructuralResource2 STR = StructuralResource2.getInstance(graph);
result = null;
}
- Resource v1 = graph.getSingleObject(mapElement, DN.HasStartVertex);
- double[] coords1 = graph.getRelatedValue(v1, DIA.HasLocation);
- Resource v2 = graph.getSingleObject(mapElement, DN.HasEndVertex);
- double[] coords2 = graph.getRelatedValue(v2, DIA.HasLocation);
- Point2D p1 = DistrictNetworkNodeUtils.calculatePoint2D(new Point2D.Double(coords1[0], coords1[1]), null);
- Point2D p2 = DistrictNetworkNodeUtils.calculatePoint2D(new Point2D.Double(coords2[0], coords2[1]), null);
+ if (isVertex) {
+ double[] coords = graph.getRelatedValue(mapElement, DIA.HasLocation);
+ Point2D p = DistrictNetworkNodeUtils.calculatePoint2D(new Point2D.Double(coords[0], coords[1]), null);
+ return new StyleResult(p, p, result);
+ }
+ else if (isEdge) {
+ Resource v1 = graph.getSingleObject(mapElement, DN.HasStartVertex);
+ double[] coords1 = graph.getRelatedValue(v1, DIA.HasLocation);
+ Resource v2 = graph.getSingleObject(mapElement, DN.HasEndVertex);
+ double[] coords2 = graph.getRelatedValue(v2, DIA.HasLocation);
+ Point2D p1 = DistrictNetworkNodeUtils.calculatePoint2D(new Point2D.Double(coords1[0], coords1[1]), null);
+ Point2D p2 = DistrictNetworkNodeUtils.calculatePoint2D(new Point2D.Double(coords2[0], coords2[1]), null);
+
+ return new StyleResult(p1, p2, result);
+ }
- return new StyleResult(p1, p2, result);
+ return null;
}
@Override
Point2D p1 = result.p1;
Point2D p2 = result.p2;
- double sign = Math.signum(p1.getX() - p2.getX());
- Point2D.Double origin = new Point2D.Double(0.5 * (p1.getX() + p2.getX()), 0.5 * (p1.getY() + p2.getY()));
- Point2D direction = new Point2D.Double(0.5 * sign * (p1.getX() - p2.getX()), 0.5 * sign * (p1.getY() - p2.getY()));
+ if (p1.equals(p2)) {
+ node.setLocation(p1, new Point2D.Double(1.0, 0.0));
+ }
+ else {
+ double sign = Math.signum(p1.getX() - p2.getX());
+ Point2D.Double origin = new Point2D.Double(0.5 * (p1.getX() + p2.getX()), 0.5 * (p1.getY() + p2.getY()));
+ Point2D direction = new Point2D.Double(0.5 * sign * (p1.getX() - p2.getX()), 0.5 * sign * (p1.getY() - p2.getY()));
+
+ node.setLocation(origin, direction);
+ }
- node.setLocation(origin, direction);
node.setInfo(result.info);
}
@Override
protected void cleanupStyleForNode(EvaluationContext evaluationContext, INode node) {
- ProfileVariables.denyChild(node, DistrictNetworkStaticInfoNode.NODE_KEY);
+ ProfileVariables.denyChild(node, "*", DistrictNetworkStaticInfoNode.NODE_KEY);
}
}