List of usage examples for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT
Font DEFAULT_TITLE_FONT
To view the source code for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT.
Click Source Link
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 v a 2s.co m*/ } 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.schreibubi.JCombinations.logic.visitors.ChartNodesVisitor.java
public void visit(Shmoo s) throws Exception { if (s.componentSelected(this.treePaths, OurTreeNode.MYSELF | OurTreeNode.PARENTS | OurTreeNode.CHILDS)) { NumberAxis xAxis = new NumberAxis(s.getTrim() + " [" + s.getXdataDefault().getUnit() + "]"); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis( s.getMeasure() + " [" + ((Ydata) s.getYdata().get(0)).getUnit() + "]"); yAxis.setAutoRangeIncludesZero(false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRendererExtended(true, true); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); this.dutData = new ArrayList<ArrayList<Double>>(); this.dutName = new ArrayList<String>(); for (int i = 0; i < s.getChildCount(); i++) (s.getChildAt(i)).accept(this); XYSeriesCollection xyseries = new XYSeriesCollection(); ArrayList<Double> x = s.getXdataDefault().getXPositions(); for (int j = 0; j < this.dutData.size(); j++) { ArrayList<Double> y = this.dutData.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)); xyseries.addSeries(xy);/*from www .jav a2s . co m*/ } XYPlot plot = new XYPlot(xyseries, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); Marker marker = s.getMarker(); if (marker != null) plot.addRangeMarker(marker, Layer.BACKGROUND); ExtendedJFreeChart chart = new ExtendedJFreeChart(s.getDescription(), JFreeChart.DEFAULT_TITLE_FONT, plot, false); if (marker == null) chart.addSubtitle(new TextTitle(s.getSubtitle())); else chart.addSubtitle(new TextTitle( s.getSubtitle() + " " + s.getValueAt(3) + "/" + s.getValueAt(4) + "/" + s.getValueAt(5))); chart.setTreePath(s.getTreePath()); this.charts.add(chart); } }
From source file:org.pentaho.plugin.jfreereport.reportcharts.AreaChartExpression.java
/** * Creates a stacked area chart with default settings. The chart object returned by this method uses a {@link * CategoryPlot} instance as the plot, with a {@link org.jfree.chart.axis.CategoryAxis} for the domain axis, a {@link * org.jfree.chart.axis.NumberAxis} as the range axis, and a {@link org.jfree.chart.renderer.category * .StackedAreaRenderer}/*from w w w. j a v a 2 s .c o m*/ * as the renderer. * * @param title the chart title (<code>null</code> permitted). * @param categoryAxisLabel the label for the category axis (<code>null</code> permitted). * @param valueAxisLabel the label for the value axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the plot orientation (horizontal or vertical) (<code>null</code> not permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * @return A stacked area chart. */ private JFreeChart createStackedAreaChart(final String title, final String categoryAxisLabel, final String valueAxisLabel, final CategoryDataset dataset, final PlotOrientation orientation, final boolean legend, final boolean tooltips, final boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } final CategoryAxis categoryAxis = new FormattedCategoryAxis(categoryAxisLabel, getCategoricalAxisMessageFormat(), getRuntime().getResourceBundleFactory().getLocale()); categoryAxis.setCategoryMargin(0.0); final ValueAxis valueAxis = new NumberAxis(valueAxisLabel); final StackedAreaRenderer renderer = new StackedAreaRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); } if (urls) { renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator()); } final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); }
From source file:org.jfree.chart.demo.OverlaidXYPlotDemo.java
/** * Creates an overlaid chart./*from w w w . ja v a 2s . c o m*/ * * @return The chart. */ private JFreeChart createOverlaidChart() { // create plot ... final IntervalXYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new XYBarRenderer(0.20); renderer1.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); final DateAxis domainAxis = new DateAxis("Date"); domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); final ValueAxis rangeAxis = new NumberAxis("Value"); final XYPlot plot = new XYPlot(data1, domainAxis, rangeAxis, renderer1); final double x = new Day(9, SerialDate.MARCH, 2002).getMiddleMillisecond(); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", x, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); plot.addAnnotation(annotation); // add a second dataset and renderer... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); plot.setDataset(1, data2); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // return a new chart containing the overlaid plot... return new JFreeChart("Overlaid Plot Example", JFreeChart.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()); }// w w w. ja v a2 s . c o m 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:de.bund.bfr.knime.nls.chart.ChartCreator.java
public JFreeChart createChart() throws ParseException { if (varX == null || varY == null) { return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, new XYPlot(), showLegend); }/*from w w w.j a v a 2 s . c o m*/ List<String> idsToPaint; if (selectAll) { idsToPaint = new ArrayList<>(plotables.keySet()); } else { idsToPaint = selectedIds; } NumberAxis xAxis = new NumberAxis(transformX.getName(varX)); NumberAxis yAxis = new NumberAxis(transformY.getName(varY)); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); double usedMinX = Double.POSITIVE_INFINITY; double usedMaxX = Double.NEGATIVE_INFINITY; int index = 0; List<Color> defaultColors = ChartUtils.createColorList(idsToPaint.size()); List<NamedShape> defaultShapes = ChartUtils.createShapeList(idsToPaint.size()); for (String id : idsToPaint) { Plotable plotable = plotables.get(id); if (plotable == null) { continue; } if (plotable.isDataType()) { double[][] points = plotable.getDataPoints(varX, varY, transformX, transformY); if (points != null) { for (int i = 0; i < points[0].length; i++) { usedMinX = Math.min(usedMinX, points[0][i]); usedMaxX = Math.max(usedMaxX, points[0][i]); } } } if (plotable.isParamType()) { double minArg = transformX.to(MathUtils.nullToNan(plotable.getMinValues().get(varX))); double maxArg = transformX.to(MathUtils.nullToNan(plotable.getMaxValues().get(varX))); if (Double.isFinite(minArg)) { usedMinX = Math.min(usedMinX, minArg); } if (Double.isFinite(maxArg)) { usedMaxX = Math.max(usedMaxX, maxArg); } } } if (!Double.isFinite(usedMinX)) { usedMinX = 0.0; } if (!Double.isFinite(usedMaxX)) { usedMaxX = 100.0; } xAxis.setAutoRangeIncludesZero(false); yAxis.setAutoRangeIncludesZero(false); if (usedMinX == usedMaxX) { usedMinX -= 1.0; usedMaxX += 1.0; } if (useManualRange && minX < maxX && minY < maxY) { usedMinX = minX; usedMaxX = maxX; xAxis.setRange(new Range(minX, maxX)); yAxis.setRange(new Range(minY, maxY)); } for (String id : idsToPaint) { Plotable plotable = plotables.get(id); if (plotable == null) { continue; } plotable.setFunctionSteps(resolution); plotable.setInterpolator(interpolator); switch (plotable.getType()) { case DATA: plotData(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index)); break; case FUNCTION: plotFunction(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX, usedMaxX); break; case DATA_FUNCTION: plotDataFunction(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX, usedMaxX); break; case DIFF: plotDiff(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX, usedMaxX); break; case DATA_DIFF: plotDataDiff(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX, usedMaxX); break; default: throw new RuntimeException("Unknown type of plotable: " + plotable.getType()); } index++; } if (minToZero && !useManualRange) { Range xRange = xAxis.getRange(); Range yRange = yAxis.getRange(); if (xRange.getUpperBound() <= 0.0 || yRange.getUpperBound() <= 0.0) { return null; } xAxis.setRange(new Range(0.0, xRange.getUpperBound())); yAxis.setRange(new Range(0.0, yRange.getUpperBound())); } return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.ThermometerChartExpression.java
protected JFreeChart computeChart(final Dataset dataset) { ValueDataset thermometerDataset = null; if (dataset instanceof ValueDataset) { thermometerDataset = (ValueDataset) dataset; }/* www.ja v a 2 s. c o m*/ final ThermometerPlot plot = new ThermometerPlot(thermometerDataset); return new JFreeChart(computeTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:sim.util.media.chart.BoxPlotGenerator.java
protected void buildChart() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); // we build the chart manually rather than using ChartFactory // because we need to customize the getDataRange method below CategoryAxis categoryAxis = new CategoryAxis(""); NumberAxis valueAxis = new NumberAxis("Untitled Y Axis"); valueAxis.setAutoRangeIncludesZero(false); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer) { // Customizing this method in order to provide a bit of // vertical buffer. Otherwise the bar chart box gets drawn // slightly off-chart, which looks really bad. public Range getDataRange(ValueAxis axis) { Range range = super.getDataRange(axis); if (range == null) return null; final double EXTRA_PERCENTAGE = 0.02; return Range.expand(range, EXTRA_PERCENTAGE, EXTRA_PERCENTAGE); }/*from ww w . jav a2 s. com*/ }; chart = new JFreeChart("Untitled Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, false); ChartFactory.getChartTheme().apply(chart); chart.setAntiAlias(true); chartPanel = buildChartPanel(chart); setChartPanel(chartPanel); // this must come last because the chart must exist for us to set its dataset setSeriesDataset(dataset); }
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); /*/*w w w . j a va 2 s . c o 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:org.optaplanner.benchmark.impl.statistic.stepscore.StepScoreProblemStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { List<XYPlot> plotList = new ArrayList<XYPlot>(BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); int seriesIndex = 0; for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) { List<XYSeries> seriesList = new ArrayList<XYSeries>(BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); // No direct ascending lines between 2 points, but a stepping line instead XYItemRenderer renderer = new XYStepRenderer(); if (singleBenchmarkResult.isSuccess()) { StepScoreSingleStatistic singleStatistic = (StepScoreSingleStatistic) singleBenchmarkResult .getSingleStatistic(problemStatisticType); for (StepScoreStatisticPoint point : singleStatistic.getPointList()) { long timeMillisSpent = point.getTimeMillisSpent(); double[] levelValues = ScoreUtils.extractLevelDoubles(point.getScore()); for (int i = 0; i < levelValues.length && i < BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE; i++) { if (i >= seriesList.size()) { seriesList.add(new XYSeries( singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix())); }// ww w . j a v a2s . c o m seriesList.get(i).add(timeMillisSpent, levelValues[i]); } } if (singleStatistic.getPointList().size() <= 1) { // Workaround for https://sourceforge.net/tracker/?func=detail&aid=3387330&group_id=15494&atid=115494 renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES); } } if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) { // Make the favorite more obvious renderer.setSeriesStroke(0, new BasicStroke(2.0f)); } for (int i = 0; i < seriesList.size(); i++) { if (i >= plotList.size()) { plotList.add(createPlot(benchmarkReport, i)); } plotList.get(i).setDataset(seriesIndex, new XYSeriesCollection(seriesList.get(i))); plotList.get(i).setRenderer(seriesIndex, renderer); } seriesIndex++; } graphFileList = new ArrayList<File>(plotList.size()); for (int scoreLevelIndex = 0; scoreLevelIndex < plotList.size(); scoreLevelIndex++) { JFreeChart chart = new JFreeChart( problemBenchmarkResult.getName() + " step score level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plotList.get(scoreLevelIndex), true); graphFileList.add(writeChartToImageFile(chart, problemBenchmarkResult.getName() + "StepScoreStatisticLevel" + scoreLevelIndex)); } }