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.subsingle.constraintmatchtotalbestscore.ConstraintMatchTotalBestScoreSubSingleStatistic.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 va 2 s. 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(subSingleBenchmarkResult.getName() + " constraint match total best score diff level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFileList.add( writeChartToImageFile(chart, "ConstraintMatchTotalBestScoreStatisticLevel" + scoreLevelIndex)); } }
From source file:jhplot.HChart.java
/** * Create HChart canvas with a several chart plots * //from w ww . jav a2 s. c om * @param title * Title * @param xsize * size in x direction * @param ysize * size in y direction * @param n1 * number of plots/graphs in x * @param n2 * number of plots/graphs in y * @param set * set or not the graph */ public HChart(String title, int xsize, int ysize, int n1, int n2, boolean set) { super(title, xsize, ysize, n1, n2, set); cdatPie = new DefaultPieDataset[N1final][N2final]; cdatPie3D = new DefaultPieDataset[N1final][N2final]; cdatBar = new DefaultCategoryDataset[N1final][N2final]; cdatBar3D = new DefaultCategoryDataset[N1final][N2final]; cdatLine = new DefaultCategoryDataset[N1final][N2final]; cdatArea = new DefaultCategoryDataset[N1final][N2final]; cdatPolar = new XYSeriesCollection[N1final][N2final]; isLog = new boolean[2]; isLog[0] = false; isLog[1] = false; xAxis = new NumberAxis[N1final][N2final]; yAxis = new NumberAxis[N1final][N2final]; xyplot = new XYPlot[N1final][N2final]; type = new HashMap[N1final][N2final]; indexdat = new int[N1final][N2final]; rdat = new ArrayList[N1final][N2final]; axisPenwidth = 3.0f; XYBarRenderer defaultrender = new XYBarRenderer(0.2D); // IntervalXYDataset intervalxydataset = new IntervalXYDataset(); tickFont = new Font("Arial", Font.BOLD, 14); labelFont = new Font("Arial", Font.BOLD, 16); labelColor = Color.BLACK; tickColor = Color.BLACK; chart = new JFreeChart[N1final][N2final]; cp = new ChartPanel[N1final][N2final]; antiAlias = true; this.title = new String[N1final][N2final]; this.titleX = new String[N1final][N2final]; this.titleY = new String[N1final][N2final]; // build empty canvas for (int i2 = 0; i2 < N2final; i2++) { for (int i1 = 0; i1 < N1final; i1++) { this.title[i1][i2] = title; this.titleX[i1][i2] = "X"; this.titleY[i1][i2] = "Y"; rdat[i1][i2] = new ArrayList<AbstractRenderer>(); xAxis[i1][i2] = new NumberAxis(titleX[i1][i2]); xAxis[i1][i2].setTickLabelPaint(tickColor); xAxis[i1][i2].setTickLabelFont(tickFont); xAxis[i1][i2].setLabelPaint(labelColor); xAxis[i1][i2].setLabelFont(labelFont); xAxis[i1][i2].setAxisLineStroke(new BasicStroke(axisPenwidth)); xAxis[i1][i2].setAxisLinePaint(Color.black); type[i1][i2] = new HashMap<Integer, String>(); indexdat[i1][i2] = 0; yAxis[i1][i2] = new NumberAxis(titleX[i1][i2]); yAxis[i1][i2].setTickLabelPaint(tickColor); yAxis[i1][i2].setTickLabelFont(tickFont); yAxis[i1][i2].setLabelPaint(labelColor); yAxis[i1][i2].setLabelFont(labelFont); yAxis[i1][i2].setAxisLineStroke(new BasicStroke(axisPenwidth)); yAxis[i1][i2].setAxisLinePaint(Color.black); xyplot[i1][i2] = new XYPlot(null, (ValueAxis) xAxis[i1][i2], (ValueAxis) yAxis[i1][i2], defaultrender); // for outline xyplot[i1][i2].setOutlinePaint(Color.black); xyplot[i1][i2].setOutlineStroke(new BasicStroke(axisPenwidth)); xyplot[i1][i2].setOutlineVisible(true); xyplot[i1][i2].setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); xyplot[i1][i2].setOrientation(PlotOrientation.VERTICAL); chart[i1][i2] = new JFreeChart(this.title[i1][i2], JFreeChart.DEFAULT_TITLE_FONT, xyplot[i1][i2], true); chart[i1][i2].setAntiAlias(antiAlias); chart[i1][i2].setBorderPaint(DEFAULT_BG_COLOR); chart[i1][i2].setBackgroundPaint(DEFAULT_BG_COLOR); chart[i1][i2].setBorderVisible(false); cp[i1][i2] = new ChartPanel(chart[i1][i2]); cp[i1][i2].setBackground(DEFAULT_BG_COLOR); cp[i1][i2].setLayout(new BorderLayout()); cp[i1][i2].setDomainZoomable(true); cp[i1][i2].setRangeZoomable(true); if (set) mainPanel.add(cp[i1][i2]); } } setTheme("LEGACY_THEME"); }
From source file:net.commerce.zocalo.freechart.ChartGenerator.java
private static JFreeChart createCustomXYStepChart(TimePeriodValuesCollection prices) { DateAxis xAxis = new DateAxis(null); NumberAxis yAxis = new NumberAxis("price"); yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); XYPlot plot = new XYPlot(prices, xAxis, yAxis, null); plot.setRenderer(new XYStepRenderer(null, null)); plot.setOrientation(PlotOrientation.VERTICAL); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:edu.scripps.fl.curves.plot.CurvePlot.java
public void init() { dataset = new YIntervalSeriesCollection(); LogAxis xAxis = new LogAxis(xAxisLabel) { @Override//from www . j a va2s. c o m public NumberFormat getNumberFormatOverride() { return nf; } protected String createTickLabel(double value) { return getNumberFormatOverride().format(value); } }; xAxis.setTickUnit(new NumberTickUnit(1.0, nf)); xAxis.setTickMarksVisible(true); // xAxis.setTickLabelFont(font); // now set in separate method NumberAxis yAxis = new NumberAxis(yAxisLabel); // yAxis.setRange(-20, 120); // yAxis.setTickLabelFont(font); yAxis.setTickUnit(new NumberTickUnit(25)); plot = new XYPlot(dataset, xAxis, yAxis, null); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setRangeMinorGridlinesVisible(true); // XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); MyXYErrorRenderer renderer = new MyXYErrorRenderer(); plot.setRenderer(renderer); plot.setBackgroundPaint(Color.WHITE); chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(Color.WHITE); plot.setDrawingSupplier(new CurvePlotDrawingSupplier()); }
From source file:org.locationtech.udig.processingtoolbox.tools.HistogramDialog.java
private void createGraphTab(final CTabFolder parentTabFolder) { plotTab = new CTabItem(parentTabFolder, SWT.NONE); plotTab.setText(Messages.ScatterPlotDialog_Graph); JFreeChart chart = new JFreeChart(EMPTY, JFreeChart.DEFAULT_TITLE_FONT, new XYPlot(), false); chart.setBackgroundPaint(java.awt.Color.WHITE); chart.setBorderVisible(false);/*w ww. j av a 2 s.c o m*/ 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.addChartMouseListener(new PlotMouseListener()); plotTab.setControl(chartComposite); chartComposite.pack(); }
From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java
private static JFreeChart createScatterChart(XYDataset dataset) { NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); }/*from www. j a v a 2 s . c om*/ XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setURLGenerator(urlGenerator); plot.setRenderer(renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart("Scatter 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.jfree.chart.demo.SymbolicYPlotDemo.java
/** * Create and display a multi XY plot with horizontal layout. * /*from w ww .j a v a 2s.c om*/ * @param frameTitle * the frame title. * @param data1 * dataset1. * @param data2 * dataset2. */ private static void displayYSymbolicCombinedHorizontally(final String frameTitle, final SampleYSymbolicDataset data1, final SampleYSymbolicDataset data2) { final String title = "Animals Horizontally Combined"; final String xAxisLabel = "Miles"; final String yAxisLabel = null; // combine the y symbolic values of the two data sets final String[] combinedYSymbolicValues = SampleYSymbolicDataset.combineYSymbolicDataset(data1, 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); final XYDataset series2 = new SubSeriesDataset(data, 2); final XYDataset series3 = new SubSeriesDataset(data, 3); final XYDataset series4 = new SubSeriesDataset(data, 4); final XYDataset series5 = new SubSeriesDataset(data, 5); final XYDataset series6 = new SubSeriesDataset(data, 6); final XYDataset series7 = new SubSeriesDataset(data, 7); // create axes... final ValueAxis valueAxis0 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis1 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis2 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis3 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis4 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis5 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis6 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis7 = new NumberAxis(xAxisLabel); final SymbolicAxis symbolicAxis = new SymbolicAxis(yAxisLabel, combinedYSymbolicValues); // make a combined plot final CombinedRangeXYPlot mainPlot = new CombinedRangeXYPlot(symbolicAxis); // add the sub-plots final XYItemRenderer renderer0 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot0 = new XYPlot(series0, valueAxis0, null, renderer0); final XYItemRenderer renderer1 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot1 = new XYPlot(series1, valueAxis1, null, renderer1); final XYItemRenderer renderer2 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot2 = new XYPlot(series2, valueAxis2, null, renderer2); final XYItemRenderer renderer3 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot3 = new XYPlot(series3, valueAxis3, null, renderer3); final XYItemRenderer renderer4 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot4 = new XYPlot(series4, valueAxis4, null, renderer4); final XYItemRenderer renderer5 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot5 = new XYPlot(series5, valueAxis5, null, renderer5); final XYItemRenderer renderer6 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot6 = new XYPlot(series6, valueAxis6, null, renderer6); final XYItemRenderer renderer7 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot7 = new XYPlot(series7, valueAxis7, null, renderer7); mainPlot.add(subplot0, 1); mainPlot.add(subplot1, 1); mainPlot.add(subplot2, 1); mainPlot.add(subplot3, 1); mainPlot.add(subplot4, 1); mainPlot.add(subplot5, 1); mainPlot.add(subplot6, 1); mainPlot.add(subplot7, 1); // make the top level JFreeChart object final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true); // then customise it a little... chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); // and present it in a frame... final JFrame ySymbolicFrame = new ChartFrame(frameTitle, chart); ySymbolicFrame.pack(); RefineryUtilities.positionFrameRandomly(ySymbolicFrame); ySymbolicFrame.show(); }
From source file:org.gumtree.vis.awt.PlotFactory.java
/** * Creates a line chart (based on an {@link XYDataset}) with default * settings./*from w ww . ja va2 s.c o m*/ * * @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 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 The chart. */ protected static JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } // NumberAxis xAxis = new NumberAxis(xAxisLabel); LogarithmizableAxis xAxis = new LogarithmizableAxis(xAxisLabel); boolean isLogX = false; try { isLogX = Boolean.valueOf(System.getProperty(LOGX_PROPERTY)); } catch (Exception e) { } xAxis.setLogarithmic(isLogX); // xAxis.setAutoRangeIncludesZero(false); xAxis.setAllowNegativesFlag(true); xAxis.setLowerMargin(0.02); xAxis.setUpperMargin(0.02); // NumberAxis yAxis = new NumberAxis(yAxisLabel); LogarithmizableAxis yAxis = new LogarithmizableAxis(yAxisLabel); boolean isLogY = false; try { isLogY = Boolean.valueOf(System.getProperty(LOGY_PROPERTY)); } catch (Exception e) { } yAxis.setLogarithmic(isLogY); yAxis.setAllowNegativesFlag(true); yAxis.setAutoRangeNextLogFlag(false); yAxis.setLowerMargin(0.02); yAxis.setUpperMargin(0.02); XYErrorRenderer renderer = new XYErrorRenderer(); renderer.setBaseLinesVisible(true); renderer.setBaseShapesVisible(false); renderer.setDrawYError(true); // XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chartTheme.apply(chart); return chart; }
From source file:org.hxzon.demo.jfreechart.DatasetVisibleDemo3.java
private static JFreeChart createTimeSeriesChart() { XYDataset dataset1 = createDataset1(); //DomainAxis/*from w w w . jav a2 s . c o m*/ DateAxis timeAxis = new DateAxis(""); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02); timeAxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy")); //RangeAxis NumberAxis valueAxis = new NumberAxis(""); valueAxis.setAutoRangeIncludesZero(false); // override default NumberAxis valueAxis2 = new NumberAxis(""); valueAxis2.setAutoRangeIncludesZero(false); // override default // valueAxis.setDefaultAutoRange(new Range(100, 1150)); //Renderer XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); XYDataset dataset2 = createDataset2(); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false); //Plot XYPlot plot = new XYPlot(dataset1, timeAxis, valueAxis, null); plot.setRenderer(renderer); plot.setDataset(1, dataset2); plot.setRenderer(1, renderer2); plot.setRangeAxis(1, valueAxis2); plot.mapDatasetToRangeAxis(1, 1); plot.setBackgroundPaint(plotBackgroundPaint); 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); // plot.setRangePannable(true); //chart JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(Color.white); valueAxis.setAutoRange(false); timeAxis.setAutoRange(false); return chart; }
From source file:crossspectrumapp.CrossSpectrumApp.java
private void plotData(double[] frequency, double[] power, double[] phase, String title, String subTitleText1, String subTitleText2) throws WebUtilException { XYSeries asdSeries = new XYSeries("asd"); XYSeries phiSeries = new XYSeries("phase"); for (int i = 1; i < frequency.length; i++) { double f = frequency[i]; double pwr = power[i]; double phi = phase[i]; asdSeries.add(f, pwr);//from www .jav a 2 s . com phiSeries.add(f, phi); } XYSeriesCollection asdCollection = new XYSeriesCollection(); asdCollection.addSeries(asdSeries); XYSeriesCollection phiCollection = new XYSeriesCollection(); phiCollection.addSeries(phiSeries); // create the chart XYItemRenderer asdRenderer = new StandardXYItemRenderer(); LogAxis asdAxis = new LogAxis("ASD counts/ \u221AHz"); XYPlot asdSubplot = new XYPlot(asdCollection, null, asdAxis, asdRenderer); asdSubplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); XYItemRenderer phiRenderer = new StandardXYItemRenderer(); NumberAxis phiAxis = new NumberAxis("Phase degrees"); XYPlot phiSubplot = new XYPlot(phiCollection, null, phiAxis, phiRenderer); asdSubplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new LogAxis("Frequency (Hz)")); plot.setGap(10.0); // add the subplots... plot.add(asdSubplot, 2); plot.add(phiSubplot, 1); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); Title subTitle = new TextTitle(subTitleText1); chart.addSubtitle(subTitle); subTitle = new TextTitle(subTitleText2); chart.addSubtitle(subTitle); ChartPanel panel = new ChartPanel(chart, true, true, true, false, true); panel.setPreferredSize(new java.awt.Dimension(cscl.getOutX(), cscl.getOutY())); FileOutputStream fos = null; try { fos = new FileOutputStream(cscl.getOfileName()); ChartUtilities.writeChartAsPNG(fos, chart, cscl.getOutX(), cscl.getOutY()); fos.close(); fos = null; } catch (Exception ex) { throw new WebUtilException("Saving image: " + ex.getClass() + " - " + ex.getLocalizedMessage()); } finally { try { if (fos != null) { fos.close(); } } catch (Exception ex) { throw new WebUtilException("Saving image: " + ex.getClass() + " - " + ex.getLocalizedMessage()); } } }