List of usage examples for org.jfree.chart.plot XYPlot setOrientation
public void setOrientation(PlotOrientation orientation)
From source file:org.optaplanner.benchmark.impl.statistic.bestsolutionmutation.BestSolutionMutationProblemStatistic.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("Best solution mutation count"); yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale)); yAxis.setAutoRangeIncludesZero(true); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); plot.setOrientation(PlotOrientation.VERTICAL); int seriesIndex = 0; for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) { XYSeries series = new XYSeries( singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix()); XYItemRenderer renderer = new XYLineAndShapeRenderer(); if (singleBenchmarkResult.isSuccess()) { BestSolutionMutationSingleStatistic singleStatistic = (BestSolutionMutationSingleStatistic) singleBenchmarkResult .getSingleStatistic(problemStatisticType); for (BestSolutionMutationStatisticPoint point : singleStatistic.getPointList()) { long timeMillisSpent = point.getTimeMillisSpent(); long mutationCount = point.getMutationCount(); series.add(timeMillisSpent, mutationCount); }/* ww w. j av a2s.c om*/ } plot.setDataset(seriesIndex, new XYSeriesCollection(series)); if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) { // Make the favorite more obvious renderer.setSeriesStroke(0, new BasicStroke(2.0f)); } plot.setRenderer(seriesIndex, renderer); seriesIndex++; } JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " best solution mutation statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "BestSolutionMutationStatistic"); }
From source file:org.optaplanner.benchmark.impl.statistic.stepscore.StepScoreProblemStatistic.java
private XYPlot createPlot(BenchmarkReport benchmarkReport, int scoreLevelIndex) { Locale locale = benchmarkReport.getLocale(); NumberAxis xAxis = new NumberAxis("Time spent"); xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale)); NumberAxis yAxis = new NumberAxis("Step score level " + scoreLevelIndex); yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale)); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); plot.setOrientation(PlotOrientation.VERTICAL); return plot;/*ww w . j a v a 2 s . c om*/ }
From source file:org.btrg.df.betterologist.swingui.ProjectJobSchedulingPanel.java
private JFreeChart createChart(Schedule schedule) { YIntervalSeriesCollection seriesCollection = new YIntervalSeriesCollection(); Map<Project, YIntervalSeries> projectSeriesMap = new LinkedHashMap<Project, YIntervalSeries>( schedule.getProjectList().size()); YIntervalRenderer renderer = new YIntervalRenderer(); int maximumEndDate = 0; int seriesIndex = 0; for (Project project : schedule.getProjectList()) { YIntervalSeries projectSeries = new YIntervalSeries(project.getLabel()); seriesCollection.addSeries(projectSeries); projectSeriesMap.put(project, projectSeries); renderer.setSeriesShape(seriesIndex, new Rectangle()); renderer.setSeriesStroke(seriesIndex, new BasicStroke(3.0f)); seriesIndex++;//from ww w . ja v a 2 s. co m } for (Allocation allocation : schedule.getAllocationList()) { int startDate = allocation.getStartDate(); int endDate = allocation.getEndDate(); YIntervalSeries projectSeries = projectSeriesMap.get(allocation.getProject()); projectSeries.add(allocation.getId(), (startDate + endDate) / 2.0, startDate, endDate); maximumEndDate = Math.max(maximumEndDate, endDate); } NumberAxis domainAxis = new NumberAxis("Job"); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setRange(-0.5, schedule.getAllocationList().size() - 0.5); domainAxis.setInverted(true); NumberAxis rangeAxis = new NumberAxis("Day (start to end date)"); rangeAxis.setRange(-0.5, maximumEndDate + 0.5); XYPlot plot = new XYPlot(seriesCollection, domainAxis, rangeAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); return new JFreeChart("Project Job Scheduling", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.optaplanner.benchmark.impl.statistic.scorecalculationspeed.ScoreCalculationSpeedProblemStatistic.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("Score calculation speed per second"); yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale)); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); plot.setOrientation(PlotOrientation.VERTICAL); int seriesIndex = 0; for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) { XYSeries series = new XYSeries( singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix()); XYItemRenderer renderer = new XYLineAndShapeRenderer(); if (singleBenchmarkResult.hasAllSuccess()) { ScoreCalculationSpeedSubSingleStatistic subSingleStatistic = (ScoreCalculationSpeedSubSingleStatistic) singleBenchmarkResult .getSubSingleStatistic(problemStatisticType); List<ScoreCalculationSpeedStatisticPoint> points = subSingleStatistic.getPointList(); for (ScoreCalculationSpeedStatisticPoint point : points) { long timeMillisSpent = point.getTimeMillisSpent(); long scoreCalculationSpeed = point.getScoreCalculationSpeed(); series.add(timeMillisSpent, scoreCalculationSpeed); }//from w w w . j av a2s .com } plot.setDataset(seriesIndex, new XYSeriesCollection(series)); if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) { // Make the favorite more obvious renderer.setSeriesStroke(0, new BasicStroke(2.0f)); } plot.setRenderer(seriesIndex, renderer); seriesIndex++; } JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " score calculation speed statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "ScoreCalculationSpeedStatistic"); }
From source file:org.jfree.chart.demo.MultipleAxisDemo2.java
/** * Creates the demo chart.//from www.j a v a 2 s . com * * @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 2", "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); // 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.optaplanner.benchmark.impl.statistic.bestscore.BestScoreProblemStatistic.java
private XYPlot createPlot(BenchmarkReport benchmarkReport, int scoreLevelIndex) { Locale locale = benchmarkReport.getLocale(); NumberAxis xAxis = new NumberAxis("Time spent"); xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale)); NumberAxis yAxis = new NumberAxis("Best score level " + scoreLevelIndex); yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale)); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); plot.setOrientation(PlotOrientation.VERTICAL); return plot;// ww w. j ava2s . c o m }
From source file:net.commerce.zocalo.freechart.ChartGenerator.java
public static JFreeChart createOverlaidOHLCAndStepChart(TimePeriodValuesCollection bottom, TimePeriodValuesCollection top, OHLCDataset ohlCdata) { DateAxis xAxis = new DateAxis(null); NumberAxis yAxis = new NumberAxis("price"); yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); yAxis.setUpperBound(100);//from ww w . j a v a 2 s . c o m yAxis.setLowerBound(0.0); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); plot.setDataset(0, bottom); plot.setDataset(1, top); plot.setDataset(2, ohlCdata); XYStepAreaRenderer bottomRenderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA, null, null); XYStepAreaRenderer topRenderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA, null, null); HighLowRenderer hiLoRenderer = new HighLowRenderer(); topRenderer.setRangeBase(1.0); topRenderer.setSeriesPaint(0, new Color(204, 255, 153)); bottomRenderer.setSeriesPaint(0, new Color(51, 255, 204)); plot.setRenderer(bottomRenderer); plot.setRenderer(1, topRenderer); plot.setRenderer(2, hiLoRenderer); plot.setOrientation(PlotOrientation.VERTICAL); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.jfree.chart.demo.TimeSeriesDemo11.java
/** * Creates the demo chart./*from www. j av a2 s . c om*/ * * @param title the title. * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final String title, final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, "Date", "Price", dataset, 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.blue); return chart; }
From source file:org.optaplanner.benchmark.impl.statistic.improvingsteppercentage.ImprovingStepPercentageProblemStatistic.java
private XYPlot createPlot(Class<? extends Move> moveClass) { Locale locale = problemBenchmark.getPlannerBenchmark().getBenchmarkReport().getLocale(); NumberAxis xAxis = new NumberAxis("Time spend"); xAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat(locale)); NumberAxis yAxis = new NumberAxis("Percentage that improve the score"); yAxis.setNumberFormatOverride(NumberFormat.getPercentInstance(locale)); yAxis.setRange(0.0, 1.0);//from w w w . ja va 2 s .c om XYPlot plot = new XYPlot(null, xAxis, yAxis, null); plot.setOrientation(PlotOrientation.VERTICAL); return plot; }
From source file:com.sixrr.metrics.ui.charts.DistributionDialog.java
private JFreeChart createChart(XYDataset dataset) { final String title = getTitle(); final NumberAxis xAxis = new NumberAxis(metricName); xAxis.setAutoRangeIncludesZero(false); if (metricType == MetricType.Ratio || metricType == MetricType.RecursiveRatio) { xAxis.setNumberFormatOverride(new PercentFormatter()); }/*w w w. j a va2s.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); }