KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > axis > AxisCollection


1 /* ===========================================================
2  * JFreeChart : a free chart library for the Java(tm) platform
3  * ===========================================================
4  *
5  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jfreechart/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this library; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
24  * in the United States and other countries.]
25  *
26  * -------------------
27  * AxisCollection.java
28  * -------------------
29  * (C) Copyright 2003-2005, by Object Refinery Limited.
30  *
31  * Original Author: David Gilbert (for Object Refinery Limited);
32  * Contributor(s): -;
33  *
34  * $Id: AxisCollection.java,v 1.2 2005/02/28 11:45:17 mungady Exp $
35  *
36  * Changes
37  * -------
38  * 03-Nov-2003 : Added standard header (DG);
39  *
40  */

41
42 package org.jfree.chart.axis;
43
44 import java.util.List JavaDoc;
45
46 import org.jfree.ui.RectangleEdge;
47
48 /**
49  * A collection of axes that have been assigned to the TOP, BOTTOM, LEFT or
50  * RIGHT of a chart. This class is used internally by JFreeChart, you won't
51  * normally need to use it yourself.
52  */

53 public class AxisCollection {
54     
55     /** The axes that need to be drawn at the top of the plot area. */
56     private List JavaDoc axesAtTop;
57     
58     /** The axes that need to be drawn at the bottom of the plot area. */
59     private List JavaDoc axesAtBottom;
60     
61     /** The axes that need to be drawn at the left of the plot area. */
62     private List JavaDoc axesAtLeft;
63     
64     /** The axes that need to be drawn at the right of the plot area. */
65     private List JavaDoc axesAtRight;
66    
67     /**
68      * Creates a new empty collection.
69      */

70     public AxisCollection() {
71         this.axesAtTop = new java.util.ArrayList JavaDoc();
72         this.axesAtBottom = new java.util.ArrayList JavaDoc();
73         this.axesAtLeft = new java.util.ArrayList JavaDoc();
74         this.axesAtRight = new java.util.ArrayList JavaDoc();
75     }
76     
77     /**
78      * Returns a list of the axes (if any) that need to be drawn at the top of
79      * the plot area.
80      *
81      * @return A list of axes.
82      */

83     public List JavaDoc getAxesAtTop() {
84         return this.axesAtTop;
85     }
86     
87    /**
88     * Returns a list of the axes (if any) that need to be drawn at the bottom
89     * of the plot area.
90     *
91     * @return A list of axes.
92     */

93    public List JavaDoc getAxesAtBottom() {
94         return this.axesAtBottom;
95     }
96     
97     /**
98      * Returns a list of the axes (if any) that need to be drawn at the left
99      * of the plot area.
100      *
101      * @return A list of axes.
102      */

103     public List JavaDoc getAxesAtLeft() {
104         return this.axesAtLeft;
105     }
106     
107     /**
108     * Returns a list of the axes (if any) that need to be drawn at the right
109     * of the plot area.
110     *
111     * @return A list of axes.
112     */

113     public List JavaDoc getAxesAtRight() {
114         return this.axesAtRight;
115     }
116     
117     /**
118      * Adds an axis to the collection.
119      *
120      * @param axis the axis (<code>null</code> not permitted).
121      * @param edge the edge of the plot that the axis should be drawn on
122      * (<code>null</code> not permitted).
123      */

124     public void add(Axis axis, RectangleEdge edge) {
125         if (axis == null) {
126             throw new IllegalArgumentException JavaDoc("Null 'axis' argument.");
127         }
128         if (edge == null) {
129             throw new IllegalArgumentException JavaDoc("Null 'edge' argument.");
130         }
131         if (edge == RectangleEdge.TOP) {
132             this.axesAtTop.add(axis);
133         }
134         else if (edge == RectangleEdge.BOTTOM) {
135             this.axesAtBottom.add(axis);
136         }
137         else if (edge == RectangleEdge.LEFT) {
138             this.axesAtLeft.add(axis);
139         }
140         else if (edge == RectangleEdge.RIGHT) {
141             this.axesAtRight.add(axis);
142         }
143     }
144
145 }
146
Popular Tags