Esempio n. 1
0
 /**
  * This method initializes dynChartPanel
  *
  * @return javax.swing.JPanel
  */
 private JPanel getDynChartPanel() {
   if (dynChartPanel == null) {
     CardLayout cardLayout = new CardLayout();
     dynChartPanel = new JPanel();
     dynChartPanel.setLayout(cardLayout);
     dynChartPanel.add(relChart, relChart.getName());
     dynChartPanel.add(alertChart, alertChart.getName());
   }
   return dynChartPanel;
 }
Esempio n. 2
0
  /**
   * Main entry.
   *
   * <p>
   *
   * @param args ignored.
   */
  public static void main(final String[] args) {
    // Create a chart:
    Chart2D chart = new Chart2D();

    // Create an ITrace:
    ITrace2D trace = new Trace2DSimple();
    // Add the trace to the chart:
    chart.addTrace(trace);
    trace.setTracePainter(new TracePainterDisc());
    trace.setColor(Color.DARK_GRAY);
    // Add all points, as it is static:
    double count = 0;
    double value;
    double place = 0;
    for (int i = 120; i >= 0; i--) {
      count += 1.0;
      place += 1.0;
      value = Math.random() * count * 10;
      trace.addPoint(place, value);
    }

    // Make it visible:
    // Create a frame.
    JFrame frame = new JFrame("StaticChartDiscs");
    // add the chart to the frame:
    frame.getContentPane().add(new ChartPanel(chart));
    frame.setSize(400, 300);
    // Enable the termination button [cross on the upper right edge]:
    frame.addWindowListener(
        new WindowAdapter() {
          /** @see java.awt.event.WindowAdapter#windowClosing(java.awt.event.WindowEvent) */
          @Override
          public void windowClosing(final WindowEvent e) {
            System.exit(0);
          }
        });
    frame.setVisible(true);
  }
Esempio n. 3
0
  public void init() {
    boolean online;

    url = getCodeBase().toString();
    System.out.println(url);
    createCharts();
    online = isOnline();
    setBounds(new Rectangle(0, 0, 700, 560));
    setContentPane(getCardPanel());

    // set to simple view
    alertChartS.setVisible(false);
    ((CardLayout) dynChartPanel.getLayout()).show(dynChartPanel, "alertChart");
    logButton.setVisible(false);

    // all the layout is rendered
    if (online && url != null) startCharts();
  }
Esempio n. 4
0
  private void createCharts() {
    // mini plot (advanced mode)
    alertChartS = new Chart2D();
    alertChartS.setPaintLabels(false);
    alertChartS.setName("alertChartS");
    alertChartS.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Last ten minutes alerts",
            TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION,
            new Font("Dialog", Font.BOLD, 12),
            new Color(51, 51, 51)));
    alertChartS.getAxisX().setPaintGrid(true);
    alertChartS.getAxisY().setPaintGrid(true);
    alertChartS.getAxisX().setPaintScale(true);
    alertChartS.getAxisY().setPaintScale(true);
    alertChartS.getAxisY().setRangePolicy(new RangePolicyForcedPoint());

    alert_trace_s = new Trace2DLtd(MINI_TRACE_SIZE, "Alerts");
    alert_trace_s.setColor(Color.BLUE);
    alert_trace_s.setPhysicalUnits("Alerts", "Minutes");
    alert_trace_s.setTracePainter$30c0137f(new TracePainterBar(alertChartS, 10));

    alertChartS.addTrace(alert_trace_s);

    // first plot (advanced mode)
    relChart = new Chart2D();
    relChart.setName("relChart");
    relChart.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Packet similarity value per second",
            TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION,
            new Font("Dialog", Font.BOLD, 12),
            new Color(51, 51, 51)));
    relChart.getAxisX().setPaintGrid(true);
    relChart.getAxisY().setPaintGrid(true);
    relChart.getAxisX().setPaintScale(true);
    relChart.getAxisY().setPaintScale(true);

    rel_trace = new Trace2DLtd(TRACE_SIZE, "Similarity");
    rel_trace.setColor(Color.BLUE);
    rel_trace.setPhysicalUnits("Seconds", "Similarity");

    thres_trace = new Trace2DLtd(TRACE_SIZE, "Threshold");
    thres_trace.setColor(Color.RED);
    thres_trace.setPhysicalUnits("Seconds", "Similarity");

    relChart.addTrace(rel_trace);
    relChart.addTrace(thres_trace);

    // first plot (simple view)
    alertChart = new Chart2D();
    alertChart.setName("alertChart");
    alertChart.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Alerts per second",
            TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION,
            new Font("Dialog", Font.BOLD, 12),
            new Color(51, 51, 51)));
    alertChart.getAxisX().setPaintGrid(true);
    alertChart.getAxisY().setPaintGrid(true);
    alertChart.getAxisX().setPaintScale(true);
    alertChart.getAxisY().setPaintScale(true);
    alertChart.getAxisY().setRangePolicy(new RangePolicyForcedPoint());

    alert_trace = new Trace2DLtd(TRACE_SIZE, "Alerts");
    alert_trace.setColor(Color.BLUE);
    alert_trace.setPhysicalUnits("Seconds", "Alerts");
    alert_trace.setTracePainter$30c0137f(new TracePainterBar(alertChart, 5));

    alertChart.addTrace(alert_trace);

    // second plot (simple view)
    dataChart = new Chart2D();
    dataChart.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Bytes processed per second",
            TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION,
            new Font("Dialog", Font.BOLD, 12),
            new Color(51, 51, 51)));
    dataChart.getAxisX().setPaintGrid(true);
    dataChart.getAxisY().setPaintGrid(true);
    dataChart.getAxisX().setPaintScale(true);
    dataChart.getAxisY().setPaintScale(true);
    dataChart.getAxisY().setRangePolicy(new RangePolicyForcedPoint());

    data_trace = new Trace2DLtd(TRACE_SIZE, "Bandwidth");
    data_trace.setColor(Color.GREEN);
    data_trace.setPhysicalUnits("Seconds", "Bytes");
    alertChart.getAxisY().setRangePolicy(new RangePolicyForcedPoint());

    dataChart.addTrace(data_trace);

    // charts initialization
    for (int i = -TRACE_SIZE; i < 0; i++) {
      rel_trace.addPoint(new TracePoint2D(i, 0.0D));
      thres_trace.addPoint(new TracePoint2D(i, 0.0D));
      data_trace.addPoint(new TracePoint2D(i, 0.0D));
      alert_trace.addPoint(new TracePoint2D(i, 0.0D));
      if (i >= -MINI_TRACE_SIZE) {
        alert_trace_s.addPoint(new TracePoint2D(i, 0.0D));
      }
    }
    last_point = new TracePoint2D(0, 0);
  }