1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43:
44:
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: if (listener == null)
91: return;
92: adjustmentListener = AWTEventMulticaster.add (adjustmentListener, listener);
93: }
94:
95: public void removeAdjustmentListener (AdjustmentListener listener)
96: {
97: if (listener == null)
98: return;
99: adjustmentListener = AWTEventMulticaster.remove (adjustmentListener, listener);
100: }
101:
102: public AdjustmentListener[] getAdjustmentListeners ()
103: {
104: return (AdjustmentListener[]) AWTEventMulticaster.getListeners
105: (adjustmentListener, AdjustmentListener.class);
106: }
107:
108: public int getBlockIncrement ()
109: {
110: return blockIncrement;
111: }
112:
113: public int getMaximum ()
114: {
115: return maximum;
116: }
117:
118: public int getMinimum ()
119: {
120: return minimum;
121: }
122:
123: public int getOrientation ()
124: {
125: return orientation;
126: }
127:
128: public int getUnitIncrement ()
129: {
130: return unitIncrement;
131: }
132:
133: public int getValue ()
134: {
135: return value;
136: }
137:
138: public int getVisibleAmount ()
139: {
140: return visibleAmount;
141: }
142:
143: public void setBlockIncrement (int blockIncrement)
144: {
145: this.blockIncrement = blockIncrement;
146: }
147:
148:
154: public void setMaximum (int maximum) throws AWTError
155: {
156: throw new AWTError("Can be set by scrollpane only");
157: }
158:
159:
165: public void setMinimum (int minimum)
166: {
167: throw new AWTError("Can be set by scrollpane only");
168: }
169:
170: public void setUnitIncrement (int unitIncrement)
171: {
172: this.unitIncrement = unitIncrement;
173: }
174:
175: public void setValue (int value)
176: {
177: this.value = value;
178:
179: if (value < minimum)
180: minimum = value;
181:
182: if (value > maximum)
183: maximum = value;
184: }
185:
186:
192: public void setVisibleAmount (int visibleAmount)
193: {
194: throw new AWTError("Can be set by scrollpane only");
195: }
196:
197: public String paramString ()
198: {
199: return paramStringHelper()
200: + ",[" + getMinimum() + ".." + getMaximum()
201: + "],val=" + getValue()
202: + ",vis=" + getVisibleAmount()
203: + ",unit=" + getUnitIncrement()
204: + ",block=" + getBlockIncrement()
205: + ",isAdjusting=" + valueIsAdjusting;
206: }
207:
208: private String paramStringHelper()
209: {
210: if (getOrientation() == HORIZONTAL)
211: return "horizontal";
212: else
213: return "vertical";
214: }
215:
216: public String toString()
217: {
218: return getClass().getName() + "[" + paramString() + "]";
219: }
220:
221:
226: public boolean getValueIsAdjusting ()
227: {
228: return valueIsAdjusting;
229: }
230:
231:
236: public void setValueIsAdjusting (boolean valueIsAdjusting)
237: {
238: this.valueIsAdjusting = valueIsAdjusting;
239: }
240:
241: }