KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > monitorenter > gui > chart > traces > Trace2DAxisSwap


1 /*
2  * Trace2DAxisSwap.java jchart2d
3  * Copyright (C) Achim Westermann, created on 20.04.2005, 09:06:33
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.traces;
24
25 import info.monitorenter.gui.chart.Chart2D;
26 import info.monitorenter.gui.chart.ITrace2D;
27 import info.monitorenter.gui.chart.ITracePainter;
28 import info.monitorenter.gui.chart.TracePoint2D;
29
30 import java.awt.Color JavaDoc;
31 import java.awt.Stroke JavaDoc;
32 import java.beans.PropertyChangeListener JavaDoc;
33 import java.util.Iterator JavaDoc;
34 import java.util.Set JavaDoc;
35
36 /**
37  * <p>
38  * A delegator / proxy that delegates all calls to an internal constructor-given
39  * ITrace2d and swaps the data of the added Point2D instances.
40  * </p>
41  * <p>
42  * x values become y values and vice versa. Performance is bad, as unnecessary
43  * instances are created (each TracePoint2D is instantiated twice) so this
44  * instance is for debugging / testing purposes only.
45  *
46  * </p>
47  *
48  * @author <a HREF="mailto:Achim.Westermann@gmx.de">Achim Westermann </a>
49  *
50  * @version $Revision: 1.2 $
51  */

52 public class Trace2DAxisSwap implements ITrace2D {
53   /** The delagate instance to decorate with axis swapping. */
54   private ITrace2D m_delegate;
55
56   /**
57    * Creates an instance that will swap the axis of the given delegate.
58    * <p>
59    *
60    * @param trace
61    * the delagate instance to decorate with axis swapping.
62    */

63   public Trace2DAxisSwap(final ITrace2D trace) {
64     if (trace == null) {
65       throw new IllegalArgumentException JavaDoc("Argument must not be null.");
66     }
67     if (trace.getClass() == this.getClass()) {
68       throw new IllegalArgumentException JavaDoc("Nesting of " + this.getClass().getName()
69           + " is unnecessary and may be harmful.");
70     }
71     this.m_delegate = trace;
72   }
73
74   /**
75    * @see info.monitorenter.gui.chart.ITrace2D#addPoint(double, double)
76    */

77   public boolean addPoint(final double x, final double y) {
78     return this.addPoint(new TracePoint2D(x, y));
79   }
80
81   /**
82    * @see info.monitorenter.gui.chart.ITrace2D#addPoint(info.monitorenter.gui.chart.TracePoint2D)
83    */

84   public boolean addPoint(final TracePoint2D p) {
85     return this.m_delegate.addPoint(new TracePoint2D(p.getY(), p.getX()));
86   }
87
88   /**
89    * @see info.monitorenter.gui.chart.ITrace2D#addPropertyChangeListener(java.lang.String,
90    * java.beans.PropertyChangeListener)
91    */

92   public void addPropertyChangeListener(final String JavaDoc propertyName,
93       final PropertyChangeListener JavaDoc listener) {
94     this.m_delegate.addPropertyChangeListener(propertyName, listener);
95   }
96
97   /**
98    * @see info.monitorenter.gui.chart.ITrace2D#addTracePainter(info.monitorenter.gui.chart.ITracePainter)
99    */

100   public boolean addTracePainter(final ITracePainter painter) {
101     return this.m_delegate.addTracePainter(painter);
102   }
103
104   /**
105    * @see info.monitorenter.gui.chart.ITrace2D#containsTracePainter(info.monitorenter.gui.chart.ITracePainter)
106    */

107   public boolean containsTracePainter(final ITracePainter painter) {
108     return this.m_delegate.containsTracePainter(painter);
109   }
110
111   /**
112    * @see java.lang.Object#equals(java.lang.Object)
113    */

114   public boolean equals(final Object JavaDoc obj) {
115     return this.m_delegate.equals(obj);
116   }
117
118   /**
119    * @see info.monitorenter.gui.chart.ITrace2D#getColor()
120    */

121   public Color JavaDoc getColor() {
122     return this.m_delegate.getColor();
123   }
124
125   /**
126    * @see info.monitorenter.util.collections.IComparableProperty#getComparableProperty()
127    */

128   public Number JavaDoc getComparableProperty() {
129     return this.m_delegate.getComparableProperty();
130   }
131
132   /**
133    * @see info.monitorenter.gui.chart.ITrace2D#getLable()
134    */

135   public String JavaDoc getLable() {
136     return this.m_delegate.getLable();
137   }
138
139   /**
140    * @see info.monitorenter.gui.chart.ITrace2D#getMaxSize()
141    */

142   public int getMaxSize() {
143     return this.m_delegate.getMaxSize();
144   }
145
146   /**
147    * @see info.monitorenter.gui.chart.ITrace2D#getMaxX()
148    */

149   public double getMaxX() {
150     return this.m_delegate.getMaxX();
151   }
152
153   /**
154    * @see info.monitorenter.gui.chart.ITrace2D#getMaxY()
155    */

156   public double getMaxY() {
157     return this.m_delegate.getMaxY();
158   }
159
160   /**
161    * @see info.monitorenter.gui.chart.ITrace2D#getMinX()
162    */

163   public double getMinX() {
164     return this.m_delegate.getMinX();
165   }
166
167   /**
168    * @see info.monitorenter.gui.chart.ITrace2D#getMinY()
169    */

170   public double getMinY() {
171     return this.m_delegate.getMinY();
172   }
173
174   /**
175    * @see info.monitorenter.gui.chart.ITrace2D#getName()
176    */

177   public String JavaDoc getName() {
178     return this.m_delegate.getName();
179   }
180
181   /**
182    * @see info.monitorenter.gui.chart.ITrace2D#getPhysicalUnits()
183    */

184   public String JavaDoc getPhysicalUnits() {
185     return this.m_delegate.getPhysicalUnits();
186   }
187
188   /**
189    * @see info.monitorenter.gui.chart.ITrace2D#getPropertyChangeListeners(java.lang.String)
190    */

191   public PropertyChangeListener JavaDoc[] getPropertyChangeListeners(final String JavaDoc property) {
192     return this.m_delegate.getPropertyChangeListeners(property);
193   }
194
195   /**
196    * @see info.monitorenter.gui.chart.ITrace2D#getRenderer()
197    */

198   public Chart2D getRenderer() {
199     return this.m_delegate.getRenderer();
200   }
201
202   /**
203    * @see info.monitorenter.gui.chart.ITrace2D#getSize()
204    */

205   public int getSize() {
206     return this.m_delegate.getSize();
207   }
208
209   /**
210    * @see info.monitorenter.gui.chart.ITrace2D#getStroke()
211    */

212   public Stroke JavaDoc getStroke() {
213     return this.m_delegate.getStroke();
214   }
215
216   /**
217    *
218    * @see info.monitorenter.gui.chart.ITrace2D#getTracePainters()
219    */

220   public Set JavaDoc getTracePainters() {
221     return this.m_delegate.getTracePainters();
222   }
223
224   /**
225    * @see info.monitorenter.gui.chart.ITrace2D#isVisible()
226    */

227   public boolean isVisible() {
228     return this.m_delegate.isVisible();
229   }
230
231   /**
232    * @see info.monitorenter.gui.chart.ITrace2D#getZIndex()
233    */

234   public Integer JavaDoc getZIndex() {
235     return this.m_delegate.getZIndex();
236   }
237
238   /**
239    * @see java.lang.Object#hashCode()
240    */

241   public int hashCode() {
242     return this.m_delegate.hashCode();
243   }
244
245   /**
246    * @see info.monitorenter.gui.chart.ITrace2D#isEmpty()
247    */

248   public boolean isEmpty() {
249     return this.m_delegate.isEmpty();
250   }
251
252   /**
253    * @see info.monitorenter.gui.chart.ITrace2D#iterator()
254    */

255   public Iterator JavaDoc iterator() {
256     return this.m_delegate.iterator();
257   }
258
259   /**
260    * @see info.monitorenter.gui.chart.ITrace2D#removeAllPoints()
261    */

262   public void removeAllPoints() {
263     this.m_delegate.removeAllPoints();
264   }
265
266   /**
267    * @see info.monitorenter.gui.chart.ITrace2D#removePoint(info.monitorenter.gui.chart.TracePoint2D)
268    */

269   public boolean removePoint(final TracePoint2D point) {
270     return this.m_delegate.removePoint(point);
271   }
272
273   /**
274    * @see info.monitorenter.gui.chart.ITrace2D#removePropertyChangeListener(java.beans.PropertyChangeListener)
275    */

276   public void removePropertyChangeListener(final PropertyChangeListener JavaDoc listener) {
277     this.m_delegate.removePropertyChangeListener(listener);
278   }
279
280   /**
281    * @see info.monitorenter.gui.chart.ITrace2D#removePropertyChangeListener(java.lang.String,
282    * java.beans.PropertyChangeListener)
283    */

284   public void removePropertyChangeListener(final String JavaDoc property,
285       final PropertyChangeListener JavaDoc listener) {
286     this.m_delegate.removePropertyChangeListener(property, listener);
287   }
288
289   /**
290    * @see info.monitorenter.gui.chart.ITrace2D#removeTracePainter(info.monitorenter.gui.chart.ITracePainter)
291    */

292   public boolean removeTracePainter(final ITracePainter painter) {
293     return this.m_delegate.removeTracePainter(painter);
294   }
295
296   /**
297    * @see info.monitorenter.gui.chart.ITrace2D#setColor(java.awt.Color)
298    */

299   public void setColor(final Color JavaDoc color) {
300     this.m_delegate.setColor(color);
301   }
302
303   /**
304    * @see info.monitorenter.util.collections.IComparableProperty#setComparableProperty(java.lang.Number)
305    */

306   public void setComparableProperty(final Number JavaDoc n) {
307     this.m_delegate.setComparableProperty(n);
308   }
309
310   /**
311    * @see info.monitorenter.gui.chart.ITrace2D#setName(java.lang.String)
312    */

313   public void setName(final String JavaDoc name) {
314     this.m_delegate.setName(name);
315   }
316
317   /**
318    * @see info.monitorenter.gui.chart.ITrace2D#setPhysicalUnits(java.lang.String,
319    * java.lang.String)
320    */

321   public void setPhysicalUnits(final String JavaDoc xunit, final String JavaDoc yunit) {
322     this.m_delegate.setPhysicalUnits(xunit, yunit);
323   }
324
325   /**
326    * @see info.monitorenter.gui.chart.ITrace2D#setRenderer(info.monitorenter.gui.chart.Chart2D)
327    */

328   public void setRenderer(final Chart2D renderer) {
329     this.m_delegate.setRenderer(renderer);
330   }
331
332   /**
333    * @see info.monitorenter.gui.chart.ITrace2D#setStroke(java.awt.Stroke)
334    */

335   public void setStroke(final Stroke JavaDoc stroke) {
336     this.m_delegate.setStroke(stroke);
337   }
338
339   /**
340    *
341    * @see info.monitorenter.gui.chart.ITrace2D#setTracePainter(info.monitorenter.gui.chart.ITracePainter)
342    */

343   public Set JavaDoc setTracePainter(final ITracePainter painter) {
344     return this.m_delegate.setTracePainter(painter);
345   }
346
347   /**
348    * @see info.monitorenter.gui.chart.ITrace2D#setVisible(boolean)
349    */

350   public void setVisible(final boolean visible) {
351     this.m_delegate.setVisible(visible);
352   }
353
354   /**
355    * @see info.monitorenter.gui.chart.ITrace2D#setZIndex(java.lang.Integer)
356    */

357   public void setZIndex(final Integer JavaDoc zIndex) {
358     this.m_delegate.setZIndex(zIndex);
359   }
360
361   /**
362    * @see java.lang.Object#toString()
363    */

364   public String JavaDoc toString() {
365     return this.m_delegate.toString();
366   }
367 }
368
Popular Tags