List of usage examples for org.jfree.chart.title TextTitle setPadding
public void setPadding(double top, double left, double bottom, double right)
From source file:edu.jhuapl.graphs.jfreechart.JFreeChartPieGraphSource.java
@SuppressWarnings("unchecked") @Override//from ww w . jav a 2 s . c o m public void initialize() throws GraphException { String title = getParam(GraphSource.GRAPH_TITLE, String.class, DEFAULT_TITLE); boolean legend = getParam(GraphSource.GRAPH_LEGEND, Boolean.class, DEFAULT_GRAPH_LEGEND); boolean graphToolTip = getParam(GraphSource.GRAPH_TOOL_TIP, Boolean.class, DEFAULT_GRAPH_TOOL_TIP); boolean graphDisplayLabel = getParam(GraphSource.GRAPH_DISPLAY_LABEL, Boolean.class, false); boolean legendBorder = getParam(GraphSource.LEGEND_BORDER, Boolean.class, DEFAULT_LEGEND_BORDER); boolean graphBorder = getParam(GraphSource.GRAPH_BORDER, Boolean.class, DEFAULT_GRAPH_BORDER); Font titleFont = getParam(GraphSource.GRAPH_FONT, Font.class, DEFAULT_GRAPH_TITLE_FONT); String noDataMessage = getParam(GraphSource.GRAPH_NO_DATA_MESSAGE, String.class, DEFAULT_GRAPH_NO_DATA_MESSAGE); PieGraphData pieGraphData = makeDataSet(); Map<Comparable, Paint> colors = pieGraphData.colors; this.chart = ChartFactory.createPieChart(title, pieGraphData.data, false, graphToolTip, false); Paint backgroundColor = getParam(GraphSource.BACKGROUND_COLOR, Paint.class, DEFAULT_BACKGROUND_COLOR); Paint plotColor = getParam(JFreeChartTimeSeriesGraphSource.PLOT_COLOR, Paint.class, backgroundColor); Paint labelColor = getParam(JFreeChartTimeSeriesGraphSource.GRAPH_LABEL_BACKGROUND_COLOR, Paint.class, DEFAULT_BACKGROUND_COLOR); this.chart.setBackgroundPaint(backgroundColor); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(plotColor); plot.setNoDataMessage(noDataMessage); if (!graphDisplayLabel) { plot.setLabelGenerator(null); } else { plot.setInteriorGap(0.001); plot.setMaximumLabelWidth(.3); // plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setShadowPaint(null); // plot.setOutlineVisible(false); //TODO use title font? Font font = plot.getLabelFont(); plot.setLabelLinkStyle(PieLabelLinkStyle.CUBIC_CURVE); plot.setLabelFont(font.deriveFont(font.getSize2D() * .75f)); plot.setLabelBackgroundPaint(labelColor); plot.setLabelShadowPaint(null); plot.setLabelOutlinePaint(null); plot.setLabelGap(0.001); plot.setLabelLinkMargin(0.0); plot.setLabelLinksVisible(true); // plot.setSimpleLabels(true); // plot.setCircular(true); } if (!graphBorder) { plot.setOutlineVisible(false); } if (title != null && !"".equals(title)) { TextTitle title1 = new TextTitle(); title1.setText(title); title1.setFont(titleFont); title1.setPadding(3, 2, 5, 2); chart.setTitle(title1); } else { chart.setTitle((TextTitle) null); } plot.setLabelPadding(new RectangleInsets(1, 1, 1, 1)); //Makes a wrapper for the legend to remove the border around it if (legend) { LegendTitle legend1 = new LegendTitle(chart.getPlot()); BlockContainer wrapper = new BlockContainer(new BorderArrangement()); if (legendBorder) { wrapper.setFrame(new BlockBorder(1, 1, 1, 1)); } else { wrapper.setFrame(new BlockBorder(0, 0, 0, 0)); } BlockContainer items = legend1.getItemContainer(); items.setPadding(2, 10, 5, 2); wrapper.add(items); legend1.setWrapper(wrapper); legend1.setPosition(RectangleEdge.BOTTOM); legend1.setHorizontalAlignment(HorizontalAlignment.CENTER); if (params.get(GraphSource.LEGEND_FONT) instanceof Font) { legend1.setItemFont(((Font) params.get(GraphSource.LEGEND_FONT))); } chart.addSubtitle(legend1); plot.setLegendLabelGenerator(new PieGraphLabelGenerator()); } for (Comparable category : colors.keySet()) { plot.setSectionPaint(category, colors.get(category)); } plot.setToolTipGenerator(new PieGraphToolTipGenerator(pieGraphData)); plot.setURLGenerator(new PieGraphURLGenerator(pieGraphData)); initialized = true; }
From source file:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java
/** * *//* ww w . ja v a2s .co m*/ 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()); } }
From source file:net.sf.jasperreports.chartthemes.spring.AegeanChartTheme.java
@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()); }/*from w ww .java 2 s. c o m*/ }
From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java
/** * *//*from w ww . j ava2s . com*/ 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)); }
From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.java
@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()); }/*from w w w . j a v a 2 s . co m*/ GradientPaint gp = (GradientPaint) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BACKGROUND_PAINT); jfreeChart.setBackgroundPaint(new GradientPaint(0f, 0f, gp.getColor1(), 0f, getChart().getHeight() * 0.7f, gp.getColor2(), false)); }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
private void setTitle(JFreeChart chart, String title, Font titleFont, Color foregroundColor, List<cfCHARTTITLEData> titles) throws cfmRunTimeException { if (titles.size() > 0) { // One or more CFCHARTTITLE tags were specified so use them to configure // the chart titles for (int i = 0; i < titles.size(); i++) { cfCHARTTITLEData data = titles.get(i); Font font = getFont(data.getFont(), data.getFontBold(), data.getFontItalic(), data.getFontSize()); TextTitle textTitle = new TextTitle(data.getTitle(), font); textTitle.setPaint(convertStringToColor(data.getLabelColor())); textTitle.setBackgroundPaint(convertStringToColor(data.getBackgroundColor())); String pos = data.getPosition(); if (pos.equals("top")) textTitle.setPosition(RectangleEdge.TOP); else if (pos.equals("bottom")) textTitle.setPosition(RectangleEdge.BOTTOM); else if (pos.equals("left")) textTitle.setPosition(RectangleEdge.LEFT); else if (pos.equals("right")) textTitle.setPosition(RectangleEdge.RIGHT); if (!data.getShowBorder()) textTitle.setBorder(BlockBorder.NONE); else/*from w w w.j a v a2s.co m*/ textTitle.setBorder(new BlockBorder()); textTitle.setPadding(data.getPadding(), data.getPadding(), data.getPadding(), data.getPadding()); textTitle.setMargin(data.getMargin(), data.getMargin(), data.getMargin(), data.getMargin()); chart.addSubtitle(textTitle); } } else { // A CFCHARTTITLE tag was NOT specified so use the CFCHART attributes to // configure the chart title if (title == null) return; TextTitle textTitle = new TextTitle(title, titleFont); textTitle.setPaint(foregroundColor); // Add a border around the title to match CFMX 7 textTitle.setBorder(new BlockBorder()); textTitle.setPadding(10, 10, 10, 10); textTitle.setMargin(5, 5, 5, 5); chart.setTitle(textTitle); } }