KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > monitorenter > gui > chart > rangepolicies > RangePolicyHighestValuesForcedMin


1 /*
2  * RangePolicyHighestValuesForcedMin.java,
3  * range policy that shows the highest values and forces to show empty
4  * space towards the first hightest values.
5  *
6  * Copyright (C) 2006 Achim Westermann, Achim.Westermann@gmx.de
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * If you modify or optimize the code in a useful way please let me know.
23  * Achim.Westermann@gmx.de
24  */

25 package info.monitorenter.gui.chart.rangepolicies;
26
27 import info.monitorenter.util.Range;
28
29 /**
30  * Range policy implementation that will show a viewport with only the highest
31  * values that are in the range of maximum - x which also forces the lower bound
32  * to be shown if no data towards this bound exists.
33  * <p>
34  *
35  * @author zoola
36  *
37  * @author <a HREF="mailto:Achim.Westermann@gmx.de">Achim Westermann </a>
38  *
39  * @version $Revision: 1.2 $
40  *
41  */

42 public final class RangePolicyHighestValuesForcedMin extends ARangePolicy {
43
44   /** The value range for the highest values to show. */
45   private double m_highestValueRangeToShow;
46
47   /**
48    * Constructor with a range and the value range for the highest values to show
49    * only.
50    * <p>
51    *
52    * @param range
53    * unused, maximum bound is always returned.
54    *
55    * @param highestValueRangeToShow
56    * the value range for the highest values to show.
57    */

58   public RangePolicyHighestValuesForcedMin(final Range range, final double highestValueRangeToShow) {
59     super(range);
60     this.m_highestValueRangeToShow = highestValueRangeToShow;
61   }
62
63   /**
64    * Returns the maximum of the chart always.
65    * <p>
66    *
67    * @return Returns the maximum of the chart always.
68    *
69    * @param chartMin
70    * ignored.
71    *
72    * @param chartMax
73    * returned always.
74    *
75    * @see info.monitorenter.gui.chart.IRangePolicy#getMax(double, double)
76    */

77   public double getMax(final double chartMin, final double chartMax) {
78     return chartMax;
79   }
80
81   /**
82    * Returns the maximum of the chart - interal highestValueRangeToShow.
83    * <p>
84    *
85    *
86    * @param chartMin
87    * unused: the lower bound is always controlled by max - internal
88    * highesValueRangeToShow.
89    *
90    * @param chartMax
91    * upper bound to compute down to the start of the latest highest
92    * values.
93    *
94    * @return the maximum of the chart - interal highestValueRangeToShow.
95    *
96    * @see info.monitorenter.gui.chart.IRangePolicy#getMin(double, double)
97    */

98   public double getMin(final double chartMin, final double chartMax) {
99     return chartMax - this.m_highestValueRangeToShow;
100   }
101 }
102
Popular Tags