-
- Point2D point;
- DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
- if (graph.isInstanceOf(mapElement, DN.Vertex)) {
- double[] coords = graph.getRelatedValue(mapElement, DIA.HasLocation);
- point = DistrictNetworkNodeUtils.calculatePoint2D(new Point2D.Double(coords[0], coords[1]), null);
- }
- else if (graph.isInstanceOf(mapElement, DN.Edge)) {
- 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);
- point = DistrictNetworkNodeUtils.calculatePoint2D(new Point2D.Double((coords1[0] + coords2[0]) / 2, (coords1[1] + coords2[1]) / 2), null);
- }
- else {
- return null;
- }
-
- return new StyleResult(point, result);
- }
-
- @Override
- public void applyStyleForNode(EvaluationContext observer, INode parent, StyleResult results) {
- if (results == null) {
- cleanupStyleForNode(observer, parent);
- return;
- }
-
- DistrictNetworkHoverInfoNode node = ProfileVariables.claimChild(parent, "*", DistrictNetworkHoverInfoNode.NODE_KEY, DistrictNetworkHoverInfoNode.class, observer);
- if (node == null)
- return;
-
- ParentNode<?> root = (ParentNode<?>) NodeUtil.getNearestParentOfType(parent, RTreeNode.class);
- if (root != null) {
- DeferredRenderingNode deferred = ProfileVariables.claimChild(root, "", HOVER_INFO_DEFERRED, DeferredRenderingNode.class, observer);
- deferred.setZIndex(Integer.MAX_VALUE);
- }
-
- node.setLabels(results.getLabels());
- node.setOrigin(results.getOrigin());
- }
-
- @Override
- protected void cleanupStyleForNode(EvaluationContext observer, INode node) {
- ProfileVariables.denyChild(node, "*", DistrictNetworkHoverInfoNode.NODE_KEY);
- }
-
- private static Function1<Variable, List<Tuple3>> getUCTextGridFunctionCached(ReadGraph graph, Resource componentType)
- throws DatabaseException {
- return graph.syncRequest(new UCTextGridFunctionRequest(componentType), TransientCacheListener.instance());
- }
-
- private static final class UCTextGridFunctionRequest extends ResourceRead<Function1<Variable, List<Tuple3>>> {
- public UCTextGridFunctionRequest(Resource resource) {
- super(resource);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Function1<Variable, List<Tuple3>> perform(ReadGraph graph) throws DatabaseException {
- Resource actionsModule = Layer0Utils.getPossibleChild(graph, resource, ACTIONS_MODULE);
- if (actionsModule == null || !graph.isInstanceOf(actionsModule, Layer0.getInstance(graph).SCLModule))
- return null;
-
- String uri = graph.getURI(actionsModule);
- SCLContext sclContext = SCLContext.getCurrent();
- Object oldGraph = sclContext.get("graph");
- try {
- sclContext.put("graph", graph);
- return (Function1<Variable, List<Tuple3>>) SCLOsgi.MODULE_REPOSITORY.getValue(uri, HOVER_CONTRIBUTION);
- } catch (ValueNotFound e1) {
- return null;
- } finally {
- sclContext.put("graph", oldGraph);
- }
- }
- }
+ return null;
+ }
+
+ private static Function1<Variable, List<Tuple3>> getUCTextGridFunctionCached(ReadGraph graph, Resource componentType)
+ throws DatabaseException {
+ return graph.syncRequest(new UCTextGridFunctionRequest(componentType), TransientCacheListener.instance());
+ }
+
+ private static final class UCTextGridFunctionRequest extends ResourceRead<Function1<Variable, List<Tuple3>>> {
+ public UCTextGridFunctionRequest(Resource resource) {
+ super(resource);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Function1<Variable, List<Tuple3>> perform(ReadGraph graph) throws DatabaseException {
+ Resource actionsModule = Layer0Utils.getPossibleChild(graph, resource, ACTIONS_MODULE);
+ if (actionsModule == null || !graph.isInstanceOf(actionsModule, Layer0.getInstance(graph).SCLModule))
+ return null;
+
+ String uri = graph.getURI(actionsModule);
+ SCLContext sclContext = SCLContext.getCurrent();
+ Object oldGraph = sclContext.get("graph");
+ try {
+ sclContext.put("graph", graph);
+ return (Function1<Variable, List<Tuple3>>) SCLOsgi.MODULE_REPOSITORY.getValue(uri, HOVER_CONTRIBUTION);
+ } catch (ValueNotFound e1) {
+ return null;
+ } finally {
+ sclContext.put("graph", oldGraph);
+ }
+ }
+ }
+