KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > monitorenter > gui > chart > IAxis


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

23 package info.monitorenter.gui.chart;
24
25 import info.monitorenter.gui.chart.AAxis.Chart2DDataAccessor;
26 import info.monitorenter.gui.chart.labelformatters.ALabelFormatter;
27 import info.monitorenter.util.Range;
28
29 import java.beans.PropertyChangeListener JavaDoc;
30
31 /**
32  * Interface for an axis of the {@link info.monitorenter.gui.chart.Chart2D}.
33  * <p>
34  *
35  * @author <a HREF="mailto:Achim.Westermann@gmx.de">Achim Westermann</a>
36  *
37  *
38  * @version $Revision: 1.4 $
39  */

40 public interface IAxis {
41
42   /**
43    * Add a listener for the given property.
44    * <p>
45    *
46    * The following {@link java.beans.PropertyChangeEvent} types should be fired
47    * to listeners:<br>
48    *
49    * <table border="0">
50    * <tr>
51    * <th><code>getPropertyName()</code></th>
52    * <th><code>getSource()</code></th>
53    * <th><code>getOldValue()</code></th>
54    * <th><code>getNewValue()</code></th>
55    * </tr>
56    * <tr>
57    * <td><code>{@link info.monitorenter.gui.chart.IAxis#PROPERTY_RANGEPOLICY}</code></td>
58    * <td><code>{@link IAxis}</code> that changed</td>
59    * <td><code>{@link IRangePolicy}</code>, the old value</td>
60    * <td><code>{@link IRangePolicy}</code>, the new value</td>
61    * </tr>
62    * <tr>
63    * <td><code>{@link info.monitorenter.gui.chart.IAxis#PROPERTY_PAINTGRID}</code></td>
64    * <td><code>{@link IAxis}</code> that changed</td>
65    * <td><code>{@link Boolean}</code>, the old value</td>
66    * <td><code>{@link Boolean}</code>, the new value</td>
67    * </tr>
68    * </table>
69    *
70    * @param propertyName
71    * the property to be informed about changes.
72    *
73    * @param listener
74    * the listener that will be informed.
75    */

76   public void addPropertyChangeListener(String JavaDoc propertyName, PropertyChangeListener JavaDoc listener);
77
78   /** Constant for a {@link java.beans.PropertyChangeEvent} of the range policy. */
79   public static final String JavaDoc PROPERTY_RANGEPOLICY = "axis.rangepolicy";
80
81   /** Constant for a {@link java.beans.PropertyChangeEvent} of the paint grid flag. */
82   public static final String JavaDoc PROPERTY_PAINTGRID = "axis.paintgrid";
83
84   /**
85    * Returns the accessor to the chart.
86    * <p>
87    *
88    * @return the accessor to the chart.
89    */

90   public abstract Chart2DDataAccessor getAccessor();
91
92   /**
93    * Returns the formatter for labels.
94    * <p>
95    *
96    * @return the formatter for labels.
97    */

98   public abstract ILabelFormatter getFormatter();
99
100   /**
101    * Get the major tick spacing for label generation.
102    * <p>
103    *
104    * @see #setMajorTickSpacing(double)
105    *
106    */

107
108   public abstract double getMajorTickSpacing();
109
110   /**
111    * Get the minor tick spacing for label generation.
112    * <p>
113    *
114    * @return he minor tick spacing for label generation.
115    *
116    * @see #setMinorTickSpacing(double)
117    *
118    */

119   public abstract double getMinorTickSpacing();
120
121   /**
122    * This method is used by the Chart2D to scale it's values during painting.
123    * <p>
124    * Caution: This method does not necessarily return the Range configured with
125    * {@link #setRange(Range)}. The internal {@link IRangePolicy} is taken into
126    * account.
127    * <p>
128    *
129    * @return the range corresponding to the upper and lower bound of the values
130    * that will be displayable on this Axis of the Chart2D.
131    *
132    * @see #setRangePolicy(IRangePolicy)
133    * @see info.monitorenter.gui.chart.AAxis.Chart2DDataAccessor#getRange()
134    *
135    */

136   public abstract Range getRange();
137
138   /**
139    * See!
140    * <p>
141    *
142    * @see info.monitorenter.gui.chart.AAxis.Chart2DDataAccessor#getRangePolicy()
143    *
144    */

145   public abstract IRangePolicy getRangePolicy();
146
147   /**
148    * Returns wether the x grid is painted or not.
149    * <p>
150    *
151    * @return wether the x grid is painted or not.
152    */

153   public abstract boolean isPaintGrid();
154
155   /**
156    * Returns whether the scale for this axis should be painted or not.
157    * <p>
158    *
159    * @return whether the scale for this axis should be painted or not.
160    */

161   public abstract boolean isPaintScale();
162
163   /**
164    * Check wether scale values are started from major ticks.
165    * <p>
166    *
167    * @return true if scale values start from major ticks.
168    *
169    * @see AAxis#setMajorTickSpacing(double)
170    */

171   public abstract boolean isStartMajorTick();
172
173   /**
174    * Sets the formatter to use for labels.
175    * <p>
176    *
177    * @param formatter
178    * The formatter to set.
179    */

180   public abstract void setFormatter(final ALabelFormatter formatter);
181
182   /**
183    * This method sets the major tick spacing for label generation.
184    * <p>
185    *
186    * Only values between 0.0 and 100.0 are allowed.
187    * <p>
188    *
189    * The number that is passed-in represents the distance, measured in values,
190    * between each major tick mark. If you have a trace with a range from 0 to 50
191    * and the major tick spacing is set to 10, you will get major ticks next to
192    * the following values: 0, 10, 20, 30, 40, 50.
193    * <p>
194    *
195    * <b>Note: </b> <br>
196    * Ticks are free of any multiples of 1000. If the chart contains values
197    * between 0 an 1000 and configured a tick of 2 the values 0, 200, 400, 600,
198    * 800 and 1000 will highly probable to be displayed. This depends on the size
199    * (in pixels) of the <code>Chart2D<</code>. Of course there is a
200    * difference: ticks are used in divisions and multiplications: If the
201    * internal values are very low and the ticks are very high, huge rounding
202    * errors might occur (division by ticks results in very low values a double
203    * cannot hit exactly. So prefer setting ticks between 0 an 10 or - if you
204    * know your values are very small (e.g. in nano range [10 <sup>-9 </sup>])
205    * use a small value (e.g. 2*10 <sup>-9 </sup>).
206    * <p>
207    *
208    * @param majorTickSpacing
209    * the major tick spacing for label generation.
210    */

211   public abstract void setMajorTickSpacing(final double majorTickSpacing);
212
213   /**
214    * This method sets the minor tick spacing for label generation.
215    * <p>
216    *
217    * The number that is passed-in represents the distance, measured in values,
218    * between each major tick mark. If you have a trace with a range from 0 to 50
219    * and the major tick spacing is set to 10, you will get major ticks next to
220    * the following values: 0, 10, 20, 30, 40, 50.
221    * <p>
222    *
223    * <b>Note: </b> <br>
224    * Ticks are free of any powers of 10. There is no difference between setting
225    * a tick to 2, 200 or 20000 because ticks cannot break the rule that every
226    * scale label has to be visible. If the chart contains values between 0 an
227    * 1000 and configured a tick of 2 the values 0, 200, 400, 600, 800 and 1000
228    * will highly probable to be displayed. This depends on the size (in pixels)
229    * of the <code>Chart2D<</code>. Of course there is a difference: ticks
230    * are used in divisions and multiplications: If the internal values are very
231    * low and the ticks are very high, huge rounding errors might occur (division
232    * by ticks results in very low values a double cannot hit exactly. So prefer
233    * setting ticks between 0 an 10 or - if you know your values are very small
234    * (e.g. in nano range [10 <sup>-9 </sup>]) use a small value (e.g. 2*10
235    * <sup>-9 </sup>).
236    * <p>
237    *
238    * @param minorTickSpacing
239    * the minor tick spacing to set.
240    *
241    */

242   public abstract void setMinorTickSpacing(final double minorTickSpacing);
243
244   /**
245    * Set wether the grid in this dimension should be painted or not.
246    * <p>
247    * A repaint operation for the chart is triggered.
248    * <p>
249    *
250    * @param grid
251    * true if the grid should be painted or false if not.
252    */

253
254   public abstract void setPaintGrid(boolean grid);
255
256   /**
257    * Set if the scale for this axis should be shown.
258    * <p>
259    *
260    * @param show
261    * true if the scale on this axis should be shown, false else.
262    */

263   public abstract void setPaintScale(final boolean show);
264
265   /**
266    * <p>
267    * Sets a Range to use for filtering the view to the the connected Axis. Note
268    * that it's effect will be affected by the internal {@link IRangePolicy}.
269    * </p>
270    * <p>
271    * To get full control use: <br>
272    * <code> setRangePolicy(new &lt;AnARangePolicy&gt;(range);</code>
273    * </p>
274    *
275    * @param range
276    * Range to use for filtering the view to the the connected Axis.
277    *
278    * @see #getRangePolicy()
279    *
280    * @see IRangePolicy#setRange(Range)
281    */

282   public abstract void setRange(final Range range);
283
284   /**
285    * <p>
286    * Sets the RangePolicy.
287    * </p>
288    * <p>
289    * If the given RangePolicy has an unconfigured internal Range (
290    * {@link Range#RANGE_UNBOUNDED}) the old internal RangePolicy is taken into
291    * account: <br>
292    * If the old RangePolicy has a configured Range this is transferred to the
293    * new RangePolicy.
294    * </p>
295    *
296    * @param rangePolicy
297    * The rangePolicy to set.
298    */

299   public abstract void setRangePolicy(final IRangePolicy rangePolicy);
300
301   /**
302    * Set wether scale values are started from major ticks.
303    * <p>
304    *
305    * @param majorTick
306    * true if scale values shall start with a major tick.
307    *
308    * @see AAxis#setMajorTickSpacing(double)
309    */

310   public abstract void setStartMajorTick(final boolean majorTick);
311
312 }
313
Popular Tags