edu.uci.ics.jung.visualization.decorators.ToStringLabeller Java Examples
The following examples show how to use
edu.uci.ics.jung.visualization.decorators.ToStringLabeller.
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: GraphComponent.java From ghidra with Apache License 2.0 | 6 votes |
/** * This is called to configure the satellite viewer's rendering settings. Subclasses can * override this method to change, as needed. * * @param viewer the new satellite viewer * @param layout the viewer's layout */ protected void decorateSatelliteViewer(SatelliteGraphViewer<V, E> viewer, VisualGraphLayout<V, E> layout) { RenderContext<V, E> renderContext = viewer.getRenderContext(); Renderer<V, E> renderer = viewer.getRenderer(); renderer.setVertexRenderer(viewer.getPreferredVertexRenderer()); renderer.setEdgeRenderer(new VisualGraphEdgeSatelliteRenderer<>( (VisualEdgeRenderer<V, E>) layout.getEdgeRenderer())); Function<E, Shape> edgeTransformer = layout.getEdgeShapeTransformer(); renderContext.setEdgeShapeTransformer(edgeTransformer); renderContext.setVertexShapeTransformer(new VisualGraphVertexShapeTransformer<>()); viewer.setVertexToolTipTransformer(new ToStringLabeller()); }
Example #2
Source File: DerivationViewer.java From joshua with Apache License 2.0 | 6 votes |
public DerivationViewer(DerivationTree g, Dimension d, Color targetColor, AnchorType anchor) { super(new CircleLayout<>(g)); anchorStyle = anchor; DerivationTreeTransformer dtt = new DerivationTreeTransformer(g, d, false); StaticLayout<Node, DerivationTreeEdge> derivationLayout = new StaticLayout<>(g, dtt); // derivationLayout.setSize(dtt.getSize()); setGraphLayout(derivationLayout); scaleToLayout(new LayoutScalingControl()); // g.addCorrespondences(); setPreferredSize(new Dimension(DEFAULT_HEIGHT, DEFAULT_WIDTH)); getRenderContext().setVertexLabelTransformer(new ToStringLabeller<>()); DefaultModalGraphMouse<Node, DerivationTreeEdge> graphMouse = new DefaultModalGraphMouse<>(); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); setGraphMouse(graphMouse); addKeyListener(graphMouse.getModeKeyListener()); // this.setPickedVertexState(new DerivationTreePickedState(g)); getRenderContext().setVertexFillPaintTransformer(vp); getRenderContext().setEdgeStrokeTransformer(es); getRenderContext().setVertexShapeTransformer(ns); getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); TGT = targetColor; anchorPoint = dtt.getAnchorPosition(anchorStyle); }
Example #3
Source File: StateVisualizer.java From osmo with GNU Lesser General Public License v2.1 | 6 votes |
public StateVisualizer() { super("Model Visualizer"); graph = new DirectedSparseMultigraph<>(); graph.addVertex(current); // Layout<FSMTransition, String> layout = new CircleLayout<FSMTransition, String>(graph); layout = new KKLayout<>(graph); layout.setSize(new Dimension(800, 600)); // sets the initial size of the space vv = new VisualizationViewer<>(layout); vv.setPreferredSize(new Dimension(800, 600)); //Sets the viewing area size vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); VertexLabelAsShapeRenderer<String, StepCounter> vlasr = new VertexLabelAsShapeRenderer<>(vv.getRenderContext()); // vv.getRenderContext().setVertexShapeTransformer(vlasr); vv.getRenderContext().setVertexShapeTransformer(new EllipseVertexTransformer()); // vv.getRenderContext().setVertexLabelRenderer(new TransitionVertextLabelRenderer(Color.GREEN)); DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.addKeyListener(gm.getModeKeyListener()); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); vv.setGraphMouse(gm); getContentPane().add(vv); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(1024, 768); pack(); setVisible(true); }
Example #4
Source File: FSMBuildVisualizer.java From osmo with GNU Lesser General Public License v2.1 | 6 votes |
public FSMBuildVisualizer() { super("Model Visualizer"); graph = new DirectedSparseMultigraph<>(); graph.addVertex(current); // Layout<FSMTransition, String> layout = new CircleLayout<FSMTransition, String>(graph); layout = new KKLayout<>(graph); layout.setSize(new Dimension(800, 600)); // sets the initial size of the space vv = new VisualizationViewer<>(layout); vv.setPreferredSize(new Dimension(800, 600)); //Sets the viewing area size vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); VertexLabelAsShapeRenderer<String, StepCounter> vlasr = new VertexLabelAsShapeRenderer<>(vv.getRenderContext()); // vv.getRenderContext().setVertexShapeTransformer(vlasr); vv.getRenderContext().setVertexShapeTransformer(new EllipseVertexTransformer()); // vv.getRenderContext().setVertexLabelRenderer(new TransitionVertextLabelRenderer(Color.GREEN)); DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.addKeyListener(gm.getModeKeyListener()); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); vv.setGraphMouse(gm); getContentPane().add(vv); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(1024, 768); pack(); setVisible(true); }
Example #5
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 #6
Source File: DrawnIconVertexDemo.java From cloudml with GNU Lesser General Public License v3.0 | 6 votes |
public DrawnIconVertexDemo(final Deployment dm) { this.dmodel = dm; // create a simple graph for the demo graph = new DirectedSparseGraph<Vertex, Edge>(); vv = new VisualizationViewer<Vertex, Edge>(new SpringLayout2<Vertex, Edge>(graph)); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); vv.getRenderContext().setVertexIconTransformer(vertexColor); vv.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<Vertex>(vv.getPickedVertexState(), Color.white, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer(edgeColor); vv.setBackground(Color.white); // add my listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Vertex>()); }
Example #7
Source File: Prim.java From Algorithms with MIT License | 5 votes |
public static void display(Graphs graph, String color, String name){ Graph<Integer,Integer> g=convertGraph(graph); //VisualizationImageServer vs = new VisualizationImageServer(new CircleLayout(g), new Dimension(650, 650)); //Initialize visualization Layout<Integer, String> layout = new CircleLayout(g); layout.setSize(new Dimension(620,620)); VisualizationViewer<Integer,String> vs = new VisualizationViewer<Integer,String>(layout); vs.setPreferredSize(new Dimension(650,650)); //Creates GraphMouse and adds to visualization DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); vs.setGraphMouse(gm); //Initialize JFrames JFrame frame = new JFrame(name); frame.getContentPane().setBackground(Color.RED); frame.getContentPane().add(vs); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); //Colors Vertices Transformer<Integer,Paint> vertexPaint = new Transformer<Integer,Paint>() { public Paint transform(Integer i) { if(color=="green"){ return Color.GREEN; } else{ return Color.RED; } } }; //Labels Edges float dash[] = {10.0f}; final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f); Transformer<String, Stroke> edgeStrokeTransformer =new Transformer<String, Stroke>(){ public Stroke transform(String s) { return edgeStroke; } }; //Renders Vertex colors/labels vs.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vs.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vs.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); //Renders Edge labels vs.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); }
Example #8
Source File: FrmPConns.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
private void setVisualizationViewer (VisualizationViewer vviewer) { PortConnections pconns = PortConnections.getInstance(); // give other color Transformer vertexPaint = new Transformer() { public Paint transform (Object obj) { if (obj instanceof ProcletBlock) { if (((ProcletBlock) obj).getBlockID().equals("exception")) { return Color.BLUE; } else { return Color.RED; } } else if (obj instanceof ProcletPort) { return Color.GREEN; } return Color.RED; } }; this.vertexPaint = vertexPaint; vv = vviewer; //vv.setPickSupport(new edu.uci.ics.jung.visualization.picking.ShapePickSupport(vv)); vv.setPreferredSize(new Dimension(350,350)); vv.getRenderContext().setVertexFillPaintTransformer(this.vertexPaint); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.setGraphMouse(gm); splitPanelLeft.setRightComponent(new GraphZoomScrollPane(vv)); // vv.validate(); // vv.repaint(); // splitPanelLeft.repaint(); // getContentPane().repaint(); // validate(); // repaint(); }
Example #9
Source File: FrmGraph.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
private void setVisualizationViewer (VisualizationViewer vviewer) { // vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv = vviewer; //vv.setPickSupport(new edu.uci.ics.jung.visualization.picking.ShapePickSupport(vv)); vv.setPreferredSize(new Dimension(350,350)); // vv.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer); vv.setGraphMouse(gm); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); splitPanelLeft.setRightComponent(new GraphZoomScrollPane(vv)); }
Example #10
Source File: GraphUtils.java From roboconf-platform with Apache License 2.0 | 5 votes |
/** * Writes a graph as a PNG image. * @param outputFile the output file * @param selectedComponent the component to highlight * @param layout the layout * @param graph the graph * @param edgeShapeTransformer the transformer for edge shapes (straight line, curved line, etc) * @throws IOException if something went wrong */ public static void writeGraph( File outputFile, Component selectedComponent, Layout<AbstractType,String> layout, Graph<AbstractType,String> graph , AbstractEdgeShapeTransformer<AbstractType,String> edgeShapeTransformer, Map<String,String> options ) throws IOException { VisualizationImageServer<AbstractType,String> vis = new VisualizationImageServer<AbstractType,String>( layout, layout.getSize()); vis.setBackground( Color.WHITE ); vis.getRenderContext().setEdgeLabelTransformer( new NoStringLabeller ()); vis.getRenderContext().setEdgeShapeTransformer( edgeShapeTransformer ); vis.getRenderContext().setVertexLabelTransformer( new ToStringLabeller<AbstractType> ()); vis.getRenderContext().setVertexShapeTransformer( new VertexShape()); vis.getRenderContext().setVertexFontTransformer( new VertexFont()); Color defaultBgColor = decode( options.get( DocConstants.OPTION_IMG_BACKGROUND_COLOR ), DocConstants.DEFAULT_BACKGROUND_COLOR ); Color highlightBgcolor = decode( options.get( DocConstants.OPTION_IMG_HIGHLIGHT_BG_COLOR ), DocConstants.DEFAULT_HIGHLIGHT_BG_COLOR ); vis.getRenderContext().setVertexFillPaintTransformer( new VertexColor( selectedComponent, defaultBgColor, highlightBgcolor )); Color defaultFgColor = decode( options.get( DocConstants.OPTION_IMG_FOREGROUND_COLOR ), DocConstants.DEFAULT_FOREGROUND_COLOR ); vis.getRenderContext().setVertexLabelRenderer( new MyVertexLabelRenderer( selectedComponent, defaultFgColor )); vis.getRenderer().getVertexLabelRenderer().setPosition( Position.CNTR ); BufferedImage image = (BufferedImage) vis.getImage( new Point2D.Double( layout.getSize().getWidth() / 2, layout.getSize().getHeight() / 2), new Dimension( layout.getSize())); ImageIO.write( image, "png", outputFile ); }
Example #11
Source File: Karger.java From Algorithms with MIT License | 4 votes |
public static void display(int[] vertices, int[][] edges, String color, String name){ Graph<Integer,Integer> g=convertGraph(vertices, edges); //VisualizationImageServer vs = new VisualizationImageServer(new CircleLayout(g), new Dimension(650, 650)); //Initialize visualization Layout<Integer, String> layout = new CircleLayout(g); layout.setSize(new Dimension(620,620)); VisualizationViewer<Integer,String> vs = new VisualizationViewer<Integer,String>(layout); vs.setPreferredSize(new Dimension(650,650)); //Creates GraphMouse and adds to visualization DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); vs.setGraphMouse(gm); //Initialize JFrames JFrame frame = new JFrame(name); frame.getContentPane().setBackground(Color.RED); frame.getContentPane().add(vs); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); //Colors Vertices Transformer<Integer,Paint> vertexPaint = new Transformer<Integer,Paint>() { public Paint transform(Integer i) { if(color=="green"){ return Color.GREEN; } else{ return Color.RED; } } }; //Labels Edges float dash[] = {10.0f}; final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f); Transformer<String, Stroke> edgeStrokeTransformer =new Transformer<String, Stroke>(){ public Stroke transform(String s) { return edgeStroke; } }; //Renders Vertex colors/labels vs.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vs.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vs.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); //Renders Edge labels vs.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); }