|
@@ -1,284 +1,284 @@ |
1 |
|
- |
package org.litesoft.GWT.client.widgets.sliderbar.client.view; |
2 |
|
- |
|
3 |
|
- |
import org.litesoft.GWT.client.widgets.sliderbar.client.event.*; |
4 |
|
- |
import org.litesoft.GWT.client.widgets.sliderbar.client.exception.*; |
5 |
|
- |
import org.litesoft.GWT.client.widgets.sliderbar.client.presenter.*; |
6 |
|
- |
import org.litesoft.GWT.client.widgets.sliderbar.client.presenter.Presenter.*; |
7 |
|
- |
|
8 |
|
- |
import com.google.gwt.event.shared.*; |
9 |
|
- |
import com.google.gwt.user.client.*; |
10 |
|
- |
import com.google.gwt.user.client.ui.*; |
11 |
|
- |
|
12 |
|
- |
import java.util.*; |
13 |
|
- |
|
14 |
|
- |
/** |
15 |
|
- |
* @author kiouri |
16 |
|
- |
* The base class for Horizontal and Vertical SliderBar |
17 |
|
- |
*/ |
18 |
|
- |
public abstract class SliderBar extends FocusPanel implements Display { |
19 |
|
- |
|
20 |
|
- |
protected Widget scale, drag; |
21 |
|
- |
protected int scaleSize, startPosition, delimSize; |
22 |
|
- |
protected ArrayList<Widget> less = new ArrayList<Widget>(), |
23 |
|
- |
more = new ArrayList<Widget>(), |
24 |
|
- |
orderedWidgets = new ArrayList<Widget>(); |
25 |
|
- |
protected TouchableAbsolutePanelPK absPanel = new TouchableAbsolutePanelPK(); |
26 |
|
- |
protected boolean isMarksPlaced = false, wasInited = false; |
27 |
|
- |
protected String color; |
28 |
|
- |
protected Presenter presenter; |
29 |
|
- |
|
30 |
|
- |
public SliderBar() { |
31 |
|
- |
presenter = new Presenter( this, getOrientation() ); |
32 |
|
- |
this.add( absPanel ); |
33 |
|
- |
} |
34 |
|
- |
|
35 |
|
- |
public SliderBar( Presenter presenter ) { |
36 |
|
- |
if ( presenter == null ) { |
37 |
|
- |
this.presenter = new Presenter( this, getOrientation() ); |
38 |
|
- |
} else { |
39 |
|
- |
this.presenter = presenter; |
40 |
|
- |
presenter.setDislay( this ); |
41 |
|
- |
} |
42 |
|
- |
this.add( absPanel ); |
43 |
|
- |
} |
44 |
|
- |
|
45 |
|
- |
/** |
46 |
|
- |
* @return knob widget |
47 |
|
- |
*/ |
48 |
|
- |
public Widget getDragWidget() { |
49 |
|
- |
return drag; |
50 |
|
- |
} |
51 |
|
- |
|
52 |
|
- |
/** |
53 |
|
- |
* Sets knob visible. Knob becomes invisible if maxValue equals zero. |
54 |
|
- |
*/ |
55 |
|
- |
public void setDragVisible( boolean isVisible ) { |
56 |
|
- |
if ( drag != null ) { |
57 |
|
- |
drag.setVisible( isVisible ); |
58 |
|
- |
} |
59 |
|
- |
} |
60 |
|
- |
|
61 |
|
- |
/** |
62 |
|
- |
* @return list of buttons that increase the current value (knob moves right or down) |
63 |
|
- |
*/ |
64 |
|
- |
public ArrayList<Widget> getLessWidgets() { |
65 |
|
- |
return less; |
66 |
|
- |
} |
67 |
|
- |
|
68 |
|
- |
/** |
69 |
|
- |
* @return list of buttons that reduce the current value (knob moves left or up) |
70 |
|
- |
*/ |
71 |
|
- |
public ArrayList<Widget> getMoreWidgets() { |
72 |
|
- |
return more; |
73 |
|
- |
} |
74 |
|
- |
|
75 |
|
- |
public Widget getScaleWidget() { |
76 |
|
- |
return scale; |
77 |
|
- |
} |
78 |
|
- |
|
79 |
|
- |
protected int getStartPosition() { |
80 |
|
- |
return this.startPosition; |
81 |
|
- |
} |
82 |
|
- |
|
83 |
|
- |
/** |
84 |
|
- |
* Sets the button for increase the current value (knob moves right or down) |
85 |
|
- |
* |
86 |
|
- |
* @param moreWidget - widget which supports handling of onMouseClick event |
87 |
|
- |
*/ |
88 |
|
- |
protected void setMoreWidget( Widget moreWidget ) { |
89 |
|
- |
orderedWidgets.add( moreWidget ); |
90 |
|
- |
more.add( moreWidget ); |
91 |
|
- |
} |
92 |
|
- |
|
93 |
|
- |
/** |
94 |
|
- |
* Sets the button for decrease the current value (knob moves left or up) |
95 |
|
- |
* |
96 |
|
- |
* @param moreWidget - widget which supports handling of onMouseClick event |
97 |
|
- |
*/ |
98 |
|
- |
protected void setLessWidget( Widget lessWidget ) { |
99 |
|
- |
orderedWidgets.add( lessWidget ); |
100 |
|
- |
less.add( lessWidget ); |
101 |
|
- |
} |
102 |
|
- |
|
103 |
|
- |
/** |
104 |
|
- |
* @param drag - widget for knob representing |
105 |
|
- |
*/ |
106 |
|
- |
protected void setDragWidget( Widget drag ) { |
107 |
|
- |
this.drag = drag; |
108 |
|
- |
} |
109 |
|
- |
|
110 |
|
- |
/** |
111 |
|
- |
* @param scaleWidget - widget for scale representing |
112 |
|
- |
* @param scaleSize - height of scale for horizontal sliderbar |
113 |
|
- |
* or width of scale for vertical sliderbar.<br> |
114 |
|
- |
* It is possible to adjust thickness of scale with help of this parameter. |
115 |
|
- |
*/ |
116 |
|
- |
protected void setScaleWidget( Widget scaleWidget, int scaleSize ) { |
117 |
|
- |
orderedWidgets.add( scaleWidget ); |
118 |
|
- |
this.scale = scaleWidget; |
119 |
|
- |
this.scaleSize = scaleSize; |
120 |
|
- |
} |
121 |
|
- |
|
122 |
|
- |
public Widget getRootWidget() { |
123 |
|
- |
return this; |
124 |
|
- |
} |
125 |
|
- |
|
126 |
|
- |
/** |
127 |
|
- |
* With help of this method it is possible to control appearance of outline border around the sliderbar when sliderbar is in focus. |
128 |
|
- |
*/ |
129 |
|
- |
public void setNotSelectedInFocus() { |
130 |
|
- |
DOM.setStyleAttribute( this.getElement(), "outline", "0px" ); |
131 |
|
- |
} |
132 |
|
- |
|
133 |
|
- |
/** |
134 |
|
- |
* With help of this method it is possible to draw marks of discret positions of knob on scale |
135 |
|
- |
* |
136 |
|
- |
* @param color - color of marks |
137 |
|
- |
* @param delimSize - height of marks for horizontal sliderbar or width of marks for vertical sliderbar |
138 |
|
- |
*/ |
139 |
|
- |
public void drawMarks( String color, int delimSize ) { |
140 |
|
- |
if ( !isMarksPlaced ) { |
141 |
|
- |
this.color = color; |
142 |
|
- |
this.delimSize = delimSize; |
143 |
|
- |
presenter.drawMarks( color, delimSize ); |
144 |
|
- |
isMarksPlaced = true; |
145 |
|
- |
} |
146 |
|
- |
} |
147 |
|
- |
|
148 |
|
- |
/** |
149 |
|
- |
* Remove scale marks from sliderbar |
150 |
|
- |
*/ |
151 |
|
- |
public void removeMarks() { |
152 |
|
- |
int childCount = absPanel.getWidgetCount(); |
153 |
|
- |
for ( int i = 0; i < childCount; i++ ) { |
154 |
|
- |
Widget widget = absPanel.getWidget( i ); |
155 |
|
- |
if ( widget instanceof Mark ) { |
156 |
|
- |
absPanel.remove( i ); |
157 |
|
- |
childCount--; |
158 |
|
- |
i--; |
159 |
|
- |
} |
160 |
|
- |
} |
161 |
|
- |
isMarksPlaced = false; |
162 |
|
- |
} |
163 |
|
- |
|
164 |
|
- |
/** |
165 |
|
- |
* Adds BarValueChangedHandler (for handling changes of knob position) |
166 |
|
- |
* |
167 |
|
- |
* @param barValueChangedHandler |
168 |
|
- |
* |
169 |
|
- |
* @return HandlerRegistration used to remove this handler |
170 |
|
- |
*/ |
171 |
|
- |
public HandlerRegistration addBarValueChangedHandler( |
172 |
|
- |
BarValueChangedHandler barValueChangedHandler ) { |
173 |
|
- |
return presenter.addBarValueChangedHandler( barValueChangedHandler ); |
174 |
|
- |
} |
175 |
|
- |
|
176 |
|
- |
/** |
177 |
|
- |
* Sets current value. Knob will be moved to correspond position. |
178 |
|
- |
* |
179 |
|
- |
* @param value |
180 |
|
- |
*/ |
181 |
|
- |
public void setValue( int value ) { |
182 |
|
- |
presenter.setValue( value ); |
183 |
|
- |
} |
184 |
|
- |
|
185 |
|
- |
protected void prepare( int maxValue, int pixelSize ) { |
186 |
|
- |
drawScrollBar( pixelSize ); |
187 |
|
- |
presenter.setMaxValue( maxValue ); |
188 |
|
- |
presenter.setAbsMaxLength( getAbsMaxLength() ); |
189 |
|
- |
presenter.processParams(); |
190 |
|
- |
presenter.setValue( getValue() ); |
191 |
|
- |
} |
192 |
|
- |
|
193 |
|
- |
/** |
194 |
|
- |
* @return max possible value which knob may point to. This value corresponds to rightmost knob position for horizontal sliderbar or |
195 |
|
- |
* bottommost knob position for vertical sliderbar |
196 |
|
- |
*/ |
197 |
|
- |
public int getMaxValue() { |
198 |
|
- |
return presenter.getMaxValue(); |
199 |
|
- |
} |
200 |
|
- |
|
201 |
|
- |
/** |
202 |
|
- |
* Sets value which corresponds to rightmost position of knob for horizontal sliderbar o bottommost position |
203 |
|
- |
* for vertical sliderbar. |
204 |
|
- |
* |
205 |
|
- |
* @param maxValue |
206 |
|
- |
*/ |
207 |
|
- |
public void setMaxValue( int maxValue ) { |
208 |
|
- |
presenter.setMaxValue( maxValue ); |
209 |
|
- |
presenter.processParams(); |
210 |
|
- |
try { |
211 |
|
- |
if ( isMarksPlaced ) { |
212 |
|
- |
this.removeMarks(); |
213 |
|
- |
this.drawMarks( color, delimSize ); |
214 |
|
- |
} |
215 |
|
- |
setValue( getValue() ); |
216 |
|
- |
} |
217 |
|
- |
catch ( Exception e ) { |
218 |
|
- |
} |
219 |
|
- |
} |
220 |
|
- |
|
221 |
|
- |
public void processParams() { |
222 |
|
- |
presenter.processParams(); |
223 |
|
- |
if ( isMarksPlaced ) { |
224 |
|
- |
isMarksPlaced = false; |
225 |
|
- |
this.drawMarks( color, delimSize ); |
226 |
|
- |
} |
227 |
|
- |
} |
228 |
|
- |
|
229 |
|
- |
/** |
230 |
|
- |
* Returns the value which corresponds to current position of knob |
231 |
|
- |
* |
232 |
|
- |
* @return |
233 |
|
- |
*/ |
234 |
|
- |
public int getValue() { |
235 |
|
- |
return presenter.getValue(); |
236 |
|
- |
} |
237 |
|
- |
|
238 |
|
- |
protected void onLoad() { |
239 |
|
- |
super.onLoad(); |
240 |
|
- |
|
241 |
|
- |
if ( drag == null ) { |
242 |
|
- |
throw new WidgetNotFoundError( "Drag widget not found..." ); |
243 |
|
- |
} |
244 |
|
- |
|
245 |
|
- |
if ( scale == null ) { |
246 |
|
- |
throw new WidgetNotFoundError( "Scale widget not found..." ); |
247 |
|
- |
} |
248 |
|
- |
|
249 |
|
- |
if ( !wasInited ) { |
250 |
|
- |
presenter.bind(); |
251 |
|
- |
wasInited = true; |
252 |
|
- |
} |
253 |
|
- |
if ( this.getOrientation() == Orientation.HORIZONTAL ) { |
254 |
|
- |
this.prepare( presenter.getMaxValue(), this.getOffsetWidth() ); |
255 |
|
- |
} else { |
256 |
|
- |
this.prepare( presenter.getMaxValue(), this.getOffsetHeight() ); |
257 |
|
- |
} |
258 |
|
- |
reDrawMarks(); |
259 |
|
- |
} |
260 |
|
- |
|
261 |
|
- |
protected void reDrawMarks() { |
262 |
|
- |
if ( isMarksPlaced ) { |
263 |
|
- |
this.removeMarks(); |
264 |
|
- |
this.drawMarks( color, delimSize ); |
265 |
|
- |
} |
266 |
|
- |
} |
267 |
|
- |
|
268 |
|
- |
protected void putWidgetsToAbsPanel() { |
269 |
|
- |
for ( int i = 0; i < orderedWidgets.size(); i++ ) { |
270 |
|
- |
absPanel.add( orderedWidgets.get( i ) ); |
271 |
|
- |
} |
272 |
|
- |
this.absPanel.add( drag, 0, 0 ); |
273 |
|
- |
DOM.setStyleAttribute( drag.getElement(), "zIndex", "500" ); |
274 |
|
- |
} |
275 |
|
- |
|
276 |
|
- |
/** |
277 |
|
- |
* Sets minimal distance between scale marks in pixels. If distance between marks will be less then this value - marks will not be drowning. |
278 |
|
- |
* |
279 |
|
- |
* @param minMarkStep |
280 |
|
- |
*/ |
281 |
|
- |
public void setMinMarkStep( int minMarkStep ) { |
282 |
|
- |
presenter.setMinMarkStep( minMarkStep ); |
283 |
|
- |
} |
284 |
|
- |
} |
|
1 |
+ |
package org.litesoft.GWT.client.widgets.sliderbar.client.view; |
|
2 |
+ |
|
|
3 |
+ |
import org.litesoft.GWT.client.widgets.sliderbar.client.event.*; |
|
4 |
+ |
import org.litesoft.GWT.client.widgets.sliderbar.client.exception.*; |
|
5 |
+ |
import org.litesoft.GWT.client.widgets.sliderbar.client.presenter.*; |
|
6 |
+ |
import org.litesoft.GWT.client.widgets.sliderbar.client.presenter.Presenter.*; |
|
7 |
+ |
|
|
8 |
+ |
import com.google.gwt.event.shared.*; |
|
9 |
+ |
import com.google.gwt.user.client.*; |
|
10 |
+ |
import com.google.gwt.user.client.ui.*; |
|
11 |
+ |
|
|
12 |
+ |
import java.util.*; |
|
13 |
+ |
|
|
14 |
+ |
/** |
|
15 |
+ |
* @author kiouri |
|
16 |
+ |
* The base class for Horizontal and Vertical SliderBar |
|
17 |
+ |
*/ |
|
18 |
+ |
public abstract class SliderBar extends FocusPanel implements Display { |
|
19 |
+ |
|
|
20 |
+ |
protected Widget scale, drag; |
|
21 |
+ |
protected int scaleSize, startPosition, delimSize; |
|
22 |
+ |
protected ArrayList<Widget> less = new ArrayList<Widget>(), |
|
23 |
+ |
more = new ArrayList<Widget>(), |
|
24 |
+ |
orderedWidgets = new ArrayList<Widget>(); |
|
25 |
+ |
protected TouchableAbsolutePanelPK absPanel = new TouchableAbsolutePanelPK(); |
|
26 |
+ |
protected boolean isMarksPlaced = false, wasInited = false; |
|
27 |
+ |
protected String color; |
|
28 |
+ |
protected Presenter presenter; |
|
29 |
+ |
|
|
30 |
+ |
public SliderBar() { |
|
31 |
+ |
presenter = new Presenter( this, getOrientation() ); |
|
32 |
+ |
this.add( absPanel ); |
|
33 |
+ |
} |
|
34 |
+ |
|
|
35 |
+ |
public SliderBar( Presenter presenter ) { |
|
36 |
+ |
if ( presenter == null ) { |
|
37 |
+ |
this.presenter = new Presenter( this, getOrientation() ); |
|
38 |
+ |
} else { |
|
39 |
+ |
this.presenter = presenter; |
|
40 |
+ |
presenter.setDislay( this ); |
|
41 |
+ |
} |
|
42 |
+ |
this.add( absPanel ); |
|
43 |
+ |
} |
|
44 |
+ |
|
|
45 |
+ |
/** |
|
46 |
+ |
* @return knob widget |
|
47 |
+ |
*/ |
|
48 |
+ |
public Widget getDragWidget() { |
|
49 |
+ |
return drag; |
|
50 |
+ |
} |
|
51 |
+ |
|
|
52 |
+ |
/** |
|
53 |
+ |
* Sets knob visible. Knob becomes invisible if maxValue equals zero. |
|
54 |
+ |
*/ |
|
55 |
+ |
public void setDragVisible( boolean isVisible ) { |
|
56 |
+ |
if ( drag != null ) { |
|
57 |
+ |
drag.setVisible( isVisible ); |
|
58 |
+ |
} |
|
59 |
+ |
} |
|
60 |
+ |
|
|
61 |
+ |
/** |
|
62 |
+ |
* @return list of buttons that increase the current value (knob moves right or down) |
|
63 |
+ |
*/ |
|
64 |
+ |
public ArrayList<Widget> getLessWidgets() { |
|
65 |
+ |
return less; |
|
66 |
+ |
} |
|
67 |
+ |
|
|
68 |
+ |
/** |
|
69 |
+ |
* @return list of buttons that reduce the current value (knob moves left or up) |
|
70 |
+ |
*/ |
|
71 |
+ |
public ArrayList<Widget> getMoreWidgets() { |
|
72 |
+ |
return more; |
|
73 |
+ |
} |
|
74 |
+ |
|
|
75 |
+ |
public Widget getScaleWidget() { |
|
76 |
+ |
return scale; |
|
77 |
+ |
} |
|
78 |
+ |
|
|
79 |
+ |
protected int getStartPosition() { |
|
80 |
+ |
return this.startPosition; |
|
81 |
+ |
} |
|
82 |
+ |
|
|
83 |
+ |
/** |
|
84 |
+ |
* Sets the button for increase the current value (knob moves right or down) |
|
85 |
+ |
* |
|
86 |
+ |
* @param moreWidget - widget which supports handling of onMouseClick event |
|
87 |
+ |
*/ |
|
88 |
+ |
protected void setMoreWidget( Widget moreWidget ) { |
|
89 |
+ |
orderedWidgets.add( moreWidget ); |
|
90 |
+ |
more.add( moreWidget ); |
|
91 |
+ |
} |
|
92 |
+ |
|
|
93 |
+ |
/** |
|
94 |
+ |
* Sets the button for decrease the current value (knob moves left or up) |
|
95 |
+ |
* |
|
96 |
+ |
* @param moreWidget - widget which supports handling of onMouseClick event |
|
97 |
+ |
*/ |
|
98 |
+ |
protected void setLessWidget( Widget lessWidget ) { |
|
99 |
+ |
orderedWidgets.add( lessWidget ); |
|
100 |
+ |
less.add( lessWidget ); |
|
101 |
+ |
} |
|
102 |
+ |
|
|
103 |
+ |
/** |
|
104 |
+ |
* @param drag - widget for knob representing |
|
105 |
+ |
*/ |
|
106 |
+ |
protected void setDragWidget( Widget drag ) { |
|
107 |
+ |
this.drag = drag; |
|
108 |
+ |
} |
|
109 |
+ |
|
|
110 |
+ |
/** |
|
111 |
+ |
* @param scaleWidget - widget for scale representing |
|
112 |
+ |
* @param scaleSize - height of scale for horizontal sliderbar |
|
113 |
+ |
* or width of scale for vertical sliderbar.<br> |
|
114 |
+ |
* It is possible to adjust thickness of scale with help of this parameter. |
|
115 |
+ |
*/ |
|
116 |
+ |
protected void setScaleWidget( Widget scaleWidget, int scaleSize ) { |
|
117 |
+ |
orderedWidgets.add( scaleWidget ); |
|
118 |
+ |
this.scale = scaleWidget; |
|
119 |
+ |
this.scaleSize = scaleSize; |
|
120 |
+ |
} |
|
121 |
+ |
|
|
122 |
+ |
public Widget getRootWidget() { |
|
123 |
+ |
return this; |
|
124 |
+ |
} |
|
125 |
+ |
|
|
126 |
+ |
/** |
|
127 |
+ |
* With help of this method it is possible to control appearance of outline border around the sliderbar when sliderbar is in focus. |
|
128 |
+ |
*/ |
|
129 |
+ |
public void setNotSelectedInFocus() { |
|
130 |
+ |
DOM.setStyleAttribute( this.getElement(), "outline", "0px" ); |
|
131 |
+ |
} |
|
132 |
+ |
|
|
133 |
+ |
/** |
|
134 |
+ |
* With help of this method it is possible to draw marks of discret positions of knob on scale |
|
135 |
+ |
* |
|
136 |
+ |
* @param color - color of marks |
|
137 |
+ |
* @param delimSize - height of marks for horizontal sliderbar or width of marks for vertical sliderbar |
|
138 |
+ |
*/ |
|
139 |
+ |
public void drawMarks( String color, int delimSize ) { |
|
140 |
+ |
if ( !isMarksPlaced ) { |
|
141 |
+ |
this.color = color; |
|
142 |
+ |
this.delimSize = delimSize; |
|
143 |
+ |
presenter.drawMarks( color, delimSize ); |
|
144 |
+ |
isMarksPlaced = true; |
|
145 |
+ |
} |
|
146 |
+ |
} |
|
147 |
+ |
|
|
148 |
+ |
/** |
|
149 |
+ |
* Remove scale marks from sliderbar |
|
150 |
+ |
*/ |
|
151 |
+ |
public void removeMarks() { |
|
152 |
+ |
int childCount = absPanel.getWidgetCount(); |
|
153 |
+ |
for ( int i = 0; i < childCount; i++ ) { |
|
154 |
+ |
Widget widget = absPanel.getWidget( i ); |
|
155 |
+ |
if ( widget instanceof Mark ) { |
|
156 |
+ |
absPanel.remove( i ); |
|
157 |
+ |
childCount--; |
|
158 |
+ |
i--; |
|
159 |
+ |
} |
|
160 |
+ |
} |
|
161 |
+ |
isMarksPlaced = false; |
|
162 |
+ |
} |
|
163 |
+ |
|
|
164 |
+ |
/** |
|
165 |
+ |
* Adds BarValueChangedHandler (for handling changes of knob position) |
|
166 |
+ |
* |
|
167 |
+ |
* @param barValueChangedHandler |
|
168 |
+ |
* |
|
169 |
+ |
* @return HandlerRegistration used to remove this handler |
|
170 |
+ |
*/ |
|
171 |
+ |
public HandlerRegistration addBarValueChangedHandler( |
|
172 |
+ |
BarValueChangedHandler barValueChangedHandler ) { |
|
173 |
+ |
return presenter.addBarValueChangedHandler( barValueChangedHandler ); |
|
174 |
+ |
} |
|
175 |
+ |
|
|
176 |
+ |
/** |
|
177 |
+ |
* Sets current value. Knob will be moved to correspond position. |
|
178 |
+ |
* |
|
179 |
+ |
* @param value |
|
180 |
+ |
*/ |
|
181 |
+ |
public void setValue( int value ) { |
|
182 |
+ |
presenter.setValue( value ); |
|
183 |
+ |
} |
|
184 |
+ |
|
|
185 |
+ |
protected void prepare( int maxValue, int pixelSize ) { |
|
186 |
+ |
drawScrollBar( pixelSize ); |
|
187 |
+ |
presenter.setMaxValue( maxValue ); |
|
188 |
+ |
presenter.setAbsMaxLength( getAbsMaxLength() ); |
|
189 |
+ |
presenter.processParams(); |
|
190 |
+ |
presenter.setValue( getValue() ); |
|
191 |
+ |
} |
|
192 |
+ |
|
|
193 |
+ |
/** |
|
194 |
+ |
* @return max possible value which knob may point to. This value corresponds to rightmost knob position for horizontal sliderbar or |
|
195 |
+ |
* bottommost knob position for vertical sliderbar |
|
196 |
+ |
*/ |
|
197 |
+ |
public int getMaxValue() { |
|
198 |
+ |
return presenter.getMaxValue(); |
|
199 |
+ |
} |
|
200 |
+ |
|
|
201 |
+ |
/** |
|
202 |
+ |
* Sets value which corresponds to rightmost position of knob for horizontal sliderbar o bottommost position |
|
203 |
+ |
* for vertical sliderbar. |
|
204 |
+ |
* |
|
205 |
+ |
* @param maxValue |
|
206 |
+ |
*/ |
|
207 |
+ |
public void setMaxValue( int maxValue ) { |
|
208 |
+ |
presenter.setMaxValue( maxValue ); |
|
209 |
+ |
presenter.processParams(); |
|
210 |
+ |
try { |
|
211 |
+ |
if ( isMarksPlaced ) { |
|
212 |
+ |
this.removeMarks(); |
|
213 |
+ |
this.drawMarks( color, delimSize ); |
|
214 |
+ |
} |
|
215 |
+ |
setValue( getValue() ); |
|
216 |
+ |
} |
|
217 |
+ |
catch ( Exception e ) { |
|
218 |
+ |
} |
|
219 |
+ |
} |
|
220 |
+ |
|
|
221 |
+ |
public void processParams() { |
|
222 |
+ |
presenter.processParams(); |
|
223 |
+ |
if ( isMarksPlaced ) { |
|
224 |
+ |
isMarksPlaced = false; |
|
225 |
+ |
this.drawMarks( color, delimSize ); |
|
226 |
+ |
} |
|
227 |
+ |
} |
|
228 |
+ |
|
|
229 |
+ |
/** |
|
230 |
+ |
* Returns the value which corresponds to current position of knob |
|
231 |
+ |
* |
|
232 |
+ |
* @return |
|
233 |
+ |
*/ |
|
234 |
+ |
public int getValue() { |
|
235 |
+ |
return presenter.getValue(); |
|
236 |
+ |
} |
|
237 |
+ |
|
|
238 |
+ |
protected void onLoad() { |
|
239 |
+ |
super.onLoad(); |
|
240 |
+ |
|
|
241 |
+ |
if ( drag == null ) { |
|
242 |
+ |
throw new WidgetNotFoundError( "Drag widget not found..." ); |
|
243 |
+ |
} |
|
244 |
+ |
|
|
245 |
+ |
if ( scale == null ) { |
|
246 |
+ |
throw new WidgetNotFoundError( "Scale widget not found..." ); |
|
247 |
+ |
} |
|
248 |
+ |
|
|
249 |
+ |
if ( !wasInited ) { |
|
250 |
+ |
presenter.bind(); |
|
251 |
+ |
wasInited = true; |
|
252 |
+ |
} |
|
253 |
+ |
if ( this.getOrientation() == Orientation.HORIZONTAL ) { |
|
254 |
+ |
this.prepare( presenter.getMaxValue(), this.getOffsetWidth() ); |
|
255 |
+ |
} else { |
|
256 |
+ |
this.prepare( presenter.getMaxValue(), this.getOffsetHeight() ); |
|
257 |
+ |
} |
|
258 |
+ |
reDrawMarks(); |
|
259 |
+ |
} |
|
260 |
+ |
|
|
261 |
+ |
protected void reDrawMarks() { |
|
262 |
+ |
if ( isMarksPlaced ) { |
|
263 |
+ |
this.removeMarks(); |
|
264 |
+ |
this.drawMarks( color, delimSize ); |
|
265 |
+ |
} |
|
266 |
+ |
} |
|
267 |
+ |
|
|
268 |
+ |
protected void putWidgetsToAbsPanel() { |
|
269 |
+ |
for ( int i = 0; i < orderedWidgets.size(); i++ ) { |
|
270 |
+ |
absPanel.add( orderedWidgets.get( i ) ); |
|
271 |
+ |
} |
|
272 |
+ |
this.absPanel.add( drag, 0, 0 ); |
|
273 |
+ |
DOM.setStyleAttribute( drag.getElement(), "zIndex", "500" ); |
|
274 |
+ |
} |
|
275 |
+ |
|
|
276 |
+ |
/** |
|
277 |
+ |
* Sets minimal distance between scale marks in pixels. If distance between marks will be less then this value - marks will not be drowning. |
|
278 |
+ |
* |
|
279 |
+ |
* @param minMarkStep |
|
280 |
+ |
*/ |
|
281 |
+ |
public void setMinMarkStep( int minMarkStep ) { |
|
282 |
+ |
presenter.setMinMarkStep( minMarkStep ); |
|
283 |
+ |
} |
|
284 |
+ |
} |