|
/*
|
|
* This program is a part of the IoTa project.
|
|
*
|
|
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
* <http://www.gnu.org/licenses/>
|
|
*
|
|
* See AUTHORS for a list of contributors.
|
|
*/
|
|
package fr.unicaen.iota.validator.gui;
|
|
|
|
import fr.unicaen.iota.validator.IOTA;
|
|
import fr.unicaen.iota.validator.model.Link;
|
|
import java.awt.BorderLayout;
|
|
import java.awt.Color;
|
|
import java.awt.Container;
|
|
import java.awt.image.BufferedImage;
|
|
import javax.swing.*;
|
|
import org.jfree.chart.ChartFactory;
|
|
import org.jfree.chart.JFreeChart;
|
|
import org.jfree.chart.plot.PlotOrientation;
|
|
import org.jfree.data.category.DefaultCategoryDataset;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public class Stats extends javax.swing.JFrame {
|
|
|
|
private IOTA iota;
|
|
private Box box;
|
|
private JScrollPane scrollPane;
|
|
|
|
/** Creates new form Stats */
|
|
public Stats(IOTA iota, Container parent) {
|
|
this.iota = iota;
|
|
initComponents();
|
|
this.box = Box.createVerticalBox();
|
|
processStats();
|
|
JPanel panel = new JPanel(new BorderLayout());
|
|
panel.add(box, BorderLayout.CENTER);
|
|
panel.setBackground(Color.WHITE);
|
|
scrollPane = new JScrollPane();
|
|
scrollPane.setViewportView(panel);
|
|
add(scrollPane, BorderLayout.CENTER);
|
|
setSize(700, 500);
|
|
setLocationRelativeTo(parent);
|
|
}
|
|
|
|
/** This method is called from within the constructor to
|
|
* initialize the form.
|
|
* WARNING: Do NOT modify this code. The content of this method is
|
|
* always regenerated by the Form Editor.
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
private void initComponents() {
|
|
|
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
|
setTitle("Stats");
|
|
setBackground(new java.awt.Color(254, 254, 254));
|
|
setForeground(new java.awt.Color(1, 1, 1));
|
|
|
|
pack();
|
|
}// </editor-fold>//GEN-END:initComponents
|
|
|
|
private void processStats() {
|
|
for (Link l : iota.getAllLinks()) {
|
|
DefaultCategoryDataset dcd = new DefaultCategoryDataset();
|
|
for (Integer i : l.getTimeResponseSupervisor().keySet()) {
|
|
dcd.addValue(l.getTimeResponseSupervisor().get(i), "responseTime", i);
|
|
}
|
|
JFreeChart chart = ChartFactory.createLineChart(l.getServiceAddress(), "queries", "Response Time (ms)", dcd, PlotOrientation.VERTICAL, false, false, false);
|
|
BufferedImage image = chart.createBufferedImage(650, 300);
|
|
JLabel lblChart = new JLabel();
|
|
lblChart.setIcon(new ImageIcon(image));
|
|
box.add(lblChart);
|
|
}
|
|
|
|
}
|
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
// End of variables declaration//GEN-END:variables
|
|
}
|