KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > monitorenter > gui > chart > events > Trace2DActionSetZindex


1 /*
2  * Trace2DActionSetZindex, action to control the z-Index property of an ITrace2D.
3  * Copyright (C) Achim Westermann, created on 10.12.2004, 13:48:55
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.events;
24
25 import info.monitorenter.gui.chart.ITrace2D;
26 import info.monitorenter.gui.chart.layout.LayoutFactory.PropertyChangeCheckBoxMenuItem;
27
28 import java.awt.event.ActionEvent JavaDoc;
29 import java.beans.PropertyChangeEvent JavaDoc;
30
31 /**
32  * <code>Action</code> that sets a constructor-given zIndex to the
33  * corresponding trace.
34  * <p>
35  *
36  * @author <a HREF="mailto:Achim.Westermann@gmx.de">Achim Westermann </a>
37  *
38  * @version $Revision: 1.2 $
39  */

40 public final class Trace2DActionSetZindex extends ATrace2DAction {
41
42   /**
43    * Generated <code>serialVersionUID</code>.
44    */

45   private static final long serialVersionUID = 3978986583057707570L;
46
47   /** The zIndex to set to the trace. */
48   private Integer JavaDoc m_zIndex;
49
50   /**
51    * Create an <code>Action</code> that accesses the trace and identifies
52    * itself with the given action String.
53    * <p>
54    *
55    * @param trace
56    * the target the action will work on.
57    *
58    * @param description
59    * the descriptive <code>String</code> that will be displayed by
60    * {@link javax.swing.AbstractButton} subclasses that get this
61    * <code>Action</code> assigned (
62    * {@link javax.swing.AbstractButton#setAction(javax.swing.Action)}).
63    *
64    * @param zIndex
65    * the z-index property to set to the corresponding trace (see
66    * {@link ITrace2D#setZIndex(Integer)}).
67    *
68    */

69   public Trace2DActionSetZindex(final ITrace2D trace, final String JavaDoc description, final int zIndex) {
70     super(trace, description);
71     this.m_zIndex = new Integer JavaDoc(zIndex);
72     trace.addPropertyChangeListener(ITrace2D.PROPERTY_ZINDEX, this);
73   }
74
75   /**
76    * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
77    */

78   public void actionPerformed(final ActionEvent JavaDoc e) {
79     this.m_trace.setZIndex(this.m_zIndex);
80   }
81
82   /**
83    * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
84    */

85   public void propertyChange(final PropertyChangeEvent JavaDoc evt) {
86     String JavaDoc property = evt.getPropertyName();
87     if (property.equals(ITrace2D.PROPERTY_ZINDEX)) {
88       Number JavaDoc newValue = (Number JavaDoc) evt.getNewValue();
89       if (newValue.equals(this.m_zIndex)) {
90         this.firePropertyChange(PropertyChangeCheckBoxMenuItem.PROPERTY_SELECTED,
91             new Boolean JavaDoc(false), new Boolean JavaDoc(true));
92       } else {
93         this.firePropertyChange(PropertyChangeCheckBoxMenuItem.PROPERTY_SELECTED,
94             new Boolean JavaDoc(true), new Boolean JavaDoc(false));
95       }
96     }
97   }
98 }
99
Popular Tags