KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jrobin > graph > GridRange


1 /* ============================================================
2  * JRobin : Pure java implementation of RRDTool's functionality
3  * ============================================================
4  *
5  * Project Info: http://www.jrobin.org
6  * Project Lead: Sasa Markovic (saxon@jrobin.org)
7  *
8  * Developers: Sasa Markovic (saxon@jrobin.org)
9  * Arne Vandamme (cobralord@jrobin.org)
10  *
11  * (C) Copyright 2003, by Sasa Markovic.
12  *
13  * This library is free software; you can redistribute it and/or modify it under the terms
14  * of the GNU Lesser General Public License as published by the Free Software Foundation;
15  * either version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
18  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  * See the GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License along with this
22  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23  * Boston, MA 02111-1307, USA.
24  */

25 package org.jrobin.graph;
26
27 import org.jrobin.core.XmlWriter;
28
29 /**
30  * <p>Represents Y grid specifications for the chart area.</p>
31  *
32  * @author Arne Vandamme (cobralord@jrobin.org)
33  */

34 class GridRange
35 {
36     // ================================================================
37
// -- Members
38
// ================================================================
39
private double lower = Double.NaN;
40     private double upper = Double.NaN;
41     private boolean rigid = false;
42     
43     
44     // ================================================================
45
// -- Constructors
46
// ================================================================
47
/**
48      * Constructs a <code>GridRange</code> object based on a lower and upper value.
49      * @param lower Lower value of the grid range.
50      * @param upper Upper value of the grid range.
51      */

52     GridRange( double lower, double upper )
53     {
54         this.lower = lower;
55         this.upper = upper;
56     }
57     
58     /**
59      * Constructs a <code>GridRange</code> object based on a lower and upper value and a rigid specification.
60      * If a grid is specified as rigid, then the specified range of lower/upper value will be used as graph boundaries.
61      * If a grid is not rigid, then the boundaries might be scaled to allow for the complete necessary range of values:
62      * if the maximum Y value is higher than upper value, then upper value will be raised, reverse with the lower value.
63      * A non-rigid grid will always at least display a range of lower/upper value, a rigid grid will always display the range
64      * of lower and upper value, no more and no less.
65      * @param lower Lower value of the grid range.
66      * @param upper Upper value of the grid range.
67      * @param rigid True if the grid is rigid, false if not (default: false).
68      */

69     GridRange( double lower, double upper, boolean rigid )
70     {
71         this.lower = lower;
72         this.upper = upper;
73         this.rigid = rigid;
74     }
75     
76     
77     // ================================================================
78
// -- Protected methods
79
// ================================================================
80
double getLowerValue() {
81         return lower;
82     }
83     
84     double getUpperValue() {
85         return upper;
86     }
87     
88     boolean isRigid() {
89         return rigid;
90     }
91
92     void exportXmlTemplate(XmlWriter xml) {
93         xml.startTag("grid_range");
94         xml.writeTag("lower", getLowerValue());
95         xml.writeTag("upper", getUpperValue());
96         xml.writeTag("rigid", isRigid());
97         xml.closeTag(); // grid_range
98
}
99 }
100
Popular Tags