Java Code Examples for edu.uci.ics.jung.algorithms.layout.Layout#setSize()
The following examples show how to use
edu.uci.ics.jung.algorithms.layout.Layout#setSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Mpl.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) public static <O, A> JComponent doTermView2(Graph<MplStrict2.Node<O, A>, Integer> sgv) { if (sgv.getVertexCount() == 0) { return new JPanel(); } Layout layout = new FRLayout<>(sgv); layout.setSize(new Dimension(600, 400)); VisualizationViewer vv = new VisualizationViewer<>(layout); DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>(); gm.setMode(Mode.TRANSFORMING); vv.setGraphMouse(gm); gm.setMode(Mode.PICKING); // vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); // vv.getRenderContext().setVertexLabelTransformer(ttt); vv.getRenderContext().setEdgeLabelTransformer(xx -> ""); GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv); JPanel ret = new JPanel(new GridLayout(1, 1)); ret.add(zzz); ret.setBorder(BorderFactory.createEtchedBorder()); return ret; }
Example 2
Source File: ProcletModel.java From yawl with GNU Lesser General Public License v3.0 | 6 votes |
public static void main(String [] args) { ProcletModel pmodel = new ProcletModel("visit"); pmodel.buildFromDB(); pmodel.persistProcletModel(); ProcletBlock block1 = new ProcletBlock("b1",BlockType.PI,false,5); ProcletBlock block2 = new ProcletBlock("b2",BlockType.PI,false,5); pmodel.addBlock(block1); pmodel.addBlock(block2); ProcletPort port = new ProcletPort("p1",Direction.OUT,Signature.ONE,Signature.ONE); ProcletPort port2 = new ProcletPort("p2",Direction.OUT,Signature.ONE,Signature.ONE); pmodel.addProcletPort(port, block1); pmodel.addProcletPort(port2, block1); pmodel.getBlocks(); pmodel.getPortsBlock(block1); // visualization Layout layout = new CircleLayout(pmodel); layout.setSize(new Dimension(300,300)); BasicVisualizationServer vv = new BasicVisualizationServer(layout); vv.setPreferredSize(new Dimension(350,350)); JFrame frame = new JFrame("simple"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); frame.pack(); frame.setVisible(true); }
Example 3
Source File: InteractionGraphs.java From yawl with GNU Lesser General Public License v3.0 | 6 votes |
public static void main(String [] args) { JOptionPane.showMessageDialog(null, "Block already exists!", "Error", JOptionPane.ERROR_MESSAGE); InteractionGraphs igraphs = InteractionGraphs.getInstance(); igraphs.buildFromDB(); InteractionGraph graph = igraphs.getGraph(new EntityMID("test")); Layout<Integer,String> layout = new CircleLayout(graph); layout.setSize(new Dimension(300,300)); BasicVisualizationServer<Integer,String> vv = new BasicVisualizationServer<Integer,String>(layout); vv.setPreferredSize(new Dimension(350,350)); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); JFrame frame = new JFrame("simple"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); frame.pack(); frame.setVisible(true); System.out.println("done"); }
Example 4
Source File: Mpl.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) private static <O, A> JComponent doTermView(Color src, Color dst, Graph<Node<O, A>, Integer> sgv) { if (sgv.getVertexCount() == 0) { return new JPanel(); } Layout layout = new FRLayout<>(sgv); layout.setSize(new Dimension(600, 400)); VisualizationViewer vv = new VisualizationViewer<>(layout); Function<Node<O, A>, Color> vertexPaint = x -> { if (x.isInput) { return src; } return dst; }; DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>(); gm.setMode(Mode.TRANSFORMING); vv.setGraphMouse(gm); gm.setMode(Mode.PICKING); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); Function<Node<O, A>, String> ttt = arg0 -> { String w = arg0.isInput ? "in" : "out"; return arg0.term + " #" + arg0.which + " " + w; }; vv.getRenderContext().setVertexLabelTransformer(ttt); vv.getRenderContext().setEdgeLabelTransformer(xx -> ""); GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv); JPanel ret = new JPanel(new GridLayout(1, 1)); ret.add(zzz); ret.setBorder(BorderFactory.createEtchedBorder()); return ret; }
Example 5
Source File: AqlViewer.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
private static <N, E> JComponent viewGraph(DMG<N, E> g) { Graph<N, E> sgv = new DirectedSparseMultigraph<>(); for (N n : g.nodes) { sgv.addVertex(n); } for (E e : g.edges.keySet()) { sgv.addEdge(e, g.edges.get(e).first, g.edges.get(e).second); } if (sgv.getVertexCount() == 0) { return new JPanel(); } Layout<N, E> layout = new FRLayout<>(sgv); layout.setSize(new Dimension(600, 400)); VisualizationViewer<N, E> vv = new VisualizationViewer<>(layout); Function<N, Paint> vertexPaint = x -> Color.black; DefaultModalGraphMouse<N, E> gm = new DefaultModalGraphMouse<>(); gm.setMode(Mode.TRANSFORMING); vv.setGraphMouse(gm); gm.setMode(Mode.PICKING); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); Function<E, String> et = Object::toString; Function<N, String> vt = Object::toString; vv.getRenderContext().setEdgeLabelTransformer(et); vv.getRenderContext().setVertexLabelTransformer(vt); GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv); JPanel ret = new JPanel(new GridLayout(1, 1)); ret.add(zzz); ret.setBorder(BorderFactory.createEtchedBorder()); vv.getRenderContext().setLabelOffset(16); vv.setBackground(Color.white); return ret; }
Example 6
Source File: ShowLayouts.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void actionPerformed(ActionEvent arg0) { Object[] constructorArgs = { g_array[graph_index]}; Class<? extends Layout<Integer,Number>> layoutC = (Class<? extends Layout<Integer,Number>>) jcb.getSelectedItem(); // Class lay = layoutC; try { Constructor<? extends Layout<Integer, Number>> constructor = layoutC .getConstructor(new Class[] {Graph.class}); Object o = constructor.newInstance(constructorArgs); Layout<Integer,Number> l = (Layout<Integer,Number>) o; l.setInitializer(vv.getGraphLayout()); l.setSize(vv.getSize()); LayoutTransition<Integer,Number> lt = new LayoutTransition<Integer,Number>(vv, vv.getGraphLayout(), l); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } catch (Exception e) { e.printStackTrace(); } }
Example 7
Source File: BNplot.java From cst with GNU Lesser General Public License v3.0 | 5 votes |
public void plot() { BNplot sgv = this; //We create our graph in here // The Layout<V, E> is parameterized by the vertex and edge types // Layout<Integer, String> layout = new CircleLayout(sgv.g); // Layout<String, String> layout = new ISOMLayout<String, String>(sgv.g); Layout<String, String> layout = new KKLayout<String, String>(sgv.g); layout.setSize(new Dimension(600,600)); // sets the initial size of the layout space // The BasicVisualizationServer<V,E> is parameterized by the vertex and edge types BasicVisualizationServer<String,String> vv = new BasicVisualizationServer<String,String>(layout); vv_global=vv; vv.setPreferredSize(new Dimension(650,650)); //Sets the viewing area size // vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.setBackground(Color.white); // vv.getRenderContext().setVertexShapeTransformer(vertexShape); JFrame frame = new JFrame("Behavior Network Graph View"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); frame.pack(); frame.setVisible(true); // vv.getRenderContext().setVertexFillPaintTransformer(vertexColor); }