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:opendial.gui.utils.DistributionViewer.java
/** * Constructs a chart panel for the continuous distribution. * /*w w w. ja v a 2 s . co m*/ * @param distrib the continuous distribution * @return the generated chart panel */ private ChartPanel generatePanel(ContinuousDistribution distrib) { final String variableName = distrib.getVariable(); List<XYSeries> series = extractSeries(distrib.getFunction()); CombinedDomainXYPlot combined = new CombinedDomainXYPlot(new NumberAxis("Value")); for (XYSeries serie : series) { JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "Value", // domain axis label "Density", // range axis label new XYSeriesCollection(serie), // data PlotOrientation.VERTICAL, // orientation (distrib.getFunction().getDimensions() > 1), // include // legend true, // tooltips? false); // URLs? XYPlot plot = (XYPlot) chart.getPlot(); combined.add(plot); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.white); } return new ChartPanel(new JFreeChart("Probability distribution P(" + variableName + ")", JFreeChart.DEFAULT_TITLE_FONT, combined, true), false); }
From source file:org.moeaframework.analysis.plot.Plot.java
/** * If the chart has not yet been initialized, creates a chart for * categorical data. If the chart is already initialized, checks if the * chart is for categorical data.// w w w. j av a2 s. c om * * @throws FrameworkException if the chart does not support categorical data */ private void createCategoryPlot() { if (chart == null) { CategoryAxis xAxis = new CategoryAxis(""); NumberAxis yAxis = new NumberAxis("Value"); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(true); renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final CategoryPlot plot = new CategoryPlot(); plot.setDomainAxis(xAxis); plot.setRangeAxis(yAxis); plot.setRenderer(renderer); chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); ChartFactory.getChartTheme().apply(chart); } else if (!(chart.getPlot() instanceof CategoryPlot)) { throw new FrameworkException("Can not combine XY plot and categorial plot"); } }
From source file:org.jfree.chart.demo.StackedXYAreaChartDemo.java
/** * Creates a chart.//w ww. j av a 2 s. c o m * * @param dataset the dataset. * * @return A chart. */ private JFreeChart createChart(final TableXYDataset dataset) { final StandardXYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("dd-MMM-yyyy", Locale.UK), NumberFormat.getInstance()); final DateAxis xAxis = new DateAxis("Domain (X)"); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); final NumberAxis yAxis = new NumberAxis("Range (Y)"); yAxis.setAutoRangeIncludesZero(true); final StackedXYAreaRenderer renderer = new StackedXYAreaRenderer(XYAreaRenderer.AREA_AND_SHAPES, toolTipGenerator, null); renderer.setOutline(true); renderer.setSeriesPaint(0, new Color(255, 255, 206)); renderer.setSeriesPaint(1, new Color(206, 230, 255)); renderer.setSeriesPaint(2, new Color(255, 230, 230)); renderer.setShapePaint(Color.gray); renderer.setShapeStroke(new BasicStroke(0.5f)); renderer.setShape(new Ellipse2D.Double(-3, -3, 6, 6)); final XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true); return chart; }
From source file:org.drools.planner.benchmark.statistic.calculatecount.CalculateCountStatistic.java
private CharSequence writeGraphStatistic(File solverStatisticFilesDirectory, String baseName) { XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (Map.Entry<String, CalculateCountStatisticListener> listenerEntry : statisticListenerMap.entrySet()) { String configName = listenerEntry.getKey(); XYSeries series = new XYSeries(configName); List<CalculateCountStatisticPoint> statisticPointList = listenerEntry.getValue() .getStatisticPointList(); for (CalculateCountStatisticPoint statisticPoint : statisticPointList) { long timeMillisSpend = statisticPoint.getTimeMillisSpend(); long calculateCountPerSecond = statisticPoint.getCalculateCountPerSecond(); series.add(timeMillisSpend, calculateCountPerSecond); }/*w w w. ja v a 2 s. c o m*/ seriesCollection.addSeries(series); } NumberAxis xAxis = new NumberAxis("Time millis 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(baseName + " calculate count statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); BufferedImage chartImage = chart.createBufferedImage(1024, 768); File graphStatisticFile = new File(solverStatisticFilesDirectory, baseName + "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); } return " <img src=\"" + graphStatisticFile.getName() + "\"/>\n"; }
From source file:org.hxzon.demo.jfreechart.PieDatasetDemo2.java
private static JFreeChart createRingChart(PieDataset dataset) { RingPlot plot = new RingPlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); }//from w ww . j a va2 s. c o m if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } JFreeChart chart = new JFreeChart("Ring Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); return chart; }
From source file:opendial.gui.stateviewer.DistributionViewer.java
/** * Constructs a chart panel for the continuous distribution. * /*from w w w . j av a 2 s.c o m*/ * @param distrib the continuous distribution * @return the generated chart panel * @throws DialException if the distribution could not be displayed */ private ChartPanel generatePanel(ContinuousDistribution distrib) throws DialException { final String variableName = distrib.getVariable(); List<XYSeries> series = extractSeries(distrib.getFunction()); CombinedDomainXYPlot combined = new CombinedDomainXYPlot(new NumberAxis("Value")); for (XYSeries serie : series) { JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "Value", // domain axis label "Density", // range axis label new XYSeriesCollection(serie), // data PlotOrientation.VERTICAL, // orientation (distrib.getFunction().getDimensionality() > 1), // include legend true, // tooltips? false); // URLs? XYPlot plot = (XYPlot) chart.getPlot(); combined.add(plot); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.white); } return new ChartPanel(new JFreeChart("Probability distribution P(" + variableName + ")", JFreeChart.DEFAULT_TITLE_FONT, combined, true), false); }
From source file:no.met.jtimeseries.chart.ChartPlotter.java
/** * Create a overlaind chart/*from ww w . j av a 2 s . co m*/ * * @param chartTitle * The title of the chart * @return The JfreeChart object */ public JFreeChart createOverlaidChart(String chartTitle) { logger.info("Creating chart " + chartTitle); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // return a new chart containing the overlaid plot... Plot chartPlot = createOverlaidPlot(); /* * // make combined plot if sub-plots are defined if (windPlot != null * || weatherSymbolPlot != null || cloudPlot != null) { StackedXYPlot * combiPlot = new StackedXYPlot(plot.getDomainAxis()); if (cloudPlot != * null) { combiPlot.add(cloudPlot, cloudPlotWeight); } if * (weatherSymbolPlot != null) { combiPlot.add(weatherSymbolPlot, * weatherSymbolPlotWeight); } combiPlot.add(plot, mainPlotWeight); if * (windPlot != null) { combiPlot.add(windPlot, windPlotWeight); } * combiPlot.setGap(0.0f); chartPlot = combiPlot; } else { chartPlot = * plot; } */ JFreeChart chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, chartPlot, true); chart.setBorderVisible(false); Paint paint = new GradientPaint(0, 0, Color.WHITE, getWidth(), 0, Color.WHITE); chart.setBackgroundPaint(paint); return chart; }
From source file:edu.cudenver.bios.chartsvc.resource.ScatterPlotResource.java
/** * Create a JFreeChart object from the chart specification. JFreechart provides * functionality to render 2D scatter plots as jpeg images * //from w w w.j a va 2 s. co m * @param chart chart specification object * @return JFreeChart object * @throws ResourceException */ private JFreeChart buildScatterPlot(Chart chart) throws ResourceException { ArrayList<LineStyle> lineStyleList = chart.getLineStyleList(); float dashedLength = 1.0f; float spaceLength = 1.0f; float thickness = 1.0f; // the first series is treated as the x values if (chart.getSeries() == null || chart.getSeries().size() <= 0) throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No data series specified"); // create the jfree chart series XYSeriesCollection chartData = new XYSeriesCollection(); // use a spline renderer to make the connecting lines smooth XYSplineRenderer rend = new XYSplineRenderer(); int seriesIdx = 0; for (Series series : chart.getSeries()) { XYSeries xySeries = new XYSeries(series.getLabel()); List<Double> xList = series.getXCoordinates(); List<Double> yList = series.getYCoordinates(); if (xList != null && yList != null && xList.size() == yList.size()) { for (int i = 0; i < xList.size(); i++) { xySeries.add(xList.get(i), yList.get(i)); } } if (seriesIdx >= 0 && seriesIdx < lineStyleList.size()) { LineStyle lineStyle = lineStyleList.get(seriesIdx); dashedLength = (float) lineStyle.getDashLength(); spaceLength = (float) lineStyle.getSpaceLength(); thickness = (float) lineStyle.getWidth(); } else { dashedLength = 1.0f; spaceLength = 1.0f; thickness = 1.0f; } // set the line style rend.setSeriesPaint(seriesIdx, Color.BLACK); if (seriesIdx >= 0) { /*rend.setSeriesStroke(seriesIdx, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] {(float) seriesIdx, (float) 2*seriesIdx}, 0.0f));*/ rend.setSeriesStroke(seriesIdx, new BasicStroke(thickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { dashedLength, spaceLength }, 0.0f)); } // add the series to the data set chartData.addSeries(xySeries); seriesIdx++; } // turn off shapes displayed at each data point to make a smooth curve rend.setBaseShapesVisible(false); // Create the line chart NumberAxis xAxis = new NumberAxis(); xAxis.setAutoRangeIncludesZero(false); if (chart.getXAxis() != null) { Axis xAxisSpec = chart.getXAxis(); xAxis.setLabel(xAxisSpec.getLabel()); if (!Double.isNaN(xAxisSpec.getRangeMin()) && !Double.isNaN(xAxisSpec.getRangeMax())) { xAxis.setRange(xAxisSpec.getRangeMin(), xAxisSpec.getRangeMax()); } } NumberAxis yAxis = new NumberAxis(); if (chart.getYAxis() != null) { Axis yAxisSpec = chart.getYAxis(); yAxis.setLabel(chart.getYAxis().getLabel()); if (!Double.isNaN(yAxisSpec.getRangeMin()) && !Double.isNaN(yAxisSpec.getRangeMax())) { xAxis.setRange(yAxisSpec.getRangeMin(), yAxisSpec.getRangeMax()); } } XYPlot plot = new XYPlot((XYDataset) chartData, xAxis, yAxis, rend); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); JFreeChart renderedChart = new JFreeChart(chart.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, false); renderedChart.setBackgroundPaint(Color.WHITE); if (chart.hasLegend()) { LegendTitle legend = new LegendTitle(plot, new ColumnArrangement(), new ColumnArrangement()); legend.setFrame(BlockBorder.NONE); legend.setPosition(RectangleEdge.BOTTOM); renderedChart.addLegend(legend); } return renderedChart; }
From source file:org.drools.planner.benchmark.statistic.memoryuse.MemoryUseStatistic.java
private CharSequence writeGraphStatistic(File solverStatisticFilesDirectory, String baseName) { XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (Map.Entry<String, MemoryUseStatisticListener> listenerEntry : statisticListenerMap.entrySet()) { String configName = listenerEntry.getKey(); XYSeries usedSeries = new XYSeries(configName + " used"); XYSeries maxSeries = new XYSeries(configName + " max"); List<MemoryUseStatisticPoint> statisticPointList = listenerEntry.getValue().getStatisticPointList(); for (MemoryUseStatisticPoint statisticPoint : statisticPointList) { long timeMillisSpend = statisticPoint.getTimeMillisSpend(); MemoryUseMeasurement memoryUseMeasurement = statisticPoint.getMemoryUseMeasurement(); usedSeries.add(timeMillisSpend, memoryUseMeasurement.getUsedMemory()); maxSeries.add(timeMillisSpend, memoryUseMeasurement.getMaxMemory()); }/* www . java2 s .co m*/ seriesCollection.addSeries(usedSeries); seriesCollection.addSeries(maxSeries); } NumberAxis xAxis = new NumberAxis("Time millis 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(baseName + " memory use statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); BufferedImage chartImage = chart.createBufferedImage(1024, 768); File graphStatisticFile = new File(solverStatisticFilesDirectory, baseName + "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); } return " <img src=\"" + graphStatisticFile.getName() + "\"/>\n"; }
From source file:org.locationtech.udig.processingtoolbox.tools.ScatterPlotDialog.java
private void createGraphTab(final CTabFolder parentTabFolder) { plotTab = new CTabItem(parentTabFolder, SWT.NONE); plotTab.setText(Messages.ScatterPlotDialog_Graph); XYPlot plot = new XYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setDomainPannable(false);/* w w w.j ava 2s .c om*/ plot.setRangePannable(false); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); JFreeChart chart = new JFreeChart(EMPTY, JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(java.awt.Color.WHITE); chart.setBorderVisible(false); chartComposite = new ChartComposite2(parentTabFolder, SWT.NONE | SWT.EMBEDDED, chart, true); chartComposite.setLayout(new FillLayout()); chartComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); chartComposite.setDomainZoomable(false); chartComposite.setRangeZoomable(false); chartComposite.setMap(map); chartComposite.addChartMouseListener(new PlotMouseListener()); plotTab.setControl(chartComposite); chartComposite.pack(); }