OSDN Git Service

Initial revision
[pf3gnuchains/gcc-fork.git] / libjava / classpath / java / awt / ScrollPaneAdjustable.java
1 /* ScrollPaneAdjustable.java -- Scrollbars for a ScrollPane
2    Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING.  If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
20
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library.  Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
25
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module.  An independent module is a module which is not derived from
33 or based on this library.  If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so.  If you do not wish to do so, delete this
36 exception statement from your version. */
37
38
39 package java.awt;
40
41 import java.awt.event.AdjustmentListener;
42 import java.io.Serializable;
43
44 /**
45  * Need this class since the serialization spec for ScrollPane
46  * uses it.
47  *
48  * @author Aaron M. Renn (arenn@urbanophile.com)
49  * @since 1.4
50  */
51 public class ScrollPaneAdjustable
52   implements Adjustable, Serializable
53 {
54   private static final long serialVersionUID = -3359745691033257079L;
55  
56   ScrollPane sp;
57   int orientation;
58   int value;
59   int minimum;
60   int maximum;
61   int visibleAmount;
62   int unitIncrement = 1;
63   int blockIncrement = 1;
64   AdjustmentListener adjustmentListener;
65
66   private transient boolean valueIsAdjusting = false;
67
68   ScrollPaneAdjustable (ScrollPane sp, int orientation)
69   {
70     this.sp = sp;
71     this.orientation = orientation;
72   }
73   
74   ScrollPaneAdjustable (ScrollPane sp, int orientation, int value, int minimum,
75                         int maximum, int visibleAmount, int unitIncrement,
76                         int blockIncrement)
77   {
78     this.sp = sp;
79     this.orientation = orientation;
80     this.value = value;
81     this.minimum = minimum;
82     this.maximum = maximum;
83     this.visibleAmount = visibleAmount;
84     this.unitIncrement = unitIncrement;
85     this.blockIncrement = blockIncrement;
86   }
87   
88   public void addAdjustmentListener (AdjustmentListener listener)
89   {
90     AWTEventMulticaster.add (adjustmentListener, listener);
91   }
92   
93   public void removeAdjustmentListener (AdjustmentListener listener)
94   {
95     AWTEventMulticaster.remove (adjustmentListener, listener);
96   }
97   
98   public AdjustmentListener[] getAdjustmentListeners ()
99   {
100     return (AdjustmentListener[]) AWTEventMulticaster.getListeners
101                                (adjustmentListener, AdjustmentListener.class);
102   }
103
104   public int getBlockIncrement ()
105   {
106     return blockIncrement;
107   }
108
109   public int getMaximum ()
110   {
111     return maximum;
112   }
113
114   public int getMinimum ()
115   {
116     return minimum;
117   }
118
119   public int getOrientation ()
120   {
121     return orientation;
122   }
123
124   public int getUnitIncrement ()
125   {
126     return unitIncrement;
127   }
128   
129   public int getValue ()
130   {
131     return value;
132   }
133
134   public int getVisibleAmount ()
135   {
136     return visibleAmount;
137   }
138
139   public void setBlockIncrement (int blockIncrement)
140   {
141     this.blockIncrement = blockIncrement;
142   }
143     
144   public void setMaximum (int maximum)
145   {
146     this.maximum = maximum;
147   }
148
149   public void setMinimum (int minimum)
150   {
151     this.minimum = minimum;
152   }
153
154   public void setUnitIncrement (int unitIncrement)
155   {
156     this.unitIncrement = unitIncrement;
157   }
158
159   public void setValue (int value)
160   {
161     this.value = value;
162
163     if (value < minimum)
164       minimum = value;
165
166     if (value > maximum)
167       maximum = value;
168   }
169   
170   public void setVisibleAmount (int visibleAmount)
171   {
172     this.visibleAmount = visibleAmount;
173   }
174
175   public String paramString ()
176   {
177     throw new Error ("not implemented");
178   }
179
180   /**
181    * Returns true if the value is in the process of changing.
182    *
183    * @since 1.4
184    */
185   public boolean getValueIsAdjusting ()
186   {
187     return valueIsAdjusting;
188   }
189
190   /**
191    * Sets the value of valueIsAdjusting.
192    *
193    * @since 1.4
194    */
195   public void setValueIsAdjusting (boolean valueIsAdjusting)
196   {
197     this.valueIsAdjusting = valueIsAdjusting;
198   }
199 } // class ScrollPaneAdjustable
200