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

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

Introduction

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

Prototype

public void setOrientation(PlotOrientation orientation) 

Source Link

Document

Sets the orientation for the plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:org.optaplanner.benchmark.impl.statistic.memoryuse.MemoryUseProblemStatistic.java

@Override
public void writeGraphFiles(BenchmarkReport benchmarkReport) {
    Locale locale = benchmarkReport.getLocale();
    NumberAxis xAxis = new NumberAxis("Time spent");
    xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale));
    NumberAxis yAxis = new NumberAxis("Memory");
    yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale));
    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    plot.setOrientation(PlotOrientation.VERTICAL);
    int seriesIndex = 0;
    for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
        XYSeries usedSeries = new XYSeries(
                singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " used");
        // TODO enable max memory, but in the same color as used memory, but with a dotted line instead
        //            XYSeries maxSeries = new XYSeries(
        //                    singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " max");
        XYItemRenderer renderer = new XYLineAndShapeRenderer();
        if (singleBenchmarkResult.isSuccess()) {
            MemoryUseSingleStatistic singleStatistic = (MemoryUseSingleStatistic) singleBenchmarkResult
                    .getSingleStatistic(problemStatisticType);
            for (MemoryUseStatisticPoint point : singleStatistic.getPointList()) {
                long timeMillisSpent = point.getTimeMillisSpent();
                MemoryUseMeasurement memoryUseMeasurement = point.getMemoryUseMeasurement();
                usedSeries.add(timeMillisSpent, memoryUseMeasurement.getUsedMemory());
                //                    maxSeries.add(timeMillisSpent, memoryUseMeasurement.getMaxMemory());
            }/*from   ww  w.j a  va 2  s  . com*/
        }
        XYSeriesCollection seriesCollection = new XYSeriesCollection();
        seriesCollection.addSeries(usedSeries);
        //            seriesCollection.addSeries(maxSeries);
        plot.setDataset(seriesIndex, seriesCollection);

        if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) {
            // Make the favorite more obvious
            renderer.setSeriesStroke(0, new BasicStroke(2.0f));
            //                renderer.setSeriesStroke(1, new BasicStroke(2.0f));
        }
        plot.setRenderer(seriesIndex, renderer);
        seriesIndex++;
    }
    JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " memory use statistic",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "MemoryUseStatistic");
}

From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java

private static JFreeChart createBubbleChart(XYZDataset dataset) {
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    //        A renderer that draws a circle at each data point with a diameter that is
    //        determined by the z-value in the dataset (the renderer requires the dataset
    //        to be an instance of {@link XYZDataset}.
    XYItemRenderer renderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
    }//from   ww  w .ja  v a2  s. c om
    if (urls) {
        renderer.setURLGenerator(new StandardXYZURLGenerator());
    }
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart("Bubble Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    return chart;
}

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

/**
 * Creates the demo chart./*from www.  jav a  2s  .  c o m*/
 * 
 * @return The chart.
 */
private JFreeChart createChart() {

    final XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200);

    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 3", "Time of Day",
            "Primary Range Axis", dataset1, true, true, false);

    chart.setBackgroundPaint(Color.white);
    final XYPlot plot = chart.getXYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));

    final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer();
    renderer.setPaint(Color.black);

    // DOMAIN AXIS 2
    final NumberAxis xAxis2 = new NumberAxis("Domain Axis 2");
    xAxis2.setAutoRangeIncludesZero(false);
    plot.setDomainAxis(1, xAxis2);
    plot.setDomainAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);

    // DOMAIN AXIS 3
    final NumberAxis xAxis3 = new NumberAxis("Domain Axis 3");
    xAxis2.setAutoRangeIncludesZero(false);
    plot.setDomainAxis(2, xAxis3);
    plot.setDomainAxisLocation(2, AxisLocation.BOTTOM_OR_LEFT);

    // RANGE AXIS 2
    final NumberAxis yAxis2 = new NumberAxis("Range Axis 2");
    plot.setRangeAxis(1, yAxis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

    final XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToDomainAxis(1, 1);
    plot.mapDatasetToRangeAxis(1, 1);

    return chart;

}

From source file:org.drools.planner.benchmark.core.statistic.calculatecount.CalculateCountProblemStatistic.java

protected void writeGraphStatistic() {
    XYSeriesCollection seriesCollection = new XYSeriesCollection();
    for (SingleBenchmark singleBenchmark : problemBenchmark.getSingleBenchmarkList()) {
        CalculateCountSingleStatistic singleStatistic = (CalculateCountSingleStatistic) singleBenchmark
                .getSingleStatistic(problemStatisticType);
        XYSeries series = new XYSeries(singleBenchmark.getSolverBenchmark().getName());
        for (CalculateCountSingleStatisticPoint point : singleStatistic.getPointList()) {
            long timeMillisSpend = point.getTimeMillisSpend();
            long calculateCountPerSecond = point.getCalculateCountPerSecond();
            series.add(timeMillisSpend, calculateCountPerSecond);
        }/*from   w  ww .  java 2  s  .c o  m*/
        seriesCollection.addSeries(series);
    }
    NumberAxis xAxis = new NumberAxis("Time spend");
    xAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat());
    NumberAxis yAxis = new NumberAxis("Calculate count per second");
    yAxis.setAutoRangeIncludesZero(false);
    XYItemRenderer renderer = new XYLineAndShapeRenderer();
    XYPlot plot = new XYPlot(seriesCollection, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    JFreeChart chart = new JFreeChart(problemBenchmark.getName() + " calculate count statistic",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    BufferedImage chartImage = chart.createBufferedImage(1024, 768);
    graphStatisticFile = new File(problemBenchmark.getProblemReportDirectory(),
            problemBenchmark.getName() + "CalculateCountStatistic.png");
    OutputStream out = null;
    try {
        out = new FileOutputStream(graphStatisticFile);
        ImageIO.write(chartImage, "png", out);
    } catch (IOException e) {
        throw new IllegalArgumentException("Problem writing graphStatisticFile: " + graphStatisticFile, e);
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:greenapi.ui.charts.LineChartPanelSupport.java

@Override
public JFreeChart createChart() {
    this.timeSeries = new TimeSeriesCollection();
    this.dataset = new TranslatingXYDataset(this.timeSeries);

    JFreeChart chart = ChartFactory.createTimeSeriesChart(this.getTitle(), null, this.getAxisLabel(),
            this.dataset, true, true, false);

    chart.setBackgroundPaint(getBackground());
    XYPlot xyPlot = chart.getXYPlot();
    xyPlot.setOrientation(PlotOrientation.VERTICAL);
    xyPlot.setBackgroundPaint(Color.WHITE);
    xyPlot.setDomainGridlinePaint(Color.BLACK.darker());
    xyPlot.setRangeGridlinePaint(Color.BLACK.darker());
    xyPlot.setAxisOffset(new RectangleInsets(5.0D, 5.0D, 5.0D, 5.0D));
    xyPlot.setDomainCrosshairLockedOnData(true);
    xyPlot.setRangeCrosshairVisible(true);
    chart.setAntiAlias(true);//from ww w.j  ava 2s  . c  o m

    return chart;
}

From source file:com.sixrr.metrics.ui.charts.DiffDistributionDialog.java

private JFreeChart createChart(XYDataset dataset) {
    final String title = getTitle();

    final NumberAxis xAxis = new NumberAxis(metricName);
    xAxis.setAutoRangeIncludesZero(false);
    if (metricType.equals(MetricType.Ratio) || metricType.equals(MetricType.RecursiveRatio)) {
        xAxis.setNumberFormatOverride(new PercentFormatter());
    }//from   w w w  .jav a  2s.  c  o  m
    final NumberAxis yAxis = new NumberAxis("%");
    final XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);
    final XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    return new JFreeChart(title, JFreeChartConstants.DEFAULT_TITLE_FONT, plot, true);
}

From source file:org.drools.planner.benchmark.core.statistic.memoryuse.MemoryUseProblemStatistic.java

protected void writeGraphStatistic() {
    XYSeriesCollection seriesCollection = new XYSeriesCollection();
    for (SingleBenchmark singleBenchmark : problemBenchmark.getSingleBenchmarkList()) {
        MemoryUseSingleStatistic singleStatistic = (MemoryUseSingleStatistic) singleBenchmark
                .getSingleStatistic(problemStatisticType);
        XYSeries usedSeries = new XYSeries(singleBenchmark.getSolverBenchmark().getName() + " used");
        XYSeries maxSeries = new XYSeries(singleBenchmark.getSolverBenchmark().getName() + " max");
        for (MemoryUseSingleStatisticPoint point : singleStatistic.getPointList()) {
            long timeMillisSpend = point.getTimeMillisSpend();
            MemoryUseMeasurement memoryUseMeasurement = point.getMemoryUseMeasurement();
            usedSeries.add(timeMillisSpend, memoryUseMeasurement.getUsedMemory());
            maxSeries.add(timeMillisSpend, memoryUseMeasurement.getMaxMemory());
        }/*from   w ww .  jav  a  2s . c om*/
        seriesCollection.addSeries(usedSeries);
        seriesCollection.addSeries(maxSeries);
    }
    NumberAxis xAxis = new NumberAxis("Time spend");
    xAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat());
    NumberAxis yAxis = new NumberAxis("Memory");
    yAxis.setAutoRangeIncludesZero(false);
    XYItemRenderer renderer = new XYAreaRenderer2();
    XYPlot plot = new XYPlot(seriesCollection, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    JFreeChart chart = new JFreeChart(problemBenchmark.getName() + " memory use statistic",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    BufferedImage chartImage = chart.createBufferedImage(1024, 768);
    graphStatisticFile = new File(problemBenchmark.getProblemReportDirectory(),
            problemBenchmark.getName() + "MemoryUseStatistic.png");
    OutputStream out = null;
    try {
        out = new FileOutputStream(graphStatisticFile);
        ImageIO.write(chartImage, "png", out);
    } catch (IOException e) {
        throw new IllegalArgumentException("Problem writing graphStatisticFile: " + graphStatisticFile, e);
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:org.schreibubi.JCombinations.logic.visitors.ChartNodesVisitorOverlay.java

private void accumulateVisit(OurTreeNode o) throws Exception {
    this.dutYData = new ArrayList<ArrayList<Double>>();
    this.dutName = new ArrayList<String>();

    for (int i = 0; i < o.getChildCount(); i++)
        ((OurTreeNode) o.getChildAt(i)).accept(this);

    /*//from  w w w  . j ava 2s  .  co m
     * ArrayList< Double > x = s.getXdataDefault().getXPositions(); for ( int j = 0; j < this.dutYData.size(); j++ ) {
     * ArrayList< Double > y = this.dutYData.get( j ); XYSeries xy = new XYSeries( this.dutName.get( j ) ); for ( int i =
     * 0; i < y.size(); i++ ) { xy.add( x.get( i ), y.get( i ) ); } this.xyseries.addSeries( xy ); }
     */
    NumberAxis xAxis = new NumberAxis(" X ");
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(" Y ");
    yAxis.setAutoRangeIncludesZero(false);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRendererExtended(true, true);
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    xyseries = new XYSeriesCollection();

    XYPlot plot = new XYPlot(xyseries, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    ExtendedJFreeChart chart = new ExtendedJFreeChart("Overlay", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    this.charts.add(chart);

}

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

/**
 * Creates the demo chart.//  ww w  .  j a  v  a 2 s.  com
 * 
 * @return The chart.
 */
protected JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart1 = ChartFactory.createTimeSeriesChart(chartTitle, domainLabel, //"Time of Day", 
            rangeLabel, //"Value",
            dataset, !legendPanelOn, true, false);

    chart1.setBackgroundPaint(Color.white);
    XYPlot plot = chart1.getXYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    plot.setDomainCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(false);
    plot.setRangeCrosshairVisible(false);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setBasePaint(Color.black);
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    //         setXSummary(dataset); X is time
    return chart1;
}

From source file:org.encog.workbench.dialogs.training.ChartPane.java

/**
 * Create the initial chart.//  w  w  w.j a  va2 s . co  m
 * @return The chart.
 */
private JFreeChart createChart() {

    this.chart = ChartFactory.createXYLineChart(null, "Iteration", "Current Error", this.dataset1,
            PlotOrientation.VERTICAL, true, true, false);

    final XYPlot plot = (XYPlot) this.chart.getPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);

    plot.getRangeAxis().setFixedDimension(15.0);

    // AXIS 2
    final NumberAxis axis2 = new NumberAxis("Error Improvement");
    axis2.setFixedDimension(10.0);
    axis2.setAutoRangeIncludesZero(false);
    axis2.setLabelPaint(Color.red);
    axis2.setTickLabelPaint(Color.red);
    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

    plot.setDataset(1, this.dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    final XYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, Color.red);
    plot.setRenderer(1, renderer2);

    ChartUtilities.applyCurrentTheme(this.chart);

    return this.chart;
}