public Layout<V,E> getGraphLayout() { return model.getGraphLayout(); }
/** * Method to override current status when using LoadAppearance. * * @param show * labels shown */ @Override public void setShowEdgeLabels(boolean show) { isShowEdgeLabels = show; edgelabels.fillMask(show); visviewer.getModel().fireStateChanged(); }
public void actionPerformed(ActionEvent ae) { Dimension d = new Dimension(600,600); if (switchLayout.getText().indexOf("Spring") > 0) { switchLayout.setText("Switch to FRLayout"); layout = new SpringLayout<Number,Number>(g, Functions.<Integer>constant(EDGE_LENGTH)); layout.setSize(d); vv.getModel().setGraphLayout(layout, d); } else { switchLayout.setText("Switch to SpringLayout"); layout = new FRLayout<Number,Number>(g, d); vv.getModel().setGraphLayout(layout, d); } } });
public BaseVisualizationModel(VisualizationModel<N, E> other, Dimension layoutSize) { this(other.getNetwork(), other.getLayoutAlgorithm(), null, layoutSize); }
public BaseVisualizationModel(VisualizationModel<N, E> other) { this(other.getNetwork(), other.getLayoutAlgorithm(), null, other.getLayoutSize()); }
public Edge(VisualizationModel<N, E> visualizationModel) { super(visualizationModel.getLayoutModel()); this.visualizationModel = visualizationModel; this.accessor = new RadiusNetworkElementAccessor<>(visualizationModel.getNetwork()); }
model.setGraphLayout(layout); model.fireStateChanged(); viewer.center();
@Override public Set<E> getVisibleElements(Shape shape) { return Sets.newHashSet(visualizationModel.getNetwork().edges()); }
public NodeLabelAsShapeRenderer( VisualizationModel<N, E> visualizationModel, RenderContext<N, ?> rc) { this.layoutModel = visualizationModel.getLayoutModel(); this.renderContext = rc; }
Collection picked = new HashSet(vv.getPickedNodeState().getPicked()); if (picked.size() > 1) { Network inGraph = vv.getModel().getNetwork(); LayoutModel layoutModel = vv.getModel().getLayoutModel(); Network clusterGraph = collapser.getClusterGraph(inGraph, picked); log.info("clusterGraph:" + clusterGraph); layoutModel.lock(clusterGraph, true); layoutModel.lock(true); vv.getModel().setNetwork(g); layoutModel.accept(vv.getModel().getLayoutAlgorithm()); vv.getPickedNodeState().clear(); vv.repaint(); for (Object v : picked) { if (v instanceof Network) { Network inGraph = vv.getModel().getNetwork(); LayoutModel layoutModel = vv.getModel().getLayoutModel(); Network g = collapser.expand(graph, inGraph, (Network) v); vv.getModel().setNetwork(g); Object nodeU = pickedIter.next(); Object nodeV = pickedIter.next(); Network graph = vv.getModel().getNetwork(); Collection edges = new HashSet(graph.incidentEdges(nodeU)); edges.retainAll(graph.incidentEdges(nodeV));
/** * Create an instance with the specified model and view dimension. * * @param model the model to use * @param preferredSize initial preferred size of the view */ public BasicVisualizationServer(VisualizationModel<V,E> model, Dimension preferredSize) { this.model = model; renderContext = new PluggableRenderContext<V,E>(model.getGraphLayout().getGraph()); model.addChangeListener(this); setDoubleBuffered(false); this.addComponentListener(new VisualizationListener(this)); setPickSupport(new ShapePickSupport<V,E>(this)); setPickedVertexState(new MultiPickedState<V>()); setPickedEdgeState(new MultiPickedState<E>()); renderContext.setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<E>(getPickedEdgeState(), Color.black, Color.cyan)); renderContext.setVertexFillPaintTransformer(new PickableVertexPaintTransformer<V>(getPickedVertexState(), Color.red, Color.yellow)); setPreferredSize(preferredSize); renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); renderContext.getMultiLayerTransformer().addChangeListener(this); }
/** * Invoked when the component's size changes. * * @param e */ @Override public void componentResized(ComponentEvent e) { super.componentResized(e); VisualizationViewer vv = (VisualizationViewer) e.getComponent(); VisualizationModel model = vv.getModel(); LayoutModel layoutModel = model.getLayoutModel(); layoutModel.setSize(vv.getWidth(), vv.getHeight()); layoutModel.accept(model.getLayoutAlgorithm()); } });
public void scaleToLayout(ScalingControl scaler) { Dimension vd = getPreferredSize(); if (this.isShowing()) { vd = getSize(); } Dimension ld = model.getLayoutSize(); if (vd.equals(ld) == false) { scaler.scale(this, (float) (vd.getWidth() / ld.getWidth()), new Point2D.Double()); } }
@Override public void dispose() { super.dispose(); // stop layouter Relaxer relaxer = visviewer.getModel().getRelaxer(); if (relaxer != null) { relaxer.stop(); } }
new BaseVisualizationModel<>(graph, layout2, vm1.getLayoutModel(), vm1.getLayoutSize());
/** * hook up events so that when the VisualizationModel gets an event from the LayoutModel and fires * it, the Spatial will get the same event and know to update or recalculate its space * * @param spatial */ private void connectListeners(Spatial<?> spatial) { if (model instanceof LayoutEventSupport && spatial instanceof LayoutChangeListener) { if (spatial instanceof LayoutChangeListener) { model.addLayoutChangeListener((LayoutChangeListener) spatial); } } // this one toggles active/inactive as the opposite of the LayoutModel's active/inactive state model.getLayoutModel().getLayoutStateChangeSupport().addLayoutStateChangeListener(spatial); }
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); }
model.setGraphLayout(layout); model.fireStateChanged(); viewer.center();
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 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); } } }