KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > monitorenter > gui > chart > axis > AxisLinear


1 /*
2  * AxisLinear.java of project jchart2d, Axis implementation with linear display.
3  * Copyright 2006 (C) Achim Westermann, created on 20:33:13.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
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.axis;
24
25 import info.monitorenter.gui.chart.AAxis;
26 import info.monitorenter.util.Range;
27
28 import java.awt.event.MouseEvent JavaDoc;
29
30
31 /**
32  * An {@link AAxis} with linear display of values.
33  * <p>
34  *
35  * @author <a HREF="mailto:Achim.Westermann@gmx.de">Achim Westermann</a>
36  *
37  *
38  * @version $Revision: 1.1 $
39  */

40 public class AxisLinear extends AAxis {
41
42   /**
43    * @see info.monitorenter.gui.chart.AAxis#translateMousePosition(java.awt.event.MouseEvent)
44    */

45   protected double translateMousePosition(final MouseEvent JavaDoc mouseEvent) throws IllegalArgumentException JavaDoc {
46     return this.getAccessor().translateMousePosition(mouseEvent);
47   }
48
49   /**
50    * @see info.monitorenter.gui.chart.AAxis#getScaledValue(double)
51    */

52   protected double getScaledValue(final double absolute) {
53     Range range = this.getRange();
54     double scalerX = range.getExtent();
55     double result = (absolute - range.getMin()) / scalerX;
56     if (result == Double.NaN || Double.isInfinite(result)) {
57       result = 0;
58     }
59     return result;
60   }
61 }
62
Popular Tags