Example usage for org.jfree.chart.plot XYPlot getDataset

List of usage examples for org.jfree.chart.plot XYPlot getDataset

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot getDataset.

Prototype

public XYDataset getDataset() 

Source Link

Document

Returns the primary dataset for the plot.

Usage

From source file:cgpanalyser.gui.chart.XYChartPanel.java

public void setPrevCrosshairValue(JFreeChart jfreechart) {
    XYPlot plot = (XYPlot) jfreechart.getPlot();
    XYDataset dataset = plot.getDataset();

    //set crosshair to previous value if not on first already
    for (int i = 0; i < dataSampler.getLastToDisplay().size(); i++) { //find generation in datasampler.todisplay
        if ((int) plot.getDomainCrosshairValue() == dataSampler.getLastToDisplay().get(i).getGenNumber()) {
            if (i > 0) {
                plot.setDomainCrosshairValue(dataset.getXValue(0, i - 1));
                plot.setRangeCrosshairValue(dataset.getYValue(0, i - 1));
            }//from   w w  w.j  av a2  s. co  m
            break;
        }
    }

}

From source file:ec.nbdemetra.sa.revisionanalysis.RevisionAnalysisChart.java

@Override
protected void onColorSchemeChange() {
    XYPlot plot = chartPanel.getChart().getXYPlot();
    for (int i = 0; i < plot.getDataset().getSeriesCount(); i++) {
        plot.getRenderer().setSeriesPaint(i, themeSupport.getLineColor(i));
    }/*from w ww.  j a v  a 2s.  c o m*/
    plot.setBackgroundPaint(themeSupport.getPlotColor());
    plot.setDomainGridlinePaint(themeSupport.getGridColor());
    plot.setRangeGridlinePaint(themeSupport.getGridColor());
    chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor());
}

From source file:com.alcatel_lucent.nz.wnmsreport.chart.TimeSeriesIuRChartCustomiser.java

public void customise(JFreeChart chart, JRChart jasperchart) {
    XYPlot xyplot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    XYDataset xyDataset = xyplot.getDataset();
    LegendItemCollection legend = xyplot.getLegendItems();
    LegendItemCollection revised = new LegendItemCollection();

    if (xyDataset != null) {
        for (int i = 0; i < xyDataset.getSeriesCount(); i++) {
            if (i < 1) {
                //make line 1 dashed
                renderer.setSeriesStroke(i, stroke_dashed);
            } else {
                //make other lines filled and add to new legend
                renderer.setSeriesStroke(i, stroke_normal);
                revised.add(legend.get(i));
            }/*  ww w  .j a v a 2s.  c om*/
            renderer.setSeriesLinesVisible(i, true);
        }
    }
    xyplot.setFixedLegendItems(revised);
}

From source file:org.jfree.chart.demo.selection.SelectionDemo4.java

/**
 * Creates a new demo./*  w ww .  ja  v  a  2 s . c o m*/
 * 
 * @param title  the frame title.
 */
public SelectionDemo4(String title) {
    super(title);
    ChartPanel chartPanel = (ChartPanel) createDemoPanel();
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    JFreeChart chart = chartPanel.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    this.dataset = (HistogramDataset) plot.getDataset();
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.add(chartPanel);

    this.model = new DefaultTableModel(new String[] { "Item:", "Bin Start:", "Bin End:", "Value:" }, 0);
    this.table = new JTable(this.model);
    JPanel p = new JPanel(new BorderLayout());
    JScrollPane scroller = new JScrollPane(this.table);
    p.add(scroller);
    p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "),
            new EmptyBorder(4, 4, 4, 4)));
    split.add(p);
    setContentPane(split);
}

From source file:org.jfree.chart.demo.selection.SelectionDemo2.java

/**
 * A demonstration application showing a scatter plot.
 *
 * @param title  the frame title.//from w ww  .java2s .  c  o  m
 */
public SelectionDemo2(String title) {
    super(title);
    ChartPanel chartPanel = (ChartPanel) createDemoPanel();
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    JFreeChart chart = chartPanel.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    this.dataset = (XYSeriesCollection) plot.getDataset();
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.add(chartPanel);

    this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "X:", "Y:" }, 0);
    this.table = new JTable(this.model);
    TableColumnModel tcm = this.table.getColumnModel();
    tcm.getColumn(2).setCellRenderer(new NumberCellRenderer());
    tcm.getColumn(3).setCellRenderer(new NumberCellRenderer());
    JPanel p = new JPanel(new BorderLayout());
    JScrollPane scroller = new JScrollPane(this.table);
    p.add(scroller);
    p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "),
            new EmptyBorder(4, 4, 4, 4)));
    split.add(p);
    setContentPane(split);
}

From source file:org.jfree.expdemo.SelectionDemo4.java

/**
 * Creates a new demo./*from   www.  j a v  a  2s .com*/
 * 
 * @param title
 *            the frame title.
 */
public SelectionDemo4(String title) {
    super(title);
    ChartPanel chartPanel = (ChartPanel) createDemoPanel();
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    JFreeChart chart = chartPanel.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    this.dataset = (SimpleHistogramDataset) plot.getDataset();
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.add(chartPanel);

    this.model = new DefaultTableModel(new String[] { "Item:", "Bin Start::", "Bin End:", "Value:" }, 0);
    this.table = new JTable(this.model);
    JPanel p = new JPanel(new BorderLayout());
    JScrollPane scroller = new JScrollPane(this.table);
    p.add(scroller);
    p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "),
            new EmptyBorder(4, 4, 4, 4)));
    split.add(p);
    setContentPane(split);
}

From source file:org.jfree.chart.demo.selection.SelectionDemo3.java

/**
 * A demonstration application showing a scatter plot.
 *
 * @param title  the frame title.//from  www. jav a  2s. c o  m
 */
public SelectionDemo3(String title) {
    super(title);
    ChartPanel chartPanel = (ChartPanel) createDemoPanel();
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    JFreeChart chart = chartPanel.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    this.dataset = (XYSeriesCollection) plot.getDataset();
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.add(chartPanel);

    this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "X:", "Y:" }, 0);
    this.table = new JTable(this.model);
    TableColumnModel tcm = this.table.getColumnModel();
    tcm.getColumn(2).setCellRenderer(new NumberCellRenderer());
    tcm.getColumn(3).setCellRenderer(new NumberCellRenderer());
    JPanel p = new JPanel(new BorderLayout());
    JScrollPane scroller = new JScrollPane(this.table);
    p.add(scroller);
    p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "),
            new EmptyBorder(4, 4, 4, 4)));
    split.add(p);
    setContentPane(split);
}

From source file:org.jfree.chart.demo.selection.SelectionDemo8.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 *
 * @param title  the frame title./*from  w ww  . ja  v a  2 s .c o  m*/
 */
public SelectionDemo8(String title) {
    super(title);
    ChartPanel chartPanel = (ChartPanel) createDemoPanel();
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setRangeZoomable(false);

    JFreeChart chart = chartPanel.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    this.dataset = (TimeSeriesCollection) plot.getDataset();
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.add(chartPanel);

    this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "Period:", "Value:" }, 0);
    this.table = new JTable(this.model);
    TableColumnModel tcm = this.table.getColumnModel();
    tcm.getColumn(3).setCellRenderer(new NumberCellRenderer());
    JPanel p = new JPanel(new BorderLayout());
    JScrollPane scroller = new JScrollPane(this.table);
    p.add(scroller);
    p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "),
            new EmptyBorder(4, 4, 4, 4)));
    split.add(p);
    setContentPane(split);

}

From source file:org.jfree.chart.demo.selection.SelectionDemo1.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 * /*from  w  ww. j a v  a  2s  . co  m*/
 * @param title  the frame title.
 */
public SelectionDemo1(String title) {
    super(title);
    ChartPanel chartPanel = (ChartPanel) createDemoPanel();
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    JFreeChart chart = chartPanel.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    this.dataset = (TimeSeriesCollection) plot.getDataset();
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.add(chartPanel);

    this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "Period:", "Value:" }, 0);
    this.table = new JTable(this.model);
    TableColumnModel tcm = this.table.getColumnModel();
    tcm.getColumn(3).setCellRenderer(new NumberCellRenderer());
    JPanel p = new JPanel(new BorderLayout());
    JScrollPane scroller = new JScrollPane(this.table);
    p.add(scroller);
    p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "),
            new EmptyBorder(4, 4, 4, 4)));
    split.add(p);
    setContentPane(split);

}

From source file:com.googlecode.logVisualizer.chart.MPGainedSpentPerTurnXYBarChart.java

/**
 * Method overridden to make the MP spent bar colour use a bit of alpha,
 * otherwise MP gains below MP spent wouldn't be viewable.
 *///from ww  w . j a va2s .  c  o m
@Override
protected ChartPanel createChartPanel() {
    final ChartPanel panel = super.createChartPanel();
    final XYPlot plot = (XYPlot) panel.getChart().getPlot();
    final XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    final XYDataset dataset = plot.getDataset();

    for (int i = 0; i < dataset.getSeriesCount(); i++)
        if (dataset.getSeriesKey(i).equals("MP spent"))
            renderer.setSeriesPaint(i, new Color(255, 80, 80, 200));
        else if (dataset.getSeriesKey(i).equals("MP gained"))
            renderer.setSeriesPaint(i, new Color(100, 100, 255));

    return panel;
}