/** * Returns <code>true</code> if this vertex in this graph is included * in the collections of elements to be rendered, and <code>false</code> otherwise. * @param context the vertex and graph to be queried * @return <code>true</code> if this vertex is * included in the collections of elements to be rendered, <code>false</code> * otherwise. */ protected boolean isVertexRendered(Context<Graph<V,E>,V> context) { Predicate<Context<Graph<V,E>,V>> vertexIncludePredicate = vv.getRenderContext().getVertexIncludePredicate(); return vertexIncludePredicate == null || vertexIncludePredicate.apply(context); }
/** * Quick test to allow optimization of <code>getFilteredVertices()</code>. * @return <code>true</code> if there is an active vertex filtering * mechanism for this visualization, <code>false</code> otherwise */ protected boolean verticesAreFiltered() { Predicate<Context<Graph<V,E>,V>> vertexIncludePredicate = vv.getRenderContext().getVertexIncludePredicate(); return vertexIncludePredicate != null && vertexIncludePredicate.equals(Predicates.alwaysTrue()) == false; }
public void paintVertex(RenderContext<V,E> rc, Layout<V,E> layout, V v) { Graph<V,E> graph = layout.getGraph(); if (rc.getVertexIncludePredicate().apply(Context.<Graph<V,E>,V>getInstance(graph,v))) { paintIconForVertex(rc, v, layout); } }
public void paintVertex(RenderContext<V,E> rc, Layout<V,E> layout, V v) { Graph<V,E> graph = layout.getGraph(); if (rc.getVertexIncludePredicate().apply(Context.<Graph<V,E>,V>getInstance(graph,v))) { boolean vertexHit = true; // get the shape to be rendered Shape shape = rc.getVertexShapeTransformer().apply(v); Point2D p = layout.apply(v); p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p); float x = (float)p.getX(); float y = (float)p.getY(); // create a transform that translates to the location of // the vertex to be rendered AffineTransform xform = AffineTransform.getTranslateInstance(x,y); // transform the vertex shape with xtransform shape = xform.createTransformedShape(shape); vertexHit = vertexHit(rc, shape); //rc.getViewTransformer().transform(shape).intersects(deviceRectangle); if (vertexHit) { paintShapeForVertex(rc, v, shape); } } }
/** * Labels the specified vertex with the specified label. * Uses the font specified by this instance's * <code>VertexFontFunction</code>. (If the font is unspecified, the existing * font for the graphics context is used.) If vertex label centering * is active, the label is centered on the position of the vertex; otherwise * the label is offset slightly. */ public void labelVertex(RenderContext<V,E> rc, Layout<V,E> layout, V v, String label) { Graph<V,E> graph = layout.getGraph(); if (rc.getVertexIncludePredicate().apply(Context.<Graph<V,E>,V>getInstance(graph,v)) == false) { return; } GraphicsDecorator g = rc.getGraphicsContext(); Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), label, rc.getPickedVertexState().isPicked(v), v); Dimension d = component.getPreferredSize(); int h_offset = -d.width / 2; int v_offset = -d.height / 2; Point2D p = layout.apply(v); p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p); int x = (int)p.getX(); int y = (int)p.getY(); g.draw(component, rc.getRendererPane(), x+h_offset, y+v_offset, d.width, d.height, true); Dimension size = component.getPreferredSize(); Rectangle bounds = new Rectangle(-size.width/2 -2, -size.height/2 -2, size.width+4, size.height); shapes.put(v, bounds); }
/** * 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; }
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); }
if (!rc.getVertexIncludePredicate().evaluate(Context.<Graph<Node, Edge>, Node>getInstance(graph, v1)) || !rc.getVertexIncludePredicate().evaluate(Context.<Graph<Node, Edge>, Node>getInstance(graph, v2))) { return;
return; if (!rc.getVertexIncludePredicate().apply(Context.<Graph<V,E>,V>getInstance(graph,v1)) || !rc.getVertexIncludePredicate().apply(Context.<Graph<V,E>,V>getInstance(graph,v2))) return;
public void labelVertex(final RenderContext<ElementName, Dependency> rc, final Layout<ElementName, Dependency> layout, final ElementName v, final String label) { final Graph<ElementName, Dependency> graph = layout.getGraph(); if (rc.getVertexIncludePredicate().evaluate( Context.<Graph<ElementName, Dependency>, ElementName> getInstance( graph, v)) == false) { return; } final GraphicsDecorator g = rc.getGraphicsContext(); final Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), label, rc.getPickedVertexState().isPicked(v), v); final Dimension d = component.getPreferredSize(); final int h_offset = -d.width / 2; final int v_offset = -d.height / 2; Point2D p = layout.transform(v); p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p); final int x = (int) p.getX(); final int y = (int) p.getY(); g.draw(component, rc.getRendererPane(), x + h_offset, y + v_offset, d.width, d.height, true); }
public void labelVertex(final RenderContext<ElementName, Dependency> rc, final Layout<ElementName, Dependency> layout, final ElementName v, final String label) { final Graph<ElementName, Dependency> graph = layout.getGraph(); if (rc.getVertexIncludePredicate().evaluate( Context.<Graph<ElementName, Dependency>, ElementName> getInstance( graph, v)) == false) { return; } final GraphicsDecorator g = rc.getGraphicsContext(); final Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), label, rc.getPickedVertexState().isPicked(v), v); final Dimension d = component.getPreferredSize(); final int h_offset = -d.width / 2; final int v_offset = -d.height / 2; Point2D p = layout.transform(v); p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p); final int x = (int) p.getX(); final int y = (int) p.getY(); g.draw(component, rc.getRendererPane(), x + h_offset, y + v_offset, d.width, d.height, true); }
public void labelVertex(final RenderContext<ElementName, Dependency> rc, final Layout<ElementName, Dependency> layout, final ElementName v, final String label) { final Graph<ElementName, Dependency> graph = layout.getGraph(); if (rc.getVertexIncludePredicate().evaluate( Context.<Graph<ElementName, Dependency>, ElementName> getInstance( graph, v)) == false) { return; } final GraphicsDecorator g = rc.getGraphicsContext(); final Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), label, rc.getPickedVertexState().isPicked(v), v); final Dimension d = component.getPreferredSize(); final int h_offset = -d.width / 2; final int v_offset = -d.height / 2; Point2D p = layout.transform(v); p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p); final int x = (int) p.getX(); final int y = (int) p.getY(); g.draw(component, rc.getRendererPane(), x + h_offset, y + v_offset, d.width, d.height, true); }
if (rc.getVertexIncludePredicate().apply(Context.<Graph<V,E>,V>getInstance(graph,v)) == false) { return;
return; if (!rc.getVertexIncludePredicate() .evaluate(Context.<Graph<V, E>, V> getInstance(graph, v1)) || !rc.getVertexIncludePredicate() .evaluate(Context.<Graph<V, E>, V> getInstance(graph, v2))) return;