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