Example usage for org.jfree.chart JFreeChart clone

List of usage examples for org.jfree.chart JFreeChart clone

Introduction

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

Prototype

@Override
public Object clone() throws CloneNotSupportedException 

Source Link

Document

Clones the object, and takes care of listeners.

Usage

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

public CloneTest1(String s) {
    super(s);/*from w  ww .j a  v  a2 s .c om*/
    lastValue = 100D;
    series = new TimeSeries("Random Data");
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(series);
    JFreeChart jfreechart = createChart(timeseriescollection);
    JFreeChart jfreechart1 = null;
    try {
        jfreechart1 = (JFreeChart) jfreechart.clone();
    } catch (Exception exception) {
        exception.printStackTrace();
    }
    XYPlot xyplot = (XYPlot) jfreechart1.getPlot();
    TimeSeriesCollection timeseriescollection1 = (TimeSeriesCollection) xyplot.getDataset();
    series = timeseriescollection1.getSeries(0);
    ChartPanel chartpanel = new ChartPanel(jfreechart1);
    JButton jbutton = new JButton("Add New Data Item");
    jbutton.setActionCommand("ADD_DATA");
    jbutton.addActionListener(this);
    JPanel jpanel = new JPanel(new BorderLayout());
    jpanel.add(chartpanel);
    jpanel.add(jbutton, "South");
    chartpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(jpanel);
}

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

public PDFChartTransferable(JFreeChart jfreechart, int i, int j, boolean flag) {
    pdfFlavor = new DataFlavor("application/pdf", "PDF");
    try {/*w  w w  .  j a v a2 s  .c om*/
        chart = (JFreeChart) jfreechart.clone();
    } catch (CloneNotSupportedException clonenotsupportedexception) {
        chart = jfreechart;
    }
    width = i;
    height = j;
}

From source file:org.gumtree.vis.mask.ChartTransferableWithMask.java

/**
 * @param chart//  w  w w .  j a  v a 2 s.  com
 * @param width
 * @param height
 * @param cloneData
 */
public ChartTransferableWithMask(JFreeChart chart, int width, int height, boolean cloneData) {
    try {
        this.chart = (JFreeChart) chart.clone();
    } catch (CloneNotSupportedException e) {
        this.chart = chart;
    }
    this.width = width;
    this.height = height;
}

From source file:net.sf.mzmine.chartbasics.graphicsexport.GraphicsExportDialog.java

protected void openDialogI(JFreeChart chart) {
    try {//from   w  w w  .  java 2  s .  c  o  m
        // create new chart to decouple from original chart
        JFreeChart copy = chart;
        try {
            copy = (JFreeChart) chart.clone();
        } catch (Exception e) {
            LOG.log(Level.WARNING, "Chart cannot be cloned", e);
        }
        addChartToPanel(new EChartPanel(copy), true);
        setVisible(true);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java

@Override
public void mouseClicked(MouseEvent event) {
    super.mouseClicked(event);

    if (SwingUtilities.isLeftMouseButton(event) && event.getClickCount() == 2) {
        final JFreeChart chartToExplain = getChart();
        if (chartToExplain.getPlot() instanceof PiePlot) {
            return;
        }/*from   ww  w . ja  v  a 2 s .c  o m*/
        DBSeerXYLineAndShapeRenderer renderer = (DBSeerXYLineAndShapeRenderer) chartToExplain.getXYPlot()
                .getRenderer();
        renderer.setLastSeriesAndCategory(-1, -1);

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                try {
                    DBSeerPlotExplainFrame newFrame = new DBSeerPlotExplainFrame(
                            (JFreeChart) chartToExplain.clone());
                    //                  newFrame.setPreferredSize(new Dimension(1280,800));
                    newFrame.pack();
                    newFrame.setLocationRelativeTo(DBSeerGUI.mainFrame);
                    newFrame.setVisible(true);
                } catch (CloneNotSupportedException e) {
                    JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
                }
            }
        });
    }
}