/** * Creates a sample chart. * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart( "Performance: JFreeSVG vs Batik", null /* x-axis label*/, "Milliseconds" /* y-axis label */, dataset); chart.addSubtitle(new TextTitle("Time to generate 1000 charts in SVG " + "format (lower bars = better performance)")); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); chart.getLegend().setFrame(BlockBorder.NONE); return chart; }
/** * Creates a sample chart. * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart( "Performance: JFreeSVG vs Batik", null /* x-axis label*/, "Milliseconds" /* y-axis label */, dataset, PlotOrientation.HORIZONTAL,false,false,false); chart.addSubtitle(new TextTitle("Time to generate 1000 charts in SVG " + "format (lower bars = better performance)")); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // ****************************************************************** // More than 150 demo applications are included with the JFreeChart // Developer Guide...for more information, see: // // > http://www.object-refinery.com/jfreechart/guide.html // // ****************************************************************** NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // chart.getLegend().setFrame(BlockBorder.NONE); return chart; }
/** * Sets the chart title. This is a convenience method that ends up calling the * {@link #setTitle(TextTitle)} method. * * @param title the new title (<code>null</code> permitted). */ public void setTitle(String title) { if (title != null) { if (this.title == null) { setTitle(new TextTitle(title, JFreeChart.DEFAULT_TITLE_FONT)); } else { this.title.setText(title); } } else { setTitle((TextTitle) null); } }
/** * Some checks for the equals() method. */ public void testEquals() { // use the TextTitle class because it is a concrete subclass Title t1 = new TextTitle(); Title t2 = new TextTitle(); assertEquals(t1, t2); t1.setPosition(RectangleEdge.LEFT); assertFalse(t1.equals(t2)); t2.setPosition(RectangleEdge.LEFT); assertTrue(t1.equals(t2)); t1.setHorizontalAlignment(HorizontalAlignment.RIGHT); assertFalse(t1.equals(t2)); t2.setHorizontalAlignment(HorizontalAlignment.RIGHT); assertTrue(t1.equals(t2)); t1.setVerticalAlignment(VerticalAlignment.BOTTOM); assertFalse(t1.equals(t2)); t2.setVerticalAlignment(VerticalAlignment.BOTTOM); assertTrue(t1.equals(t2)); }
/** * Creates a new plot. * * @param dataset the dataset (<code>null</code> permitted). */ public MultiplePiePlot(CategoryDataset dataset) { super(); this.dataset = dataset; PiePlot piePlot = new PiePlot(null); this.pieChart = new JFreeChart(piePlot); this.pieChart.removeLegend(); this.dataExtractOrder = TableOrder.BY_COLUMN; this.pieChart.setBackgroundPaint(null); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); this.pieChart.setTitle(seriesTitle); this.aggregatedItemsKey = "Other"; this.aggregatedItemsPaint = Color.lightGray; this.sectionPaints = new HashMap(); }
/** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { TextTitle t = new TextTitle("Title"); XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); XYTitleAnnotation a2 = new XYTitleAnnotation(1.0, 2.0, t); assertTrue(a1.equals(a2)); a1 = new XYTitleAnnotation(1.1, 2.0, t); assertFalse(a1.equals(a2)); a2 = new XYTitleAnnotation(1.1, 2.0, t); assertTrue(a1.equals(a2)); a1 = new XYTitleAnnotation(1.1, 2.2, t); assertFalse(a1.equals(a2)); a2 = new XYTitleAnnotation(1.1, 2.2, t); assertTrue(a1.equals(a2)); TextTitle t2 = new TextTitle("Title 2"); a1 = new XYTitleAnnotation(1.1, 2.2, t2); assertFalse(a1.equals(a2)); a2 = new XYTitleAnnotation(1.1, 2.2, t2); assertTrue(a1.equals(a2)); }
/** * Creates a sample chart. * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart( "Performance: JFreeSVG vs Batik", null /* x-axis label*/, "Milliseconds" /* y-axis label */, dataset); chart.addSubtitle(new TextTitle("Time to generate 1000 charts in SVG " + "format (lower bars = better performance)")); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // ****************************************************************** // More than 150 demo applications are included with the JFreeChart // Developer Guide...for more information, see: // // > http://www.object-refinery.com/jfreechart/guide.html // // ****************************************************************** NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); chart.getLegend().setFrame(BlockBorder.NONE); return chart; }
/** * Creates a new plot. * * @param dataset the dataset (<code>null</code> permitted). */ public MultiplePiePlot(CategoryDataset dataset) { super(); setDataset(dataset); PiePlot piePlot = new PiePlot(null); piePlot.setIgnoreNullValues(true); this.pieChart = new JFreeChart(piePlot); this.pieChart.removeLegend(); this.dataExtractOrder = TableOrder.BY_COLUMN; this.pieChart.setBackgroundPaint(null); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); this.pieChart.setTitle(seriesTitle); this.aggregatedItemsKey = "Other"; this.aggregatedItemsPaint = Color.lightGray; this.sectionPaints = new HashMap(); this.legendItemShape = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0); }
/** * Applies this theme to the supplied chart. * * @param chart the chart (<code>null</code> not permitted). */ @Override public void apply(JFreeChart chart) { ParamChecks.nullNotPermitted(chart, "chart"); TextTitle title = chart.getTitle(); if (title != null) { title.setFont(this.extraLargeFont); title.setPaint(this.titlePaint); } int subtitleCount = chart.getSubtitleCount(); for (int i = 0; i < subtitleCount; i++) { applyToTitle(chart.getSubtitle(i)); } chart.setBackgroundPaint(this.chartBackgroundPaint); // now process the plot if there is one Plot plot = chart.getPlot(); if (plot != null) { applyToPlot(plot); } }
/** * Creates a new plot. * * @param dataset the dataset ({@code null} permitted). */ public MultiplePiePlot(CategoryDataset dataset) { super(); setDataset(dataset); PiePlot piePlot = new PiePlot(null); piePlot.setIgnoreNullValues(true); this.pieChart = new JFreeChart(piePlot); this.pieChart.removeLegend(); this.dataExtractOrder = TableOrder.BY_COLUMN; this.pieChart.setBackgroundPaint(null); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); this.pieChart.setTitle(seriesTitle); this.aggregatedItemsKey = "Other"; this.aggregatedItemsPaint = Color.lightGray; this.sectionPaints = new HashMap(); this.legendItemShape = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0); }
/** * Applies this theme to the supplied chart. * * @param chart the chart ({@code null} not permitted). */ @Override public void apply(JFreeChart chart) { Args.nullNotPermitted(chart, "chart"); TextTitle title = chart.getTitle(); if (title != null) { title.setFont(this.extraLargeFont); title.setPaint(this.titlePaint); } int subtitleCount = chart.getSubtitleCount(); for (int i = 0; i < subtitleCount; i++) { applyToTitle(chart.getSubtitle(i)); } chart.setBackgroundPaint(this.chartBackgroundPaint); // now process the plot if there is one Plot plot = chart.getPlot(); if (plot != null) { applyToPlot(plot); } }
@Override protected void configureChart(JFreeChart jfreeChart, JRChartPlot jrPlot) throws JRException { super.configureChart(jfreeChart, jrPlot); TextTitle title = jfreeChart.getTitle(); if (title != null) { RectangleInsets padding = title.getPadding(); double bottomPadding = Math.max(padding.getBottom(), 15d); title.setPadding(padding.getTop(), padding.getLeft(), bottomPadding, padding.getRight()); } GradientPaint gp = (GradientPaint)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BACKGROUND_PAINT); jfreeChart.setBackgroundPaint(new GradientPaint(0f, 0f, gp.getColor1(), 0f, getChart().getHeight() * 0.7f, gp.getColor2(), false)); }
protected void setChartSubtitles(JFreeChart jfreeChart) throws JRException { TitleSettings subtitleSettings = getSubtitleSettings(); Boolean subtitleVisibility = subtitleSettings.getShowTitle(); if (subtitleVisibility == null || subtitleVisibility.booleanValue()) { String subtitleText = evaluateTextExpression(getChart().getSubtitleExpression()); if (subtitleText != null) { TextTitle subtitle = new TextTitle(subtitleText); Paint subtitleForecolor = getChart().getOwnSubtitleColor() != null ? getChart().getOwnSubtitleColor() : subtitleSettings.getForegroundPaint() != null ? subtitleSettings.getForegroundPaint().getPaint() : getChart().getSubtitleColor(); //Subtitle has not its own position set, and by default this will be set the same as title position RectangleEdge subtitleEdge = getEdge(subtitleSettings.getPositionValue(), jfreeChart.getTitle() == null ? null : jfreeChart.getTitle().getPosition()); handleTitleSettings(subtitle, subtitleSettings, getChart().getSubtitleFont(), subtitleForecolor, subtitleEdge); jfreeChart.addSubtitle(subtitle); } } }
private void setChartTitle() { JFreeChart chart = getCurrentChart(); if (chart != null) { String text = plotInstance.getCurrentPlotConfigurationClone().getTitleText(); if (text == null) { chart.setTitle(text); return; } Font font = plotInstance.getCurrentPlotConfigurationClone().getTitleFont(); if (font == null) { font = FontTools.getFont(Font.DIALOG, Font.PLAIN, 10); } TextTitle textTitle = new TextTitle(text, font); textTitle.setPaint(plotInstance.getCurrentPlotConfigurationClone().getTitleColor()); chart.setTitle(textTitle); } }
private void fillChart(String title, List<String> names, List<String> colors, List<Float> values) throws Exception { DefaultPieDataset data=new DefaultPieDataset(); for (int ix=0; ix<names.size(); ix++) { data.setValue( names.get(ix), values.get(ix) ); } this.chart=ChartFactory.createPieChart3D( title, data, true, true, false); LegendTitle legend=this.chart.getLegend(); legend.setItemFont(new Font("", Font.TRUETYPE_FONT, 9) ); PiePlot plot=(PiePlot)this.chart.getPlot(); plot.setCircular(true); plot.setBackgroundAlpha(0.9f); plot.setForegroundAlpha(0.5f); plot.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9) ); this.setPlotColor( plot, names, colors ); this.chart.setTitle(new TextTitle(title, new Font("", Font.TRUETYPE_FONT, 9) ) ); }
private void fillChart(String title, String categoryLabel, String valueLabel, List<String> names, List<Float> values, List<String> colors, boolean horizontal) throws Exception { DefaultCategoryDataset data=new DefaultCategoryDataset(); for (int ix=0; ix<names.size(); ix++) { data.addValue(values.get(ix), "", names.get(ix)); } this.chart=ChartFactory.createBarChart3D( title, // title categoryLabel, valueLabel, data, ( horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL ), false, false, false); CategoryPlot plot=(CategoryPlot)this.chart.getPlot(); CategoryAxis categoryAxis=plot.getDomainAxis(); categoryAxis.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9) ); categoryAxis.setTickLabelFont(new Font("", Font.TRUETYPE_FONT, 9) ); NumberAxis numberAxis=(NumberAxis)plot.getRangeAxis(); numberAxis.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9) ); this.setPlotColor(plot, names, colors); this.chart.setTitle(new TextTitle(title, new Font("", Font.TRUETYPE_FONT, 9) ) ); }
public static JFreeChart createLine(final String title, final String subtitle, final String xAxis, final String yAxis, final XYDataset dataset) { JFreeChart plot = ChartFactory.createXYLineChart( (title != null)?title:"", xAxis, yAxis, dataset, PlotOrientation.VERTICAL, true, false, false ); if (subtitle != null) { plot.addSubtitle(new TextTitle(subtitle, FONT_NL)); //plot.addSubtitle(0, new TextTitle(subtitle, FONT_NL)); } applyTheme(plot); return plot; }
/** * Creates a sample chart. * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // get a reference to the plot for further customisation... SOCRSpiderWebPlot plot = new SOCRSpiderWebPlot(dataset); JFreeChart chart = new JFreeChart( chartTitle, TextTitle.DEFAULT_FONT, plot, false ); LegendTitle legend = new LegendTitle(plot); legend.setPosition(RectangleEdge.BOTTOM); //renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); chart.addSubtitle(legend); setCategorySummary(dataset); if (legendPanelOn) chart.removeLegend(); return chart; }
/** * Creates a new plot. * * @param dataset the dataset (<code>null</code> permitted). */ public MultiplePiePlot(CategoryDataset dataset) { super(); setDataset(dataset); PiePlot piePlot = new PiePlot(null); this.pieChart = new JFreeChart(piePlot); this.pieChart.removeLegend(); this.dataExtractOrder = TableOrder.BY_COLUMN; this.pieChart.setBackgroundPaint(null); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); this.pieChart.setTitle(seriesTitle); this.aggregatedItemsKey = "Other"; this.aggregatedItemsPaint = Color.lightGray; this.sectionPaints = new HashMap(); }
/** * Applies this theme to the supplied chart. * * @param chart the chart (<code>null</code> not permitted). */ public void apply(JFreeChart chart) { if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } TextTitle title = chart.getTitle(); if (title != null) { title.setFont(this.extraLargeFont); title.setPaint(this.titlePaint); } int subtitleCount = chart.getSubtitleCount(); for (int i = 0; i < subtitleCount; i++) { applyToTitle(chart.getSubtitle(i)); } chart.setBackgroundPaint(this.chartBackgroundPaint); // now process the plot if there is one Plot plot = chart.getPlot(); if (plot != null) { applyToPlot(plot); } }
private void setGenTitle(){ StringBuilder builder = new StringBuilder(); if(receptor != null) { // Obtains the receptor name builder.append("View From "); builder.append(receptor.toString()); builder.append("\n"); } // and the time the collection last started. builder.append("Since: "); builder.append(Util.getTimeStamp(lastReset, true, true)); // set the title on the chart title = builder.toString(); Font font = new Font("Verdana", Font.BOLD, 12); dataChart.setTitle(new TextTitle(title, font)); }