KickJava   Java API By Example, From Geeks To Geeks.

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


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  * AxisState.java
28  * --------------
29  * (C) Copyright 2003, 2004, by Object Refinery Limited and Contributors.
30  *
31  * Original Author: David Gilbert (for Object Refinery Limited);
32  * Contributor(s): -;
33  *
34  * $Id: AxisState.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  * 07-Nov-2003 : Added 'max' attribute (DG);
40  *
41  */

42
43 package org.jfree.chart.axis;
44
45 import java.util.List JavaDoc;
46
47 import org.jfree.ui.RectangleEdge;
48
49 /**
50  * Instances of this class are used to carry state information for an axis
51  * during the drawing process. By retaining this information in a separate
52  * object, it is possible for multiple threads to draw the same axis to
53  * different output targets (each drawing will maintain separate state
54  * information).
55  */

56 public class AxisState {
57
58     /** The cursor position. */
59     private double cursor;
60     
61     /** The axis ticks. */
62     private List JavaDoc ticks;
63     
64     /** The maximum width/height. */
65     private double max;
66     
67     /**
68      * Creates a new axis state.
69      */

70     public AxisState() {
71         this(0.0);
72     }
73     
74     /**
75      * Creates a new axis state.
76      *
77      * @param cursor the cursor.
78      */

79     public AxisState(double cursor) {
80         this.cursor = cursor;
81         this.ticks = new java.util.ArrayList JavaDoc();
82     }
83     
84     /**
85      * Returns the cursor position.
86      *
87      * @return The cursor position.
88      */

89     public double getCursor() {
90         return this.cursor;
91     }
92
93     /**
94      * Sets the cursor position.
95      *
96      * @param cursor the cursor position.
97      */

98     public void setCursor(double cursor) {
99         this.cursor = cursor;
100     }
101     
102     /**
103      * Moves the cursor outwards by the specified number of units.
104      *
105      * @param units the units.
106      * @param edge the edge.
107      */

108     public void moveCursor(double units, RectangleEdge edge) {
109         if (edge == RectangleEdge.TOP) {
110             cursorUp(units);
111         }
112         else if (edge == RectangleEdge.BOTTOM) {
113             cursorDown(units);
114         }
115         else if (edge == RectangleEdge.LEFT) {
116             cursorLeft(units);
117         }
118         else if (edge == RectangleEdge.RIGHT) {
119             cursorRight(units);
120         }
121     }
122     
123     /**
124      * Moves the cursor up by the specified number of Java 2D units.
125      *
126      * @param units the units.
127      */

128     public void cursorUp(double units) {
129         this.cursor = this.cursor - units;
130     }
131     
132     /**
133      * Moves the cursor down by the specified number of Java 2D units.
134      *
135      * @param units the units.
136      */

137     public void cursorDown(double units) {
138         this.cursor = this.cursor + units;
139     }
140     
141     /**
142      * Moves the cursor left by the specified number of Java 2D units.
143      *
144      * @param units the units.
145      */

146     public void cursorLeft(double units) {
147         this.cursor = this.cursor - units;
148     }
149     
150     /**
151      * Moves the cursor right by the specified number of Java 2D units.
152      *
153      * @param units the units.
154      */

155     public void cursorRight(double units) {
156         this.cursor = this.cursor + units;
157     }
158     
159     /**
160      * Returns the list of ticks.
161      *
162      * @return The list of ticks.
163      */

164     public List JavaDoc getTicks() {
165         return this.ticks;
166     }
167     
168     /**
169      * Sets the list of ticks.
170      *
171      * @param ticks the ticks.
172      */

173     public void setTicks(List JavaDoc ticks) {
174         this.ticks = ticks;
175     }
176     
177     /**
178      * Returns the maximum width/height.
179      *
180      * @return The maximum width/height.
181      */

182     public double getMax() {
183         return this.max;
184     }
185     
186     /**
187      * Sets the maximum width/height.
188      *
189      * @param max the maximum width/height.
190      */

191     public void setMax(double max) {
192         this.max = max;
193     }
194 }
195
Popular Tags