KickJava   Java API By Example, From Geeks To Geeks.

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


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
10 /**
11  * Description of the Class
12  *
13  * @author Laurent Etiemble
14  * @version $Revision: 1.7 $
15  * @todo Javadoc to complete
16  */

17 public class Range
18 {
19    /** Description of the Field */
20    protected double max = 0.0f;
21    /** Description of the Field */
22    protected double min = 0.0f;
23    /** Description of the Field */
24    public final static int X_AXIS = 0;
25    /** Description of the Field */
26    public final static int Y_AXIS = 1;
27
28
29    /**
30     *Constructor for the Range object
31     *
32     * @param min Description of the Parameter
33     * @param max Description of the Parameter
34     */

35    public Range(double min, double max)
36    {
37       this.min = (double) min;
38       this.max = (double) max;
39    }
40
41
42    /**
43     * Description of the Method
44     *
45     * @param range Description of the Parameter
46     * @return Description of the Return Value
47     */

48    public Range compose(Range range)
49    {
50       double nmin = Math.min(this.min, range.min);
51       double nmax = Math.max(this.max, range.max);
52
53       return new Range(nmin, nmax);
54    }
55
56
57    /**
58     * Gets the max attribute of the Range object
59     *
60     * @return The max value
61     */

62    public double getMax()
63    {
64       return this.max;
65    }
66
67
68    /**
69     * Gets the min attribute of the Range object
70     *
71     * @return The min value
72     */

73    public double getMin()
74    {
75       return this.min;
76    }
77
78
79    /**
80     * Description of the Method
81     *
82     * @param value Description of the Parameter
83     */

84    public synchronized void put(double value)
85    {
86       this.min = Math.min(this.min, value);
87       this.max = Math.max(this.max, value);
88    }
89
90
91    /**
92     * Sets the max.
93     *
94     * @param max The max to set
95     */

96    public void setMax(double max)
97    {
98       this.max = max;
99    }
100
101
102    /**
103     * Sets the min.
104     *
105     * @param min The min to set
106     */

107    public void setMin(double min)
108    {
109       this.min = min;
110    }
111
112
113    /**
114     * Description of the Method
115     *
116     * @return Description of the Return Value
117     */

118    public String JavaDoc toString()
119    {
120       return "[" + getMin() + " to " + getMax() + "]";
121    }
122 }
123
Popular Tags