public VisualizationViewer<String, Edge> generateGraphView() { Transformer<String, Paint> vertexColor = new Transformer<String, Paint>() { public Paint transform(String licenseTerm) { if (licenseTerm.contains("May")) return Color.GREEN; if (licenseTerm.contains("Must")) return Color.ORANGE; if (licenseTerm.equals("LimitedLiability") || licenseTerm.equals("ProvideWithoutWarranty")) return Color.CYAN; return Color.YELLOW; } }; Layout<String, Edge> layout = new CircleLayout<String, Edge>(this.licenseGraph); layout.setSize(new Dimension(1024, 768)); VisualizationViewer<String, Edge> vv = new VisualizationViewer<String, Edge>(layout); vv.setPreferredSize(new Dimension(1024, 768)); vv.getRenderContext().setVertexFillPaintTransformer(vertexColor); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>()); AbstractModalGraphMouse gm = new DefaultModalGraphMouse<String, Edge>(); vv.setGraphMouse(gm); popupMenu = new LicenseTermPopupMenu<>(licenseModel); gm.add(popupMenu); return vv; }
public void displayLicenseGraph() { Transformer<String, Paint> vertexColor = new Transformer<String, Paint>() { public Paint transform(String licenseTerm) { if (licenseTerm.contains("May")) return Color.GREEN; if (licenseTerm.contains("Must")) return Color.ORANGE; if (licenseTerm.equals("LimitedLiability") || licenseTerm.equals("ProvideWithoutWarranty")) return Color.CYAN; return Color.YELLOW; } }; Layout<String, Edge> layout = new CircleLayout<String, Edge>(this.licenseGraph); layout.setSize(new Dimension(1024, 768)); VisualizationViewer<String, Edge> vv = new VisualizationViewer<String, Edge>(layout); vv.setPreferredSize(new Dimension(1024, 768)); vv.getRenderContext().setVertexFillPaintTransformer(vertexColor); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>()); AbstractModalGraphMouse gm = new DefaultModalGraphMouse<String, Edge>(); vv.setGraphMouse(gm); LicenseTermPopupMenu<String, Edge> popupMenu = new LicenseTermPopupMenu<>(licenseModel); gm.add(popupMenu); JFrame frame = new JFrame("Interactive Graph View 1"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); frame.pack(); frame.setVisible(true); }