List of usage examples for org.jfree.chart.title LegendTitle setBorder
public void setBorder(BlockBorder border)
From source file:org.jrecruiter.web.actions.admin.ShowStatisticsAction.java
private static JFreeChart createChart(final CategoryDataset categorydataset, final String chartTitle) { final JFreeChart chart = ChartFactory.createBarChart(chartTitle, "Jobs", "Number of Hits", categorydataset, PlotOrientation.VERTICAL, true, true, false); final CategoryPlot categoryplot = (CategoryPlot) chart.getPlot(); categoryplot.setNoDataMessage("NO DATA!"); chart.setBackgroundPaint(new Color(245, 245, 255)); chart.setBorderPaint(new Color(204, 204, 204)); chart.setBorderStroke(new BasicStroke(1f)); final LegendTitle legend = chart.getLegend(); legend.setWidth(1000);//from w ww .j a va2 s. co m legend.setPosition(RectangleEdge.BOTTOM); final BlockBorder border = new BlockBorder(new Color(204, 204, 204)); legend.setBorder(border); final CategoryPlot categoryPlot = (CategoryPlot) chart.getPlot(); categoryPlot.setBackgroundPaint(Color.WHITE); categoryPlot.setRangeGridlinePaint(new Color(204, 204, 204)); categoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); final NumberAxis numberaxis = (NumberAxis) categoryPlot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer(); renderer.setDrawBarOutline(true); final ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER); renderer.setPositiveItemLabelPosition(itemlabelposition); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelsVisible(true); return chart; }
From source file:grafix.graficos.eixos.Eixo.java
private void incluirLegenda(final XYPlot plot) { if (isLegenda()) { LegendTitle lt = new LegendTitle(plot); lt.setItemFont(new Font("Dialog", Font.PLAIN, 11)); lt.setBackgroundPaint(new Color(255, 255, 255, 100)); lt.setBorder(new BlockBorder(new Color(180, 180, 180))); lt.setPosition(RectangleEdge.TOP); XYTitleAnnotation ta = new XYTitleAnnotation(0.01, 0.98, lt, RectangleAnchor.TOP_LEFT); ta.setMaxWidth(0.48);// w w w . j a v a 2s . c om plot.addAnnotation(ta); } }
From source file:org.pentaho.plugin.jfreereport.reportcharts.MultiPieChartExpression.java
protected void configureSubChart(final JFreeChart chart) { final TextTitle chartTitle = chart.getTitle(); if (chartTitle != null) { if (getPieTitleFont() != null) { chartTitle.setFont(getPieTitleFont()); } else {/*from www. j ava 2s. co m*/ final Font titleFont = Font.decode(getTitleFont()); chartTitle.setFont(titleFont); } } if (isAntiAlias() == false) { chart.setAntiAlias(false); } final LegendTitle chLegend = chart.getLegend(); if (chLegend != null) { final RectangleEdge loc = translateEdge(getLegendLocation().toLowerCase()); if (loc != null) { chLegend.setPosition(loc); } if (getLegendFont() != null) { chLegend.setItemFont(Font.decode(getLegendFont())); } if (!isDrawLegendBorder()) { chLegend.setBorder(BlockBorder.NONE); } if (getLegendBackgroundColor() != null) { chLegend.setBackgroundPaint(getLegendBackgroundColor()); } if (getLegendTextColor() != null) { chLegend.setItemPaint(getLegendTextColor()); } } final Plot plot = chart.getPlot(); plot.setNoDataMessageFont(Font.decode(getLabelFont())); final String pieNoData = getPieNoDataMessage(); if (pieNoData != null) { plot.setNoDataMessage(pieNoData); } else { final String message = getNoDataMessage(); if (message != null) { plot.setNoDataMessage(message); } } }
From source file:org.pentaho.plugin.jfreereport.reportcharts.AbstractChartExpression.java
protected void configureChart(final JFreeChart chart) { // Misc Properties final TextTitle chartTitle = chart.getTitle(); if (chartTitle != null) { final Font titleFont = Font.decode(getTitleFont()); chartTitle.setFont(titleFont);//from w ww . ja va 2 s. c o m } if (isAntiAlias() == false) { chart.setAntiAlias(false); } chart.setBorderVisible(isShowBorder()); final Color backgroundColor = parseColorFromString(getBackgroundColor()); if (backgroundColor != null) { chart.setBackgroundPaint(backgroundColor); } if (plotBackgroundColor != null) { chart.getPlot().setBackgroundPaint(plotBackgroundColor); } chart.getPlot().setBackgroundAlpha(plotBackgroundAlpha); chart.getPlot().setForegroundAlpha(plotForegroundAlpha); final Color borderCol = parseColorFromString(getBorderColor()); if (borderCol != null) { chart.setBorderPaint(borderCol); } //remove legend if showLegend = false if (!isShowLegend()) { chart.removeLegend(); } else { //if true format legend final LegendTitle chLegend = chart.getLegend(); if (chLegend != null) { final RectangleEdge loc = translateEdge(legendLocation.toLowerCase()); if (loc != null) { chLegend.setPosition(loc); } if (getLegendFont() != null) { chLegend.setItemFont(Font.decode(getLegendFont())); } if (!isDrawLegendBorder()) { chLegend.setBorder(BlockBorder.NONE); } if (legendBackgroundColor != null) { chLegend.setBackgroundPaint(legendBackgroundColor); } if (legendTextColor != null) { chLegend.setItemPaint(legendTextColor); } } } final Plot plot = chart.getPlot(); plot.setNoDataMessageFont(Font.decode(getLabelFont())); final String message = getNoDataMessage(); if (message != null) { plot.setNoDataMessage(message); } plot.setOutlineVisible(isChartSectionOutline()); if (backgroundImage != null) { if (plotImageCache != null) { plot.setBackgroundImage(plotImageCache); } else { final ExpressionRuntime expressionRuntime = getRuntime(); final ProcessingContext context = expressionRuntime.getProcessingContext(); final ResourceKey contentBase = context.getContentBase(); final ResourceManager manager = context.getResourceManager(); try { final ResourceKey key = createKeyFromString(manager, contentBase, backgroundImage); final Resource resource = manager.create(key, null, Image.class); final Image image = (Image) resource.getResource(); plot.setBackgroundImage(image); plotImageCache = image; } catch (Exception e) { logger.error("ABSTRACTCHARTEXPRESSION.ERROR_0007_ERROR_RETRIEVING_PLOT_IMAGE", e); //$NON-NLS-1$ throw new IllegalStateException("Failed to process chart"); } } } }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
private void setLegend(JFreeChart chart, boolean bShowLegend, Font font, Color foregroundColor, Color backgroundColor, cfCHARTLEGENDData legendData) throws cfmRunTimeException { LegendTitle legend = new LegendTitle(chart.getPlot()); legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0)); // If a CFCHARTLEGEND tag was used then use it's attributes to configure the // legend//ww w . j a va 2 s . c o m if (legendData != null) { // A CFCHARTLEGEND tag is present so use its attributes to configure the // legend legend.setItemFont(getFont(legendData.getFont(), legendData.getFontBold(), legendData.getFontItalic(), legendData.getFontSize())); legend.setItemPaint(convertStringToColor(legendData.getLabelColor())); legend.setBackgroundPaint(convertStringToColor(legendData.getBackgroundColor())); String pos = legendData.getPosition(); if (pos.equals("top")) legend.setPosition(RectangleEdge.TOP); else if (pos.equals("bottom")) legend.setPosition(RectangleEdge.BOTTOM); else if (pos.equals("left")) legend.setPosition(RectangleEdge.LEFT); else if (pos.equals("right")) legend.setPosition(RectangleEdge.RIGHT); if (!legendData.getShowBorder()) legend.setBorder(BlockBorder.NONE); else legend.setBorder(new BlockBorder()); } else { // A CFCHARTLEGEND tag is NOT present so use the attributes from the // CFCHART tag to configure the legend if (!bShowLegend) return; legend.setItemFont(font); legend.setItemPaint(foregroundColor); legend.setBackgroundPaint(backgroundColor); // By default CFMX 7 places the legend at the top with no border legend.setPosition(RectangleEdge.TOP); legend.setBorder(BlockBorder.NONE); } // Add the legend to the chart chart.addSubtitle(legend); }