Java Code Examples for org.jfree.chart.title.LegendTitle#setBackgroundPaint()
The following examples show how to use
org.jfree.chart.title.LegendTitle#setBackgroundPaint() .
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: StandardChartTheme.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Applies the attributes of this theme to the specified title. * * @param title the title. */ protected void applyToTitle(Title title) { if (title instanceof TextTitle) { TextTitle tt = (TextTitle) title; tt.setFont(this.largeFont); tt.setPaint(this.subtitlePaint); } else if (title instanceof LegendTitle) { LegendTitle lt = (LegendTitle) title; if (lt.getBackgroundPaint() != null) { lt.setBackgroundPaint(this.legendBackgroundPaint); } lt.setItemFont(this.regularFont); lt.setItemPaint(this.legendItemPaint); if (lt.getWrapper() != null) { applyToBlockContainer(lt.getWrapper()); } } else if (title instanceof PaintScaleLegend) { PaintScaleLegend psl = (PaintScaleLegend) title; psl.setBackgroundPaint(this.legendBackgroundPaint); ValueAxis axis = psl.getAxis(); if (axis != null) { applyToValueAxis(axis); } } else if (title instanceof CompositeTitle) { CompositeTitle ct = (CompositeTitle) title; BlockContainer bc = ct.getContainer(); List blocks = bc.getBlocks(); Iterator iterator = blocks.iterator(); while (iterator.hasNext()) { Block b = (Block) iterator.next(); if (b instanceof Title) { applyToTitle((Title) b); } } } }
Example 2
Source File: LegendTitleTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYPlot plot1 = new XYPlot(); LegendTitle t1 = new LegendTitle(plot1); LegendTitle t2 = new LegendTitle(plot1); assertEquals(t1, t2); t1.setBackgroundPaint( new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow) ); assertFalse(t1.equals(t2)); t2.setBackgroundPaint( new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow) ); assertTrue(t1.equals(t2)); t1.setLegendItemGraphicEdge(RectangleEdge.BOTTOM); assertFalse(t1.equals(t2)); t2.setLegendItemGraphicEdge(RectangleEdge.BOTTOM); assertTrue(t1.equals(t2)); t1.setLegendItemGraphicAnchor(RectangleAnchor.BOTTOM_LEFT); assertFalse(t1.equals(t2)); t2.setLegendItemGraphicAnchor(RectangleAnchor.BOTTOM_LEFT); assertTrue(t1.equals(t2)); t1.setLegendItemGraphicLocation(RectangleAnchor.TOP_LEFT); assertFalse(t1.equals(t2)); t2.setLegendItemGraphicLocation(RectangleAnchor.TOP_LEFT); assertTrue(t1.equals(t2)); t1.setItemFont(new Font("Dialog", Font.PLAIN, 19)); assertFalse(t1.equals(t2)); t2.setItemFont(new Font("Dialog", Font.PLAIN, 19)); assertTrue(t1.equals(t2)); }
Example 3
Source File: StandardChartTheme.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Applies the attributes of this theme to the specified title. * * @param title the title. */ protected void applyToTitle(Title title) { if (title instanceof TextTitle) { TextTitle tt = (TextTitle) title; tt.setFont(this.largeFont); tt.setPaint(this.subtitlePaint); } else if (title instanceof LegendTitle) { LegendTitle lt = (LegendTitle) title; if (lt.getBackgroundPaint() != null) { lt.setBackgroundPaint(this.legendBackgroundPaint); } lt.setItemFont(this.regularFont); lt.setItemPaint(this.legendItemPaint); if (lt.getWrapper() != null) { applyToBlockContainer(lt.getWrapper()); } } else if (title instanceof PaintScaleLegend) { PaintScaleLegend psl = (PaintScaleLegend) title; psl.setBackgroundPaint(this.legendBackgroundPaint); ValueAxis axis = psl.getAxis(); if (axis != null) { applyToValueAxis(axis); } } else if (title instanceof CompositeTitle) { CompositeTitle ct = (CompositeTitle) title; BlockContainer bc = ct.getContainer(); List blocks = bc.getBlocks(); Iterator iterator = blocks.iterator(); while (iterator.hasNext()) { Block b = (Block) iterator.next(); if (b instanceof Title) { applyToTitle((Title) b); } } } }
Example 4
Source File: StandardChartTheme.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Applies the attributes of this theme to the specified title. * * @param title the title. */ protected void applyToTitle(Title title) { if (title instanceof TextTitle) { TextTitle tt = (TextTitle) title; tt.setFont(this.largeFont); tt.setPaint(this.subtitlePaint); } else if (title instanceof LegendTitle) { LegendTitle lt = (LegendTitle) title; if (lt.getBackgroundPaint() != null) { lt.setBackgroundPaint(this.legendBackgroundPaint); } lt.setItemFont(this.regularFont); lt.setItemPaint(this.legendItemPaint); if (lt.getWrapper() != null) { applyToBlockContainer(lt.getWrapper()); } } else if (title instanceof PaintScaleLegend) { PaintScaleLegend psl = (PaintScaleLegend) title; psl.setBackgroundPaint(this.legendBackgroundPaint); ValueAxis axis = psl.getAxis(); if (axis != null) { applyToValueAxis(axis); } } else if (title instanceof CompositeTitle) { CompositeTitle ct = (CompositeTitle) title; BlockContainer bc = ct.getContainer(); List blocks = bc.getBlocks(); Iterator iterator = blocks.iterator(); while (iterator.hasNext()) { Block b = (Block) iterator.next(); if (b instanceof Title) { applyToTitle((Title) b); } } } }
Example 5
Source File: JGenProg2015_000_t.java From coming with MIT License | 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.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // 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 6
Source File: JGenProg2017_00104_t.java From coming with MIT License | 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.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // 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 7
Source File: Cardumen_003_s.java From coming with MIT License | 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.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // 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 8
Source File: XYTitleAnnotationDemo1.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data false, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); 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); LegendTitle lt = new LegendTitle(plot); lt.setItemFont(new Font("Dialog", Font.PLAIN, 9)); lt.setBackgroundPaint(new Color(200, 200, 255, 100)); lt.setFrame(new BlockBorder(Color.white)); lt.setPosition(RectangleEdge.BOTTOM); XYTitleAnnotation ta = new XYTitleAnnotation(0.98, 0.02, lt, RectangleAnchor.BOTTOM_RIGHT); ta.setMaxWidth(0.48); plot.addAnnotation(ta); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); ValueAxis yAxis = plot.getRangeAxis(); yAxis.setLowerMargin(0.35); return chart; }
Example 9
Source File: JGenProg2015_000_s.java From coming with MIT License | 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.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // 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 10
Source File: JGenProg2017_00106_t.java From coming with MIT License | 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.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // 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 11
Source File: Cardumen_0077_s.java From coming with MIT License | 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.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // 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 12
Source File: JFreeChart.java From ECG-Viewer with GNU General Public License v2.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) { ParamChecks.nullNotPermitted(plot, "plot"); // 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); // added the following hint because of // http://stackoverflow.com/questions/7785082/ this.renderingHints.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); 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.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // 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 13
Source File: Cardumen_00193_s.java From coming with MIT License | 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.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // 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 14
Source File: JFreeChart.java From SIMVA-SoS 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) { ParamChecks.nullNotPermitted(plot, "plot"); // 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); // added the following hint because of // http://stackoverflow.com/questions/7785082/ this.renderingHints.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); 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.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // 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 15
Source File: SimpleChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
protected void setChartLegend(JFreeChart jfreeChart) { //The legend visibility is already taken into account in the jfreeChart object's constructor LegendTitle legend = jfreeChart.getLegend(); if (legend != null) { LegendSettings legendSettings = getLegendSettings(); JRBaseFont font = new JRBaseFont(); FontUtil.copyNonNullOwnProperties(legendSettings.getFont(), font); FontUtil.copyNonNullOwnProperties(getChart().getLegendFont(), font); font = new JRBaseFont(getChart(), font); legend.setItemFont(getFontUtil().getAwtFont(font, getLocale())); Paint forePaint = getChart().getOwnLegendColor(); if (forePaint == null && legendSettings.getForegroundPaint() != null) { forePaint = legendSettings.getForegroundPaint().getPaint(); } if (forePaint == null) { forePaint = getChart().getLegendColor(); } if (forePaint != null) legend.setItemPaint(forePaint); Paint backPaint = getChart().getOwnLegendBackgroundColor(); if (backPaint == null && legendSettings.getBackgroundPaint() != null) { backPaint = legendSettings.getBackgroundPaint().getPaint(); } if (backPaint == null) { backPaint = getChart().getLegendBackgroundColor(); } if (backPaint != null) legend.setBackgroundPaint(backPaint); BlockFrame blockFrame = legendSettings.getBlockFrame(); if (blockFrame != null) legend.setFrame(blockFrame); HorizontalAlignment hAlign = legendSettings.getHorizontalAlignment(); if (hAlign != null) legend.setHorizontalAlignment(hAlign); VerticalAlignment vAlign = legendSettings.getVerticalAlignment(); if (vAlign != null) legend.setVerticalAlignment(vAlign); RectangleInsets padding = legendSettings.getPadding(); if (padding != null) legend.setPadding(padding); legend.setPosition( getEdge( getChart().getLegendPositionValue(), getEdge( legendSettings.getPositionValue() , RectangleEdge.BOTTOM ) ) ); } }
Example 16
Source File: JGenProg2017_00127_t.java From coming with MIT License | 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.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // 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 17
Source File: DefaultChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ protected void configureChart(JFreeChart jfreeChart) throws JRException { if (getChart().getModeValue() == ModeEnum.OPAQUE) { jfreeChart.setBackgroundPaint(getChart().getBackcolor()); } else { jfreeChart.setBackgroundPaint(null); } RectangleEdge titleEdge = getEdge(getChart().getTitlePositionValue(), RectangleEdge.TOP); if (jfreeChart.getTitle() != null) { TextTitle title = jfreeChart.getTitle(); title.setPaint(getChart().getTitleColor()); title.setFont(fontUtil.getAwtFont(getFont(getChart().getTitleFont()), getLocale())); title.setPosition(titleEdge); } String subtitleText = evaluateTextExpression(getChart().getSubtitleExpression()); if (subtitleText != null) { TextTitle subtitle = new TextTitle(subtitleText); subtitle.setPaint(getChart().getSubtitleColor()); subtitle.setFont(fontUtil.getAwtFont(getFont(getChart().getSubtitleFont()), getLocale())); subtitle.setPosition(titleEdge); jfreeChart.addSubtitle(subtitle); } // Apply all of the legend formatting options LegendTitle legend = jfreeChart.getLegend(); if (legend != null) { legend.setItemPaint(getChart().getLegendColor()); if (getChart().getOwnLegendBackgroundColor() == null)// in a way, legend backcolor inheritance from chart is useless { legend.setBackgroundPaint(null); } else { legend.setBackgroundPaint(getChart().getLegendBackgroundColor()); } legend.setItemFont(fontUtil.getAwtFont(getFont(getChart().getLegendFont()), getLocale())); legend.setPosition(getEdge(getChart().getLegendPositionValue(), RectangleEdge.BOTTOM)); } configurePlot(jfreeChart.getPlot()); }
Example 18
Source File: JFreeChart.java From astor with GNU General Public License v2.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.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // 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 19
Source File: jKali_0052_t.java From coming with MIT License | 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.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // 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 20
Source File: JFreeChart.java From buffer_bci with GNU General Public License v3.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) { ParamChecks.nullNotPermitted(plot, "plot"); // 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); // added the following hint because of // http://stackoverflow.com/questions/7785082/ this.renderingHints.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); 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.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // 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; }