public static JComponent getZoomControls(VisualizationServer vv, String title) { final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(e -> scaler.scale(vv, 1.1f, vv.getCenter())); JButton minus = new JButton("-"); minus.addActionListener(e -> scaler.scale(vv, 1 / 1.1f, vv.getCenter())); JPanel zoomPanel = new JPanel(); zoomPanel.setBorder(BorderFactory.createTitledBorder(title)); zoomPanel.add(plus); zoomPanel.add(minus); return zoomPanel; }
/** * 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)); }
public GradientNodeRenderer( VisualizationServer<N, ?> vv, Color colorOne, Color colorTwo, Color pickedColorOne, Color pickedColorTwo, boolean cyclic) { this.colorOne = colorOne; this.colorTwo = colorTwo; this.pickedColorOne = pickedColorOne; this.pickedColorTwo = pickedColorTwo; this.pickedState = vv.getPickedNodeState(); this.cyclic = cyclic; }
/** zoom the display in or out, depending on the direction of the mouse wheel motion. */ public void scale(VisualizationServer<?, ?> vv, float amount, Point2D from) { MutableTransformer viewTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW); viewTransformer.scale(amount, amount, from); vv.repaint(); } }
if (loadFromAppName() || loadFromDefault()) { RenderContext rc = vv.getRenderContext(); vv.getPickedNodeState(), new Color(Integer.getInteger(NODE_COLOR, 0xFF0000)), new Color(Integer.getInteger(PICKED_NODE_COLOR, 0x00FFFF)))); vv.getPickedEdgeState(), new Color(Integer.getInteger(EDGE_COLOR, 0xFF0000)), new Color(Integer.getInteger(PICKED_EDGE_COLOR, 0x00FFFF)))); vv.getRenderContext() .setNodeShapeFunction(n -> getNodeShape(System.getProperty(NODE_SHAPE, "CIRCLE"), size)); vv.setNodeSpatial(spatial); vv.setEdgeSpatial(spatial); vv.getRenderer() .getNodeLabelRenderer() .setPosition(getPosition(System.getProperty(NODE_LABEL_POSITION, "SE")));
/** * 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)); }
public N getNode(LayoutModel<N> layoutModel, double x, double y) { log.trace("look for node at (layout coords) {},{}", x, y); TransformSupport<N, E> transformSupport = vv.getTransformSupport(); N closest = null; double minDistance = Double.MAX_VALUE; Spatial<N> nodeSpatial = vv.getNodeSpatial(); if (nodeSpatial.isActive()) { return getNode(nodeSpatial, layoutModel, pickPoint.getX(), pickPoint.getY()); Shape shape = vv.getRenderContext().getNodeShapeFunction().apply(v);
TransformSupport<N, E> transformSupport = vv.getTransformSupport(); Shape shape = vv.getRenderContext().getNodeShapeFunction().apply(node);
public static <N, E> void apply( VisualizationServer<N, E> visualizationServer, LayoutAlgorithm<N> endLayoutAlgorithm) { visualizationServer.getModel().setLayoutAlgorithm(endLayoutAlgorithm); }
Point2D pickPoint = new Point2D.Double(x, y); Spatial<E> edgeSpatial = vv.getEdgeSpatial(); if (edgeSpatial != null && edgeSpatial instanceof SpatialRTree.Edges) { return getEdge(
Spatial spatial = vv.getNodeSpatial(); if (spatial != null) { return getContained(spatial, layoutModel, shape);
/** * Quick test to allow optimization of <code>getFilteredNodes()</code>. * * @return <code>true</code> if there is an relaxing node filtering mechanism for this * visualization, <code>false</code> otherwise */ protected boolean nodesAreFiltered() { Predicate<N> nodeIncludePredicate = vv.getRenderContext().getNodeIncludePredicate(); return nodeIncludePredicate != null && !nodeIncludePredicate.equals((Predicate<N>) (n -> true)); }
/** * zoom the display in or out, depending on the direction of the * mouse wheel motion. */ public void scale(VisualizationServer<?, ?> vv, float amount, Point2D from) { MutableTransformer viewTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW); viewTransformer.scale(amount, amount, from); vv.repaint(); } }
public static <N, E> void animate( VisualizationServer<N, E> visualizationServer, LayoutAlgorithm<N> endLayoutAlgorithm) { fireLayoutStateChanged(visualizationServer.getModel().getLayoutModel(), true); LayoutAlgorithm<N> transitionLayoutAlgorithm = new AnimationLayoutAlgorithm<>(visualizationServer, endLayoutAlgorithm); visualizationServer.getModel().setLayoutAlgorithm(transitionLayoutAlgorithm); }
protected Collection<N> getFilteredNodes() { Set<N> nodes = vv.getModel().getNetwork().nodes(); return nodesAreFiltered() ? Sets.filter(nodes, vv.getRenderContext().getNodeIncludePredicate()::test) : nodes; }
/** * Returns <code>true</code> if this node in this graph is included in the collections of elements * to be rendered, and <code>false</code> otherwise. * * @return <code>true</code> if this node is included in the collections of elements to be * rendered, <code>false</code> otherwise. */ protected boolean isNodeRendered(N node) { Predicate<N> nodeIncludePredicate = vv.getRenderContext().getNodeIncludePredicate(); return nodeIncludePredicate == null || nodeIncludePredicate.test(node); }
/** zoom the display in or out, depending on the direction of the mouse wheel motion. */ public void scale(VisualizationServer<?, ?> vv, float amount, Point2D from) { Point2D ivtfrom = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(Layer.VIEW, from); MutableTransformer modelTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT); modelTransformer.scale(amount, amount, ivtfrom); vv.repaint(); } }
/** * each step of the animation moves every pouit 1/count of the distance from its old location to * its new location */ public void step() { for (N v : layoutModel.getGraph().nodes()) { Point tp = layoutModel.apply(v); Point fp = transitionLayoutModel.apply(v); double dx = (fp.x - tp.x) / (count - counter); double dy = (fp.y - tp.y) / (count - counter); log.trace("dx:{},dy:{}", dx, dy); layoutModel.set(v, tp.x + dx, tp.y + dy); } counter++; if (counter >= count) { done = true; this.transitionLayoutModel.stopRelaxer(); this.visualizationServer.getModel().setLayoutAlgorithm(endLayoutAlgorithm); } }
public static JComponent getZoomControls( VisualizationServer vv, String title, LayoutManager buttonContainerLayoutManager) { final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(e -> scaler.scale(vv, 1.1f, vv.getCenter())); JButton minus = new JButton("-"); minus.addActionListener(e -> scaler.scale(vv, 1 / 1.1f, vv.getCenter())); JPanel zoomPanel = new JPanel(buttonContainerLayoutManager); zoomPanel.setBorder(BorderFactory.createTitledBorder(title)); zoomPanel.add(plus); zoomPanel.add(minus); return zoomPanel; }
protected Collection<E> getFilteredEdges() { Set<E> edges = vv.getModel().getNetwork().edges(); return edgesAreFiltered() ? Sets.filter(edges, vv.getRenderContext().getEdgeIncludePredicate()::test) : edges; }