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:jgnash.ui.report.compiled.MonthlyAccountBalanceChart.java
private JFreeChart createVerticalXYBarChart(Account a) { DateFormat df = new SimpleDateFormat("MM/yy"); TimeSeriesCollection data = createTimeSeriesCollection(a); 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 ww w . j av a2 s .c om // } NumberAxis valueAxis = new NumberAxis(rb.getString("Column.Balance")); StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance()); XYBarRenderer renderer = new XYBarRenderer(0.2); renderer.setBaseToolTipGenerator(tooltipGenerator); XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer); String 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.locationtech.udig.processingtoolbox.tools.BubbleChartDialog.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 2 s . c o m*/ 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 ChartComposite3(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(); }
From source file:org.locationtech.udig.processingtoolbox.tools.BoxPlotDialog.java
private void createGraphTab(final CTabFolder parentTabFolder) { plotTab = new CTabItem(parentTabFolder, SWT.NONE); plotTab.setText(Messages.ScatterPlotDialog_Graph); CategoryPlot plot = new CategoryPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setRangePannable(false);/*from w ww . j a va2 s.c o m*/ JFreeChart chart = new JFreeChart(EMPTY, JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(java.awt.Color.WHITE); chart.setBorderVisible(false); chartComposite = new ChartComposite(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(); }
From source file:org.drools.planner.benchmark.statistic.bestscore.BestScoreStatistic.java
private CharSequence writeGraphStatistic(File solverStatisticFilesDirectory, String baseName) { NumberAxis xAxis = new NumberAxis("Time millis spend"); xAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat()); NumberAxis yAxis = new NumberAxis("Score"); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); int seriesIndex = 0; for (Map.Entry<String, BestScoreStatisticListener> listenerEntry : bestScoreStatisticListenerMap .entrySet()) {/*from w w w .j a va2s .co m*/ String configName = listenerEntry.getKey(); XYSeries series = new XYSeries(configName); List<BestScoreStatisticPoint> statisticPointList = listenerEntry.getValue().getStatisticPointList(); for (BestScoreStatisticPoint statisticPoint : statisticPointList) { long timeMillisSpend = statisticPoint.getTimeMillisSpend(); Score score = statisticPoint.getScore(); Double scoreGraphValue = scoreDefinition.translateScoreToGraphValue(score); if (scoreGraphValue != null) { series.add(timeMillisSpend, scoreGraphValue); } } XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(series); plot.setDataset(seriesIndex, seriesCollection); XYItemRenderer renderer; // No direct lines between 2 points renderer = new XYStepRenderer(); if (statisticPointList.size() <= 1) { // Workaround for https://sourceforge.net/tracker/?func=detail&aid=3387330&group_id=15494&atid=115494 renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES); } plot.setRenderer(seriesIndex, renderer); seriesIndex++; } plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(baseName + " best score statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); BufferedImage chartImage = chart.createBufferedImage(1024, 768); File graphStatisticFile = new File(solverStatisticFilesDirectory, baseName + "BestScoreStatistic.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.drools.planner.benchmark.core.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 (SolverBenchmark solverBenchmark : plannerBenchmark.getSolverBenchmarkList()) { String solverLabel = solverBenchmark.getNameWithFavoriteSuffix(); for (SingleBenchmark singleBenchmark : solverBenchmark.getSingleBenchmarkList()) { String planningProblemLabel = singleBenchmark.getProblemBenchmark().getName(); if (singleBenchmark.isSuccess()) { double[] levelValues = singleBenchmark.getScore().toDoubleLevels(); for (int i = 0; i < levelValues.length && i < CHARTED_SCORE_LEVEL_SIZE; i++) { if (i >= datasetList.size()) { datasetList.add(new DefaultCategoryDataset()); }/*from w ww. j av a 2 s. c om*/ 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.hxzon.demo.jfreechart.CategoryDatasetDemo2.java
private static JFreeChart createBarChart(CategoryDataset dataset) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); ValueAxis valueAxis = new NumberAxis(valueAxisLabel); BarRenderer renderer = new BarRenderer(); if (orientation == PlotOrientation.HORIZONTAL) { ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setBasePositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT); renderer.setBaseNegativeItemLabelPosition(position2); } else if (orientation == PlotOrientation.VERTICAL) { ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); renderer.setBasePositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); renderer.setBaseNegativeItemLabelPosition(position2); }//from ww w .j ava 2 s . com if (tooltips) { renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); } if (urls) { renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart("Bar Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setDrawBarOutline(false); GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); categoryAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:org.fhcrc.cpl.toolbox.gui.chart.PanelWithHeatMap.java
public void setData(double[] xValues, double[] yValues, double[][] zValues) { this.xValues = xValues; this.yValues = yValues; this.zValues = zValues; double minZValue = Double.MAX_VALUE; double maxZValue = Double.MIN_VALUE; int width = xValues.length; int height = yValues.length; int numCells = width * height; _log.debug("Number of cells in heat map: " + numCells); if (zValues.length != width || zValues[0].length != height) throw new RuntimeException( "PanelWithHeatMap: wrong number of z values for x and y values (" + zValues.length + " vs. " + width + ", " + zValues[0].length + " vs. " + height + ", x/y first, z second)"); DefaultXYZDataset theDataset = new DefaultXYZDataset(); double[][] data = new double[3][numCells]; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { int cellIndex = (j * width) + i; data[0][cellIndex] = xValues[i]; data[1][cellIndex] = yValues[j]; data[2][cellIndex] = zValues[i][j]; //keep track of lowest/highest z values minZValue = Math.min(zValues[i][j], minZValue); maxZValue = Math.max(zValues[i][j], maxZValue); }/*from w w w . j av a 2 s.co m*/ } lowerZBound = Rounder.round(minZValue, 3); upperZBound = Rounder.round(maxZValue, 3); if (lowerZBound == upperZBound) upperZBound += .0001; _log.debug("low,high values: " + lowerZBound + ", " + upperZBound); theDataset.addSeries("Range: " + lowerZBound + "-" + upperZBound, data); dataset = theDataset; if (renderer == null) { renderer = new XYBlockRenderer(); } if (paintScale == null) { setPaintScale(createPaintScale(palette)); } //This is necessary to get everything to line up renderer.setBlockAnchor(RectangleAnchor.BOTTOM); if (getPlot() != null) { ((XYPlot) getPlot()).setDataset(dataset); ((XYPlot) getPlot()).setRenderer(renderer); invalidate(); return; } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(dataSetName, JFreeChart.DEFAULT_TITLE_FONT, plot, true); // chart.addLegend(new LegendTitle(renderer)); // PaintScaleLegend legend = new PaintScaleLegend(paintScale, xAxis); // chart.addLegend(legend); // LegendItemCollection c1 = new LegendItemCollection(); // // LegendItem item1 = new LegendItem("Label", "Description", // "ToolTip", "URL", true, // new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, // true, Color.blue, new BasicStroke(1.2f), true, // new Line2D.Double(1.0, 2.0, 3.0, 4.0), // new BasicStroke(2.1f), Color.green); // LegendItem item2 = new LegendItem("Label", "Description", // "ToolTip", "URL", true, // new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), // true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, // new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), // Color.green); // c1.add(item1); // // chart.getLegend().setSources(new LegendItemSource[]{renderer}); init(chart); }
From source file:no.met.jtimeseries.marinogram.MarinogramWrapper.java
private static JFreeChart createJFreeChart(String title, Plot plot, int width) { JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBorderVisible(false);/*from w ww.j av a2 s. c om*/ Paint paint = new GradientPaint(0, 0, Color.WHITE, width, 0, Color.WHITE); chart.setBackgroundPaint(paint); return chart; }
From source file:com.opendoorlogistics.components.gantt.GanttChartComponent.java
@Override public void execute(final ComponentExecutionApi api, int mode, Object configuration, ODLDatastore<? extends ODLTable> ioDs, ODLDatastoreAlterable<? extends ODLTableAlterable> outputDs) { // Get items and sort by resource then date final StringConventions sc = api.getApi().stringConventions(); List<GanttItem> items = GanttItem.beanMapping.getTableMapping(0).readObjectsFromTable(ioDs.getTableAt(0)); // Rounding doubles to longs can create small errors where a start time is 1 millisecond after an end. // Set all start times to be <= end time for (GanttItem item : items) { if (item.getStart() == null || item.getEnd() == null) { throw new RuntimeException("Found Gannt item with null start or end time."); }//ww w . j a v a2 s . c om if (item.getStart().getValue() > item.getEnd().getValue()) { item.setStart(item.getEnd()); } } Collections.sort(items, new Comparator<GanttItem>() { @Override public int compare(GanttItem o1, GanttItem o2) { int diff = sc.compareStandardised(o1.getResourceId(), o2.getResourceId()); if (diff == 0) { diff = o1.getStart().compareTo(o2.getStart()); } if (diff == 0) { diff = o1.getEnd().compareTo(o2.getEnd()); } if (diff == 0) { diff = sc.compareStandardised(o1.getActivityId(), o2.getActivityId()); } if (diff == 0) { diff = Colours.compare(o1.getColor(), o2.getColor()); } return diff; } }); // Filter any zero duration items Iterator<GanttItem> it = items.iterator(); while (it.hasNext()) { GanttItem item = it.next(); if (item.getStart().compareTo(item.getEnd()) == 0) { it.remove(); } } // Get average colour for each activity type Map<String, CalculateAverageColour> calcColourMap = api.getApi().stringConventions() .createStandardisedMap(); for (GanttItem item : items) { CalculateAverageColour calc = calcColourMap.get(item.getActivityId()); if (calc == null) { calc = new CalculateAverageColour(); calcColourMap.put(item.getActivityId(), calc); } calc.add(item.getColor()); } // Put into colour map Map<String, Color> colourMap = api.getApi().stringConventions().createStandardisedMap(); for (Map.Entry<String, CalculateAverageColour> entry : calcColourMap.entrySet()) { colourMap.put(entry.getKey(), entry.getValue().getAverage()); } // Split items by resource ArrayList<ArrayList<GanttItem>> splitByResource = new ArrayList<>(); ArrayList<GanttItem> current = null; for (GanttItem item : items) { if (current == null || sc.compareStandardised(current.get(0).getResourceId(), item.getResourceId()) != 0) { current = new ArrayList<>(); splitByResource.add(current); } current.add(item); } // put into jfreechart's task data structure TaskSeries ts = new TaskSeries("Resources"); for (ArrayList<GanttItem> resource : splitByResource) { // get earliest and latest time (last time may not be in the last item) ODLTime earliest = resource.get(0).getStart(); ODLTime latest = null; for (GanttItem item : resource) { if (latest == null || latest.compareTo(item.getEnd()) < 0) { latest = item.getEnd(); } } Task task = new Task(resource.get(0).getResourceId(), new Date(earliest.getTotalMilliseconds()), new Date(latest.getTotalMilliseconds())); // add all items as subtasks for (GanttItem item : resource) { task.addSubtask(new MySubtask(item, new Date(item.getStart().getTotalMilliseconds()), new Date(item.getEnd().getTotalMilliseconds()))); } ts.add(task); } TaskSeriesCollection collection = new TaskSeriesCollection(); collection.add(ts); // Create the plot CategoryAxis categoryAxis = new CategoryAxis(null); DateAxis dateAxis = new DateAxis("Time"); CategoryItemRenderer renderer = new MyRenderer(collection, colourMap); final CategoryPlot plot = new CategoryPlot(collection, categoryAxis, dateAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); plot.getDomainAxis().setLabel(null); ((DateAxis) plot.getRangeAxis()).setDateFormatOverride(new DateFormat() { @Override public Date parse(String source, ParsePosition pos) { // TODO Auto-generated method stub return null; } @Override public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { toAppendTo.append(new ODLTime(date.getTime()).toString()); return toAppendTo; } }); // Create the chart and apply the standard theme without shadows to it api.submitControlLauncher(new ControlLauncherCallback() { @Override public void launchControls(ComponentControlLauncherApi launcherApi) { JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true); StandardChartTheme theme = new StandardChartTheme("standard theme", false); theme.setBarPainter(new StandardBarPainter()); theme.apply(chart); class MyPanel extends ChartPanel implements Disposable { public MyPanel(JFreeChart chart) { super(chart); } @Override public void dispose() { // TODO Auto-generated method stub } } MyPanel chartPanel = new MyPanel(chart); launcherApi.registerPanel("Resource Gantt", null, chartPanel, true); } }); }
From source file:org.optaplanner.benchmark.impl.statistic.single.constraintmatchtotalbestscore.ConstraintMatchTotalBestScoreSingleStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { List<Map<String, XYSeries>> constraintIdToWeightSeriesMapList = new ArrayList<Map<String, XYSeries>>( BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); for (ConstraintMatchTotalBestScoreStatisticPoint point : getPointList()) { int scoreLevel = point.getScoreLevel(); if (scoreLevel >= BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE) { continue; }/*from ww w . j a va2s .c o m*/ while (scoreLevel >= constraintIdToWeightSeriesMapList.size()) { constraintIdToWeightSeriesMapList.add(new LinkedHashMap<String, XYSeries>()); } Map<String, XYSeries> constraintIdToWeightSeriesMap = constraintIdToWeightSeriesMapList.get(scoreLevel); if (constraintIdToWeightSeriesMap == null) { constraintIdToWeightSeriesMap = new LinkedHashMap<String, XYSeries>(); constraintIdToWeightSeriesMapList.set(scoreLevel, constraintIdToWeightSeriesMap); } String constraintId = point.getConstraintPackage() + ":" + point.getConstraintName(); XYSeries weightSeries = constraintIdToWeightSeriesMap.get(constraintId); if (weightSeries == null) { weightSeries = new XYSeries(point.getConstraintName() + " weight"); constraintIdToWeightSeriesMap.put(constraintId, weightSeries); } long timeMillisSpent = point.getTimeMillisSpent(); weightSeries.add(timeMillisSpent, point.getWeightTotal()); } graphFileList = new ArrayList<File>(constraintIdToWeightSeriesMapList.size()); for (int scoreLevelIndex = 0; scoreLevelIndex < constraintIdToWeightSeriesMapList .size(); scoreLevelIndex++) { XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex); // No direct ascending lines between 2 points, but a stepping line instead XYItemRenderer renderer = new XYStepRenderer(); plot.setRenderer(renderer); XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (XYSeries series : constraintIdToWeightSeriesMapList.get(scoreLevelIndex).values()) { seriesCollection.addSeries(series); } plot.setDataset(seriesCollection); JFreeChart chart = new JFreeChart(singleBenchmarkResult.getName() + " constraint match total best score diff level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFileList.add( writeChartToImageFile(chart, "ConstraintMatchTotalBestScoreStatisticLevel" + scoreLevelIndex)); } }