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.yahoo.egads.utilities.GUIUtils.java
/** * Creates a combined chart./*w w w.ja v a2 s .c o m*/ * * @return The combined chart. */ private JFreeChart createCombinedChart(DataSequence tsOne, DataSequence tsTwo, ArrayList<Anomaly> anomalyList) { // create subplot 1. final XYDataset data1 = createDataset(tsOne, "Original"); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Original Value"); XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // plot anomalies on subplot 1. addAnomalies(subplot1, anomalyList); // create subplot 2. final XYDataset data2 = createDataset(tsTwo, "Forecast"); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Forecast Value"); rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot. final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Time")); plot.setGap(10.0); // add the subplots. plot.add(subplot1, 1); plot.add(subplot2, 1); // Add anomaly score time-series. addAnomalyTS(plot, tsOne, tsTwo); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot. return new JFreeChart("EGADS GUI", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.jfree.chart.demo.CombinedXYPlotDemo2.java
/** * Creates a combined XYPlot chart./*from w ww .j ava2s . com*/ * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... 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,000.0"))); final XYPlot subplot1 = new XYPlot(data1, new DateAxis("Date"), null, renderer1); // create subplot 2... 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,000.0"))); final XYPlot subplot2 = new XYPlot(data2, new DateAxis("Date"), null, renderer2); // create a parent plot... final CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis("Value")); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); // return a new chart containing the overlaid plot... return new JFreeChart("Combined (Range) XY Plot", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:com.unicornlabs.kabouter.reporting.PowerReport.java
public static void GeneratePowerReport(Date startDate, Date endDate) { try {//from w w w .j a v a2 s .c om Historian theHistorian = (Historian) BusinessObjectManager.getBusinessObject(Historian.class.getName()); ArrayList<String> powerLogDeviceIds = theHistorian.getPowerLogDeviceIds(); Document document = new Document(PageSize.A4, 50, 50, 50, 50); File outputFile = new File("PowerReport.pdf"); outputFile.createNewFile(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outputFile)); document.open(); document.add(new Paragraph("Power Report for " + startDate.toString() + " to " + endDate.toString())); document.newPage(); DecimalFormat df = new DecimalFormat("#.###"); for (String deviceId : powerLogDeviceIds) { ArrayList<Powerlog> powerlogs = theHistorian.getPowerlogs(deviceId, startDate, endDate); double total = 0; double max = 0; Date maxTime = startDate; double average = 0; XYSeries series = new XYSeries(deviceId); XYDataset dataset = new XYSeriesCollection(series); for (Powerlog log : powerlogs) { total += log.getPower(); if (log.getPower() > max) { max = log.getPower(); maxTime = log.getId().getLogtime(); } series.add(log.getId().getLogtime().getTime(), log.getPower()); } average = total / powerlogs.size(); document.add(new Paragraph("\nDevice: " + deviceId)); document.add(new Paragraph("Average Power Usage: " + df.format(average))); document.add(new Paragraph("Maximum Power Usage: " + df.format(max) + " at " + maxTime.toString())); document.add(new Paragraph("Total Power Usage: " + df.format(total))); //Create a custom date axis to display dates on the X axis DateAxis dateAxis = new DateAxis("Date"); //Make the labels vertical dateAxis.setVerticalTickLabels(true); //Create the power axis NumberAxis powerAxis = new NumberAxis("Power"); //Set both axes to auto range for their values powerAxis.setAutoRange(true); dateAxis.setAutoRange(true); //Create the tooltip generator StandardXYToolTipGenerator ttg = new StandardXYToolTipGenerator("{0}: {2}", new SimpleDateFormat("yyyy/MM/dd HH:mm"), NumberFormat.getInstance()); //Set the renderer StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES, ttg, null); //Create the plot XYPlot plot = new XYPlot(dataset, dateAxis, powerAxis, renderer); //Create the chart JFreeChart myChart = new JFreeChart(deviceId, JFreeChart.DEFAULT_TITLE_FONT, plot, true); PdfContentByte pcb = writer.getDirectContent(); PdfTemplate tp = pcb.createTemplate(480, 360); Graphics2D g2d = tp.createGraphics(480, 360, new DefaultFontMapper()); Rectangle2D r2d = new Rectangle2D.Double(0, 0, 480, 360); myChart.draw(g2d, r2d); g2d.dispose(); pcb.addTemplate(tp, 0, 0); document.newPage(); } document.close(); JOptionPane.showMessageDialog(null, "Report Generated."); Desktop.getDesktop().open(outputFile); } catch (FileNotFoundException fnfe) { JOptionPane.showMessageDialog(null, "Unable To Open File For Writing, Make Sure It Is Not Currently Open"); } catch (IOException ex) { Logger.getLogger(PowerReport.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(PowerReport.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.itemanalysis.jmetrik.graph.itemmap.ItemMapPanel.java
public void setGraph() { HistogramChartDataset personDataset = null; HistogramChartDataset itemData = null; try {/*from w w w. j a v a 2 s. c o m*/ //get titles String chartTitle = command.getFreeOption("title").getString(); String chartSubtitle = command.getFreeOption("subtitle").getString(); PlotOrientation itemMapOrientation = PlotOrientation.HORIZONTAL; //create common x-axis NumberAxis domainAxis = new NumberAxis(); domainAxis.setLabel("Logits"); //create histogram personDataset = new HistogramChartDataset(); ValueAxis rangeAxis = new NumberAxis("Person Density"); if (itemMapOrientation == PlotOrientation.HORIZONTAL) rangeAxis.setInverted(true); XYBarRenderer renderer = new XYBarRenderer(); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setURLGenerator(new StandardXYURLGenerator()); renderer.setDrawBarOutline(true); renderer.setShadowVisible(false); XYPlot personPlot = new XYPlot(personDataset, null, rangeAxis, renderer); personPlot.setOrientation(PlotOrientation.HORIZONTAL); //create scatterplot of item difficulty itemData = new HistogramChartDataset(); NumberAxis itemRangeAxis = new NumberAxis("Item Frequency"); if (itemMapOrientation == PlotOrientation.VERTICAL) { itemRangeAxis.setInverted(true); } XYBarRenderer itemRenderer = new XYBarRenderer(); itemRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); itemRenderer.setURLGenerator(new StandardXYURLGenerator()); itemRenderer.setDrawBarOutline(true); itemRenderer.setShadowVisible(false); XYPlot itemPlot = new XYPlot(itemData, null, itemRangeAxis, itemRenderer); itemPlot.setOrientation(PlotOrientation.HORIZONTAL); //combine the two charts CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis); cplot.add(personPlot, 3); cplot.add(itemPlot, 2); cplot.setGap(8.0); cplot.setDomainGridlinePaint(Color.white); cplot.setDomainGridlinesVisible(true); cplot.setOrientation(itemMapOrientation); // //next four lines are temp setting for book // //these four lines will create a histogram with white bars so it appears as just the bar outline // renderer.setBarPainter(new StandardXYBarPainter()); // renderer.setSeriesPaint(0, Color.white); // itemRenderer.setBarPainter(new StandardXYBarPainter()); // itemRenderer.setSeriesPaint(0, Color.white); chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, cplot, false); chart.setBackgroundPaint(Color.white); if (chartSubtitle != null && !"".equals(chartSubtitle)) { chart.addSubtitle(new TextTitle(chartSubtitle)); } ChartPanel panel = new ChartPanel(chart); panel.getPopupMenu().addSeparator(); this.addJpgMenuItem(this, panel.getPopupMenu()); panel.setPreferredSize(new Dimension(width, height)); // //temp setting for book // this.addLocalEPSMenuItem(this, panel.getPopupMenu(), chart);//remove this line for public release versions chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0)); this.setBackground(Color.WHITE); this.add(panel); } catch (IllegalArgumentException ex) { logger.fatal(ex.getMessage(), ex); this.firePropertyChange("error", "", "Error - Check log for details."); } }
From source file:org.optaplanner.examples.cheaptime.swingui.CheapTimePanel.java
private JFreeChart createChart(CheapTimeSolution solution) { TangoColorFactory tangoColorFactory = new TangoColorFactory(); NumberAxis rangeAxis = new NumberAxis("Period"); rangeAxis.setRange(-0.5, solution.getGlobalPeriodRangeTo() + 0.5); XYPlot taskAssignmentPlot = createTaskAssignmentPlot(tangoColorFactory, solution); XYPlot periodCostPlot = createPeriodCostPlot(tangoColorFactory, solution); XYPlot capacityPlot = createAvailableCapacityPlot(tangoColorFactory, solution); CombinedRangeXYPlot combinedPlot = new CombinedRangeXYPlot(rangeAxis); combinedPlot.add(taskAssignmentPlot, 5); combinedPlot.add(periodCostPlot, 1); combinedPlot.add(capacityPlot, 1);/* w w w .ja va 2s. c om*/ combinedPlot.setOrientation(PlotOrientation.HORIZONTAL); return new JFreeChart("Cheap Power Time Scheduling", JFreeChart.DEFAULT_TITLE_FONT, combinedPlot, true); }
From source file:org.jfree.chart.demo.LayeredBarChartDemo1.java
/** * Creates a chart for the specified dataset. * /*from ww w . java 2s . c o m*/ * @param dataset the dataset. * * @return a chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final CategoryAxis categoryAxis = new CategoryAxis("Category"); //categoryAxis.setMaxCategoryLabelWidthRatio(10.0f); final ValueAxis valueAxis = new NumberAxis("Score (%)"); final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, new LayeredBarRenderer()); plot.setOrientation(PlotOrientation.HORIZONTAL); final JFreeChart chart = new JFreeChart("Layered Bar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); // set the background color for the chart... chart.setBackgroundPaint(Color.lightGray); final LayeredBarRenderer renderer = (LayeredBarRenderer) plot.getRenderer(); // we can set each series bar width individually or let the renderer manage a standard view. // the width is set in percentage, where 1.0 is the maximum (100%). renderer.setSeriesBarWidth(0, 1.0); renderer.setSeriesBarWidth(1, 0.7); renderer.setSeriesBarWidth(2, 0.4); renderer.setItemMargin(0.01); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryMargin(0.25); domainAxis.setUpperMargin(0.05); domainAxis.setLowerMargin(0.05); return chart; }
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); }/* w ww . j av a2s .c o m*/ } 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.CombinedXYPlotDemo4.java
/** * Creates a combined chart.// www . j a v a2 s . co m * * @return The combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Range 1"); final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // add secondary axis subplot1.setDataset(1, createDataset2()); final NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); subplot1.setRangeAxis(1, axis2); subplot1.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); subplot1.setRenderer(1, new StandardXYItemRenderer()); subplot1.mapDatasetToRangeAxis(1, 1); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Range 2"); rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.drools.planner.benchmark.core.statistic.calculatecount.CalculateCountProblemStatistic.java
protected void writeGraphStatistic() { XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (SingleBenchmark singleBenchmark : problemBenchmark.getSingleBenchmarkList()) { CalculateCountSingleStatistic singleStatistic = (CalculateCountSingleStatistic) singleBenchmark .getSingleStatistic(problemStatisticType); XYSeries series = new XYSeries(singleBenchmark.getSolverBenchmark().getName()); for (CalculateCountSingleStatisticPoint point : singleStatistic.getPointList()) { long timeMillisSpend = point.getTimeMillisSpend(); long calculateCountPerSecond = point.getCalculateCountPerSecond(); series.add(timeMillisSpend, calculateCountPerSecond); }//from w ww . j a v a 2 s. c o m seriesCollection.addSeries(series); } NumberAxis xAxis = new NumberAxis("Time 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(problemBenchmark.getName() + " calculate count statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); BufferedImage chartImage = chart.createBufferedImage(1024, 768); graphStatisticFile = new File(problemBenchmark.getProblemReportDirectory(), problemBenchmark.getName() + "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); } }
From source file:com.spotify.heroic.http.render.RenderUtils.java
private static JFreeChart buildChart(final String title, final XYDataset lineAndShape, final XYDataset interval, final XYItemRenderer lineAndShapeRenderer, final XYItemRenderer intervalRenderer) { final ValueAxis timeAxis = new DateAxis(); timeAxis.setLowerMargin(0.02);/*from www.j av a 2 s . c om*/ timeAxis.setUpperMargin(0.02); final NumberAxis valueAxis = new NumberAxis(); valueAxis.setAutoRangeIncludesZero(false); final XYPlot plot = new XYPlot(); plot.setDomainAxis(0, timeAxis); plot.setRangeAxis(0, valueAxis); plot.setDataset(0, lineAndShape); plot.setRenderer(0, lineAndShapeRenderer); plot.setDomainAxis(1, timeAxis); plot.setRangeAxis(1, valueAxis); plot.setDataset(1, interval); plot.setRenderer(1, intervalRenderer); return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false); }