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: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);
}

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

private JFreeChart createChart() {
    XYPlot plot = new XYPlot();

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setAutoPopulateSeriesStroke(false);
    renderer.setBaseStroke(TsCharts.getStrongStroke(ITsChart.LinesThickness.Thin));
    plot.setRenderer(renderer);

    JFreeChart result = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, true);
    result.setPadding(TsCharts.CHART_PADDING);
    result.setTitle("Standard deviations");

    return result;
}

From source file:edu.mit.fss.examples.member.gui.PowerSubsystemPanel.java

/**
 * Instantiates a new power subsystem panel for a subsystem.
 *
 * @param subsystem the subsystem/*from  ww w . j  a va  2s  .  c o  m*/
 */
public PowerSubsystemPanel(SpacePowerSubsystem subsystem) {
    this.subsystem = subsystem;

    logger.trace("Creating and adding energy storage chart panel.");
    storageDataset = new TimeSeriesCollection();
    storageSeries = new TimeSeries("Storage");
    storageDataset.addSeries(storageSeries);
    storageChart = ChartFactory.createTimeSeriesChart(null, "Time", "Stored Energy (W-hr)", storageDataset,
            false, false, false);
    storageChart.setBackgroundPaint(getBackground());
    if (storageChart.getPlot() instanceof XYPlot) {
        XYPlot xyPlot = (XYPlot) storageChart.getPlot();
        XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);
        renderer.setSeriesShape(0, new Ellipse2D.Double(-2, -2, 4, 4));
        xyPlot.setRenderer(renderer);
        xyPlot.setBackgroundPaint(Color.WHITE);
        xyPlot.setDomainGridlinePaint(Color.GRAY);
        xyPlot.setRangeGridlinePaint(Color.GRAY);
    }
    addTab("Storing", new ChartPanel(storageChart));

    logger.trace("Creating and adding energy transformation chart panel.");
    powerDataset = new TimeSeriesCollection();
    generationSeries = new TimeSeries("Generation");
    powerDataset.addSeries(generationSeries);
    consumptionSeries = new TimeSeries("Consumption");
    powerDataset.addSeries(consumptionSeries);
    powerChart = ChartFactory.createTimeSeriesChart(null, "Time", "Power (W)", powerDataset, true, false,
            false);
    powerChart.setBackgroundPaint(getBackground());
    if (powerChart.getPlot() instanceof XYPlot) {
        XYPlot xyPlot = (XYPlot) powerChart.getPlot();
        XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);
        renderer.setSeriesShape(0, new Ellipse2D.Double(-2, -2, 4, 4));
        renderer.setSeriesPaint(0, Color.red);
        renderer.setSeriesShape(1, new Ellipse2D.Double(-2, -2, 4, 4));
        renderer.setSeriesPaint(1, Color.green);
        xyPlot.setRenderer(renderer);
        xyPlot.setBackgroundPaint(Color.WHITE);
        xyPlot.setDomainGridlinePaint(Color.GRAY);
        xyPlot.setRangeGridlinePaint(Color.GRAY);
    }
    JPanel chartPanel = new JPanel(new BorderLayout());
    chartPanel.add(new ChartPanel(powerChart), BorderLayout.CENTER);
    chartPanel.add(new JButton(exportAction), BorderLayout.SOUTH);
    addTab("Transforming", chartPanel);
}

From source file:ch.zhaw.init.walj.projectmanagement.util.chart.LineChart.java

/**
  * creates a line chart with all booked and planned PMs
 *//*from   w w w. j av a2 s  .com*/
public void createChart() {

    // get dataset
    XYSeriesCollection dataset = null;
    try {
        dataset = (XYSeriesCollection) createDataset();
    } catch (SQLException e) {
        e.printStackTrace();
    }

    // create line chart
    JFreeChart xylineChart = ChartFactory.createXYLineChart("", "Month", "PM", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    // set color of chart
    XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, new Color(0, 101, 166));
    renderer.setSeriesPaint(1, new Color(0, 62, 102));
    plot.setRenderer(renderer);

    // set size of the chart and save it as small JPEG for project overview
    int width = 600;
    int height = 400;
    File lineChart = new File(path + "EffortProject" + project.getID() + ".jpg");
    try {
        ChartUtilities.saveChartAsJPEG(lineChart, xylineChart, width, height);
    } catch (IOException e) {
        e.printStackTrace();
    }

    // set size of the chart and save it as large JPEG for effort detail page
    width = 1200;
    height = 600;
    lineChart = new File(path + "/Charts/EffortProject" + project.getID() + "_large.jpg");
    try {
        ChartUtilities.saveChartAsJPEG(lineChart, xylineChart, width, height);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:democsv.XYLineChart_AWT.java

public XYLineChart_AWT(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    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  . j a  va 2  s.  c om*/
}

From source file:org.optaplanner.benchmark.impl.statistic.single.constraintmatchtotalbestscore.ConstraintMatchTotalBestScoreSingleStatistic.java

@Override
public void writeGraphFiles(BenchmarkReport benchmarkReport) {
    List<Map<String, XYSeries>> constraintIdToWeightSeriesMapList = new ArrayList<Map<String, XYSeries>>(
            BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE);
    for (ConstraintMatchTotalBestScoreStatisticPoint point : getPointList()) {
        int scoreLevel = point.getScoreLevel();
        if (scoreLevel >= BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE) {
            continue;
        }/*w w w .j  a  v a2  s. c  om*/
        while (scoreLevel >= constraintIdToWeightSeriesMapList.size()) {
            constraintIdToWeightSeriesMapList.add(new LinkedHashMap<String, XYSeries>());
        }
        Map<String, XYSeries> constraintIdToWeightSeriesMap = constraintIdToWeightSeriesMapList.get(scoreLevel);
        if (constraintIdToWeightSeriesMap == null) {
            constraintIdToWeightSeriesMap = new LinkedHashMap<String, XYSeries>();
            constraintIdToWeightSeriesMapList.set(scoreLevel, constraintIdToWeightSeriesMap);
        }
        String constraintId = point.getConstraintPackage() + ":" + point.getConstraintName();
        XYSeries weightSeries = constraintIdToWeightSeriesMap.get(constraintId);
        if (weightSeries == null) {
            weightSeries = new XYSeries(point.getConstraintName() + " weight");
            constraintIdToWeightSeriesMap.put(constraintId, weightSeries);
        }
        long timeMillisSpent = point.getTimeMillisSpent();
        weightSeries.add(timeMillisSpent, point.getWeightTotal());
    }
    graphFileList = new ArrayList<File>(constraintIdToWeightSeriesMapList.size());
    for (int scoreLevelIndex = 0; scoreLevelIndex < constraintIdToWeightSeriesMapList
            .size(); scoreLevelIndex++) {
        XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex);
        // No direct ascending lines between 2 points, but a stepping line instead
        XYItemRenderer renderer = new XYStepRenderer();
        plot.setRenderer(renderer);
        XYSeriesCollection seriesCollection = new XYSeriesCollection();
        for (XYSeries series : constraintIdToWeightSeriesMapList.get(scoreLevelIndex).values()) {
            seriesCollection.addSeries(series);
        }
        plot.setDataset(seriesCollection);
        JFreeChart chart = new JFreeChart(singleBenchmarkResult.getName()
                + " constraint match total best score diff level " + scoreLevelIndex + " statistic",
                JFreeChart.DEFAULT_TITLE_FONT, plot, true);
        graphFileList.add(
                writeChartToImageFile(chart, "ConstraintMatchTotalBestScoreStatisticLevel" + scoreLevelIndex));
    }
}

From source file:co.udea.edu.proyectointegrador.gr11.parqueaderoapp.domain.stadistics.graphics.implement.Grafica.java

@Override
public JFreeChart createXYLineChartToHoursOfDay(List<HoraDelDiaEstadistica> horasDelDia) {
    //Se obtiene el conjunto de datos
    XYDataset dataset = createDataForHoursOfDay(horasDelDia);

    JFreeChart chart = ChartFactory.createXYLineChart(TITLE_OF_XY_CHART, //Titulo del grafico
            DOMAIN_AXIS_LABEL_HOUR, //Nombre del Rango
            RANGE_AXIS_LABEL, //Nombre del dominio
            dataset, //conjunto de datos
            PlotOrientation.VERTICAL, //Orientacion del grafico
            true, //incluir leyendas
            true, false);/*from   w  w w . j av a 2 s . c o m*/

    //Se pinta el fondo de blanco
    chart.setBackgroundPaint(Color.WHITE);

    //Se pintan el fondo del grafico de gris y las lineas de blanco
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.WHITE);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);
    plot.setNoDataMessage(NO_DATA_TO_DISPLAY);

    //Se configura para que solo muestre nmeros enteros en el rango
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    //Se configura para que solo muestre nmeros enteros en el dominio
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return chart;
}

From source file:org.optaplanner.benchmark.impl.statistic.subsingle.constraintmatchtotalbestscore.ConstraintMatchTotalBestScoreSubSingleStatistic.java

@Override
public void writeGraphFiles(BenchmarkReport benchmarkReport) {
    List<Map<String, XYSeries>> constraintIdToWeightSeriesMapList = new ArrayList<Map<String, XYSeries>>(
            BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE);
    for (ConstraintMatchTotalBestScoreStatisticPoint point : getPointList()) {
        int scoreLevel = point.getScoreLevel();
        if (scoreLevel >= BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE) {
            continue;
        }/*  w  w w  .  ja  v  a  2 s  . c om*/
        while (scoreLevel >= constraintIdToWeightSeriesMapList.size()) {
            constraintIdToWeightSeriesMapList.add(new LinkedHashMap<String, XYSeries>());
        }
        Map<String, XYSeries> constraintIdToWeightSeriesMap = constraintIdToWeightSeriesMapList.get(scoreLevel);
        if (constraintIdToWeightSeriesMap == null) {
            constraintIdToWeightSeriesMap = new LinkedHashMap<String, XYSeries>();
            constraintIdToWeightSeriesMapList.set(scoreLevel, constraintIdToWeightSeriesMap);
        }
        String constraintId = point.getConstraintPackage() + ":" + point.getConstraintName();
        XYSeries weightSeries = constraintIdToWeightSeriesMap.get(constraintId);
        if (weightSeries == null) {
            weightSeries = new XYSeries(point.getConstraintName() + " weight");
            constraintIdToWeightSeriesMap.put(constraintId, weightSeries);
        }
        long timeMillisSpent = point.getTimeMillisSpent();
        weightSeries.add(timeMillisSpent, point.getWeightTotal());
    }
    graphFileList = new ArrayList<File>(constraintIdToWeightSeriesMapList.size());
    for (int scoreLevelIndex = 0; scoreLevelIndex < constraintIdToWeightSeriesMapList
            .size(); scoreLevelIndex++) {
        XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex);
        // No direct ascending lines between 2 points, but a stepping line instead
        XYItemRenderer renderer = new XYStepRenderer();
        plot.setRenderer(renderer);
        XYSeriesCollection seriesCollection = new XYSeriesCollection();
        for (XYSeries series : constraintIdToWeightSeriesMapList.get(scoreLevelIndex).values()) {
            seriesCollection.addSeries(series);
        }
        plot.setDataset(seriesCollection);
        JFreeChart chart = new JFreeChart(subSingleBenchmarkResult.getName()
                + " constraint match total best score diff level " + scoreLevelIndex + " statistic",
                JFreeChart.DEFAULT_TITLE_FONT, plot, true);
        graphFileList.add(
                writeChartToImageFile(chart, "ConstraintMatchTotalBestScoreStatisticLevel" + scoreLevelIndex));
    }
}

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

/**
 * Creates a chart.//  w ww .  j  av  a  2 s  .com
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(IntervalXYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, // chart title
            "Date", // domain axis label
            true, "Y", // 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:edu.ucla.stat.SOCR.chart.SuperYIntervalChart.java

protected JFreeChart createLegend(IntervalXYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, // chart title
            "Date", // domain axis label
            true, "Y", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, false);/*w  w w  .j  av  a 2  s.  com*/

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

}