KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * AxisActionSetRange.java of project jchart2d
3  * Copyright 2006 (C) Achim Westermann, created on 20:30:06.
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.IAxis;
26 import info.monitorenter.gui.chart.dialogs.DialogRange;
27 import info.monitorenter.gui.chart.layout.controls.RangeChooserPanel;
28
29 import java.awt.event.ActionEvent JavaDoc;
30 import java.beans.PropertyChangeEvent JavaDoc;
31
32 /**
33  * <code>Action</code> that sets the range of an
34  * {@link info.monitorenter.gui.chart.AAxis} of a chart ({@link info.monitorenter.gui.chart.Chart2D})
35  * that will be used by it's viewport (
36  * {@link info.monitorenter.gui.chart.AAxis#setRangePolicy(info.monitorenter.gui.chart.IRangePolicy)})
37  * by showing a modal range chooser.
38  *
39  * @author <a HREF="mailto:Achim.Westermann@gmx.de">Achim Westermann </a>
40  *
41  *
42  * @version $Revision: 1.2 $
43  */

44 public class AxisActionSetRange extends AAxisAction {
45
46   /**
47    * Generated <code>serialVersionUID</code>.
48    */

49   private static final long serialVersionUID = 3258694286479406393L;
50
51   /**
52    * Create an <code>Action</code> that sets the range of the given axis.
53    * <p>
54    *
55    * @param axis
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   public AxisActionSetRange(final IAxis axis, final String JavaDoc description) {
65     super(axis, description);
66   }
67
68   /**
69    * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
70    */

71   public void actionPerformed(final ActionEvent JavaDoc e) {
72
73     RangeChooserPanel rangePanel = new RangeChooserPanel(this.m_axis.getRangePolicy().getRange());
74     DialogRange dialog = new DialogRange(this.m_axis.getAccessor().getChart(), "Choose a range",
75         true, rangePanel);
76     dialog.showDialog();
77     this.m_axis.setRange(rangePanel.getRange());
78   }
79
80   /**
81    * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
82    */

83   public void propertyChange(final PropertyChangeEvent JavaDoc evt) {
84     // nop as this action will not be used
85
// by checkbox or radio button menu items that have a state.
86
}
87 }
88
Popular Tags