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:com.joliciel.jochre.graphics.SourceImageImpl.java
private void drawChart(int[] pixelSpread, DescriptiveStatistics countStats, DescriptiveStatistics blackCountStats, DescriptiveStatistics blackSpread, int startWhite, int endWhite, int startBlack, int blackThresholdValue) { XYSeries xySeries = new XYSeries("Brightness data"); double maxSpread = 0; for (int i = 0; i < 256; i++) { xySeries.add(i, pixelSpread[i]); if (pixelSpread[i] > maxSpread) maxSpread = pixelSpread[i];/* ww w . ja v a 2 s .co m*/ } XYSeries keyValues = new XYSeries("Key values"); XYSeries counts = new XYSeries("Counts"); counts.add(10.0, countStats.getMean()); counts.add(100.0, blackCountStats.getMean()); counts.add(125.0, blackCountStats.getMean() + (1.0 * blackCountStats.getStandardDeviation())); counts.add(150.0, blackCountStats.getMean() + (2.0 * blackCountStats.getStandardDeviation())); counts.add(175.0, blackCountStats.getMean() + (3.0 * blackCountStats.getStandardDeviation())); counts.add(75.0, blackCountStats.getMean() - (1.0 * blackCountStats.getStandardDeviation())); counts.add(50.0, blackCountStats.getMean() - (2.0 * blackCountStats.getStandardDeviation())); counts.add(25.0, blackCountStats.getMean() - (3.0 * blackCountStats.getStandardDeviation())); keyValues.add(startWhite, maxSpread / 4.0); keyValues.add(endWhite, maxSpread / 4.0); keyValues.add(startBlack, maxSpread / 4.0); keyValues.add(blackThresholdValue, maxSpread / 2.0); XYSeriesCollection dataset = new XYSeriesCollection(xySeries); dataset.addSeries(keyValues); dataset.addSeries(counts); final ValueAxis xAxis = new NumberAxis("Brightness"); final ValueAxis yAxis = new NumberAxis("Count"); yAxis.setUpperBound(maxSpread); xAxis.setUpperBound(255.0); //final XYItemRenderer renderer = new XYBarRenderer(); final XYBarRenderer renderer = new XYBarRenderer(); renderer.setShadowVisible(false); final XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); String title = "BrightnessChart"; final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(Color.white); File file = new File("data/" + title + ".png"); try { ChartUtilities.saveChartAsPNG(file, chart, 600, 600); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e); } }
From source file:org.optaplanner.benchmark.impl.report.BenchmarkReport.java
private void writeBestScoreSummaryCharts() { // Each scoreLevel has it's own dataset and chartFile List<DefaultCategoryDataset> datasetList = new ArrayList<DefaultCategoryDataset>(CHARTED_SCORE_LEVEL_SIZE); for (SolverBenchmarkResult solverBenchmarkResult : plannerBenchmarkResult.getSolverBenchmarkResultList()) { String solverLabel = solverBenchmarkResult.getNameWithFavoriteSuffix(); for (SingleBenchmarkResult singleBenchmarkResult : solverBenchmarkResult .getSingleBenchmarkResultList()) { String planningProblemLabel = singleBenchmarkResult.getProblemBenchmarkResult().getName(); if (singleBenchmarkResult.isSuccess()) { double[] levelValues = ScoreUtils.extractLevelDoubles(singleBenchmarkResult.getScore()); for (int i = 0; i < levelValues.length && i < CHARTED_SCORE_LEVEL_SIZE; i++) { if (i >= datasetList.size()) { datasetList.add(new DefaultCategoryDataset()); }/*from w w w . ja v a 2 s .c o m*/ datasetList.get(i).addValue(levelValues[i], solverLabel, planningProblemLabel); } } } } bestScoreSummaryChartFileList = new ArrayList<File>(datasetList.size()); int scoreLevelIndex = 0; for (DefaultCategoryDataset dataset : datasetList) { CategoryPlot plot = createBarChartPlot(dataset, "Score level " + scoreLevelIndex, NumberFormat.getInstance(locale)); JFreeChart chart = new JFreeChart("Best score level " + scoreLevelIndex + " summary (higher is better)", JFreeChart.DEFAULT_TITLE_FONT, plot, true); bestScoreSummaryChartFileList .add(writeChartToImageFile(chart, "bestScoreSummaryLevel" + scoreLevelIndex)); scoreLevelIndex++; } }
From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java
private JFreeChart createChart(String title, XYPlot plot) { JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(Color.white); return chart; }
From source file:org.pentaho.platform.uifoundation.chart.JFreeChartEngine.java
private static JFreeChart createXYZSeriesCollectionChart( final XYZSeriesCollectionChartDefinition chartDefinition) { JFreeChart chart = null;/*w w w .j a va2 s .com*/ // TODO Make the following accessible from the chartDefinition String domainAxisLabel = null; String rangeAxisLabel = null; boolean tooltips = true; boolean urls = true; // ----------------------------------------------------------- String title = chartDefinition.getTitle(); boolean legend = chartDefinition.isLegendIncluded(); NumberAxis domainAxis = chartDefinition.isThreeD() ? new NumberAxis3D(domainAxisLabel) : new NumberAxis(domainAxisLabel); domainAxis.setAutoRangeIncludesZero(chartDefinition.isDomainIncludesZero()); domainAxis.setAutoRangeStickyZero(chartDefinition.isDomainStickyZero()); NumberAxis rangeAxis = new NumberAxis(rangeAxisLabel); rangeAxis.setAutoRangeIncludesZero(chartDefinition.isRangeIncludesZero()); rangeAxis.setAutoRangeStickyZero(chartDefinition.isRangeStickyZero()); BubbleRenderer renderer = null; // So far only Bubble charts are supported switch (chartDefinition.getChartType()) { case BUBBLE_CHART_TYPE: renderer = new BubbleRenderer(); break; default: // should log an error if invalid chart type passed in - at least return null for no renderer return null; } if (tooltips) { // creating the label definition renderer.setToolTipGenerator(new StandardXYZToolTipGenerator(chartDefinition.getBubbleLabelContent(), chartDefinition.getXFormat(), chartDefinition.getYFormat(), chartDefinition.getZFormat())); } if (urls) { renderer.setURLGenerator(new StandardBubbleURLGenerator()); } renderer.setMaxSize(chartDefinition.getMaxBubbleSize()); renderer.setMaxZ(chartDefinition.getMaxZValue()); XYPlot plot = new XYPlot(chartDefinition, domainAxis, rangeAxis, renderer); JFreeChartEngine.updatePlot(plot, chartDefinition); chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:net.commerce.zocalo.freechart.ChartGenerator.java
public static JFreeChart createCustomXYStepAreaChart(TimePeriodValuesCollection top, TimePeriodValuesCollection bottom) { DateAxis xAxis = new DateAxis(null); NumberAxis yAxis = new NumberAxis("price"); yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); yAxis.setUpperBound(100);//w w 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, top); plot.setDataset(1, bottom); XYStepAreaRenderer bottomRenderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA, null, null); XYStepAreaRenderer topRenderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA, null, null); 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.setOrientation(PlotOrientation.VERTICAL); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.jfree.chart.demo.SymbolicXYPlotDemo.java
/** * Displays an horizontally combined XYPlot with X and Y symbolic data. * /*w ww . jav a2 s. c om*/ * @param frameTitle * the frame title. * @param data1 * the dataset 1. * @param data2 * the dataset 2. */ private static void displayXYSymbolicCombinedHorizontally(final String frameTitle, final XYDataset data1, final XYDataset data2) { final String title = "Pollutant Horizontally Combined"; final String x1AxisLabel = "Contamination"; final String x2AxisLabel = "Type"; final String yAxisLabel = "Pollutant"; // combine the y symbolic values of the two data sets final String[] combinedYSymbolicValues = SampleXYSymbolicDataset .combineYSymbolicDataset((YisSymbolic) data1, (YisSymbolic) data2); // make master dataset... final CombinedDataset data = new CombinedDataset(); data.add(data1); data.add(data2); // decompose data... final XYDataset series0 = new SubSeriesDataset(data, 0); final XYDataset series1 = new SubSeriesDataset(data, 1); JFreeChart chart = null; // common horizontal and vertical axes final SymbolicAxis hsymbolicAxis0 = new SymbolicAxis(x1AxisLabel, ((XisSymbolic) data1).getXSymbolicValues()); final SymbolicAxis hsymbolicAxis1 = new SymbolicAxis(x2AxisLabel, ((XisSymbolic) data2).getXSymbolicValues()); final SymbolicAxis symbolicAxis = new SymbolicAxis(yAxisLabel, combinedYSymbolicValues); // create main plot... final CombinedRangeXYPlot mainPlot = new CombinedRangeXYPlot(symbolicAxis); // add subplots... final XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot0 = new XYPlot(series0, hsymbolicAxis0, null, renderer); final XYPlot subplot1 = new XYPlot(series1, hsymbolicAxis1, null, renderer); mainPlot.add(subplot0, 1); mainPlot.add(subplot1, 1); // make the top level JFreeChart object chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); // and present it in a frame... final JFrame frame = new ChartFrame(frameTitle, chart); frame.pack(); RefineryUtilities.positionFrameRandomly(frame); frame.show(); }
From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java
private static JFreeChart createXYLineChart(XYDataset dataset) { NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation);//from w ww . j a v a 2 s . c o m if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } JFreeChart chart = new JFreeChart("XYLine 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); yAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat()); return chart; }
From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java
/** * Creates a bubble chart with default settings. The chart is composed of an {@link XYPlot}, with a {@link NumberAxis} for the * domain axis, a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer} to draw the data items. * /* www . j a va 2s .c om*/ * This method is copied from * {@link org.jfree.chart.ChartFactory#createBubbleChart(String, String, String, XYZDataset, PlotOrientation, boolean, boolean, boolean)} * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the 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 bubble chart. */ public static JFreeChart createBubbleChart(String title, String xAxisLabel, String yAxisLabel, XYZDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException(Messages.getString("TopChartFactory.argument")); //$NON-NLS-1$ } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); XYItemRenderer renderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS) { @Override public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // return straight away if the item is not visible if (!getItemVisible(series, item)) { return; } PlotOrientation orientation = plot.getOrientation(); // get the data point... double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); double z = Double.NaN; if (dataset instanceof XYZDataset) { XYZDataset xyzData = (XYZDataset) dataset; z = xyzData.getZValue(series, item); } if (!Double.isNaN(z)) { RectangleEdge domainAxisLocation = plot.getDomainAxisEdge(); RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); double transX = domainAxis.valueToJava2D(x, dataArea, domainAxisLocation); double transY = rangeAxis.valueToJava2D(y, dataArea, rangeAxisLocation); double transDomain = 0.0; double transRange = 0.0; double zero; // MOD scorreia +2L avoid points: minimal size of circle must be 1 // z = z * transX + 1; // ADD xqliu 2009-07-06 bug 8035 double zSize = getBubbleSize(z); // calculate the multiple of bubble's default size z = 0; // use bubble's default size // ~ switch (getScaleType()) { case SCALE_ON_DOMAIN_AXIS: zero = domainAxis.valueToJava2D(0.0, dataArea, domainAxisLocation); transDomain = domainAxis.valueToJava2D(z, dataArea, domainAxisLocation) - zero; transRange = transDomain; break; case SCALE_ON_RANGE_AXIS: zero = rangeAxis.valueToJava2D(0.0, dataArea, rangeAxisLocation); transRange = zero - rangeAxis.valueToJava2D(z, dataArea, rangeAxisLocation); transDomain = transRange; break; default: double zero1 = domainAxis.valueToJava2D(0.0, dataArea, domainAxisLocation); double zero2 = rangeAxis.valueToJava2D(0.0, dataArea, rangeAxisLocation); transDomain = domainAxis.valueToJava2D(z, dataArea, domainAxisLocation) - zero1; transRange = zero2 - rangeAxis.valueToJava2D(z, dataArea, rangeAxisLocation); } transDomain = Math.abs(transDomain); transRange = Math.abs(transRange); // MODSCA 2008-11-27 enlarge ellipse by diag% of the total diagonal double diag = Math.sqrt(dataArea.getHeight() * dataArea.getHeight() + dataArea.getWidth() * dataArea.getWidth()); transDomain += diag / 100; transRange += diag / 100; Ellipse2D circle = null; // ADD xqliu 2009-07-06 bug 8035 transDomain *= zSize; transRange *= zSize; // ~ if (orientation == PlotOrientation.VERTICAL) { circle = new Ellipse2D.Double(transX - transDomain / 2.0, transY - transRange / 2.0, transDomain, transRange); } else if (orientation == PlotOrientation.HORIZONTAL) { circle = new Ellipse2D.Double(transY - transRange / 2.0, transX - transDomain / 2.0, transRange, transDomain); } g2.setPaint(getItemPaint(series, item)); g2.fill(circle); g2.setStroke(getItemOutlineStroke(series, item)); g2.setPaint(getItemOutlinePaint(series, item)); g2.draw(circle); if (isItemLabelVisible(series, item)) { if (orientation == PlotOrientation.VERTICAL) { drawItemLabel(g2, orientation, dataset, series, item, transX, transY, false); } else if (orientation == PlotOrientation.HORIZONTAL) { drawItemLabel(g2, orientation, dataset, series, item, transY, transX, false); } } // add an entity if this info is being collected EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); if (entities != null && circle.intersects(dataArea)) { addEntity(entities, circle, dataset, series, item, circle.getCenterX(), circle.getCenterY()); } } int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x, y, domainAxisIndex, rangeAxisIndex, transX, transY, orientation); } } /** * DOC xqliu : calculate the size of bubble. for bug 8035 2009-07-06. * * @param z multiple of bubble's default size * @return */ private double getBubbleSize(double z) { if (z > 0 && z <= 10) { return 2; } else if (z > 10 && z <= 100) { return 3; } else if (z > 100) { return 4; } return 1; } }; if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYZURLGenerator()); } plot.setRenderer(renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:jgnash.ui.report.compiled.MonthlyAccountBalanceChartCompare.java
private JFreeChart createVerticalXYBarChart(final Account a, final Account a2) { DateFormat df = new SimpleDateFormat("MM/yy"); TimeSeriesCollection data = createTimeSeriesCollection(a, a2); DateAxis dateAxis = new DateAxis(rb.getString("Column.Date")); dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1, df)); dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); // if (a.getTransactionCount() > 0) { Date start = DateUtils.asDate(DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate())); Date end = DateUtils.asDate(DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate())); dateAxis.setRange(start, end);//from w w w .j av a 2s. com // } NumberAxis valueAxis = new NumberAxis( rb.getString("Column.Balance") + "-" + a.getCurrencyNode().getSymbol()); StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance()); ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer(0.2, false); renderer.setBaseToolTipGenerator(tooltipGenerator); XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer); String title; if (jcb_compare.isSelected()) { title = a.getPathName() + " vs " + a2.getPathName(); } else { title = rb.getString("Title.AccountBalance") + " - " + a.getPathName(); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(null); return chart; }
From source file:org.gumtree.vis.awt.PlotFactory.java
public static JFreeChart createXYBlockChart(IXYZDataset dataset) { NumberAxis xAxis = createXAxis(dataset); NumberAxis yAxis = createYAxis(dataset); NumberAxis scaleAxis = createScaleAxis(dataset); float min = (float) dataset.getZMin(); float max = (float) dataset.getZMax(); PaintScale scale = generateRainbowScale(min, max, StaticValues.DEFAULT_COLOR_SCALE); XYBlockRenderer renderer = createRender(dataset, scale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); plot.setDomainPannable(true);//from w w w .jav a 2s . c o m plot.setRangePannable(true); JFreeChart chart = new JFreeChart(dataset.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, false); // chart = new JFreeChart(dataset.getTitle(), plot); chart.removeLegend(); chart.setBackgroundPaint(Color.white); PaintScale scaleBar = generateRainbowScale(min, max, StaticValues.DEFAULT_COLOR_SCALE); PaintScaleLegend legend = createScaleLegend(scale, scaleAxis); legend.setSubdivisionCount(ColorScale.DIVISION_COUNT); // legend.setStripOutlineVisible(true); chart.addSubtitle(legend); chart.setBorderVisible(true); // ChartUtilities.applyCurrentTheme(chart); chartTheme.apply(chart); chart.fireChartChanged(); return chart; }