Example usage for org.jfree.chart ChartPanel ChartPanel

List of usage examples for org.jfree.chart ChartPanel ChartPanel

Introduction

In this page you can find the example usage for org.jfree.chart ChartPanel ChartPanel.

Prototype

public ChartPanel(JFreeChart chart) 

Source Link

Document

Constructs a panel that displays the specified chart.

Usage

From source file:IHM.compargraph.java

/**
 *
 * @param title//w w w.  ja  v  a  2 s.c  o m
 * @param c1
 * @param c2
 * @param comp
 * 
 */
public compargraph(String title, ArrayList<ReleveMeteo> c1, ArrayList<ReleveMeteo> c2, String comp) {
    super(title);
    t1 = c1;
    t2 = c2;
    c = comp;

    // jp = new JInternalFrame("courbes");

    JFreeChart chart = createChart(createDataset());
    ChartPanel panel = new ChartPanel(chart);
    panel.setPreferredSize(new Dimension(500, 300));
    setContentPane(panel);
    //  jp.add(panel, BorderLayout.EAST);
    //  jp.setVisible(true);
    panel.setVisible(true);
    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    // sets thickness for series (using strokes)
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);
    plot.setOutlinePaint(Color.BLUE);
    plot.setOutlineStroke(new BasicStroke(2.0f));
    plot.setBackgroundPaint(Color.DARK_GRAY);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.BLACK);

}

From source file:networkmonitor.MainIBMApplicationForm.java

public MainIBMApplicationForm() {

    setSize(850, 320); //set size
    setTitle("Network Monitor");//Setting the title

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Setting the action close to the close button

    //............menu........... 
    /*  JMenuBar menuBar = new JMenuBar();
               /*from  w  w  w  .  j a  v  a2  s  . c o m*/
      // Add the menubar to the frame
      setJMenuBar(menuBar);
     // Define and add two drop down menu to the menubar
      JMenu about = new JMenu("");
      menuBar.add(about);
              
              
      menuBar.add(Box.createHorizontalGlue());
               
               
      JMenu version = new JMenu("");
      menuBar.add(version);*/

    //.................. 

    series1 = new XYSeries("b/w usage in KBps");
    dataset = createDataset();
    chart = createChart(dataset);
    chartPanel = new ChartPanel(chart);
    //chartPanel.setPreferredSize(new java.awt.Dimension(850, 320));

    // chartPanel.setLayout();
    chartPanel.add(current_bandwidth_label);
    setContentPane(chartPanel);
    pmt = new PacketMonitoringThread();
    pmt.start();

    Action updateCursorAction = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {

            int current_bandwidth = new Integer((int) TcpPacketCapturer.getPacketSizeTillNowAndResetSize());

            qe.add(current_bandwidth);
            current_bandwidth_label.setText("" + current_bandwidth);
            if (qe.size() > 20) {
                System.out.println(qe.poll());
            }

            dataset = createDataset();
            chart = createChart(dataset);
            chartPanel = new ChartPanel(chart);

            //    getContentPane().repaint();
            //   SwingUtilities.updateComponentTreeUI(chartPanel);
        }
    };

    // its timer, it works like sleep, and in this apps its give you Internet speed KB/sec.

    new Timer(1000, updateCursorAction).start();

}

From source file:com.testmax.framework.CreateGraph.java

protected void createChart(double timeout) {

    TimeSeriesCollection dataset = new TimeSeriesCollection(ts);
    this.chart = ChartFactory.createTimeSeriesChart(this.graphName, this.xName, this.yName, dataset, true, true,
            false);//from w  ww  . ja  v a2s.c  o m
    final XYPlot plot = chart.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(timeout * 1000.0);

    JFrame frame = new JFrame(this.graphName);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ChartPanel label = new ChartPanel(chart);
    frame.getContentPane().add(label);
    //Suppose I add combo boxes and buttons here later 

    frame.pack();
    if (ConfigLoader.getConfig("SHOW_GRAPH_RUNTIME").equalsIgnoreCase("yes")) {
        frame.setVisible(true);
    } else {
        frame.setVisible(false);
    }
}

From source file:ca.nengo.ui.util.DialogPlotter.java

@Override
protected void showChart(JFreeChart chart, String title) {
    JPanel panel = new ChartPanel(chart);

    JDialog dialog = new JDialog(parent, title);
    dialog.getContentPane().add(panel, BorderLayout.CENTER);

    dialog.pack();/*from ww w .jav a2 s .  c  om*/
    dialog.setVisible(true);
}

From source file:neuronspike.NetPlot.java

public JPanel getPanel() {
    return new ChartPanel(chart);
}

From source file:geneticalgorithm.gui.view.VGraphic.java

public VGraphic(String title, String xLabel, String yLabel) {
    setSize(800, 600);//from   w  w  w  .  jav a  2 s . c o m
    setLocationRelativeTo(this);
    setTitle(title);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent arg0) {
            dispose();
        }
    });
    setLayout(new BorderLayout());

    average = new XYSeries("Average");
    offline = new XYSeries("Offline");
    online = new XYSeries("Online");

    dataset = new XYSeriesCollection();
    dataset.addSeries(average);
    dataset.addSeries(offline);
    dataset.addSeries(online);

    chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, true, true,
            false);
    add(new ChartPanel(chart), BorderLayout.CENTER);

    JPanel south = new JPanel(new MigLayout());

    lblAverage = new JLabel("");
    lblAverage.setHorizontalTextPosition(SwingConstants.LEFT);
    lblAverage.setFont(new Font("ARIAL", Font.BOLD, 26));
    JLabel lblAverageTitle = new JLabel("Average: ");
    lblAverageTitle.setFont(new Font("ARIAL", Font.BOLD, 26));
    south.add(lblAverageTitle);
    south.add(lblAverage, "wrap");

    lblOffline = new JLabel("");
    lblOffline.setHorizontalTextPosition(SwingConstants.LEFT);
    lblOffline.setFont(new Font("ARIAL", Font.BOLD, 26));
    JLabel lblOfflineTitle = new JLabel("Offline: ");
    lblOfflineTitle.setFont(new Font("ARIAL", Font.BOLD, 26));
    south.add(lblOfflineTitle);
    south.add(lblOffline, "wrap");

    lblOnline = new JLabel("");
    lblOnline.setHorizontalTextPosition(SwingConstants.LEFT);
    lblOnline.setFont(new Font("ARIAL", Font.BOLD, 26));
    JLabel lblOnlineTitle = new JLabel("Online: ");
    lblOnlineTitle.setFont(new Font("ARIAL", Font.BOLD, 26));
    south.add(lblOnlineTitle);
    south.add(lblOnline, "wrap");

    add(south, BorderLayout.SOUTH);
}

From source file:eu.choreos.chart.XYChart.java

public XYChart(String applicationTitle, String chartTitle, List<ScalabilityReport> reports) {
    super(applicationTitle);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    XYSeriesCollection dataset = new XYSeriesCollection();

    for (ScalabilityReport report : reports) {
        createDataset(dataset, report);//from   www . j av  a2 s  .c  o m
    }
    // based on the dataset we create the chart
    JFreeChart chart = createChart(dataset, chartTitle);
    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    // default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    // add it to our application
    setContentPane(chartPanel);

}

From source file:Componentes.TermometroMax.java

@Override
public void pintar(javax.swing.JPanel p, int pos) {
    p.removeAll();/*from   ww  w  . j  a v  a  2  s .  c  o  m*/
    DefaultValueDataset data = new DefaultValueDataset(new Double(ventana.getGraphdata().getTmax()));

    ThermometerPlot plot = new ThermometerPlot(data);
    chart = new JFreeChart("Temperatura Maxima, \nMES: " + Calculos.get_mes(ventana.getMonthdata().getdata()), // chart title
            JFreeChart.DEFAULT_TITLE_FONT, plot, // plot
            false);

    Color Darkorange = new Color(255, 140, 0);
    Color Crimson = new Color(220, 20, 60);
    Color Aquamarine = new Color(127, 255, 212);
    Color Darkslategray = new Color(47, 79, 79);

    plot.setMercuryPaint(Aquamarine);
    plot.setSubrange(NORMAL, 0, 10);
    plot.setSubrange(WARNING, 10.1, 20);
    plot.setSubrange(CRITICAL, 20.1, 50);
    plot.setSubrangePaint(NORMAL, Aquamarine);
    plot.setSubrangePaint(WARNING, Darkorange);
    plot.setSubrangePaint(CRITICAL, Crimson);

    plot.setThermometerStroke(new BasicStroke(2.0f));
    plot.setThermometerPaint(Darkslategray);

    plot.setDisplayRange(5, Calculos.get_min(datos.getTmax()), Calculos.get_max(datos.getTmax()));
    plot.setRange(Calculos.get_min(datos.getTmax()), Calculos.get_max(datos.getTmax()));

    panel = new ChartPanel(chart);
    panel.setBounds(5, 5, 300, 300);
    panel.repaint();
    p.add(panel);
    // jPanel1.repaint();
    p.updateUI();
    // aoIndex=aoAux;
    ///aoAux = 0;
}

From source file:fr.crnan.videso3d.ihm.TrajectoryProjectionGUI.java

public TrajectoryProjectionGUI(List<VidesoTrack> tracks, Globe globe) {

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);//from  ww w .j a  v  a2 s.  c  o  m

    JMenu mnParamtres = new JMenu("Paramtres");
    menuBar.add(mnParamtres);

    JMenuItem mntmNewMenuItem = new JMenuItem("New menu item");
    mnParamtres.add(mntmNewMenuItem);

    double ref = TracksStatsProducer.computeReferenceAltitude(tracks);
    XYSeriesCollection dataset = new XYSeriesCollection();

    for (VidesoTrack t : tracks) {
        dataset.addSeries(TracksStatsProducer.computeDevelopedPath(t, ref, false, globe));
    }

    JFreeChart chart = ChartFactory.createXYLineChart("Projection", "Distance (NM)", "Altitude (FL)", dataset,
            PlotOrientation.VERTICAL, false, true, false);

    ChartPanel panel = new ChartPanel(chart);
    setContentPane(panel);
    pack();
}

From source file:Interface.Teste.java

public void criacao() {
    DefaultCategoryDataset ds = new DefaultCategoryDataset();
    ds.addValue(40.5, "maximo", "dia 1");
    ds.addValue(38.2, "maximo", "dia 2");
    ds.addValue(37.3, "maximo", "dia 3");
    ds.addValue(31.5, "maximo", "dia 4");
    ds.addValue(35.7, "maximo", "dia 5");
    ds.addValue(42.5, "maximo", "dia 6");

    // cria o grfico
    JFreeChart grafico = ChartFactory.createLineChart("Meu Grafico", "Dia", "Valor", ds,
            PlotOrientation.VERTICAL, true, true, false);
    try {//  www.  j  a v a2  s . c o  m
        OutputStream arquivo = new FileOutputStream("grafico.png");
        ChartUtilities.writeChartAsPNG(arquivo, grafico, 550, 400);
        arquivo.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    JPopupMenu pop = new JPopupMenu();
    pop.add(new JMenuItem("1"));
    pop.add(new JMenuItem("2"));
    pop.add(new JMenuItem("3"));
    pop.add(new JMenuItem("4"));
    JPanel painel = new JPanel();
    JButton botao = new JButton("teste");
    JCalendar cal = new JCalendar();
    botao.add(pop);
    painel.add(cal);
    painel.add(new ChartPanel(grafico));
    //Calendar c = cal.getDate();
    Date data = cal.getDate();
    int dia = data.getDay();
    System.out.println("" + dia);

    add(painel);
}