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:com.rapidminer.gui.plotter.charts.DistributionPlotter.java

private JFreeChart createNumericalChart() {
    JFreeChart chart;// w w  w  .  jav  a 2s. c  o m
    XYDataset dataset = createNumericalDataSet();
    // create the chart...
    String domainName = dataTable == null ? MODEL_DOMAIN_AXIS_NAME : dataTable.getColumnName(plotColumn);
    chart = ChartFactory.createXYLineChart(null, // chart title
            domainName, // x axis label
            RANGE_AXIS_NAME, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    DeviationRenderer renderer = new DeviationRenderer(true, false);
    Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    if (dataset.getSeriesCount() == 1) {
        renderer.setSeriesStroke(0, stroke);
        renderer.setSeriesPaint(0, Color.RED);
        renderer.setSeriesFillPaint(0, Color.RED);
    } else {
        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            renderer.setSeriesStroke(i, stroke);
            Color color = getColorProvider()
                    .getPointColor((double) i / (double) (dataset.getSeriesCount() - 1));
            renderer.setSeriesPaint(i, color);
            renderer.setSeriesFillPaint(i, color);
        }
    }
    renderer.setAlpha(0.12f);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(renderer);

    return chart;
}

From source file:org.spantus.exp.segment.draw.DrawDtw.java

protected JFreeChart createXYZChart() {
    NumberAxis xAxis = new NumberAxis("Sample");
    NumberAxis yAxis = new NumberAxis("target");
    List<List<Double>> data = info.getDistanceMatrix();
    XYZDataset xyzset = new XYZArrayDataset(data);
    XYPlot plot = new XYPlot(xyzset, xAxis, yAxis, null);
    XYBlockRenderer r = new XYBlockRenderer();
    PaintScale ps = new GrayPaintScale(min, max);
    //      LookupPaintScale ps = new LookupPaintScale(0.0, 4.0, Color.WHITE);
    //      ps.add(1, Color.red);
    //      ps.add(2, Color.green);
    //      ps.add(3, Color.gray);

    r.setPaintScale(ps);/*w  w  w . j  a va 2s.  com*/
    r.setBlockHeight(1.0f);
    r.setBlockWidth(1.0f);
    plot.setRenderer(r);
    JFreeChart chart = new JFreeChart("Chart Title", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    NumberAxis scaleAxis = new NumberAxis("Scale");
    scaleAxis.setUpperBound(100);
    scaleAxis.setAxisLinePaint(Color.white);
    scaleAxis.setTickMarkPaint(Color.white);
    scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 12));
    //      PaintScaleLegend legend = new PaintScaleLegend(ps, scaleAxis);
    //      legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    //      legend.setPadding(new RectangleInsets(5, 5, 5, 5));
    //      legend.setStripWidth(50);
    //      legend.setPosition(RectangleEdge.RIGHT);
    //      legend.setBackgroundPaint(Color.WHITE);
    //      chart.addSubtitle(legend);
    chart.setBackgroundPaint(Color.white);
    return chart;
}

From source file:presentationGui.GraphFrame.java

/**
 * Creates a chart.//from   w ww .j  a  v  a2 s. c  om
 *
 * @param dataset the data for the chart.
 *
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart("Comportamento Asintotico del throughput", // chart title
            "numero job", // x axis label
            "throughput", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

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

    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);
    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    //    plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

    // change the auto tick unit selection to integer units only...
    /*final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());*/
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:wm.edu.cs420.Data.ChartBuilder.java

/**
 * Creates a chart./*from   w ww  .  j  a  va  2s.co m*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
private JFreeChart generateChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            null, // x axis label
            null, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // include legend
            false, // tooltips
            false // urls
    );

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

    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    Shape shape = new Ellipse2D.Double(0, 0, 3, 3);
    renderer.setSeriesShape(0, shape);
    plot.setRenderer(renderer);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:org.jax.maanova.fit.gui.ResidualPlotPanel.java

private void updateDataPoints() {
    this.cachedXYData = null;
    XYProbeData[] xyData = this.getXYData();

    DefaultXYDataset xyDataSet = new DefaultXYDataset();
    for (int arrayIndex = 0; arrayIndex < xyData.length; arrayIndex++) {
        XYProbeData currData = xyData[arrayIndex];
        xyDataSet.addSeries(arrayIndex, new double[][] { currData.getXData(), currData.getYData() });
    }/*from  ww w.  j  a va2 s . co  m*/

    JFreeChart scatterPlot = ChartFactory.createScatterPlot(this.chartConfigurationDialog.getChartTitle(),
            this.chartConfigurationDialog.getXAxisLabel(), this.chartConfigurationDialog.getYAxisLabel(),
            xyDataSet, PlotOrientation.VERTICAL, false, false, false);

    XYPlot xyPlot = (XYPlot) scatterPlot.getPlot();
    xyPlot.setRenderer(PlotUtil.createMonochromeScatterPlotRenderer());
    if (this.viewArea != null) {
        PlotUtil.rescaleXYPlot(this.viewArea, xyPlot);
    }

    this.saveGraphImageAction.setChart(scatterPlot);
    this.chartPanel.setChart(scatterPlot);
}

From source file:org.drugis.addis.gui.ConvergencePlotsDialog.java

private JFreeChart createVhatVsWChart(final XYDataset dataset) {
    final JFreeChart VhatVsWChart = ChartFactory.createXYLineChart("Plots of sqrt(vHat) and sqrt(W)",
            "Iteration No.", "Variance Estimates", dataset, PlotOrientation.VERTICAL, true, true, false);

    VhatVsWChart.setBackgroundPaint(Color.white);
    final XYPlot VhatVsWPlot = VhatVsWChart.getXYPlot();
    VhatVsWPlot.setDomainGridlinePaint(Color.white);
    VhatVsWPlot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.red);
    renderer.setSeriesPaint(1, Color.blue);
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    VhatVsWPlot.setRenderer(renderer);

    return VhatVsWChart;
}

From source file:org.jax.maanova.madata.gui.ArrayScatterPlotPanel.java

private void updateDataPoints() {
    this.cachedXYData = null;
    XYProbeData currData = this.getXYData();

    DefaultXYDataset xyDataSet = new DefaultXYDataset();
    xyDataSet.addSeries("data", new double[][] { currData.getXData(), currData.getYData() });

    JFreeChart scatterPlot = ChartFactory.createScatterPlot(this.chartConfigurationDialog.getChartTitle(),
            this.chartConfigurationDialog.getXAxisLabel(), this.chartConfigurationDialog.getYAxisLabel(),
            xyDataSet, PlotOrientation.VERTICAL, false, false, false);

    XYPlot xyPlot = (XYPlot) scatterPlot.getPlot();
    xyPlot.setRenderer(PlotUtil.createMonochromeScatterPlotRenderer());
    if (this.viewArea != null) {
        PlotUtil.rescaleXYPlot(this.viewArea, xyPlot);
    }//from  www  .  j a va2 s  . c om

    this.saveGraphImageAction.setChart(scatterPlot);
    this.chartPanel.setChart(scatterPlot);
}

From source file:LineChartDemo6.java

/**
 * Creates a chart./*  w  ww  . j av a 2s.c  o m*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart Demo 6", // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

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

    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    //    plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    //renderer.setSeriesLinesVisible(0, false);
    //renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:com.android.ddmuilib.log.event.DisplaySyncHistogram.java

/**
 * Resets the display.//from w w w. j  av  a  2  s.c om
 */
@Override
void resetUI() {
    super.resetUI();
    XYPlot xyPlot = mChart.getXYPlot();

    AbstractXYItemRenderer br = new XYBarRenderer();
    mDatasetsSyncHist = new TimePeriodValues[NUM_AUTHS + 1];

    @SuppressWarnings("unchecked")
    Map<SimpleTimePeriod, Integer> mTimePeriodMapTmp[] = new HashMap[NUM_AUTHS + 1];
    mTimePeriodMap = mTimePeriodMapTmp;

    TimePeriodValuesCollection tpvc = new TimePeriodValuesCollection();
    xyPlot.setDataset(tpvc);
    xyPlot.setRenderer(br);

    for (int i = 0; i < NUM_AUTHS + 1; i++) {
        br.setSeriesPaint(i, AUTH_COLORS[i]);
        mDatasetsSyncHist[i] = new TimePeriodValues(AUTH_NAMES[i]);
        tpvc.addSeries(mDatasetsSyncHist[i]);
        mTimePeriodMap[i] = new HashMap<SimpleTimePeriod, Integer>();

    }
}

From source file:chart.XYChart.java

public XYChart(String applicationTitle, String chartTitle, double[] xData, double[] YDataAnalitic,
        double[] YDataNumerical1, double[] YDataNumerical2, double[] YDataNumerical3) {

    super(applicationTitle);

    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "", "",
            createDatasetForFour(xData, YDataAnalitic, YDataNumerical1, YDataNumerical2, YDataNumerical3),
            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(1.0f));
    renderer.setSeriesStroke(1, new BasicStroke(1.0f));
    renderer.setSeriesStroke(2, new BasicStroke(1.0f));
    plot.setRenderer(renderer);
    setContentPane(chartPanel);/*w w w.  j a  va 2 s  .  c  o  m*/

    // panel.removeAll();
    //  panel.add(chartPanel);
    //  panel.validate();

}