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

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

Introduction

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

Prototype

public void setRenderer(XYItemRenderer renderer) 

Source Link

Document

Sets the renderer for the primary dataset and sends a change event to all registered listeners.

Usage

From source file:chart.JChartSegment.java

/**
 * Creates a sample chart./*from w w  w.j a va2 s  .c om*/
 *
 * @param dataset the dataset.
 *
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset, List<NSubsequence> subsequence) {
    final JFreeChart chart = ChartFactory.createXYLineChart("Test", "Time", "Value", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    chart.setBackgroundPaint(Color.WHITE);
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    MyRender renderer = new MyRender(dataset, subsequence);
    plot.setRenderer(renderer);
    renderer.setSeriesShapesVisible(0, false);
    chart.setBackgroundPaint(Color.white);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setAutoRangeIncludesZero(false);
    return chart;
}

From source file:graficarfreechart.GraficarFreeChart.java

public GraficarFreeChart(String applicationTitle, String chartTitle) {
    super(applicationTitle);

    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Score", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);
    setContentPane(chartPanel);//from   w  w w.j a  va 2  s  .  com
}

From source file:edu.ucla.stat.SOCR.chart.demo.XYStepRendererDemo1.java

/**
 * Creates a sample chart.//  ww  w .j a  v  a2  s. c o m
 * 
 * @param dataset  a dataset for the chart.
 * 
 * @return A sample chart.
 */
protected JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, domainLabel, rangeLabel, dataset,
            PlotOrientation.VERTICAL, !legendPanelOn, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYStepRenderer renderer = new XYStepRenderer();
    renderer.setBaseStroke(new BasicStroke(2.0f));
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setDefaultEntityRadius(6);
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    plot.setRenderer(renderer);
    setXSummary(dataset);
    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.SuperIntervalXYChart_Time.java

/**
 * Creates a chart./*w  w w  . j a  v  a  2  s  .c  om*/
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(IntervalXYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            true, rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, false);

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    XYPlot plot = chart.getXYPlot();
    plot.setRenderer(new ClusteredXYBarRenderer());
    // OPTIONAL CUSTOMISATION COMPLETED.
    return chart;
}

From source file:EHRAppointment.ChartPanelDraw.java

private ChartPanel createChart(XYDataset dataset, String type) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(type, "Date", getValueAxis(), dataset);

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    plot.setRenderer(renderer);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return new ChartPanel(chart);
}

From source file:edu.ucla.stat.SOCR.chart.demo.XYStepRendererDemo1.java

protected JFreeChart createLegend(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // url
    );// w w  w . j  a va  2  s .c  o m

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();

    XYStepRenderer renderer = new XYStepRenderer();
    renderer.setBaseStroke(new BasicStroke(2.0f));
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setDefaultEntityRadius(6);
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    plot.setRenderer(renderer);
    return chart;

}

From source file:org.pentaho.plugin.jfreereport.reportcharts.ScatterPlotChartExpression.java

protected JFreeChart computeXYChart(final XYDataset xyDataset) {
    final JFreeChart chart;
    if (xyDataset instanceof TimeSeriesCollection) {
        chart = ChartFactory.createTimeSeriesChart(computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset,
                isShowLegend(), false, false);
        final XYPlot xyPlot = chart.getXYPlot();
        final XYLineAndShapeRenderer itemRenderer = (XYLineAndShapeRenderer) xyPlot.getRenderer();
        final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);
        renderer.setBaseToolTipGenerator(itemRenderer.getBaseToolTipGenerator());
        renderer.setURLGenerator(itemRenderer.getURLGenerator());
        xyPlot.setRenderer(renderer);

    } else {//  w  w w .  j  a v a  2s  .co  m
        final PlotOrientation orientation = computePlotOrientation();
        chart = ChartFactory.createScatterPlot(computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset,
                orientation, isShowLegend(), false, false);
    }

    chart.getXYPlot().setRenderer(new XYDotRenderer());
    configureLogarithmicAxis(chart.getXYPlot());
    return chart;
}

From source file:wef.articulab.view.ui.CombinedBNXYPlot.java

private XYPlot createPlot(ChartContainer chartContainer) {
    createDataset(chartContainer);/*from  w  w  w  .j a  v  a 2  s.  co m*/
    chartContainer.target = new IntervalMarker(14, 16);
    chartContainer.target.setLabel("Activation Threshold");
    chartContainer.target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
    chartContainer.target.setLabelAnchor(RectangleAnchor.LEFT);
    chartContainer.target.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    chartContainer.target.setPaint(new Color(222, 222, 255, 128));
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    BasicStroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    for (int i = 0; i < chartContainer.series.length - 1; i++) {
        renderer.setSeriesStroke(i, stroke);
    }
    renderer.setSeriesStroke(chartContainer.series.length - 1, new BasicStroke(2.0f, BasicStroke.CAP_BUTT,
            BasicStroke.JOIN_MITER, 10.0f, new float[] { 10.0f }, 0.0f));

    NumberAxis rangeAxis = new NumberAxis("Activation");
    NumberAxis domainAxis = new NumberAxis("Time");
    XYPlot plot = new XYPlot(chartContainer.dataset, domainAxis, rangeAxis, renderer);
    plot.addRangeMarker(chartContainer.target, Layer.BACKGROUND);
    plot.setRenderer(renderer);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    chartContainer.plot = plot;
    return plot;
}

From source file:cv.mikusher.freechart.XYLineChart.java

public XYLineChart(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    setDefaultCloseOperation(ApplicationFrame.EXIT_ON_CLOSE);
    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Score", createDataset(),
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);
    setContentPane(chartPanel);// w w w  . ja  v  a2  s .c om
}

From source file:org.n52.oxf.render.sos.TimeSeriesMapChartRenderer.java

/**
 * The resulting chart consists a TimeSeries for each FeatureOfInterest contained in the
 * observationCollection.//from   w w  w  .j a  v a2s. c  o  m
 * 
 * @param foiIdArray
 *        the IDs of the FeaturesOfInterest whose Observations shall be rendered
 * @param observationCollection
 * @return
 */
protected XYPlot drawChart4FOI(String foiID, Map<ITimePosition, ObservedValueTuple> timeMap) {

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    TimeSeries timeSeries = new TimeSeries(foiID, Second.class);

    for (ITimePosition timePos : timeMap.keySet()) {
        Number value = (Number) timeMap.get(timePos).getValue(0);
        timeSeries.add(
                new Second(new Float(timePos.getSecond()).intValue(), timePos.getMinute(), timePos.getHour(),
                        timePos.getDay(), timePos.getMonth(), new Long(timePos.getYear()).intValue()),
                value);
    }

    dataset.addSeries(timeSeries);
    dataset.setDomainIsPointsInTime(true);

    //
    // create Plot:
    //

    XYPlot plot = new XYPlot();

    plot.setDataset(dataset);
    plot.setBackgroundPaint(Color.white);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(false);
    plot.setRenderer(renderer);

    DateAxis dateAxis = new DateAxis();
    dateAxis.setTickMarkPosition(DateTickMarkPosition.START);
    dateAxis.setTickMarksVisible(true);
    dateAxis.setVerticalTickLabels(true);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("dd'.'MM'.'"));
    plot.setDomainAxis(dateAxis);

    plot.setRangeAxis(new NumberAxis());

    return plot;
}