KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > LegendTitle


1 /* ======================================
2  * JFreeChart : a free Java chart library
3  * ======================================
4  *
5  * Project Info: http://www.jfree.org/jfreechart/index.html
6  * Project Lead: David Gilbert (david.gilbert@object-refinery.com);
7  *
8  * (C) Copyright 2000-2003, by Object Refinery Limited and Contributors.
9  *
10  * This library is free software; you can redistribute it and/or modify it under the terms
11  * of the GNU Lesser General Public License as published by the Free Software Foundation;
12  * either version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License along with this
19  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  *
22  * ----------------
23  * LegendTitle.java
24  * ----------------
25  * (C) Copyright 2002, 2003, by Object Refinery Limited.
26  *
27  * Original Author: David Gilbert (for Object Refinery Limited);
28  * Contributor(s): -;
29  *
30  * $Id: LegendTitle.java,v 1.3 2003/10/30 09:53:06 mungady Exp $
31  *
32  * Changes
33  * -------
34  * 07-Feb-2002 : Version 1. INCOMPLETE, PLEASE IGNORE. (DG);
35  */

36
37 package org.jfree.chart;
38
39 import java.awt.Graphics2D JavaDoc;
40 import java.awt.geom.Rectangle2D JavaDoc;
41
42 /**
43  * A chart title that displays a legend for the data in the chart.
44  * <P>
45  * The title can be populated with legend items manually, or you can assign a
46  * reference to the chart, in which case the legend items will be automatically
47  * created to match the dataset.
48  *
49  * @author David Gilbert
50  */

51 public abstract class LegendTitle extends AbstractTitle {
52
53     /** A container for the legend items. */
54     private LegendItemCollection items;
55
56     /**
57      * The object responsible for arranging the legend items to fit in whatever
58      * space is available.
59      */

60     //private LegendItemLayout layout;
61

62     /**
63      * Constructs a new, empty LegendTitle.
64      */

65     public LegendTitle() {
66         this(new StandardLegendItemLayout(0, 0.0));
67     }
68
69     /**
70      * Creates a new legend title.
71      *
72      * @param layout the layout.
73      */

74     public LegendTitle(LegendItemLayout layout) {
75         //this.layout = layout;
76
}
77
78     /**
79      * Adds a legend item to the LegendTitle.
80      *
81      * @param item the item to add.
82      */

83     public void addLegendItem(LegendItem item) {
84         items.add(item);
85     }
86
87     /**
88      * Draws the title on a Java 2D graphics device (such as the screen or a
89      * printer). Currently it does nothing.
90      *
91      * @param g2 the graphics device.
92      * @param area the area for the chart and all its titles.
93      */

94     public void draw(Graphics2D JavaDoc g2, Rectangle2D JavaDoc area) {
95
96         // if the position is TOP or BOTTOM then the constraint is on the width
97
// so layout the items accordingly
98

99         // if the position is LEFT or RIGHT then the constraint is on the height
100
// so layout the items accordingly
101

102         // get the height and width of the items, then add the space around the outside
103
// work out where to start drawing...
104
// and draw...
105
}
106
107 }
108
Popular Tags