Example usage for org.jfree.chart JFreeChart getXYPlot

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

Introduction

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

Prototype

public XYPlot getXYPlot() 

Source Link

Document

Returns the plot cast as an XYPlot .

Usage

From source file:ssq.stock.gui.CandlestickDemo.java

/**
 * A demonstration application showing a candlestick chart.
 *
 * @param title/*from  w  ww .  java  2 s .  c  o  m*/
 *            the frame title.
 */
public CandlestickDemo(final String title) {

    super(title);

    final DefaultHighLowDataset dataset = DemoDatasetFactory.createHighLowDataset();
    final JFreeChart chart = createChart(dataset);
    chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);
}

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

/**
 * A demonstration application showing a candlestick chart.
 *
 * @param title  the frame title./*from w ww.  j  a  v a2 s. c  o  m*/
 */
public CandlestickDemo(final String title) {

    super(title);

    final DefaultHighLowDataset dataset = DemoDatasetFactory.createHighLowDataset();
    final JFreeChart chart = createChart(dataset);
    chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:net.sourceforge.processdash.ev.ui.chart.AbstractEVXYChart.java

protected XYItemRenderer createRenderer(JFreeChart chart) {
    return chart.getXYPlot().getRenderer();
}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java

/**
 * Creates a scatter plot that visualizes the given data collection.
 * //from w w  w. ja va  2 s.c  o  m
 * @param aCollection
 *            Data to be visualized.
 * @param aGeneral
 *            General visual settings to be applied.
 * @param aAxes
 *            Axis-related visual settings to be applied.
 * @param aGrid
 *            Grid-related visual settings to be applied.
 * @param aScatter
 *            Point-related visual settings to be applied.
 * @return Newly created chart control.
 */
private static JFreeChart createScatter(XYSeriesCollection aCollection, GeneralVisSettings aGeneral,
        AxesSettings aAxes, GridSettings aGrid, ScatterSettings aScatter) {

    JFreeChart chart = ChartFactory.createScatterPlot(null, // title
            convertLabel(aAxes.getDomainAxisLabel()), // label of X axis
            convertLabel(aAxes.getRangeAxisLabel()), // label of Y axis
            aCollection, // dataset
            PlotOrientation.VERTICAL, // orientation
            false, // create legend
            true, // display tooltips
            false); // generate urls
    XYPlot plot = chart.getXYPlot();
    Range domainDataRange = aAxes.getLogarithmicDomainAxis()
            ? new Range(logLowerBound(plot.getDataset(), true),
                    plot.getDataRange(plot.getDomainAxis()).getUpperBound())
            : plot.getDataRange(plot.getDomainAxis());
    Range rangeDataRange = aAxes.getLogarithmicRangeAxis()
            ? new Range(logLowerBound(plot.getDataset(), false),
                    plot.getDataRange(plot.getRangeAxis()).getUpperBound())
            : plot.getDataRange(plot.getRangeAxis());
    updateGeneral(plot, aGeneral);
    updateAxes(plot, aAxes, aGrid, domainDataRange, rangeDataRange);
    updateScatter(plot, aScatter);
    chart.setBackgroundPaint(null);
    return chart;
}

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));
            }/*w  w  w  .  j  a  v  a  2  s .  c  o m*/
            renderer.setSeriesLinesVisible(i, true);
        }
    }
    xyplot.setFixedLegendItems(revised);
}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java

/**
 * Creates a histogram chart that displays the given long histogram data.
 * /*from ww  w  .j  a  va 2s. c  o  m*/
 * @param aHistogram
 *            Complex parameter that stores the data to be visualized.
 * @param aSettings
 *            Settings group for long histogram.
 * @return Newly created chart control.
 */
public static JFreeChart createHistogram(LongHistogram aHistogram, LongHistogramGroup aSettings) {
    XYSeriesCollection collection = fromLongHistogram(aHistogram);
    JFreeChart chart = ChartFactory.createHistogram(null, // title
            convertLabel(aSettings.axes.getDomainAxisLabel()), // label of X axis
            convertLabel(aSettings.axes.getRangeAxisLabel()), // label of Y axis
            collection, // dataset
            PlotOrientation.VERTICAL, // orientation
            false, // create legend
            false, // display tooltips
            false); // generate urls
    XYPlot plot = chart.getXYPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    updateGeneral(plot, aSettings.general);
    updateAxes(chart, aSettings.axes, aSettings.grid);
    updateBars(plot, aSettings.bars);
    chart.setBackgroundPaint(null);
    return chart;
}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java

/**
 * Creates a histogram chart that displays the given integer histogram data.
 * //from  w  ww. ja v  a  2s. co  m
 * @param aHistogram
 *            Complex parameter that stores the data to be visualized.
 * @param aSettings
 *            Settings group for integer histogram.
 * @return Newly created chart control.
 */
public static JFreeChart createHistogram(IntHistogram aHistogram, IntHistogramGroup aSettings) {

    XYSeriesCollection collection = fromIntHistogram(aHistogram);
    JFreeChart chart = ChartFactory.createHistogram(null, // title
            convertLabel(aSettings.axes.getDomainAxisLabel()), // label of X axis
            convertLabel(aSettings.axes.getRangeAxisLabel()), // label of Y axis
            collection, // dataset
            PlotOrientation.VERTICAL, // orientation
            false, // create legend
            false, // display tooltips
            false); // generate urls
    XYPlot plot = chart.getXYPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    updateGeneral(plot, aSettings.general);
    updateAxes(chart, aSettings.axes, aSettings.grid);
    updateBars(plot, aSettings.bars);
    chart.setBackgroundPaint(null);
    return chart;
}

From source file:app.Plot.java

public void plotDesign(JFreeChart chart) {
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesPaint(0, Color.black);
    plot.setRenderer(renderer);/*  w  w  w.ja v a  2 s . c  om*/
}

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

/**
 * A demonstration application showing a box and whisker chart.
 *
 * @param title  the frame title.//ww w  .j  ava 2 s .  c  o m
 */
public XYBoxAndWhiskerDemo(final String title) {

    super(title);

    final BoxAndWhiskerXYDataset dataset = createSampleDataset();
    final JFreeChart chart = createChart(dataset);
    chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(600, 400));
    setContentPane(chartPanel);

}

From source file:Business.Chart.ChartBP.java

public ChartBP(final String applicationTitle, String chartTitle, HospitalWorkRequest workRequest) {
    super(applicationTitle);
    series6 = new TimeSeries("Blood Pressure");
    this.chartTitle = chartTitle;
    this.workRequest = workRequest;
    final XYDataset dataset1 = createDatasetBP(workRequest);
    final JFreeChart chart1 = createChart1(dataset1);
    final XYPlot plot = chart1.getXYPlot();
    HospitalWorkRequest hos1 = (HospitalWorkRequest) workRequest;
    int age = hos1.getPerson().getAge();
    int a = hos1.getPerson().getAboveBPMarker(age);
    int b = hos1.getPerson().getBelowBPMarker(age);
    ValueMarker valueMarker = new ValueMarker(a);
    valueMarker.setLabel("ALERT");
    valueMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER);
    valueMarker.setPaint(Color.blue);
    ValueMarker valueMarker1 = new ValueMarker(b);
    valueMarker1.setLabel("ALERT");
    valueMarker1.setLabelTextAnchor(TextAnchor.TOP_CENTER);
    valueMarker1.setPaint(Color.BLUE);
    plot.addRangeMarker(valueMarker);/*  ww w.  j  ava  2  s . co m*/
    plot.addRangeMarker(valueMarker1);
}