/** * Quick test to allow optimization of <code>getFilteredEdges()</code>. * * @return <code>true</code> if there is an relaxing edge filtering mechanism for this * visualization, <code>false</code> otherwise */ protected boolean edgesAreFiltered() { Predicate<E> edgeIncludePredicate = vv.getRenderContext().getEdgeIncludePredicate(); return edgeIncludePredicate != null && !edgeIncludePredicate.equals((Predicate<N>) (n -> true)); }
/** * Quick test to allow optimization of <code>getFilteredEdges()</code>. * @return <code>true</code> if there is an active edge filtering * mechanism for this visualization, <code>false</code> otherwise */ protected boolean edgesAreFiltered() { Predicate<Context<Graph<V,E>,E>> edgeIncludePredicate = vv.getRenderContext().getEdgeIncludePredicate(); return edgeIncludePredicate != null && edgeIncludePredicate.equals(Predicates.alwaysTrue()) == false; }
/** * Returns <code>true</code> if this edge and its endpoints in this graph are all included in the * collections of elements to be rendered, and <code>false</code> otherwise. * * @return <code>true</code> if this edge and its endpoints are all included in the collections of * elements to be rendered, <code>false</code> otherwise. */ protected boolean isEdgeRendered(E edge) { Predicate<N> nodeIncludePredicate = vv.getRenderContext().getNodeIncludePredicate(); Predicate<E> edgeIncludePredicate = vv.getRenderContext().getEdgeIncludePredicate(); Network<N, E> g = vv.getModel().getNetwork(); if (edgeIncludePredicate != null && !edgeIncludePredicate.test(edge)) { return false; } EndpointPair<N> endpoints = g.incidentNodes(edge); N v1 = endpoints.nodeU(); N v2 = endpoints.nodeV(); return nodeIncludePredicate == null || (nodeIncludePredicate.test(v1) && nodeIncludePredicate.test(v2)); }
/** * Returns <code>true</code> if this edge and its endpoints * in this graph are all included in the collections of * elements to be rendered, and <code>false</code> otherwise. * @param context the edge and graph to be queried * @return <code>true</code> if this edge and its endpoints are all * included in the collections of elements to be rendered, <code>false</code> * otherwise. */ protected boolean isEdgeRendered(Context<Graph<V,E>,E> context) { Predicate<Context<Graph<V,E>,V>> vertexIncludePredicate = vv.getRenderContext().getVertexIncludePredicate(); Predicate<Context<Graph<V,E>,E>> edgeIncludePredicate = vv.getRenderContext().getEdgeIncludePredicate(); Graph<V,E> g = context.graph; E e = context.element; boolean edgeTest = edgeIncludePredicate == null || edgeIncludePredicate.apply(context); Pair<V> endpoints = g.getEndpoints(e); V v1 = endpoints.getFirst(); V v2 = endpoints.getSecond(); boolean endpointsTest = vertexIncludePredicate == null || (vertexIncludePredicate.apply(Context.<Graph<V,E>,V>getInstance(g,v1)) && vertexIncludePredicate.apply(Context.<Graph<V,E>,V>getInstance(g,v2))); return edgeTest && endpointsTest; }
protected Collection<E> getFilteredEdges() { Set<E> edges = vv.getModel().getNetwork().edges(); return edgesAreFiltered() ? Sets.filter(edges, vv.getRenderContext().getEdgeIncludePredicate()::test) : edges; }
@Override public void paintEdge( RenderContext<N, E> renderContext, VisualizationModel<N, E> visualizationModel, E e) { GraphicsDecorator g2d = renderContext.getGraphicsContext(); if (!renderContext.getEdgeIncludePredicate().test(e)) { return; } // don't draw edge if either incident node is not drawn EndpointPair<N> endpoints = visualizationModel.getNetwork().incidentNodes(e); N u = endpoints.nodeU(); N v = endpoints.nodeV(); Predicate<N> nodeIncludePredicate = renderContext.getNodeIncludePredicate(); if (!nodeIncludePredicate.test(u) || !nodeIncludePredicate.test(v)) { return; } Stroke new_stroke = renderContext.edgeStrokeFunction().apply(e); Stroke old_stroke = g2d.getStroke(); if (new_stroke != null) { g2d.setStroke(new_stroke); } drawSimpleEdge(renderContext, visualizationModel, e); // restore paint and stroke if (new_stroke != null) { g2d.setStroke(old_stroke); } }
public void paintEdge(RenderContext<V,E> rc, Layout<V, E> layout, E e) { GraphicsDecorator g2d = rc.getGraphicsContext(); Graph<V,E> graph = layout.getGraph(); if (!rc.getEdgeIncludePredicate().apply(Context.<Graph<V,E>,E>getInstance(graph,e))) return; // don't draw edge if either incident vertex is not drawn Pair<V> endpoints = graph.getEndpoints(e); V v1 = endpoints.getFirst(); V v2 = endpoints.getSecond(); if (!rc.getVertexIncludePredicate().apply(Context.<Graph<V,E>,V>getInstance(graph,v1)) || !rc.getVertexIncludePredicate().apply(Context.<Graph<V,E>,V>getInstance(graph,v2))) return; Stroke new_stroke = rc.getEdgeStrokeTransformer().apply(e); Stroke old_stroke = g2d.getStroke(); if (new_stroke != null) g2d.setStroke(new_stroke); drawSimpleEdge(rc, layout, e); // restore paint and stroke if (new_stroke != null) g2d.setStroke(old_stroke); }
final Node v1 = endpoints.getFirst(); final Node v2 = endpoints.getSecond(); if (!rc.getEdgeIncludePredicate().evaluate(Context.<Graph<Node, Edge>, Edge>getInstance(graph, e))) { return;
V v1 = endpoints.getFirst(); V v2 = endpoints.getSecond(); if (!rc.getEdgeIncludePredicate().apply(Context.<Graph<V,E>,E>getInstance(graph,e))) return;
V v1 = endpoints.getFirst(); V v2 = endpoints.getSecond(); if (!rc.getEdgeIncludePredicate().evaluate(Context.<Graph<V, E>, E> getInstance(graph, e))) return;