@Override public Set<E> getVisibleElements(Shape shape) { return Sets.newHashSet(visualizationModel.getNetwork().edges()); }
public BaseVisualizationModel(VisualizationModel<N, E> other, Dimension layoutSize) { this(other.getNetwork(), other.getLayoutAlgorithm(), null, layoutSize); }
public Edge(VisualizationModel<N, E> visualizationModel) { super(visualizationModel.getLayoutModel()); this.visualizationModel = visualizationModel; this.accessor = new RadiusNetworkElementAccessor<>(visualizationModel.getNetwork()); }
@Override public void layoutChanged(LayoutNetworkEvent<N> evt) { N node = evt.getNode(); Point p = evt.getLocation(); if (visualizationModel.getNetwork().nodes().contains(node)) { Set<E> edges = visualizationModel.getNetwork().incidentEdges(node); for (E edge : edges) { update(edge, p); } } }
public void compute() { super.compute(); for (Object v : visualizationModel.getNetwork().nodes()) { Shape shape = (Shape) rc.getNodeShapeFunction().apply(v); Point2D p = (Point2D) visualizationModel.getLayoutModel().apply(v); // p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p); float x = (float) p.getX(); float y = (float) p.getY(); AffineTransform xform = AffineTransform.getTranslateInstance(x, y); shape = xform.createTransformedShape(shape); rectangles.add(shape.getBounds2D()); } } }
public BaseVisualizationModel(VisualizationModel<N, E> other) { this(other.getNetwork(), other.getLayoutAlgorithm(), null, other.getLayoutSize()); }
@Override public void layoutChanged(LayoutEvent<N> evt) { // need to take care of edge changes N node = evt.getNode(); Point p = evt.getLocation(); if (visualizationModel.getNetwork().nodes().contains(node)) { Set<E> edges = visualizationModel.getNetwork().incidentEdges(node); for (E edge : edges) { update(edge, p); } } }
public void compute() { super.compute(); for (Object v : visualizationModel.getNetwork().nodes()) { Shape shape = (Shape) rc.getNodeShapeFunction().apply(v); Point p = (Point) visualizationModel.getLayoutModel().apply(v); // p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p); float x = (float) p.x; float y = (float) p.y; AffineTransform xform = AffineTransform.getTranslateInstance(x, y); shape = xform.createTransformedShape(shape); rectangles.add(shape.getBounds2D()); } } }
/** rebuild the data structure */ @Override public void recalculate() { gridCache = null; log.trace( "called recalculate while active:{} layout model relaxing:{}", isActive(), layoutModel.isRelaxing()); if (isActive()) { log.trace("recalculate for edges: {}", visualizationModel.getNetwork().edges()); recalculate(visualizationModel.getNetwork().edges()); } } }
/** * @param shape the possibly non-rectangular area of interest * @return all nodes that are contained within the passed Shape */ @Override public Set<E> getVisibleElements(Shape shape) { if (!isActive() || !rtree.getRoot().isPresent()) { log.trace("not relaxing so getting from the network"); return visualizationModel.getNetwork().edges(); } pickShapes.add(shape); Node<E> root = rtree.getRoot().get(); Set<E> visibleElements = Sets.newHashSet(); return root.getVisibleElements(visibleElements, shape); }
public void startNodeCreate(BasicVisualizationServer<N, E> vv, Point2D point) { Preconditions.checkState( vv.getModel().getNetwork() instanceof MutableNetwork<?, ?>, "graph must be mutable"); N newNode = nodeFactory.get(); VisualizationModel<N, E> visualizationModel = vv.getModel(); MutableNetwork<N, E> graph = (MutableNetwork<N, E>) visualizationModel.getNetwork(); graph.addNode(newNode); Point2D p2d = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(point); visualizationModel.getLayoutModel().set(newNode, p2d.getX(), p2d.getY()); vv.repaint(); }
@Override public void endEdgeCreate(BasicVisualizationServer<N, E> vv, N endNode) { Preconditions.checkState( vv.getModel().getNetwork() instanceof MutableNetwork<?, ?>, "graph must be mutable"); if (startNode != null) { MutableNetwork<N, E> graph = (MutableNetwork<N, E>) vv.getModel().getNetwork(); graph.addEdge(startNode, endNode, edgeFactory.get()); vv.getEdgeSpatial().recalculate(); vv.repaint(); } startNode = null; edgeEffects.endEdgeEffects(vv); edgeEffects.endArrowEffects(vv); }
public Edges( VisualizationModel visualizationModel, BoundingRectangleCollector.Edges<E> boundingRectangleCollector, SplitterContext<E> splitterContext) { super(visualizationModel.getLayoutModel(), splitterContext); this.visualizationModel = visualizationModel; this.boundingRectangleCollector = boundingRectangleCollector; networkElementAccessor = new RadiusNetworkElementAccessor(visualizationModel.getNetwork()); rtree = RTree.create(); recalculate(); }
@Override public void startEdgeCreate(BasicVisualizationServer<N, E> vv, N startNode, Point2D startPoint) { this.startNode = startNode; this.down = startPoint; this.edgeEffects.startEdgeEffects(vv, startPoint, startPoint); if (vv.getModel().getNetwork().isDirected()) { this.edgeEffects.startArrowEffects(vv, startPoint, startPoint); } vv.repaint(); }
@Override public void midEdgeCreate(BasicVisualizationServer<N, E> vv, Point2D midPoint) { if (startNode != null) { this.edgeEffects.midEdgeEffects(vv, down, midPoint); if (vv.getModel().getNetwork().isDirected()) { this.edgeEffects.midArrowEffects(vv, down, midPoint); } vv.repaint(); } }
protected Collection<N> getFilteredNodes() { Set<N> nodes = vv.getModel().getNetwork().nodes(); return nodesAreFiltered() ? Sets.filter(nodes, vv.getRenderContext().getNodeIncludePredicate()::test) : nodes; }
protected Collection<E> getFilteredEdges() { Set<E> edges = vv.getModel().getNetwork().edges(); return edgesAreFiltered() ? Sets.filter(edges, vv.getRenderContext().getEdgeIncludePredicate()::test) : edges; }
public GradientEdgePaintFunction(Color c1, Color c2, VisualizationViewer<N, E> vv) { this.c1 = c1; this.c2 = c2; this.graph = vv.getModel().getNetwork(); this.layoutModel = vv.getModel().getLayoutModel(); this.transformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT); }
private void groupCluster(AggregateLayoutModel<Number> layoutModel, Set<Number> nodes) { if (nodes.size() < vv.getModel().getNetwork().nodes().size()) { Point center = layoutModel.apply(nodes.iterator().next()); MutableNetwork<Number, Number> subGraph = NetworkBuilder.undirected().build(); for (Number v : nodes) { subGraph.addNode(v); } LayoutAlgorithm<Number> subLayoutAlgorithm = new CircleLayoutAlgorithm<>(); LayoutModel<Number> subModel = LoadingCacheLayoutModel.<Number>builder() .setGraph(subGraph.asGraph()) .setSize(40, 40) .build(); layoutModel.put(subModel, center); subModel.accept(subLayoutAlgorithm); vv.repaint(); } } }
public void visit(LayoutModel<N> layoutModel) { // save off the existing layoutModel this.layoutModel = layoutModel; // create a LayoutModel to hold points for the transition this.transitionLayoutModel = LoadingCacheLayoutModel.<N>builder() .setGraph(visualizationServer.getModel().getNetwork().asGraph()) .setLayoutModel(layoutModel) .setInitializer(layoutModel) .build(); // start off the transitionLayoutModel with the endLayoutAlgorithm transitionLayoutModel.accept(endLayoutAlgorithm); }