001 /* ===========================================================
002 * JFreeChart : a free chart library for the Java(tm) platform
003 * ===========================================================
004 *
005 * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
006 *
007 * Project Info: http://www.jfree.org/jfreechart/index.html
008 *
009 * This library is free software; you can redistribute it and/or modify it
010 * under the terms of the GNU Lesser General Public License as published by
011 * the Free Software Foundation; either version 2.1 of the License, or
012 * (at your option) any later version.
013 *
014 * This library is distributed in the hope that it will be useful, but
015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017 * License for more details.
018 *
019 * You should have received a copy of the GNU Lesser General Public
020 * License along with this library; if not, write to the Free Software
021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
022 * USA.
023 *
024 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
025 * in the United States and other countries.]
026 *
027 * ---------------
028 * JFreeChart.java
029 * ---------------
030 * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
031 *
032 * Original Author: David Gilbert (for Object Refinery Limited);
033 * Contributor(s): Andrzej Porebski;
034 * David Li;
035 * Wolfgang Irler;
036 * Christian W. Zuckschwerdt;
037 * Klaus Rheinwald;
038 * Nicolas Brodu;
039 *
040 * NOTE: The above list of contributors lists only the people that have
041 * contributed to this source file (JFreeChart.java) - for a list of ALL
042 * contributors to the project, please see the README.txt file.
043 *
044 * $Id: JFreeChart.java,v 1.34.2.21 2007/06/05 15:41:38 mungady Exp $
045 *
046 * Changes (from 20-Jun-2001)
047 * --------------------------
048 * 20-Jun-2001 : Modifications submitted by Andrzej Porebski for legend
049 * placement;
050 * 21-Jun-2001 : Removed JFreeChart parameter from Plot constructors (DG);
051 * 22-Jun-2001 : Multiple titles added (original code by David Berry, with
052 * reworkings by DG);
053 * 18-Sep-2001 : Updated header (DG);
054 * 15-Oct-2001 : Moved data source classes into new package
055 * com.jrefinery.data.* (DG);
056 * 18-Oct-2001 : New factory method for creating VerticalXYBarChart (DG);
057 * 19-Oct-2001 : Moved series paint and stroke methods to the Plot class (DG);
058 * Moved static chart creation methods to new ChartFactory
059 * class (DG);
060 * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG);
061 * Fixed bug where chart isn't registered with the dataset (DG);
062 * 07-Nov-2001 : Fixed bug where null title in constructor causes
063 * exception (DG);
064 * Tidied up event notification code (DG);
065 * 17-Nov-2001 : Added getLegendItemCount() method (DG);
066 * 21-Nov-2001 : Set clipping in draw method to ensure that nothing gets drawn
067 * outside the chart area (DG);
068 * 11-Dec-2001 : Added the createBufferedImage() method, taken from the
069 * JFreeChartServletDemo class (DG);
070 * 13-Dec-2001 : Added tooltips (DG);
071 * 16-Jan-2002 : Added handleClick() method (DG);
072 * 22-Jan-2002 : Fixed bug correlating legend labels with pie data (DG);
073 * 05-Feb-2002 : Removed redundant tooltips code (DG);
074 * 19-Feb-2002 : Added accessor methods for the backgroundImage and
075 * backgroundImageAlpha attributes (DG);
076 * 21-Feb-2002 : Added static fields for INFO, COPYRIGHT, LICENCE, CONTRIBUTORS
077 * and LIBRARIES. These can be used to display information about
078 * JFreeChart (DG);
079 * 06-Mar-2002 : Moved constants to JFreeChartConstants interface (DG);
080 * 18-Apr-2002 : PieDataset is no longer sorted (oldman);
081 * 23-Apr-2002 : Moved dataset to the Plot class (DG);
082 * 13-Jun-2002 : Added an extra draw() method (DG);
083 * 25-Jun-2002 : Implemented the Drawable interface and removed redundant
084 * imports (DG);
085 * 26-Jun-2002 : Added another createBufferedImage() method (DG);
086 * 18-Sep-2002 : Fixed issues reported by Checkstyle (DG);
087 * 23-Sep-2002 : Added new contributor (DG);
088 * 28-Oct-2002 : Created main title and subtitle list to replace existing title
089 * list (DG);
090 * 08-Jan-2003 : Added contributor (DG);
091 * 17-Jan-2003 : Added new constructor (DG);
092 * 22-Jan-2003 : Added ChartColor class by Cameron Riley, and background image
093 * alignment code by Christian W. Zuckschwerdt (DG);
094 * 11-Feb-2003 : Added flag to allow suppression of chart change events, based
095 * on a suggestion by Klaus Rheinwald (DG);
096 * 04-Mar-2003 : Added small fix for suppressed chart change events (see bug id
097 * 690865) (DG);
098 * 10-Mar-2003 : Added Benoit Xhenseval to contributors (DG);
099 * 26-Mar-2003 : Implemented Serializable (DG);
100 * 15-Jul-2003 : Added an optional border for the chart (DG);
101 * 11-Sep-2003 : Took care of listeners while cloning (NB);
102 * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG);
103 * 22-Sep-2003 : Added nullpointer checks.
104 * 25-Sep-2003 : Added nullpointer checks too (NB).
105 * 03-Dec-2003 : Legends are now registered by this class instead of using the
106 * old constructor way (TM);
107 * 03-Dec-2003 : Added anchorPoint to draw() method (DG);
108 * 08-Jan-2004 : Reworked title code, introducing line wrapping (DG);
109 * 09-Feb-2004 : Created additional createBufferedImage() method (DG);
110 * 05-Apr-2004 : Added new createBufferedImage() method (DG);
111 * 27-May-2004 : Moved constants from JFreeChartConstants.java back to this
112 * class (DG);
113 * 25-Nov-2004 : Updates for changes to Title class (DG);
114 * 06-Jan-2005 : Change lookup for default background color (DG);
115 * 31-Jan-2005 : Added Don Elliott to contributors (DG);
116 * 02-Feb-2005 : Added clearSubtitles() method (DG);
117 * 03-Feb-2005 : Added Mofeed Shahin to contributors (DG);
118 * 08-Feb-2005 : Updated for RectangleConstraint changes (DG);
119 * 28-Mar-2005 : Renamed Legend --> OldLegend (DG);
120 * 12-Apr-2005 : Added methods to access legend(s) in subtitle list (DG);
121 * 13-Apr-2005 : Added removeLegend() and removeSubtitle() methods (DG);
122 * 20-Apr-2005 : Modified to collect chart entities from titles and
123 * subtitles (DG);
124 * 26-Apr-2005 : Removed LOGGER (DG);
125 * 06-Jun-2005 : Added addLegend() method and padding attribute, fixed equals()
126 * method (DG);
127 * 24-Nov-2005 : Removed OldLegend and related code - don't want to support
128 * this in 1.0.0 final (DG);
129 * ------------- JFREECHART 1.0.x ---------------------------------------------
130 * 27-Jan-2006 : Updated version number (DG);
131 * 07-Dec-2006 : Added some missing credits (DG);
132 * 17-Jan-2007 : Added Darren Jung to contributor list (DG);
133 * 05-Mar-2007 : Added Sergei Ivanov to the contributor list (DG);
134 * 16-Mar-2007 : Modified initial legend border (DG);
135 * 22-Mar-2007 : New methods for text anti-aliasing (DG);
136 * 16-May-2007 : Fixed argument check in getSubtitle(), copy list in
137 * get/setSubtitles(), and added new addSubtitle(int, Title)
138 * method (DG);
139 * 05-Jun-2007 : Add change listener to default legend (DG);
140 *
141 */
142
143 package org.jfree.chart;
144
145 import java.awt.AlphaComposite;
146 import java.awt.BasicStroke;
147 import java.awt.Color;
148 import java.awt.Composite;
149 import java.awt.Font;
150 import java.awt.Graphics2D;
151 import java.awt.Image;
152 import java.awt.Paint;
153 import java.awt.RenderingHints;
154 import java.awt.Shape;
155 import java.awt.Stroke;
156 import java.awt.geom.AffineTransform;
157 import java.awt.geom.Point2D;
158 import java.awt.geom.Rectangle2D;
159 import java.awt.image.BufferedImage;
160 import java.io.IOException;
161 import java.io.ObjectInputStream;
162 import java.io.ObjectOutputStream;
163 import java.io.Serializable;
164 import java.net.URL;
165 import java.util.ArrayList;
166 import java.util.Arrays;
167 import java.util.Iterator;
168 import java.util.List;
169 import java.util.ResourceBundle;
170
171 import javax.swing.ImageIcon;
172 import javax.swing.UIManager;
173 import javax.swing.event.EventListenerList;
174
175 import org.jfree.JCommon;
176 import org.jfree.chart.block.BlockParams;
177 import org.jfree.chart.block.EntityBlockResult;
178 import org.jfree.chart.block.LengthConstraintType;
179 import org.jfree.chart.block.LineBorder;
180 import org.jfree.chart.block.RectangleConstraint;
181 import org.jfree.chart.entity.EntityCollection;
182 import org.jfree.chart.event.ChartChangeEvent;
183 import org.jfree.chart.event.ChartChangeListener;
184 import org.jfree.chart.event.ChartProgressEvent;
185 import org.jfree.chart.event.ChartProgressListener;
186 import org.jfree.chart.event.PlotChangeEvent;
187 import org.jfree.chart.event.PlotChangeListener;
188 import org.jfree.chart.event.TitleChangeEvent;
189 import org.jfree.chart.event.TitleChangeListener;
190 import org.jfree.chart.plot.CategoryPlot;
191 import org.jfree.chart.plot.Plot;
192 import org.jfree.chart.plot.PlotRenderingInfo;
193 import org.jfree.chart.plot.XYPlot;
194 import org.jfree.chart.title.LegendTitle;
195 import org.jfree.chart.title.TextTitle;
196 import org.jfree.chart.title.Title;
197 import org.jfree.data.Range;
198 import org.jfree.io.SerialUtilities;
199 import org.jfree.ui.Align;
200 import org.jfree.ui.Drawable;
201 import org.jfree.ui.HorizontalAlignment;
202 import org.jfree.ui.RectangleEdge;
203 import org.jfree.ui.RectangleInsets;
204 import org.jfree.ui.Size2D;
205 import org.jfree.ui.VerticalAlignment;
206 import org.jfree.ui.about.Contributor;
207 import org.jfree.ui.about.Licences;
208 import org.jfree.ui.about.ProjectInfo;
209 import org.jfree.util.ObjectUtilities;
210 import org.jfree.util.PaintUtilities;
211
212 /**
213 * A chart class implemented using the Java 2D APIs. The current version
214 * supports bar charts, line charts, pie charts and xy plots (including time
215 * series data).
216 * <P>
217 * JFreeChart coordinates several objects to achieve its aim of being able to
218 * draw a chart on a Java 2D graphics device: a list of {@link Title} objects
219 * (which often includes the chart's legend), a {@link Plot} and a
220 * {@link org.jfree.data.general.Dataset} (the plot in turn manages a
221 * domain axis and a range axis).
222 * <P>
223 * You should use a {@link ChartPanel} to display a chart in a GUI.
224 * <P>
225 * The {@link ChartFactory} class contains static methods for creating
226 * 'ready-made' charts.
227 *
228 * @see ChartPanel
229 * @see ChartFactory
230 * @see Title
231 * @see Plot
232 */
233 public class JFreeChart implements Drawable,
234 TitleChangeListener,
235 PlotChangeListener,
236 Serializable,
237 Cloneable {
238
239 /** For serialization. */
240 private static final long serialVersionUID = -3470703747817429120L;
241
242 /** Information about the project. */
243 public static final ProjectInfo INFO = new JFreeChartInfo();
244
245 /** The default font for titles. */
246 public static final Font DEFAULT_TITLE_FONT
247 = new Font("SansSerif", Font.BOLD, 18);
248
249 /** The default background color. */
250 public static final Paint DEFAULT_BACKGROUND_PAINT
251 = UIManager.getColor("Panel.background");
252
253 /** The default background image. */
254 public static final Image DEFAULT_BACKGROUND_IMAGE = null;
255
256 /** The default background image alignment. */
257 public static final int DEFAULT_BACKGROUND_IMAGE_ALIGNMENT = Align.FIT;
258
259 /** The default background image alpha. */
260 public static final float DEFAULT_BACKGROUND_IMAGE_ALPHA = 0.5f;
261
262 /**
263 * Rendering hints that will be used for chart drawing. This should never
264 * be <code>null</code>.
265 */
266 private transient RenderingHints renderingHints;
267
268 /** A flag that controls whether or not the chart border is drawn. */
269 private boolean borderVisible;
270
271 /** The stroke used to draw the chart border (if visible). */
272 private transient Stroke borderStroke;
273
274 /** The paint used to draw the chart border (if visible). */
275 private transient Paint borderPaint;
276
277 /** The padding between the chart border and the chart drawing area. */
278 private RectangleInsets padding;
279
280 /** The chart title (optional). */
281 private TextTitle title;
282
283 /**
284 * The chart subtitles (zero, one or many). This field should never be
285 * <code>null</code>.
286 */
287 private List subtitles;
288
289 /** Draws the visual representation of the data. */
290 private Plot plot;
291
292 /** Paint used to draw the background of the chart. */
293 private transient Paint backgroundPaint;
294
295 /** An optional background image for the chart. */
296 private transient Image backgroundImage; // todo: not serialized yet
297
298 /** The alignment for the background image. */
299 private int backgroundImageAlignment = Align.FIT;
300
301 /** The alpha transparency for the background image. */
302 private float backgroundImageAlpha = 0.5f;
303
304 /** Storage for registered change listeners. */
305 private transient EventListenerList changeListeners;
306
307 /** Storage for registered progress listeners. */
308 private transient EventListenerList progressListeners;
309
310 /**
311 * A flag that can be used to enable/disable notification of chart change
312 * events.
313 */
314 private boolean notify;
315
316 /**
317 * Creates a new chart based on the supplied plot. The chart will have
318 * a legend added automatically, but no title (although you can easily add
319 * one later).
320 * <br><br>
321 * Note that the {@link ChartFactory} class contains a range
322 * of static methods that will return ready-made charts, and often this
323 * is a more convenient way to create charts than using this constructor.
324 *
325 * @param plot the plot (<code>null</code> not permitted).
326 */
327 public JFreeChart(Plot plot) {
328 this(null, null, plot, true);
329 }
330
331 /**
332 * Creates a new chart with the given title and plot. A default font
333 * (@link DEFAULT_TITLE_FONT) is used for the title, and the chart will
334 * have a legend added automatically.
335 * <br><br>
336 * Note that the {@link ChartFactory} class contains a range
337 * of static methods that will return ready-made charts, and often this
338 * is a more convenient way to create charts than using this constructor.
339 *
340 * @param title the chart title (<code>null</code> permitted).
341 * @param plot the plot (<code>null</code> not permitted).
342 */
343 public JFreeChart(String title, Plot plot) {
344 this(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
345 }
346
347 /**
348 * Creates a new chart with the given title and plot. The
349 * <code>createLegend</code> argument specifies whether or not a legend
350 * should be added to the chart.
351 * <br><br>
352 * Note that the {@link ChartFactory} class contains a range
353 * of static methods that will return ready-made charts, and often this
354 * is a more convenient way to create charts than using this constructor.
355 *
356 * @param title the chart title (<code>null</code> permitted).
357 * @param titleFont the font for displaying the chart title
358 * (<code>null</code> permitted).
359 * @param plot controller of the visual representation of the data
360 * (<code>null</code> not permitted).
361 * @param createLegend a flag indicating whether or not a legend should
362 * be created for the chart.
363 */
364 public JFreeChart(String title, Font titleFont, Plot plot,
365 boolean createLegend) {
366
367 if (plot == null) {
368 throw new NullPointerException("Null 'plot' argument.");
369 }
370
371 // create storage for listeners...
372 this.progressListeners = new EventListenerList();
373 this.changeListeners = new EventListenerList();
374 this.notify = true; // default is to notify listeners when the
375 // chart changes
376
377 this.renderingHints = new RenderingHints(
378 RenderingHints.KEY_ANTIALIASING,
379 RenderingHints.VALUE_ANTIALIAS_ON);
380
381 this.borderVisible = false;
382 this.borderStroke = new BasicStroke(1.0f);
383 this.borderPaint = Color.black;
384
385 this.padding = RectangleInsets.ZERO_INSETS;
386
387 this.plot = plot;
388 plot.addChangeListener(this);
389
390 this.subtitles = new ArrayList();
391
392 // create a legend, if requested...
393 if (createLegend) {
394 LegendTitle legend = new LegendTitle(this.plot);
395 legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
396 legend.setFrame(new LineBorder());
397 legend.setBackgroundPaint(Color.white);
398 legend.setPosition(RectangleEdge.BOTTOM);
399 this.subtitles.add(legend);
400 legend.addChangeListener(this);
401 }
402
403 // add the chart title, if one has been specified...
404 if (title != null) {
405 if (titleFont == null) {
406 titleFont = DEFAULT_TITLE_FONT;
407 }
408 this.title = new TextTitle(title, titleFont);
409 this.title.addChangeListener(this);
410 }
411
412 this.backgroundPaint = DEFAULT_BACKGROUND_PAINT;
413
414 this.backgroundImage = DEFAULT_BACKGROUND_IMAGE;
415 this.backgroundImageAlignment = DEFAULT_BACKGROUND_IMAGE_ALIGNMENT;
416 this.backgroundImageAlpha = DEFAULT_BACKGROUND_IMAGE_ALPHA;
417
418 }
419
420 /**
421 * Returns the collection of rendering hints for the chart.
422 *
423 * @return The rendering hints for the chart (never <code>null</code>).
424 *
425 * @see #setRenderingHints(RenderingHints)
426 */
427 public RenderingHints getRenderingHints() {
428 return this.renderingHints;
429 }
430
431 /**
432 * Sets the rendering hints for the chart. These will be added (using the
433 * Graphics2D.addRenderingHints() method) near the start of the
434 * JFreeChart.draw() method.
435 *
436 * @param renderingHints the rendering hints (<code>null</code> not
437 * permitted).
438 *
439 * @see #getRenderingHints()
440 */
441 public void setRenderingHints(RenderingHints renderingHints) {
442 if (renderingHints == null) {
443 throw new NullPointerException("RenderingHints given are null");
444 }
445 this.renderingHints = renderingHints;
446 fireChartChanged();
447 }
448
449 /**
450 * Returns a flag that controls whether or not a border is drawn around the
451 * outside of the chart.
452 *
453 * @return A boolean.
454 *
455 * @see #setBorderVisible(boolean)
456 */
457 public boolean isBorderVisible() {
458 return this.borderVisible;
459 }
460
461 /**
462 * Sets a flag that controls whether or not a border is drawn around the
463 * outside of the chart.
464 *
465 * @param visible the flag.
466 *
467 * @see #isBorderVisible()
468 */
469 public void setBorderVisible(boolean visible) {
470 this.borderVisible = visible;
471 fireChartChanged();
472 }
473
474 /**
475 * Returns the stroke used to draw the chart border (if visible).
476 *
477 * @return The border stroke.
478 *
479 * @see #setBorderStroke(Stroke)
480 */
481 public Stroke getBorderStroke() {
482 return this.borderStroke;
483 }
484
485 /**
486 * Sets the stroke used to draw the chart border (if visible).
487 *
488 * @param stroke the stroke.
489 *
490 * @see #getBorderStroke()
491 */
492 public void setBorderStroke(Stroke stroke) {
493 this.borderStroke = stroke;
494 fireChartChanged();
495 }
496
497 /**
498 * Returns the paint used to draw the chart border (if visible).
499 *
500 * @return The border paint.
501 *
502 * @see #setBorderPaint(Paint)
503 */
504 public Paint getBorderPaint() {
505 return this.borderPaint;
506 }
507
508 /**
509 * Sets the paint used to draw the chart border (if visible).
510 *
511 * @param paint the paint.
512 *
513 * @see #getBorderPaint()
514 */
515 public void setBorderPaint(Paint paint) {
516 this.borderPaint = paint;
517 fireChartChanged();
518 }
519
520 /**
521 * Returns the padding between the chart border and the chart drawing area.
522 *
523 * @return The padding (never <code>null</code>).
524 *
525 * @see #setPadding(RectangleInsets)
526 */
527 public RectangleInsets getPadding() {
528 return this.padding;
529 }
530
531 /**
532 * Sets the padding between the chart border and the chart drawing area,
533 * and sends a {@link ChartChangeEvent} to all registered listeners.
534 *
535 * @param padding the padding (<code>null</code> not permitted).
536 *
537 * @see #getPadding()
538 */
539 public void setPadding(RectangleInsets padding) {
540 if (padding == null) {
541 throw new IllegalArgumentException("Null 'padding' argument.");
542 }
543 this.padding = padding;
544 notifyListeners(new ChartChangeEvent(this));
545 }
546
547 /**
548 * Returns the main chart title. Very often a chart will have just one
549 * title, so we make this case simple by providing accessor methods for
550 * the main title. However, multiple titles are supported - see the
551 * {@link #addSubtitle(Title)} method.
552 *
553 * @return The chart title (possibly <code>null</code>).
554 *
555 * @see #setTitle(TextTitle)
556 */
557 public TextTitle getTitle() {
558 return this.title;
559 }
560
561 /**
562 * Sets the main title for the chart and sends a {@link ChartChangeEvent}
563 * to all registered listeners. If you do not want a title for the
564 * chart, set it to <code>null</code>. If you want more than one title on
565 * a chart, use the {@link #addSubtitle(Title)} method.
566 *
567 * @param title the title (<code>null</code> permitted).
568 *
569 * @see #getTitle()
570 */
571 public void setTitle(TextTitle title) {
572 this.title = title;
573 fireChartChanged();
574 }
575
576 /**
577 * Sets the chart title and sends a {@link ChartChangeEvent} to all
578 * registered listeners. This is a convenience method that ends up calling
579 * the {@link #setTitle(TextTitle)} method. If there is an existing title,
580 * its text is updated, otherwise a new title using the default font is
581 * added to the chart. If <code>text</code> is <code>null</code> the chart
582 * title is set to <code>null</code>.
583 *
584 * @param text the title text (<code>null</code> permitted).
585 *
586 * @see #getTitle()
587 */
588 public void setTitle(String text) {
589 if (text != null) {
590 if (this.title == null) {
591 setTitle(new TextTitle(text, JFreeChart.DEFAULT_TITLE_FONT));
592 }
593 else {
594 this.title.setText(text);
595 }
596 }
597 else {
598 setTitle((TextTitle) null);
599 }
600 }
601
602 /**
603 * Adds a legend to the plot and sends a {@link ChartChangeEvent} to all
604 * registered listeners.
605 *
606 * @param legend the legend (<code>null</code> not permitted).
607 *
608 * @see #removeLegend()
609 */
610 public void addLegend(LegendTitle legend) {
611 addSubtitle(legend);
612 }
613
614 /**
615 * Returns the legend for the chart, if there is one. Note that a chart
616 * can have more than one legend - this method returns the first.
617 *
618 * @return The legend (possibly <code>null</code>).
619 *
620 * @see #getLegend(int)
621 */
622 public LegendTitle getLegend() {
623 return getLegend(0);
624 }
625
626 /**
627 * Returns the nth legend for a chart, or <code>null</code>.
628 *
629 * @param index the legend index (zero-based).
630 *
631 * @return The legend (possibly <code>null</code>).
632 *
633 * @see #addLegend(LegendTitle)
634 */
635 public LegendTitle getLegend(int index) {
636 int seen = 0;
637 Iterator iterator = this.subtitles.iterator();
638 while (iterator.hasNext()) {
639 Title subtitle = (Title) iterator.next();
640 if (subtitle instanceof LegendTitle) {
641 if (seen == index) {
642 return (LegendTitle) subtitle;
643 }
644 else {
645 seen++;
646 }
647 }
648 }
649 return null;
650 }
651
652 /**
653 * Removes the first legend in the chart and sends a
654 * {@link ChartChangeEvent} to all registered listeners.
655 *
656 * @see #getLegend()
657 */
658 public void removeLegend() {
659 removeSubtitle(getLegend());
660 }
661
662 /**
663 * Returns the list of subtitles for the chart.
664 *
665 * @return The subtitle list (possibly empty, but never <code>null</code>).
666 *
667 * @see #setSubtitles(List)
668 */
669 public List getSubtitles() {
670 return new ArrayList(this.subtitles);
671 }
672
673 /**
674 * Sets the title list for the chart (completely replaces any existing
675 * titles) and sends a {@link ChartChangeEvent} to all registered
676 * listeners.
677 *
678 * @param subtitles the new list of subtitles (<code>null</code> not
679 * permitted).
680 *
681 * @see #getSubtitles()
682 */
683 public void setSubtitles(List subtitles) {
684 if (subtitles == null) {
685 throw new NullPointerException("Null 'subtitles' argument.");
686 }
687 setNotify(false);
688 clearSubtitles();
689 Iterator iterator = subtitles.iterator();
690 while (iterator.hasNext()) {
691 Title t = (Title) iterator.next();
692 if (t != null) {
693 addSubtitle(t);
694 }
695 }
696 setNotify(true); // this fires a ChartChangeEvent
697 }
698
699 /**
700 * Returns the number of titles for the chart.
701 *
702 * @return The number of titles for the chart.
703 *
704 * @see #getSubtitles()
705 */
706 public int getSubtitleCount() {
707 return this.subtitles.size();
708 }
709
710 /**
711 * Returns a chart subtitle.
712 *
713 * @param index the index of the chart subtitle (zero based).
714 *
715 * @return A chart subtitle.
716 *
717 * @see #addSubtitle(Title)
718 */
719 public Title getSubtitle(int index) {
720 if ((index < 0) || (index >= getSubtitleCount())) {
721 throw new IllegalArgumentException("Index out of range.");
722 }
723 return (Title) this.subtitles.get(index);
724 }
725
726 /**
727 * Adds a chart subtitle, and notifies registered listeners that the chart
728 * has been modified.
729 *
730 * @param subtitle the subtitle (<code>null</code> not permitted).
731 *
732 * @see #getSubtitle(int)
733 */
734 public void addSubtitle(Title subtitle) {
735 if (subtitle == null) {
736 throw new IllegalArgumentException("Null 'subtitle' argument.");
737 }
738 this.subtitles.add(subtitle);
739 subtitle.addChangeListener(this);
740 fireChartChanged();
741 }
742
743 /**
744 * Adds a subtitle at a particular position in the subtitle list, and sends
745 * a {@link ChartChangeEvent} to all registered listeners.
746 *
747 * @param index the index (in the range 0 to {@link #getSubtitleCount()}).
748 * @param subtitle the subtitle to add (<code>null</code> not permitted).
749 *
750 * @since 1.0.6
751 */
752 public void addSubtitle(int index, Title subtitle) {
753 if (index < 0 || index > getSubtitleCount()) {
754 throw new IllegalArgumentException(
755 "The 'index' argument is out of range.");
756 }
757 if (subtitle == null) {
758 throw new IllegalArgumentException("Null 'subtitle' argument.");
759 }
760 this.subtitles.add(index, subtitle);
761 subtitle.addChangeListener(this);
762 fireChartChanged();
763 }
764
765 /**
766 * Clears all subtitles from the chart and sends a {@link ChartChangeEvent}
767 * to all registered listeners.
768 *
769 * @see #addSubtitle(Title)
770 */
771 public void clearSubtitles() {
772 Iterator iterator = this.subtitles.iterator();
773 while (iterator.hasNext()) {
774 Title t = (Title) iterator.next();
775 t.removeChangeListener(this);
776 }
777 this.subtitles.clear();
778 fireChartChanged();
779 }
780
781 /**
782 * Removes the specified subtitle and sends a {@link ChartChangeEvent} to
783 * all registered listeners.
784 *
785 * @param title the title.
786 *
787 * @see #addSubtitle(Title)
788 */
789 public void removeSubtitle(Title title) {
790 this.subtitles.remove(title);
791 fireChartChanged();
792 }
793
794 /**
795 * Returns the plot for the chart. The plot is a class responsible for
796 * coordinating the visual representation of the data, including the axes
797 * (if any).
798 *
799 * @return The plot.
800 */
801 public Plot getPlot() {
802 return this.plot;
803 }
804
805 /**
806 * Returns the plot cast as a {@link CategoryPlot}.
807 * <p>
808 * NOTE: if the plot is not an instance of {@link CategoryPlot}, then a
809 * <code>ClassCastException</code> is thrown.
810 *
811 * @return The plot.
812 *
813 * @see #getPlot()
814 */
815 public CategoryPlot getCategoryPlot() {
816 return (CategoryPlot) this.plot;
817 }
818
819 /**
820 * Returns the plot cast as an {@link XYPlot}.
821 * <p>
822 * NOTE: if the plot is not an instance of {@link XYPlot}, then a
823 * <code>ClassCastException</code> is thrown.
824 *
825 * @return The plot.
826 *
827 * @see #getPlot()
828 */
829 public XYPlot getXYPlot() {
830 return (XYPlot) this.plot;
831 }
832
833 /**
834 * Returns a flag that indicates whether or not anti-aliasing is used when
835 * the chart is drawn.
836 *
837 * @return The flag.
838 *
839 * @see #setAntiAlias(boolean)
840 */
841 public boolean getAntiAlias() {
842 Object val = this.renderingHints.get(RenderingHints.KEY_ANTIALIASING);
843 return RenderingHints.VALUE_ANTIALIAS_ON.equals(val);
844 }
845
846 /**
847 * Sets a flag that indicates whether or not anti-aliasing is used when the
848 * chart is drawn.
849 * <P>
850 * Anti-aliasing usually improves the appearance of charts, but is slower.
851 *
852 * @param flag the new value of the flag.
853 *
854 * @see #getAntiAlias()
855 */
856 public void setAntiAlias(boolean flag) {
857
858 Object val = this.renderingHints.get(RenderingHints.KEY_ANTIALIASING);
859 if (val == null) {
860 val = RenderingHints.VALUE_ANTIALIAS_DEFAULT;
861 }
862 if (!flag && RenderingHints.VALUE_ANTIALIAS_OFF.equals(val)
863 || flag && RenderingHints.VALUE_ANTIALIAS_ON.equals(val)) {
864 // no change, do nothing
865 return;
866 }
867 if (flag) {
868 this.renderingHints.put(RenderingHints.KEY_ANTIALIASING,
869 RenderingHints.VALUE_ANTIALIAS_ON);
870 }
871 else {
872 this.renderingHints.put(RenderingHints.KEY_ANTIALIASING,
873 RenderingHints.VALUE_ANTIALIAS_OFF);
874 }
875 fireChartChanged();
876
877 }
878
879 /**
880 * Returns the current value stored in the rendering hints table for
881 * {@link RenderingHints#KEY_TEXT_ANTIALIASING}.
882 *
883 * @return The hint value (possibly <code>null</code>).
884 *
885 * @since 1.0.5
886 *
887 * @see #setTextAntiAlias(Object)
888 */
889 public Object getTextAntiAlias() {
890 return this.renderingHints.get(RenderingHints.KEY_TEXT_ANTIALIASING);
891 }
892
893 /**
894 * Sets the value in the rendering hints table for
895 * {@link RenderingHints#KEY_TEXT_ANTIALIASING} to either
896 * {@link RenderingHints#VALUE_TEXT_ANTIALIAS_ON} or
897 * {@link RenderingHints#VALUE_TEXT_ANTIALIAS_OFF}, then sends a
898 * {@link ChartChangeEvent} to all registered listeners.
899 *
900 * @param flag
901 *
902 * @since 1.0.5
903 *
904 * @see #getTextAntiAlias()
905 * @see #setTextAntiAlias(Object)
906 */
907 public void setTextAntiAlias(boolean flag) {
908 if (flag) {
909 setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
910 }
911 else {
912 setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
913 }
914 }
915
916 /**
917 * Sets the value in the rendering hints table for
918 * {@link RenderingHints#KEY_TEXT_ANTIALIASING} and sends a
919 * {@link ChartChangeEvent} to all registered listeners.
920 *
921 * @param val the new value (<code>null</code> permitted).
922 *
923 * @since 1.0.5
924 *
925 * @see #getTextAntiAlias()
926 * @see #setTextAntiAlias(boolean)
927 */
928 public void setTextAntiAlias(Object val) {
929 this.renderingHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, val);
930 this.notifyListeners(new ChartChangeEvent(this));
931 }
932
933 /**
934 * Returns the paint used for the chart background.
935 *
936 * @return The paint (possibly <code>null</code>).
937 *
938 * @see #setBackgroundPaint(Paint)
939 */
940 public Paint getBackgroundPaint() {
941 return this.backgroundPaint;
942 }
943
944 /**
945 * Sets the paint used to fill the chart background and sends a
946 * {@link ChartChangeEvent} to all registered listeners.
947 *
948 * @param paint the paint (<code>null</code> permitted).
949 *
950 * @see #getBackgroundPaint()
951 */
952 public void setBackgroundPaint(Paint paint) {
953
954 if (this.backgroundPaint != null) {
955 if (!this.backgroundPaint.equals(paint)) {
956 this.backgroundPaint = paint;
957 fireChartChanged();
958 }
959 }
960 else {
961 if (paint != null) {
962 this.backgroundPaint = paint;
963 fireChartChanged();
964 }
965 }
966
967 }
968
969 /**
970 * Returns the background image for the chart, or <code>null</code> if
971 * there is no image.
972 *
973 * @return The image (possibly <code>null</code>).
974 *
975 * @see #setBackgroundImage(Image)
976 */
977 public Image getBackgroundImage() {
978 return this.backgroundImage;
979 }
980
981 /**
982 * Sets the background image for the chart and sends a
983 * {@link ChartChangeEvent} to all registered listeners.
984 *
985 * @param image the image (<code>null</code> permitted).
986 *
987 * @see #getBackgroundImage()
988 */
989 public void setBackgroundImage(Image image) {
990
991 if (this.backgroundImage != null) {
992 if (!this.backgroundImage.equals(image)) {
993 this.backgroundImage = image;
994 fireChartChanged();
995 }
996 }
997 else {
998 if (image != null) {
999 this.backgroundImage = image;
1000 fireChartChanged();
1001 }
1002 }
1003
1004 }
1005
1006 /**
1007 * Returns the background image alignment. Alignment constants are defined
1008 * in the <code>org.jfree.ui.Align</code> class in the JCommon class
1009 * library.
1010 *
1011 * @return The alignment.
1012 *
1013 * @see #setBackgroundImageAlignment(int)
1014 */
1015 public int getBackgroundImageAlignment() {
1016 return this.backgroundImageAlignment;
1017 }
1018
1019 /**
1020 * Sets the background alignment. Alignment options are defined by the
1021 * {@link org.jfree.ui.Align} class.
1022 *
1023 * @param alignment the alignment.
1024 *
1025 * @see #getBackgroundImageAlignment()
1026 */
1027 public void setBackgroundImageAlignment(int alignment) {
1028 if (this.backgroundImageAlignment != alignment) {
1029 this.backgroundImageAlignment = alignment;
1030 fireChartChanged();
1031 }
1032 }
1033
1034 /**
1035 * Returns the alpha-transparency for the chart's background image.
1036 *
1037 * @return The alpha-transparency.
1038 *
1039 * @see #setBackgroundImageAlpha(float)
1040 */
1041 public float getBackgroundImageAlpha() {
1042 return this.backgroundImageAlpha;
1043 }
1044
1045 /**
1046 * Sets the alpha-transparency for the chart's background image.
1047 * Registered listeners are notified that the chart has been changed.
1048 *
1049 * @param alpha the alpha value.
1050 *
1051 * @see #getBackgroundImageAlpha()
1052 */
1053 public void setBackgroundImageAlpha(float alpha) {
1054
1055 if (this.backgroundImageAlpha != alpha) {
1056 this.backgroundImageAlpha = alpha;
1057 fireChartChanged();
1058 }
1059
1060 }
1061
1062 /**
1063 * Returns a flag that controls whether or not change events are sent to
1064 * registered listeners.
1065 *
1066 * @return A boolean.
1067 *
1068 * @see #setNotify(boolean)
1069 */
1070 public boolean isNotify() {
1071 return this.notify;
1072 }
1073
1074 /**
1075 * Sets a flag that controls whether or not listeners receive
1076 * {@link ChartChangeEvent} notifications.
1077 *
1078 * @param notify a boolean.
1079 *
1080 * @see #isNotify()
1081 */
1082 public void setNotify(boolean notify) {
1083 this.notify = notify;
1084 // if the flag is being set to true, there may be queued up changes...
1085 if (notify) {
1086 notifyListeners(new ChartChangeEvent(this));
1087 }
1088 }
1089
1090 /**
1091 * Draws the chart on a Java 2D graphics device (such as the screen or a
1092 * printer).
1093 * <P>
1094 * This method is the focus of the entire JFreeChart library.
1095 *
1096 * @param g2 the graphics device.
1097 * @param area the area within which the chart should be drawn.
1098 */
1099 public void draw(Graphics2D g2, Rectangle2D area) {
1100 draw(g2, area, null, null);
1101 }
1102
1103 /**
1104 * Draws the chart on a Java 2D graphics device (such as the screen or a
1105 * printer). This method is the focus of the entire JFreeChart library.
1106 *
1107 * @param g2 the graphics device.
1108 * @param area the area within which the chart should be drawn.
1109 * @param info records info about the drawing (null means collect no info).
1110 */
1111 public void draw(Graphics2D g2, Rectangle2D area, ChartRenderingInfo info) {
1112 draw(g2, area, null, info);
1113 }
1114
1115 /**
1116 * Draws the chart on a Java 2D graphics device (such as the screen or a
1117 * printer).
1118 * <P>
1119 * This method is the focus of the entire JFreeChart library.
1120 *
1121 * @param g2 the graphics device.
1122 * @param chartArea the area within which the chart should be drawn.
1123 * @param anchor the anchor point (in Java2D space) for the chart
1124 * (<code>null</code> permitted).
1125 * @param info records info about the drawing (null means collect no info).
1126 */
1127 public void draw(Graphics2D g2,
1128 Rectangle2D chartArea, Point2D anchor,
1129 ChartRenderingInfo info) {
1130
1131 notifyListeners(new ChartProgressEvent(this, this,
1132 ChartProgressEvent.DRAWING_STARTED, 0));
1133
1134 // record the chart area, if info is requested...
1135 if (info != null) {
1136 info.clear();
1137 info.setChartArea(chartArea);
1138 }
1139
1140 // ensure no drawing occurs outside chart area...
1141 Shape savedClip = g2.getClip();
1142 g2.clip(chartArea);
1143
1144 g2.addRenderingHints(this.renderingHints);
1145
1146 // draw the chart background...
1147 if (this.backgroundPaint != null) {
1148 g2.setPaint(this.backgroundPaint);
1149 g2.fill(chartArea);
1150 }
1151
1152 if (this.backgroundImage != null) {
1153 Composite originalComposite = g2.getComposite();
1154 g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
1155 this.backgroundImageAlpha));
1156 Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0,
1157 this.backgroundImage.getWidth(null),
1158 this.backgroundImage.getHeight(null));
1159 Align.align(dest, chartArea, this.backgroundImageAlignment);
1160 g2.drawImage(this.backgroundImage, (int) dest.getX(),
1161 (int) dest.getY(), (int) dest.getWidth(),
1162 (int) dest.getHeight(), null);
1163 g2.setComposite(originalComposite);
1164 }
1165
1166 if (isBorderVisible()) {
1167 Paint paint = getBorderPaint();
1168 Stroke stroke = getBorderStroke();
1169 if (paint != null && stroke != null) {
1170 Rectangle2D borderArea = new Rectangle2D.Double(
1171 chartArea.getX(), chartArea.getY(),
1172 chartArea.getWidth() - 1.0, chartArea.getHeight()
1173 - 1.0);
1174 g2.setPaint(paint);
1175 g2.setStroke(stroke);
1176 g2.draw(borderArea);
1177 }
1178 }
1179
1180 // draw the title and subtitles...
1181 Rectangle2D nonTitleArea = new Rectangle2D.Double();
1182 nonTitleArea.setRect(chartArea);
1183 this.padding.trim(nonTitleArea);
1184
1185 EntityCollection entities = null;
1186 if (info != null) {
1187 entities = info.getEntityCollection();
1188 }
1189 if (this.title != null) {
1190 EntityCollection e = drawTitle(this.title, g2, nonTitleArea,
1191 (entities != null));
1192 if (e != null) {
1193 entities.addAll(e);
1194 }
1195 }
1196
1197 Iterator iterator = this.subtitles.iterator();
1198 while (iterator.hasNext()) {
1199 Title currentTitle = (Title) iterator.next();
1200 EntityCollection e = drawTitle(currentTitle, g2, nonTitleArea,
1201 (entities != null));
1202 if (e != null) {
1203 entities.addAll(e);
1204 }
1205 }
1206
1207 Rectangle2D plotArea = nonTitleArea;
1208
1209 // draw the plot (axes and data visualisation)
1210 PlotRenderingInfo plotInfo = null;
1211 if (info != null) {
1212 plotInfo = info.getPlotInfo();
1213 }
1214 this.plot.draw(g2, plotArea, anchor, null, plotInfo);
1215
1216 g2.setClip(savedClip);
1217
1218 notifyListeners(new ChartProgressEvent(this, this,
1219 ChartProgressEvent.DRAWING_FINISHED, 100));
1220 }
1221
1222 /**
1223 * Creates a rectangle that is aligned to the frame.
1224 *
1225 * @param dimensions
1226 * @param frame
1227 * @param hAlign
1228 * @param vAlign
1229 *
1230 * @return A rectangle.
1231 */
1232 private Rectangle2D createAlignedRectangle2D(Size2D dimensions,
1233 Rectangle2D frame, HorizontalAlignment hAlign,
1234 VerticalAlignment vAlign) {
1235 double x = Double.NaN;
1236 double y = Double.NaN;
1237 if (hAlign == HorizontalAlignment.LEFT) {
1238 x = frame.getX();
1239 }
1240 else if (hAlign == HorizontalAlignment.CENTER) {
1241 x = frame.getCenterX() - (dimensions.width / 2.0);
1242 }
1243 else if (hAlign == HorizontalAlignment.RIGHT) {
1244 x = frame.getMaxX() - dimensions.width;
1245 }
1246 if (vAlign == VerticalAlignment.TOP) {
1247 y = frame.getY();
1248 }
1249 else if (vAlign == VerticalAlignment.CENTER) {
1250 y = frame.getCenterY() - (dimensions.height / 2.0);
1251 }
1252 else if (vAlign == VerticalAlignment.BOTTOM) {
1253 y = frame.getMaxY() - dimensions.height;
1254 }
1255
1256 return new Rectangle2D.Double(x, y, dimensions.width,
1257 dimensions.height);
1258 }
1259
1260 /**
1261 * Draws a title. The title should be drawn at the top, bottom, left or
1262 * right of the specified area, and the area should be updated to reflect
1263 * the amount of space used by the title.
1264 *
1265 * @param t the title (<code>null</code> not permitted).
1266 * @param g2 the graphics device (<code>null</code> not permitted).
1267 * @param area the chart area, excluding any existing titles
1268 * (<code>null</code> not permitted).
1269 * @param entities a flag that controls whether or not an entity
1270 * collection is returned for the title.
1271 *
1272 * @return An entity collection for the title (possibly <code>null</code>).
1273 */
1274 protected EntityCollection drawTitle(Title t, Graphics2D g2,
1275 Rectangle2D area, boolean entities) {
1276
1277 if (t == null) {
1278 throw new IllegalArgumentException("Null 't' argument.");
1279 }
1280 if (area == null) {
1281 throw new IllegalArgumentException("Null 'area' argument.");
1282 }
1283 Rectangle2D titleArea = new Rectangle2D.Double();
1284 RectangleEdge position = t.getPosition();
1285 double ww = area.getWidth();
1286 if (ww <= 0.0) {
1287 return null;
1288 }
1289 double hh = area.getHeight();
1290 if (hh <= 0.0) {
1291 return null;
1292 }
1293 RectangleConstraint constraint = new RectangleConstraint(ww,
1294 new Range(0.0, ww), LengthConstraintType.RANGE, hh,
1295 new Range(0.0, hh), LengthConstraintType.RANGE);
1296 Object retValue = null;
1297 BlockParams p = new BlockParams();
1298 p.setGenerateEntities(entities);
1299 if (position == RectangleEdge.TOP) {
1300 Size2D size = t.arrange(g2, constraint);
1301 titleArea = createAlignedRectangle2D(size, area,
1302 t.getHorizontalAlignment(), VerticalAlignment.TOP);
1303 retValue = t.draw(g2, titleArea, p);
1304 area.setRect(area.getX(), Math.min(area.getY() + size.height,
1305 area.getMaxY()), area.getWidth(), Math.max(area.getHeight()
1306 - size.height, 0));
1307 }
1308 else if (position == RectangleEdge.BOTTOM) {
1309 Size2D size = t.arrange(g2, constraint);
1310 titleArea = createAlignedRectangle2D(size, area,
1311 t.getHorizontalAlignment(), VerticalAlignment.BOTTOM);
1312 retValue = t.draw(g2, titleArea, p);
1313 area.setRect(area.getX(), area.getY(), area.getWidth(),
1314 area.getHeight() - size.height);
1315 }
1316 else if (position == RectangleEdge.RIGHT) {
1317 Size2D size = t.arrange(g2, constraint);
1318 titleArea = createAlignedRectangle2D(size, area,
1319 HorizontalAlignment.RIGHT, t.getVerticalAlignment());
1320 retValue = t.draw(g2, titleArea, p);
1321 area.setRect(area.getX(), area.getY(), area.getWidth()
1322 - size.width, area.getHeight());
1323 }
1324
1325 else if (position == RectangleEdge.LEFT) {
1326 Size2D size = t.arrange(g2, constraint);
1327 titleArea = createAlignedRectangle2D(size, area,
1328 HorizontalAlignment.LEFT, t.getVerticalAlignment());
1329 retValue = t.draw(g2, titleArea, p);
1330 area.setRect(area.getX() + size.width, area.getY(), area.getWidth()
1331 - size.width, area.getHeight());
1332 }
1333 else {
1334 throw new RuntimeException("Unrecognised title position.");
1335 }
1336 EntityCollection result = null;
1337 if (retValue instanceof EntityBlockResult) {
1338 EntityBlockResult ebr = (EntityBlockResult) retValue;
1339 result = ebr.getEntityCollection();
1340 }
1341 return result;
1342 }
1343
1344 /**
1345 * Creates and returns a buffered image into which the chart has been drawn.
1346 *
1347 * @param width the width.
1348 * @param height the height.
1349 *
1350 * @return A buffered image.
1351 */
1352 public BufferedImage createBufferedImage(int width, int height) {
1353 return createBufferedImage(width, height, null);
1354 }
1355
1356 /**
1357 * Creates and returns a buffered image into which the chart has been drawn.
1358 *
1359 * @param width the width.
1360 * @param height the height.
1361 * @param info carries back chart state information (<code>null</code>
1362 * permitted).
1363 *
1364 * @return A buffered image.
1365 */
1366 public BufferedImage createBufferedImage(int width, int height,
1367 ChartRenderingInfo info) {
1368 return createBufferedImage(width, height, BufferedImage.TYPE_INT_RGB,
1369 info);
1370 }
1371
1372 /**
1373 * Creates and returns a buffered image into which the chart has been drawn.
1374 *
1375 * @param width the width.
1376 * @param height the height.
1377 * @param imageType the image type.
1378 * @param info carries back chart state information (<code>null</code>
1379 * permitted).
1380 *
1381 * @return A buffered image.
1382 */
1383 public BufferedImage createBufferedImage(int width, int height,
1384 int imageType,
1385 ChartRenderingInfo info) {
1386 BufferedImage image = new BufferedImage(width, height, imageType);
1387 Graphics2D g2 = image.createGraphics();
1388 draw(g2, new Rectangle2D.Double(0, 0, width, height), null, info);
1389 g2.dispose();
1390 return image;
1391 }
1392
1393 /**
1394 * Creates and returns a buffered image into which the chart has been drawn.
1395 *
1396 * @param imageWidth the image width.
1397 * @param imageHeight the image height.
1398 * @param drawWidth the width for drawing the chart (will be scaled to
1399 * fit image).
1400 * @param drawHeight the height for drawing the chart (will be scaled to
1401 * fit image).
1402 * @param info optional object for collection chart dimension and entity
1403 * information.
1404 *
1405 * @return A buffered image.
1406 */
1407 public BufferedImage createBufferedImage(int imageWidth,
1408