Java Code Examples for org.jfree.chart.title.LegendTitle#setBorder()
The following examples show how to use
org.jfree.chart.title.LegendTitle#setBorder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScheduleReport.java From ezScrum with GNU General Public License v2.0 | 6 votes |
private void setAttribute(JFreeChart chart) { // 圖案與文字的間隔 LegendTitle legend = chart.getLegend(); legend.setBorder(1, 1, 1, 1); CategoryPlot plot = chart.getCategoryPlot(); // 設定WorkItem的屬性 CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); // 字體角度 domainAxis.setTickLabelFont(new Font("新細明體", Font.TRUETYPE_FONT, 12)); // 字體 // 設定Date的屬性 DateAxis da = (DateAxis) plot.getRangeAxis(0); setDateAxis(da); // 設定實體的顯示名稱 CategoryItemRenderer render = plot.getRenderer(0); DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); CategoryItemLabelGenerator generator = new IntervalCategoryItemLabelGenerator( "{3} ~ {4}", format); render.setBaseItemLabelGenerator(generator); render.setBaseItemLabelPaint(Color.BLUE); render.setBaseItemLabelsVisible(true); render.setBaseItemLabelFont(new Font("黑體", Font.TRUETYPE_FONT, 8)); render.setSeriesPaint(0, Color.RED); }
Example 2
Source File: ChartFormatter.java From nmonvisualizer with Apache License 2.0 | 5 votes |
void formatLegend(LegendTitle legend) { legend.setItemFont(LEGEND_FONT); legend.setItemPaint(textColor); legend.setBorder(0, 0, 0, 0); legend.setPosition(RectangleEdge.BOTTOM); legend.setItemLabelPadding(new RectangleInsets(5, 5, 5, 5)); }
Example 3
Source File: cfCHART.java From openbd-core with GNU General Public License v3.0 | 4 votes |
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 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); }
Example 4
Source File: JFreeChart.java From opensim-gui with Apache License 2.0 | 4 votes |
/** * Creates a new chart with the given title and plot. The * <code>createLegend</code> argument specifies whether or not a legend * should be added to the chart. * <br><br> * Note that the {@link ChartFactory} class contains a range * of static methods that will return ready-made charts, and often this * is a more convenient way to create charts than using this constructor. * * @param title the chart title (<code>null</code> permitted). * @param titleFont the font for displaying the chart title * (<code>null</code> permitted). * @param plot controller of the visual representation of the data * (<code>null</code> not permitted). * @param createLegend a flag indicating whether or not a legend should * be created for the chart. */ public JFreeChart(String title, Font titleFont, Plot plot, boolean createLegend) { if (plot == null) { throw new NullPointerException("Null 'plot' argument."); } // create storage for listeners... this.progressListeners = new EventListenerList(); this.changeListeners = new EventListenerList(); this.notify = true; // default is to notify listeners when the // chart changes this.renderingHints = new RenderingHints( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); this.borderVisible = false; this.borderStroke = new BasicStroke(1.0f); this.borderPaint = Color.black; this.padding = RectangleInsets.ZERO_INSETS; this.plot = plot; plot.addChangeListener(this); this.subtitles = new ArrayList(); // create a legend, if requested... if (createLegend) { LegendTitle legend = new LegendTitle(this.plot); legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0)); legend.setBorder(new BlockBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); } // add the chart title, if one has been specified... if (title != null) { if (titleFont == null) { titleFont = DEFAULT_TITLE_FONT; } this.title = new TextTitle(title, titleFont); this.title.addChangeListener(this); } this.backgroundPaint = DEFAULT_BACKGROUND_PAINT; this.backgroundImage = DEFAULT_BACKGROUND_IMAGE; this.backgroundImageAlignment = DEFAULT_BACKGROUND_IMAGE_ALIGNMENT; this.backgroundImageAlpha = DEFAULT_BACKGROUND_IMAGE_ALPHA; }
Example 5
Source File: AbstractChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
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 ); } 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" ); } } } }
Example 6
Source File: MultiPieChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
protected void configureSubChart( final JFreeChart chart ) { final TextTitle chartTitle = chart.getTitle(); if ( chartTitle != null ) { if ( getPieTitleFont() != null ) { chartTitle.setFont( getPieTitleFont() ); } else { 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 ); } } }