/** * @see edu.uci.ics.jung.algorithms.layout.Layout#getSize() */ public Dimension getSize() { return delegate.getSize(); }
/** * Returns the size of the underlying layout. * @return the size of the underlying layout * @see edu.uci.ics.jung.algorithms.layout.Layout#getSize() */ public Dimension getSize() { return delegate.getSize(); }
public Dimension getSize() { return delegate.getSize(); }
public Dimension getSize() { return layout.getSize(); }
public Dimension getSize() { return delegate.getSize(); }
/** * Returns the location of the vertex. The location is specified first * by the sublayouts, and then by the base layout if no sublayouts operate * on this vertex. * @return the location of the vertex */ public Point2D apply(V v) { boolean wasInSublayout = false; for(Layout<V,E> layout : layouts.keySet()) { if(layout.getGraph().getVertices().contains(v)) { wasInSublayout = true; Point2D center = layouts.get(layout); // transform by the layout itself, but offset to the // center of the sublayout Dimension d = layout.getSize(); AffineTransform at = AffineTransform.getTranslateInstance(center.getX()-d.width/2, center.getY()-d.height/2); return at.transform(layout.apply(v),null); } } if(wasInSublayout == false) { return delegate.apply(v); } return null; }
public void setLocation(V v, Point2D location) { boolean wasInSublayout = false; for(Layout<V,E> layout : layouts.keySet()) { if(layout.getGraph().getVertices().contains(v)) { Point2D center = layouts.get(layout); // transform by the layout itself, but offset to the // center of the sublayout Dimension d = layout.getSize(); AffineTransform at = AffineTransform.getTranslateInstance(-center.getX()+d.width/2,-center.getY()+d.height/2); Point2D localLocation = at.transform(location, null); layout.setLocation(v, localLocation); wasInSublayout = true; } } if(wasInSublayout == false && getGraph().getVertices().contains(v)) { delegate.setLocation(v, location); } }
/** * Returns the location of the vertex. The location is specified first * by the sublayouts, and then by the base layout if no sublayouts operate * on this vertex. * @return the location of the vertex * @see org.apache.commons.collections15.Transformer#transform(java.lang.Object) */ public Point2D transform(V v) { boolean wasInSublayout = false; for(Layout<V,E> layout : layouts.keySet()) { if(layout.getGraph().getVertices().contains(v)) { wasInSublayout = true; Point2D center = layouts.get(layout); // transform by the layout itself, but offset to the // center of the sublayout Dimension d = layout.getSize(); AffineTransform at = AffineTransform.getTranslateInstance(center.getX()-d.width/2, center.getY()-d.height/2); return at.transform(layout.transform(v),null); } } if(wasInSublayout == false) { return delegate.transform(v); } return null; }
public void scaleToLayout(ScalingControl scaler) { Dimension vd = getPreferredSize(); if(this.isShowing()) { vd = getSize(); } Dimension ld = getGraphLayout().getSize(); if(vd.equals(ld) == false) { scaler.scale(this, (float)(vd.getWidth()/ld.getWidth()), new Point2D.Double()); } }
/** * @param v * @param location * @see edu.uci.ics.jung.algorithms.layout.Layout#setLocation(java.lang.Object, java.awt.geom.Point2D) */ public void setLocation(V v, Point2D location) { boolean wasInSublayout = false; for(Layout<V,E> layout : layouts.keySet()) { if(layout.getGraph().getVertices().contains(v)) { Point2D center = layouts.get(layout); // transform by the layout itself, but offset to the // center of the sublayout Dimension d = layout.getSize(); AffineTransform at = AffineTransform.getTranslateInstance(-center.getX()+d.width/2,-center.getY()+d.height/2); Point2D localLocation = at.transform(location, null); layout.setLocation(v, localLocation); wasInSublayout = true; } } if(wasInSublayout == false && getGraph().getVertices().contains(v)) { delegate.setLocation(v, location); } }
layout.setSize(new Dimension(1024,1024)); // Size of the layout VisualizationImageServer<GraphVertex, GraphEdge> vv = new VisualizationImageServer<GraphVertex, GraphEdge>(layout, layout.getSize()); vv.setPreferredSize(new Dimension(1200,1200)); // Viewing area size vv.getRenderContext().setVertexLabelTransformer(new Transformer<GraphVertex,String>() { new Point2D.Double(vv.getGraphLayout().getSize().getWidth() / 2, vv.getGraphLayout().getSize().getHeight() / 2), new Dimension(vv.getGraphLayout().getSize()));
public void writeServerJPEGImage(File file) { VisualizationImageServer<Vertex, Edge> vis = new VisualizationImageServer<Vertex, Edge>(vv.getGraphLayout(), vv.getGraphLayout().getSize()); vis.setBackground(Color.WHITE); vis.getRenderContext().setEdgeDrawPaintTransformer(edgeColor); vis.getRenderContext().setVertexIconTransformer(vertexColor); BufferedImage image = (BufferedImage) vis.getImage( new Point2D.Double(vis.getWidth(), vis.getHeight()), new Dimension(vv.getGraphLayout().getSize())); try { ImageIO.write(image, "jpeg", file); } catch (Exception e) { e.printStackTrace(); } }
.collect(Collectors.toSet()); VisualizationImageServer<VertexRef, Edge> vv = new VisualizationImageServer<>(jungLayout, jungLayout.getSize()); vv.setPreferredSize(new Dimension(2000,2000)); // Viewing area size vv.getRenderContext().setVertexLabelTransformer(VertexRef::getLabel); new Point2D.Double(vv.getGraphLayout().getSize().getWidth() / 2, vv.getGraphLayout().getSize().getHeight() / 2), new Dimension(vv.getGraphLayout().getSize()));
private void setLtoR(VisualizationViewer<String,Integer> vv) { Layout<String,Integer> layout = vv.getModel().getGraphLayout(); Dimension d = layout.getSize(); Point2D center = new Point2D.Double(d.width/2, d.height/2); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).rotate(-Math.PI/2, center); }
.collect(Collectors.toSet()); VisualizationImageServer<VertexRef, Edge> vv = new VisualizationImageServer<>(jungLayout, jungLayout.getSize()); vv.setPreferredSize(new Dimension(2000,2000)); // Viewing area size vv.getRenderContext().setVertexLabelTransformer(VertexRef::getLabel); new Point2D.Double(vv.getGraphLayout().getSize().getWidth() / 2, vv.getGraphLayout().getSize().getHeight() / 2), new Dimension(vv.getGraphLayout().getSize()));
Dimension d = vv.getGraphLayout().getSize(); Rectangle2D vvBounds = vv.getBounds();
this.vv = vv; addComponentListener(new ResizeListener()); Dimension d = vv.getGraphLayout().getSize(); verticalScrollBar = new JScrollBar(JScrollBar.VERTICAL, 0, d.height, 0, d.height); horizontalScrollBar = new JScrollBar(JScrollBar.HORIZONTAL, 0, d.width, 0, d.width);
int w = fm.stringWidth(e.text); double p = Math.max(0, p1.getX() + p2.getX() - w); xform.translate(Math.min(layout.getSize().width - w, p / 2), (p1.getY() + p2.getY() - fm.getHeight()) / 2); g.setTransform(xform); g.draw(component, rc.getRendererPane(), 0, 0, d.width, d.height, true);
viewSize = new Dimension(600,600); Dimension layoutSize = layout.getSize();