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);
  }
Exemplo n.º 3
0
  private void initComponent() {
    // TODO Auto-generated method stub

    top = new JPanel();

    nodeGraph = new JPanel();
    FRLayout<String, String> graphLayout = new FRLayout<String, String>(graph);
    nodeGraphView = new VisualizationViewer<String, String>(graphLayout);

    // nodeGraphView.setBackground(new Color(228,247,186));
    // nodeGraphView.setBackground(new Color(178,204,255));
    nodeGraphView.setBackground(new Color(255, 216, 216));

    nodeGraphView
        .getRenderContext()
        .setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<String>(
                nodeGraphView.getPickedEdgeState(), Color.black, Color.GREEN));
    nodeGraphView
        .getRenderContext()
        .setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(
                nodeGraphView.getPickedVertexState(),
                new Color(67, 116, 217),
                new Color(5, 0, 153)));
    final AbstractModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
    nodeGraphView.setGraphMouse(graphMouse);

    nodeGraphProtocolFilter = new JPanel();
    nodeGraph.add(nodeGraphProtocolFilter);
    nodeGraph.add(nodeGraphView);

    nodeGraphInform = new JPanel();
    nodeGraphMap = new SatelliteVisualizationViewer<String, String>(nodeGraphView);
    // nodeGraphMap.getRenderContext().setEdgeDrawPaintTransformer(new
    // PickableEdgePaintTransformer<String>(nodeGraphMap.getPickedEdgeState(), Color.black,
    // Color.GREEN));
    nodeGraphMap
        .getRenderContext()
        .setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(
                nodeGraphMap.getPickedVertexState(),
                new Color(67, 116, 217),
                new Color(5, 0, 153)));

    nodeTrafficTableModel = new NodeTrafficTableModel();
    TableColumnModel columnModel = new DefaultTableColumnModel();
    TableColumn column = new TableColumn(0);
    column.setHeaderValue("IP");
    columnModel.addColumn(column);

    column = new TableColumn(1);
    column.setHeaderValue("PORT");
    columnModel.addColumn(column);

    column = new TableColumn(2);
    column.setHeaderValue("PACKETS");
    columnModel.addColumn(column);

    column = new TableColumn(3);
    column.setHeaderValue("BYTES");
    columnModel.addColumn(column);

    column = new TableColumn(4);
    column.setHeaderValue("LEVEL");
    columnModel.addColumn(column);

    DefaultTableCellRenderer cellAlign = new DefaultTableCellRenderer();
    cellAlign.setHorizontalAlignment(JLabel.RIGHT);

    nodeTrafficTable = new JTable(nodeTrafficTableModel, columnModel);
    /*
       nodeTrafficTable.getColumn("IP").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("IP").setPreferredWidth(90);
       nodeTrafficTable.getColumn("PORT").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("PORT").setPreferredWidth(30);
       nodeTrafficTable.getColumn("PACKETS").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("PACKETS").setPreferredWidth(60);
       nodeTrafficTable.getColumn("BYTES").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("BYTES").setPreferredWidth(60);
       nodeTrafficTable.getColumn("LEVEL").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("LEVEL").setPreferredWidth(5);
    */
    nodeGraphicTable = new JTable(nodeGraphicTableModel);

    nodeGraphProtocolView = new JScrollPane(nodeTrafficTable);
    // nodeGraphProtocolView.setLayout(new BorderLayout());
    // nodeGraphProtocolView.add(nodeTrafficTable);

    nodeGraphInform.add(nodeGraphMap);
    nodeGraphInform.add(nodeGraphProtocolView);

    top.add(nodeGraph);
    top.add(nodeGraphInform);
    this.add(top);

    trafficGraph = new ChartPanel(trafficChart);
    trafficGraph.setFocusable(false);
    trafficChart.getLegend().setPosition(RectangleEdge.LEFT);

    this.add(trafficGraph);

    graphVerticalSizeBt = new JButton("::::::::△▽::::::::");
    graphVerticalSizeBt.setFont(graphVerticalSizeBt.getFont().deriveFont(10.0f));
    graphVerticalSizeBt.addMouseMotionListener(new GraphVerticalSizeMotionListener());
    graphVerticalSizeBt.addActionListener(new GraphVerticalSizeMotionListener());
    this.add(graphVerticalSizeBt);

    graphHorizontalSizeBt = new JButton();
    graphHorizontalSizeBt.setEnabled(false);
    top.add(graphHorizontalSizeBt);
  }