Exemplo n.º 1
0
  public void paint(Graphics g) {
    // super.repaint();
    pWidth = this.getWidth() - (inset.left + inset.right);
    pHeight = this.getHeight() - (inset.top + inset.bottom);

    top.setBounds(0, 0, pWidth, (int) (pHeight * (1.0f - graphVerticalSize)));

    nodeGraph.setBounds(0, 0, (int) (top.getWidth() * 0.8f) - 5, top.getHeight());

    nodeGraphView.setBounds(0, 20, nodeGraph.getWidth(), nodeGraph.getHeight() - 20);
    nodeGraphView.getGraphLayout().setSize(nodeGraphView.getSize());

    nodeGraphInform.setBounds(
        (int) (top.getWidth() * 0.8f), 20, (int) (top.getWidth() * 0.2f), top.getHeight() - 20);
    nodeGraphMap.setBounds(0, 0, nodeGraphInform.getWidth(), nodeGraphInform.getWidth());
    nodeGraphMap
        .getGraphLayout()
        .setSize(new Dimension(nodeGraphInform.getWidth(), nodeGraphInform.getWidth()));

    nodeGraphProtocolView.setBounds(
        0,
        nodeGraphMap.getHeight() + 5,
        nodeGraphInform.getWidth(),
        nodeGraphInform.getHeight() - nodeGraphMap.getHeight() - 5);
    /*
    Relaxer relaxer = nodeGraphView.getModel().getRelaxer();
    if(relaxer != null) {
    	relaxer.stop();
    	relaxer.prerelax();
    	relaxer.relax();
    }
    */

    trafficGraph.setBounds(
        0,
        (int) (pHeight * (1.0f - graphVerticalSize)) + 10,
        pWidth,
        (int) (pHeight * graphVerticalSize));
    trafficGraph.repaint();

    graphVerticalSizeBt.setBounds(0, (int) (pHeight * (1.0f - graphVerticalSize)), pWidth, 10);
    graphVerticalSizeBt.repaint();

    graphHorizontalSizeBt.setBounds((int) (top.getWidth() * 0.8f) - 5, 20, 5, top.getHeight());
    graphHorizontalSizeBt.repaint();
  }
Exemplo n.º 2
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);
  }