KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > graph > Axis


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.graph;
8
9 import java.awt.Dimension JavaDoc;
10 import java.awt.Font JavaDoc;
11 import java.text.DateFormat JavaDoc;
12 import java.text.DecimalFormat JavaDoc;
13 import java.text.Format JavaDoc;
14 import java.text.NumberFormat JavaDoc;
15 import java.util.Date JavaDoc;
16
17 import org.ejtools.graph.renderer.AbstractGraphRenderer;
18
19 /**
20  * @author Laurent Etiemble
21  * @version $Revision: 1.8 $
22  * @todo Javadoc to complete
23  */

24 public abstract class Axis extends AbstractGraphRenderer
25 {
26    /** Description of the Field */
27    protected Dimension JavaDoc dimension = null;
28    /** Description of the Field */
29    protected Format JavaDoc format = new DecimalFormat JavaDoc("0");
30    /** Description of the Field */
31    protected int orientation;
32    /** Description of the Field */
33    protected int position;
34    /** Description of the Field */
35    protected Range range = new Range(0.0d, 1.0d);
36    /** Description of the Field */
37    protected static Font JavaDoc FONT = new Font JavaDoc("Courrier", Font.PLAIN, 10);
38    /** Description of the Field */
39    public final static int BOTTOM = 4;
40    /** Description of the Field */
41    public final static int HORIZONTAL = 0;
42    /** Description of the Field */
43    public final static int LEFT = 2;
44    /** Description of the Field */
45    public final static int RIGHT = 3;
46    /** Description of the Field */
47    public final static int TOP = 5;
48    /** Description of the Field */
49    public final static int VERTICAL = 1;
50
51
52    /** Constructor for Axis. */
53    public Axis() { }
54
55
56    /**
57     * Returns the format.
58     *
59     * @return Format
60     */

61    public Format JavaDoc getFormat()
62    {
63       return format;
64    }
65
66
67    /**
68     * Gets the formated attribute of the Axis object
69     *
70     * @param value Description of the Parameter
71     * @return The formated value
72     */

73    public String JavaDoc getFormated(double value)
74    {
75       if (this.format instanceof NumberFormat JavaDoc)
76       {
77          return ((NumberFormat JavaDoc) this.format).format(value);
78       }
79       if (this.format instanceof DateFormat JavaDoc)
80       {
81          return ((DateFormat JavaDoc) this.format).format(new Date JavaDoc((long) value));
82       }
83       return null;
84    }
85
86
87    /**
88     * @return The minimumSize value
89     */

90    public Dimension JavaDoc getMinimumSize()
91    {
92       if (this.dimension == null)
93       {
94          this.dimension = new Dimension JavaDoc(FONT.getSize() * 2, FONT.getSize() * 2);
95       }
96       return dimension;
97    }
98
99
100    /**
101     * Returns the orientation.
102     *
103     * @return int
104     */

105    public int getOrientation()
106    {
107       return orientation;
108    }
109
110
111    /**
112     * Returns the position.
113     *
114     * @return int
115     */

116    public int getPosition()
117    {
118       return position;
119    }
120
121
122    /**
123     * @return The preferredSize value
124     */

125    public Dimension JavaDoc getPreferredSize()
126    {
127       return this.getMinimumSize();
128    }
129
130
131    /**
132     * Returns the range.
133     *
134     * @return Range
135     */

136    public Range getRange()
137    {
138       return range;
139    }
140
141
142    /**
143     * Sets the format.
144     *
145     * @param format The format to set
146     */

147    public void setFormat(Format JavaDoc format)
148    {
149       this.format = format;
150    }
151
152
153    /**
154     * Sets the position.
155     *
156     * @param position The position to set
157     */

158    public void setPosition(int position)
159    {
160       this.position = position;
161    }
162
163
164    /**
165     * Sets the range.
166     *
167     * @param range The new range value
168     */

169    public void setRange(Range range)
170    {
171       this.range = range;
172    }
173 }
174
Popular Tags