Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/sliderbar/client/presenter/Presenter.java

Diff revisions: vs.
  @@ -1,367 +1,366 @@
1 - package org.litesoft.GWT.client.widgets.sliderbar.client.presenter;
2 -
3 - import org.litesoft.GWT.client.widgets.sliderbar.client.event.*;
4 - import org.litesoft.GWT.client.widgets.sliderbar.client.view.*;
5 -
6 - import com.google.gwt.event.dom.client.*;
7 - import com.google.gwt.event.shared.*;
8 - import com.google.gwt.user.client.*;
9 - import com.google.gwt.user.client.ui.*;
10 -
11 - import java.util.*;
12 -
13 - public class Presenter {
14 -
15 - public static enum Orientation {
16 - VERTICAL, HORIZONTAL
17 - }
18 -
19 - protected String POINTER = "Pointer";
20 - protected String DEFAULT = "Default";
21 -
22 - protected HandlerManager handlerManager = new HandlerManager( this );
23 - protected SliderBarCalculator sliderBarCalulator = new SliderBarCalculator();
24 - protected Display display;
25 - protected int maxValue;
26 - protected int touchPosition;
27 - protected boolean inDrag;
28 - protected int currentValue = 0, lastFiredValue = -1;
29 - protected Orientation orientation;
30 - protected int minMarkStep = 10;
31 -
32 - public Presenter( Display display, Orientation orientation ) {
33 - this.display = display;
34 - this.orientation = orientation;
35 - }
36 -
37 - public Presenter( Orientation orientation ) {
38 - this( null, orientation );
39 - }
40 -
41 - public void setDislay( Display display ) {
42 - this.display = display;
43 - }
44 -
45 - public HandlerRegistration addBarValueChangedHandler( BarValueChangedHandler barValueChangedHandler ) {
46 - return handlerManager.addHandler( BarValueChangedEvent.TYPE, barValueChangedHandler );
47 - }
48 -
49 - public void setMaxValue( int maxValue ) {
50 - maxValue = (maxValue >= 0) ? maxValue : 0;
51 - if ( maxValue == 0 ) {
52 - display.setDragVisible( false );
53 - } else {
54 - display.setDragVisible( true );
55 - }
56 - this.maxValue = maxValue;
57 - sliderBarCalulator.setMaxValue( maxValue );
58 - }
59 -
60 - public void setAbsMaxLength( int absMaxLength ) {
61 - sliderBarCalulator.setAbsMaxLength( absMaxLength );
62 - }
63 -
64 - public void setBarPixelSize( int barPixelSize ) {
65 - display.drawScrollBar( barPixelSize );
66 - sliderBarCalulator.setAbsMaxLength( display.getAbsMaxLength() );
67 - }
68 -
69 - public void setValue( int value ) {
70 - value = checkValue( value );
71 - currentValue = value;
72 - if ( !display.isAttached() ) {
73 - return;
74 - }
75 - int absPosition = sliderBarCalulator.clcAbsPositionByValue( value );
76 - setDragPosition( absPosition, true );
77 - }
78 -
79 - public void processParams() {
80 - if ( this.maxValue == 0 ) {
81 - return;
82 - }
83 - sliderBarCalulator.processParams();
84 - }
85 -
86 - public int getValue() {
87 - return currentValue;
88 - }
89 -
90 - protected void onRootMouseWheel( MouseWheelEvent event ) {
91 - increaseValue( event.getDeltaY() );
92 - }
93 -
94 - protected void onRootKeyUpLeft() {
95 - increaseValue( -1 );
96 - }
97 -
98 - protected void onRootKeyDownRight() {
99 - increaseValue( 1 );
100 - }
101 -
102 - protected void onDragMouseDown( MouseDownEvent event ) {
103 - if ( this.maxValue == 0 ) {
104 - return;
105 - }
106 - stopDefaultAndPropagationForEvent( event );
107 - DOM.setCapture( display.getDragWidget().getElement() );
108 - inDrag = true;
109 - touchPosition = display.getScaleTouchPosition( event );
110 - }
111 -
112 - protected void onDragMouseUp( MouseUpEvent event ) {
113 - if ( this.maxValue == 0 ) {
114 - return;
115 - }
116 - inDrag = false;
117 - stopDefaultAndPropagationForEvent( event );
118 - DOM.releaseCapture( display.getDragWidget().getElement() );
119 - currentValue = sliderBarCalulator.clcValueByAbsPosition( display.getDragPosition() );
120 - setDragPosition( sliderBarCalulator.clcAbsPositionByValue( currentValue ), true );
121 - }
122 -
123 - protected void onDragMouseMove( MouseMoveEvent event ) {
124 - if ( this.maxValue == 0 ) {
125 - return;
126 - }
127 - event.preventDefault();
128 - if ( !inDrag ) {
129 - return;
130 - }
131 - int newTochPosition = display.getScaleTouchPosition( event );
132 - setDragPosition( sliderBarCalulator.checkAbsPosition( display.getDragPosition() + newTochPosition - touchPosition ), false );
133 - touchPosition = newTochPosition;
134 - }
135 -
136 - protected void onScaleMouseDown( MouseDownEvent event ) {
137 - if ( this.maxValue == 0 ) {
138 - return;
139 - }
140 - stopDefaultAndPropagationForEvent( event );
141 - currentValue = sliderBarCalulator.clcValueByAbsPosition( display.getScaleTouchPosition( event ) );
142 - setDragPosition( sliderBarCalulator.clcAbsPositionByValue( currentValue ), true );
143 - }
144 -
145 - protected void onRootMouseDown( MouseDownEvent event ) {
146 - if ( this.maxValue == 0 ) {
147 - return;
148 - }
149 - currentValue = sliderBarCalulator.clcValueByAbsPosition( display.getScaleTouchPosition( event ) );
150 - setDragPosition( sliderBarCalulator.clcAbsPositionByValue( currentValue ), true );
151 - }
152 -
153 - protected void onRootMouseOver( MouseOverEvent event ) {
154 - if ( this.maxValue == 0 ) {
155 - return;
156 - }
157 - setCursorType( POINTER );
158 - display.getRootWidget().getElement().focus();
159 - }
160 -
161 - protected void onRootMouseOut( MouseOutEvent event ) {
162 - if ( this.maxValue == 0 ) {
163 - return;
164 - }
165 - setCursorType( DEFAULT );
166 - }
167 -
168 - protected void onLessMouseDown( MouseDownEvent event ) {
169 - if ( this.maxValue == 0 ) {
170 - return;
171 - }
172 - stopDefaultAndPropagationForEvent( event );
173 - increaseValue( -1 );
174 - }
175 -
176 - protected void onMoreMouseDown( MouseDownEvent event ) {
177 - if ( this.maxValue == 0 ) {
178 - return;
179 - }
180 - stopDefaultAndPropagationForEvent( event );
181 - increaseValue( 1 );
182 - }
183 -
184 - public void bind() {
185 -
186 - ((HasMouseWheelHandlers) display.getRootWidget()).addMouseWheelHandler( new MouseWheelHandler() {
187 - public void onMouseWheel( MouseWheelEvent event ) {
188 - event.preventDefault();
189 - onRootMouseWheel( event );
190 - }
191 - } );
192 -
193 - ((HasKeyDownHandlers) display.getRootWidget())
194 - .addKeyDownHandler( new KeyDownHandler() {
195 - public void onKeyDown( KeyDownEvent event ) {
196 - int nativeKeyCode = event.getNativeKeyCode();
197 - if ( orientation == Orientation.VERTICAL ) {
198 - if ( nativeKeyCode == KeyCodes.KEY_UP ) {
199 - onRootKeyUpLeft();
200 - }
201 - if ( nativeKeyCode == KeyCodes.KEY_DOWN ) {
202 - onRootKeyDownRight();
203 - }
204 - } else {
205 - if ( nativeKeyCode == KeyCodes.KEY_LEFT ) {
206 - onRootKeyUpLeft();
207 - }
208 - if ( nativeKeyCode == KeyCodes.KEY_RIGHT ) {
209 - onRootKeyDownRight();
210 - }
211 - }
212 - }
213 -
214 - ;
215 - } );
216 -
217 - ((HasMouseDownHandlers) display.getDragWidget()).addMouseDownHandler( new MouseDownHandler() {
218 - public void onMouseDown( MouseDownEvent event ) {
219 - onDragMouseDown( event );
220 - }
221 - } );
222 -
223 - ((HasMouseMoveHandlers) display.getDragWidget()).addMouseMoveHandler( new MouseMoveHandler() {
224 - public void onMouseMove( MouseMoveEvent event ) {
225 - onDragMouseMove( event );
226 - }
227 - } );
228 -
229 - ((HasMouseUpHandlers) display.getDragWidget()).addMouseUpHandler( new MouseUpHandler() {
230 - public void onMouseUp( MouseUpEvent event ) {
231 - onDragMouseUp( event );
232 - }
233 - } );
234 -
235 - ((HasMouseDownHandlers) display.getScaleWidget()).addMouseDownHandler( new MouseDownHandler() {
236 - public void onMouseDown( MouseDownEvent event ) {
237 - onScaleMouseDown( event );
238 - }
239 - } );
240 -
241 - ((HasMouseDownHandlers) display.getRootWidget()).addMouseDownHandler( new MouseDownHandler() {
242 - public void onMouseDown( MouseDownEvent event ) {
243 - onRootMouseDown( event );
244 - }
245 - } );
246 -
247 - ((HasMouseOverHandlers) display.getRootWidget()).addMouseOverHandler( new MouseOverHandler() {
248 - public void onMouseOver( MouseOverEvent event ) {
249 - onRootMouseOver( event );
250 - }
251 - } );
252 -
253 - ((HasMouseOutHandlers) display.getRootWidget()).addMouseOutHandler( new MouseOutHandler() {
254 - public void onMouseOut( MouseOutEvent event ) {
255 - onRootMouseOut( event );
256 - }
257 - } );
258 -
259 - ArrayList<Widget> lessWidgets = display.getLessWidgets();
260 - if ( lessWidgets != null ) {
261 - for ( int i = 0; i < lessWidgets.size(); i++ ) {
262 - ((HasMouseDownHandlers) lessWidgets.get( i ))
263 - .addMouseDownHandler( new MouseDownHandler() {
264 - public void onMouseDown( MouseDownEvent event ) {
265 - onLessMouseDown( event );
266 - }
267 - } );
268 - }
269 - }
270 -
271 - ArrayList<Widget> moreWidgets = display.getMoreWidgets();
272 - if ( moreWidgets != null ) {
273 - for ( int i = 0; i < moreWidgets.size(); i++ ) {
274 - ((HasMouseDownHandlers) moreWidgets.get( i ))
275 - .addMouseDownHandler( new MouseDownHandler() {
276 - public void onMouseDown( MouseDownEvent event ) {
277 - onMoreMouseDown( event );
278 - }
279 - } );
280 - }
281 - }
282 - }
283 -
284 - public int getMaxValue() {
285 - return maxValue;
286 - }
287 -
288 - protected int checkValue( int value ) {
289 - value = (value >= maxValue) ? maxValue : value;
290 - value = (value < 0) ? 0 : value;
291 - // if (value >= maxValue){
292 - // value = maxValue;
293 - // }
294 - // if (value < 0){
295 - // value = 0;
296 - // }
297 - return value;
298 - }
299 -
300 - protected void increaseValue( int stepCount ) {
301 - currentValue += stepCount;
302 - currentValue = checkValue( currentValue );
303 - int cDragPosition = display.getDragPosition();
304 - int nPosition = sliderBarCalulator.clcAbsPositionByValue( currentValue );
305 - if ( cDragPosition == nPosition ) {
306 - nPosition += stepCount / Math.abs( stepCount );
307 - currentValue = sliderBarCalulator.clcValueByAbsPosition( nPosition );
308 - }
309 - setDragPosition( sliderBarCalulator.clcAbsPositionByValue( currentValue ), true );
310 - }
311 -
312 - public void setDragPosition( int position, boolean fireEvent ) {
313 - currentValue = sliderBarCalulator.clcValueByAbsPosition( position );
314 - display.setDragPosition( position );
315 - if ( fireEvent && currentValue != lastFiredValue ) {
316 - handlerManager.fireEvent( new BarValueChangedEvent( currentValue ) );
317 - }
318 - }
319 -
320 - protected void stopDefaultAndPropagationForEvent( DomEvent event ) {
321 - event.preventDefault();
322 - event.stopPropagation();
323 - }
324 -
325 - public void setCursorType( String cursorType ) {
326 - DOM.setStyleAttribute( display.getRootWidget().getElement(), "cursor", cursorType );
327 - }
328 -
329 - public void drawMarks( String color, int delimSize ) {
330 - if ( !isMarkAvailable() ) {
331 - return;
332 - }
333 - int markWidth, markHeight;
334 - if ( this.orientation == Orientation.VERTICAL ) {
335 - markWidth = delimSize;
336 - markHeight = 1;
337 - } else {
338 - markWidth = 1;
339 - markHeight = delimSize;
340 - }
341 -
342 - for ( int i = 0; i <= this.maxValue; i++ ) {
343 - Mark mark = new Mark( color, markWidth, markHeight );
344 - int markPosition = sliderBarCalulator.clcAbsPositionByValue( i );
345 - display.putMark( mark, markPosition );
346 - }
347 - }
348 -
349 - protected int getMarkStep() {
350 - return
351 - sliderBarCalulator.clcAbsPositionByValue( 1 ) - sliderBarCalulator.clcAbsPositionByValue( 0 );
352 - }
353 -
354 - protected boolean isMarkAvailable() {
355 - int currentMarkStep = getMarkStep();
356 - if ( currentMarkStep < this.minMarkStep || this.getMaxValue() == 0 ) {
357 - return false;
358 - } else {
359 - return true;
360 - }
361 - }
362 -
363 - public void setMinMarkStep( int minMarkStep ) {
364 - this.minMarkStep = minMarkStep;
365 - }
366 - }
367 -
1 + package org.litesoft.GWT.client.widgets.sliderbar.client.presenter;
2 +
3 + import org.litesoft.GWT.client.widgets.sliderbar.client.event.*;
4 + import org.litesoft.GWT.client.widgets.sliderbar.client.view.*;
5 +
6 + import com.google.gwt.event.dom.client.*;
7 + import com.google.gwt.event.shared.*;
8 + import com.google.gwt.user.client.*;
9 + import com.google.gwt.user.client.ui.*;
10 +
11 + import java.util.*;
12 +
13 + public class Presenter {
14 +
15 + public static enum Orientation {
16 + VERTICAL, HORIZONTAL
17 + }
18 +
19 + protected String POINTER = "Pointer";
20 + protected String DEFAULT = "Default";
21 +
22 + protected HandlerManager handlerManager = new HandlerManager( this );
23 + protected SliderBarCalculator sliderBarCalulator = new SliderBarCalculator();
24 + protected Display display;
25 + protected int maxValue;
26 + protected int touchPosition;
27 + protected boolean inDrag;
28 + protected int currentValue = 0, lastFiredValue = -1;
29 + protected Orientation orientation;
30 + protected int minMarkStep = 10;
31 +
32 + public Presenter( Display display, Orientation orientation ) {
33 + this.display = display;
34 + this.orientation = orientation;
35 + }
36 +
37 + public Presenter( Orientation orientation ) {
38 + this( null, orientation );
39 + }
40 +
41 + public void setDislay( Display display ) {
42 + this.display = display;
43 + }
44 +
45 + public HandlerRegistration addBarValueChangedHandler( BarValueChangedHandler barValueChangedHandler ) {
46 + return handlerManager.addHandler( BarValueChangedEvent.TYPE, barValueChangedHandler );
47 + }
48 +
49 + public void setMaxValue( int maxValue ) {
50 + maxValue = (maxValue >= 0) ? maxValue : 0;
51 + if ( maxValue == 0 ) {
52 + display.setDragVisible( false );
53 + } else {
54 + display.setDragVisible( true );
55 + }
56 + this.maxValue = maxValue;
57 + sliderBarCalulator.setMaxValue( maxValue );
58 + }
59 +
60 + public void setAbsMaxLength( int absMaxLength ) {
61 + sliderBarCalulator.setAbsMaxLength( absMaxLength );
62 + }
63 +
64 + public void setBarPixelSize( int barPixelSize ) {
65 + display.drawScrollBar( barPixelSize );
66 + sliderBarCalulator.setAbsMaxLength( display.getAbsMaxLength() );
67 + }
68 +
69 + public void setValue( int value ) {
70 + value = checkValue( value );
71 + currentValue = value;
72 + if ( !display.isAttached() ) {
73 + return;
74 + }
75 + int absPosition = sliderBarCalulator.clcAbsPositionByValue( value );
76 + setDragPosition( absPosition, true );
77 + }
78 +
79 + public void processParams() {
80 + if ( this.maxValue == 0 ) {
81 + return;
82 + }
83 + sliderBarCalulator.processParams();
84 + }
85 +
86 + public int getValue() {
87 + return currentValue;
88 + }
89 +
90 + protected void onRootMouseWheel( MouseWheelEvent event ) {
91 + increaseValue( event.getDeltaY() );
92 + }
93 +
94 + protected void onRootKeyUpLeft() {
95 + increaseValue( -1 );
96 + }
97 +
98 + protected void onRootKeyDownRight() {
99 + increaseValue( 1 );
100 + }
101 +
102 + protected void onDragMouseDown( MouseDownEvent event ) {
103 + if ( this.maxValue == 0 ) {
104 + return;
105 + }
106 + stopDefaultAndPropagationForEvent( event );
107 + DOM.setCapture( display.getDragWidget().getElement() );
108 + inDrag = true;
109 + touchPosition = display.getScaleTouchPosition( event );
110 + }
111 +
112 + protected void onDragMouseUp( MouseUpEvent event ) {
113 + if ( this.maxValue == 0 ) {
114 + return;
115 + }
116 + inDrag = false;
117 + stopDefaultAndPropagationForEvent( event );
118 + DOM.releaseCapture( display.getDragWidget().getElement() );
119 + currentValue = sliderBarCalulator.clcValueByAbsPosition( display.getDragPosition() );
120 + setDragPosition( sliderBarCalulator.clcAbsPositionByValue( currentValue ), true );
121 + }
122 +
123 + protected void onDragMouseMove( MouseMoveEvent event ) {
124 + if ( this.maxValue == 0 ) {
125 + return;
126 + }
127 + event.preventDefault();
128 + if ( !inDrag ) {
129 + return;
130 + }
131 + int newTochPosition = display.getScaleTouchPosition( event );
132 + setDragPosition( sliderBarCalulator.checkAbsPosition( display.getDragPosition() + newTochPosition - touchPosition ), false );
133 + touchPosition = newTochPosition;
134 + }
135 +
136 + protected void onScaleMouseDown( MouseDownEvent event ) {
137 + if ( this.maxValue == 0 ) {
138 + return;
139 + }
140 + stopDefaultAndPropagationForEvent( event );
141 + currentValue = sliderBarCalulator.clcValueByAbsPosition( display.getScaleTouchPosition( event ) );
142 + setDragPosition( sliderBarCalulator.clcAbsPositionByValue( currentValue ), true );
143 + }
144 +
145 + protected void onRootMouseDown( MouseDownEvent event ) {
146 + if ( this.maxValue == 0 ) {
147 + return;
148 + }
149 + currentValue = sliderBarCalulator.clcValueByAbsPosition( display.getScaleTouchPosition( event ) );
150 + setDragPosition( sliderBarCalulator.clcAbsPositionByValue( currentValue ), true );
151 + }
152 +
153 + protected void onRootMouseOver( MouseOverEvent event ) {
154 + if ( this.maxValue == 0 ) {
155 + return;
156 + }
157 + setCursorType( POINTER );
158 + display.getRootWidget().getElement().focus();
159 + }
160 +
161 + protected void onRootMouseOut( MouseOutEvent event ) {
162 + if ( this.maxValue == 0 ) {
163 + return;
164 + }
165 + setCursorType( DEFAULT );
166 + }
167 +
168 + protected void onLessMouseDown( MouseDownEvent event ) {
169 + if ( this.maxValue == 0 ) {
170 + return;
171 + }
172 + stopDefaultAndPropagationForEvent( event );
173 + increaseValue( -1 );
174 + }
175 +
176 + protected void onMoreMouseDown( MouseDownEvent event ) {
177 + if ( this.maxValue == 0 ) {
178 + return;
179 + }
180 + stopDefaultAndPropagationForEvent( event );
181 + increaseValue( 1 );
182 + }
183 +
184 + public void bind() {
185 +
186 + ((HasMouseWheelHandlers) display.getRootWidget()).addMouseWheelHandler( new MouseWheelHandler() {
187 + public void onMouseWheel( MouseWheelEvent event ) {
188 + event.preventDefault();
189 + onRootMouseWheel( event );
190 + }
191 + } );
192 +
193 + ((HasKeyDownHandlers) display.getRootWidget())
194 + .addKeyDownHandler( new KeyDownHandler() {
195 + public void onKeyDown( KeyDownEvent event ) {
196 + int nativeKeyCode = event.getNativeKeyCode();
197 + if ( orientation == Orientation.VERTICAL ) {
198 + if ( nativeKeyCode == KeyCodes.KEY_UP ) {
199 + onRootKeyUpLeft();
200 + }
201 + if ( nativeKeyCode == KeyCodes.KEY_DOWN ) {
202 + onRootKeyDownRight();
203 + }
204 + } else {
205 + if ( nativeKeyCode == KeyCodes.KEY_LEFT ) {
206 + onRootKeyUpLeft();
207 + }
208 + if ( nativeKeyCode == KeyCodes.KEY_RIGHT ) {
209 + onRootKeyDownRight();
210 + }
211 + }
212 + }
213 +
214 + ;
215 + } );
216 +
217 + ((HasMouseDownHandlers) display.getDragWidget()).addMouseDownHandler( new MouseDownHandler() {
218 + public void onMouseDown( MouseDownEvent event ) {
219 + onDragMouseDown( event );
220 + }
221 + } );
222 +
223 + ((HasMouseMoveHandlers) display.getDragWidget()).addMouseMoveHandler( new MouseMoveHandler() {
224 + public void onMouseMove( MouseMoveEvent event ) {
225 + onDragMouseMove( event );
226 + }
227 + } );
228 +
229 + ((HasMouseUpHandlers) display.getDragWidget()).addMouseUpHandler( new MouseUpHandler() {
230 + public void onMouseUp( MouseUpEvent event ) {
231 + onDragMouseUp( event );
232 + }
233 + } );
234 +
235 + ((HasMouseDownHandlers) display.getScaleWidget()).addMouseDownHandler( new MouseDownHandler() {
236 + public void onMouseDown( MouseDownEvent event ) {
237 + onScaleMouseDown( event );
238 + }
239 + } );
240 +
241 + ((HasMouseDownHandlers) display.getRootWidget()).addMouseDownHandler( new MouseDownHandler() {
242 + public void onMouseDown( MouseDownEvent event ) {
243 + onRootMouseDown( event );
244 + }
245 + } );
246 +
247 + ((HasMouseOverHandlers) display.getRootWidget()).addMouseOverHandler( new MouseOverHandler() {
248 + public void onMouseOver( MouseOverEvent event ) {
249 + onRootMouseOver( event );
250 + }
251 + } );
252 +
253 + ((HasMouseOutHandlers) display.getRootWidget()).addMouseOutHandler( new MouseOutHandler() {
254 + public void onMouseOut( MouseOutEvent event ) {
255 + onRootMouseOut( event );
256 + }
257 + } );
258 +
259 + ArrayList<Widget> lessWidgets = display.getLessWidgets();
260 + if ( lessWidgets != null ) {
261 + for ( int i = 0; i < lessWidgets.size(); i++ ) {
262 + ((HasMouseDownHandlers) lessWidgets.get( i ))
263 + .addMouseDownHandler( new MouseDownHandler() {
264 + public void onMouseDown( MouseDownEvent event ) {
265 + onLessMouseDown( event );
266 + }
267 + } );
268 + }
269 + }
270 +
271 + ArrayList<Widget> moreWidgets = display.getMoreWidgets();
272 + if ( moreWidgets != null ) {
273 + for ( int i = 0; i < moreWidgets.size(); i++ ) {
274 + ((HasMouseDownHandlers) moreWidgets.get( i ))
275 + .addMouseDownHandler( new MouseDownHandler() {
276 + public void onMouseDown( MouseDownEvent event ) {
277 + onMoreMouseDown( event );
278 + }
279 + } );
280 + }
281 + }
282 + }
283 +
284 + public int getMaxValue() {
285 + return maxValue;
286 + }
287 +
288 + protected int checkValue( int value ) {
289 + value = (value >= maxValue) ? maxValue : value;
290 + value = (value < 0) ? 0 : value;
291 + // if (value >= maxValue){
292 + // value = maxValue;
293 + // }
294 + // if (value < 0){
295 + // value = 0;
296 + // }
297 + return value;
298 + }
299 +
300 + protected void increaseValue( int stepCount ) {
301 + currentValue += stepCount;
302 + currentValue = checkValue( currentValue );
303 + int cDragPosition = display.getDragPosition();
304 + int nPosition = sliderBarCalulator.clcAbsPositionByValue( currentValue );
305 + if ( cDragPosition == nPosition ) {
306 + nPosition += stepCount / Math.abs( stepCount );
307 + currentValue = sliderBarCalulator.clcValueByAbsPosition( nPosition );
308 + }
309 + setDragPosition( sliderBarCalulator.clcAbsPositionByValue( currentValue ), true );
310 + }
311 +
312 + public void setDragPosition( int position, boolean fireEvent ) {
313 + currentValue = sliderBarCalulator.clcValueByAbsPosition( position );
314 + display.setDragPosition( position );
315 + if ( fireEvent && currentValue != lastFiredValue ) {
316 + handlerManager.fireEvent( new BarValueChangedEvent( currentValue ) );
317 + }
318 + }
319 +
320 + protected void stopDefaultAndPropagationForEvent( DomEvent event ) {
321 + event.preventDefault();
322 + event.stopPropagation();
323 + }
324 +
325 + public void setCursorType( String cursorType ) {
326 + DOM.setStyleAttribute( display.getRootWidget().getElement(), "cursor", cursorType );
327 + }
328 +
329 + public void drawMarks( String color, int delimSize ) {
330 + if ( !isMarkAvailable() ) {
331 + return;
332 + }
333 + int markWidth, markHeight;
334 + if ( this.orientation == Orientation.VERTICAL ) {
335 + markWidth = delimSize;
336 + markHeight = 1;
337 + } else {
338 + markWidth = 1;
339 + markHeight = delimSize;
340 + }
341 +
342 + for ( int i = 0; i <= this.maxValue; i++ ) {
343 + Mark mark = new Mark( color, markWidth, markHeight );
344 + int markPosition = sliderBarCalulator.clcAbsPositionByValue( i );
345 + display.putMark( mark, markPosition );
346 + }
347 + }
348 +
349 + protected int getMarkStep() {
350 + return
351 + sliderBarCalulator.clcAbsPositionByValue( 1 ) - sliderBarCalulator.clcAbsPositionByValue( 0 );
352 + }
353 +
354 + protected boolean isMarkAvailable() {
355 + int currentMarkStep = getMarkStep();
356 + if ( currentMarkStep < this.minMarkStep || this.getMaxValue() == 0 ) {
357 + return false;
358 + } else {
359 + return true;
360 + }
361 + }
362 +
363 + public void setMinMarkStep( int minMarkStep ) {
364 + this.minMarkStep = minMarkStep;
365 + }
366 + }