Example usage for org.jfree.chart ChartPanel setMouseZoomable

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

Introduction

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

Prototype

public void setMouseZoomable(boolean flag, boolean fillRectangle) 

Source Link

Document

A convenience method that switches on mouse-based zooming.

Usage

From source file:org.jfree.chart.demo.ChartPanelSerializationTest.java

/**
 * A demonstration application showing how to create a simple time series chart.  This
 * example uses monthly data.//from  w w  w  .j  a  v  a2 s  . c om
 *
 * @param title  the frame title.
 */
public ChartPanelSerializationTest(final String title) {

    super(title);
    final XYDataset dataset = createDataset();
    final JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel1 = new ChartPanel(chart);
    chartPanel1.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel1.setMouseZoomable(true, false);

    ChartPanel chartPanel2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(chartPanel1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        chartPanel2 = (ChartPanel) in.readObject();
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

    setContentPane(chartPanel2);

}

From source file:LineChart.java

public LineChart(JTable table) {
    final JFrame frame = new JFrame("jshow Chart");

    final JFreeChart chart = createDataset(table);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    frame.setContentPane(chartPanel);//from  w w  w  . j  av a2s .co m

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    frame.setIconImage(Toolkit.getDefaultToolkit()
            .createImage(LineChart.class.getResource("de/skelton/images/chart.png")));

    frame.pack();
    frame.setVisible(true);
    frame.requestFocus();
    frame.toFront();
}

From source file:sly.speakrecognizer.ui.TimeSeriesChartDemo1.java

/**
 * A demonstration application showing how to create a simple time series 
 * chart.  This example uses monthly data.
 *
 * @param title  the frame title.//from ww w  .  j av a2s .  c  o m
 */
public TimeSeriesChartDemo1(String title) {
    super(title);
    ChartPanel chartPanel = (ChartPanel) createDemoPanel();
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
}

From source file:techtonic.Exports.java

/**
 * Creates new form Exports//from ww  w . java 2 s .c o m
 */
public Exports(java.awt.Frame parent, boolean modal) {
    super(parent, "Exporting :-TechTonic-", true);
    initComponents();
    fBg.add(jpg);
    fBg.add(png);
    jpg.setSelected(true);
    setResizable(false);
    this.width.setText("" + Techtonic.geteWidth());
    this.height.setText("" + Techtonic.geteHeight());

    ChartPanel cp = new ChartPanel(Techtonic.getFreeChart());
    cp.setMouseZoomable(true, true);
    exportSavePanel.setLayout(new java.awt.BorderLayout());
    exportSavePanel.add(cp, BorderLayout.CENTER);
    exportSavePanel.validate();
}

From source file:bullioneconomy.bullionchart.java

/**
 * A demonstration application showing how to create a simple time series 
 * chart.  This example uses monthly data.
 *
 * @param title  the frame title.//  w  w w  .  ja va  2s  . c  o  m
 */
public bullionchart(String title) throws ClassNotFoundException, SQLException, ParseException {
    super(title);
    XYDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset);
    ChartPanel chartPanel = new ChartPanel(chart, false);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
}

From source file:org.atomserver.testutils.plot.PerfPlotter.java

private ChartPanel getChartPanel() {
    ChartPanel chartPanel = new ChartPanel(this.plot);
    if (log.isTraceEnabled())
        log.trace("chartPanel= " + chartPanel);

    chartPanel.setPreferredSize(new java.awt.Dimension(this.width, this.hieght));
    chartPanel.setMouseZoomable(true, false);

    return chartPanel;
}

From source file:techtonic.WellBoreListenerOnView.java

public void superImposGraph(List<WitsmlTrajectory> trajectorys) {
    int ct = 0;// w  w  w .j  ava  2  s  .c  om
    XYSeriesCollection data = new XYSeriesCollection();
    for (WitsmlTrajectory trajectory : trajectorys) {

        List<WitsmlTrajectoryStation> stationsAsList = Arrays
                .asList(new WitsmlTrajectoryStation[trajectory.getStations().size()]);
        for (WitsmlTrajectoryStation s : trajectory.getStations()) {
            stationsAsList.set(s.getStationNo(), s);
        }

        XYSeries series = new XYSeries(trajectory.getName());
        // add data to Dataset (here assume data is in ArrayLists x and y

        for (WitsmlTrajectoryStation station : stationsAsList) {

            Value tvd = station.getTvd();

            if (tvd == null) {
                continue;
            }
            Value md = station.getNorth();
            if (md == null) {
                continue;
            }
            //  System.out.println(count + " : ===>> tvd : "+tvd.getValue()+ "; md "+md.getValue());
            series.add(md.getValue(), tvd.getValue());

        }

        data.addSeries(series);
        ct++;
    }
    // create a chart using the createYLineChart method...
    JFreeChart chart = ChartFactory.createXYLineChart("Trajectory: True Vertical Depth Against North", // chart title
            "North", "Depth", // x and y axis labels
            data); // data

    ChartPanel cp = new ChartPanel(chart);
    //            JFrame fr = new JFrame();
    //            fr.add(cp);
    //            fr.pack();
    //            fr.setVisible(true);
    cp.setMouseZoomable(true, true);
    Techtonic.setFreeChart(chart);
    Techtonic.setDisplayArea(cp);

}

From source file:edu.unibonn.plotting.TimeSeriesPlotter_Sensors.java

public TimeSeriesPlotter_Sensors(String title, ArrayList<Sensor> sensors) {
    super(title);
    final XYDataset dataset = createDataset(sensors);
    final JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);/*from  w  w  w  . j  ava  2  s  .  c  o m*/
}

From source file:dpnm.netmsuite.plc.manager.frontend.graph.TimeSeriesChartDemo1.java

/**
 * A demonstration application showing how to create a simple time series 
 * chart.  This example uses monthly data.
 *
 * @param title  the frame title./*  w  w  w  . j a  va2 s  .  c  om*/
 * @param graphType - 1,2,3 -> inPkts/outPkts | inBytes/outBytes | inSpeed/outSpeed
 * @param statisticsInfos - Vector<StatisticInfo>
 * @param heigh/width -> graph's size
 * @param time - graph size
 */
public TimeSeriesChartDemo1(String title, int graphType, Vector statisticInfos, int height, int width,
        int time) {
    super(title);
    this.title = title;
    this.graphType = graphType;
    this.statisticInfos = statisticInfos;
    this.height = height;
    this.width = width;
    this.time = time;

    ChartPanel chartPanel = (ChartPanel) createDemoPanel();
    chartPanel.setPreferredSize(new java.awt.Dimension(height, width));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
}

From source file:edu.unibonn.kmeans.mapreduce.plotting.TimeSeriesPlotter_KMeans.java

/**
 * A demonstration application showing how to create a simple time series chart.  This
 * example uses monthly data./*from w ww .ja  va 2 s.c  om*/
 *
 * @param title  the frame title.
 */
//    public TimeSeriesPlotter(final String title) {
//        
//        super(title);
//        final XYDataset dataset = createDataset();
//        final JFreeChart chart = createChart(dataset);
//        final ChartPanel chartPanel = new ChartPanel(chart);
//        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
//        chartPanel.setMouseZoomable(true, false);
//        
//        setContentPane(chartPanel);
//
//    }

//    public TimeSeriesPlotter(String title, ArrayList<Sensor> sensors)
//    {
//       super(title);
//        final XYDataset dataset = createDataset(sensors);
//        final JFreeChart chart = createChart(dataset);
//        final ChartPanel chartPanel = new ChartPanel(chart);
//        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
//        chartPanel.setMouseZoomable(true, false);
//        setContentPane(chartPanel);
//   }

public TimeSeriesPlotter_KMeans(String title, ArrayList<Cluster_KMeans> clusters, LocalDateTime from) {
    super(title);
    final XYDataset dataset = createDataset(clusters, from);
    final XYDataset dataset_cetroids = createDataset_centroids(clusters, from);
    final JFreeChart chart = createChart(dataset, dataset_cetroids, clusters);
    final ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.setPreferredSize(new java.awt.Dimension(2560, 1600));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);

    try {
        ChartUtilities.saveChartAsJPEG(new File("./jpgs/" + title + ".jpg"), chart, 1920, 1200);
    } catch (Exception e) {
        e.printStackTrace();
    }
}