|
@@ -1,83 +1,82 @@ |
1 |
1 |
|
package org.litesoft.GWT.client.widgets.sliderbar.client.view; |
2 |
2 |
|
|
3 |
|
- |
import java.util.ArrayList; |
|
3 |
+ |
import org.litesoft.GWT.client.widgets.sliderbar.client.presenter.*; |
|
4 |
+ |
import org.litesoft.GWT.client.widgets.sliderbar.client.presenter.Presenter.*; |
4 |
5 |
|
|
5 |
|
- |
import com.google.gwt.event.dom.client.MouseEvent; |
6 |
|
- |
import com.google.gwt.user.client.ui.Widget; |
7 |
|
- |
import org.litesoft.GWT.client.widgets.sliderbar.client.presenter.Presenter; |
8 |
|
- |
import org.litesoft.GWT.client.widgets.sliderbar.client.presenter.Presenter.Orientation; |
|
6 |
+ |
import com.google.gwt.event.dom.client.*; |
|
7 |
+ |
import com.google.gwt.user.client.ui.*; |
|
8 |
+ |
|
|
9 |
+ |
import java.util.*; |
9 |
10 |
|
|
10 |
11 |
|
/** |
11 |
|
- |
* |
12 |
12 |
|
* @author kiouri |
13 |
|
- |
* |
14 |
13 |
|
*/ |
15 |
|
- |
public class SliderBarVertical extends SliderBar{ |
|
14 |
+ |
public class SliderBarVertical extends SliderBar { |
16 |
15 |
|
|
17 |
16 |
|
protected int barWidth, barHeight, dragLeftPosition, scaleHeight; |
18 |
17 |
|
|
19 |
|
- |
public SliderBarVertical(Presenter presenter){ |
20 |
|
- |
super(presenter); |
|
18 |
+ |
public SliderBarVertical( Presenter presenter ) { |
|
19 |
+ |
super( presenter ); |
21 |
20 |
|
} |
22 |
21 |
|
|
23 |
|
- |
public SliderBarVertical(){ |
|
22 |
+ |
public SliderBarVertical() { |
24 |
23 |
|
super(); |
25 |
24 |
|
} |
26 |
25 |
|
|
27 |
|
- |
public int getBarWidth(){ |
|
26 |
+ |
public int getBarWidth() { |
28 |
27 |
|
barWidth = drag.getOffsetWidth(); |
29 |
|
- |
for (int i = 0; i < orderedWidgets.size(); i++){ |
30 |
|
- |
if (orderedWidgets.get(i) == scale){ |
31 |
|
- |
barWidth = Math.max(barWidth, scaleSize); |
|
28 |
+ |
for ( int i = 0; i < orderedWidgets.size(); i++ ) { |
|
29 |
+ |
if ( orderedWidgets.get( i ) == scale ) { |
|
30 |
+ |
barWidth = Math.max( barWidth, scaleSize ); |
32 |
31 |
|
} else { |
33 |
|
- |
barWidth = Math.max(barWidth, orderedWidgets.get(i).getOffsetWidth()); |
|
32 |
+ |
barWidth = Math.max( barWidth, orderedWidgets.get( i ).getOffsetWidth() ); |
34 |
33 |
|
} |
35 |
34 |
|
} |
36 |
|
- |
barWidth = Math.max(barWidth, scaleSize); |
|
35 |
+ |
barWidth = Math.max( barWidth, scaleSize ); |
37 |
36 |
|
return barWidth; |
38 |
37 |
|
} |
39 |
38 |
|
|
40 |
|
- |
public void ajustScaleSize(int widgetHeight){ |
|
39 |
+ |
public void ajustScaleSize( int widgetHeight ) { |
41 |
40 |
|
scaleHeight = widgetHeight; |
42 |
|
- |
if (less != null) { |
43 |
|
- |
for (int i = 0; i < less.size(); i++) { |
44 |
|
- |
scaleHeight -= less.get(i).getOffsetHeight(); |
|
41 |
+ |
if ( less != null ) { |
|
42 |
+ |
for ( int i = 0; i < less.size(); i++ ) { |
|
43 |
+ |
scaleHeight -= less.get( i ).getOffsetHeight(); |
45 |
44 |
|
} |
46 |
45 |
|
} |
47 |
|
- |
if (more != null) { |
48 |
|
- |
for (int i = 0; i < more.size(); i++) { |
49 |
|
- |
scaleHeight -= more.get(i).getOffsetHeight(); |
|
46 |
+ |
if ( more != null ) { |
|
47 |
+ |
for ( int i = 0; i < more.size(); i++ ) { |
|
48 |
+ |
scaleHeight -= more.get( i ).getOffsetHeight(); |
50 |
49 |
|
} |
51 |
50 |
|
} |
52 |
|
- |
scale.setPixelSize(scaleSize, scaleHeight); |
|
51 |
+ |
scale.setPixelSize( scaleSize, scaleHeight ); |
53 |
52 |
|
} |
54 |
53 |
|
|
55 |
54 |
|
public int getAbsMaxLength() { |
56 |
55 |
|
return scaleHeight - drag.getOffsetHeight(); |
57 |
56 |
|
} |
58 |
57 |
|
|
59 |
|
- |
public void drawScrollBar(int barHeight) { |
|
58 |
+ |
public void drawScrollBar( int barHeight ) { |
60 |
59 |
|
absPanel.clear(); |
61 |
60 |
|
putWidgetsToAbsPanel(); |
62 |
|
- |
initVariables(barHeight); |
63 |
|
- |
ajustScaleSize(barHeight); |
64 |
|
- |
this.setWidth(getBarWidth() + "px"); |
65 |
|
- |
absPanel.setPixelSize(getBarWidth(), barHeight); |
66 |
|
- |
placeWidgets(orderedWidgets); |
67 |
|
- |
absPanel.setWidgetPosition(drag, dragLeftPosition, getScaleTop(orderedWidgets)); |
|
61 |
+ |
initVariables( barHeight ); |
|
62 |
+ |
ajustScaleSize( barHeight ); |
|
63 |
+ |
this.setWidth( getBarWidth() + "px" ); |
|
64 |
+ |
absPanel.setPixelSize( getBarWidth(), barHeight ); |
|
65 |
+ |
placeWidgets( orderedWidgets ); |
|
66 |
+ |
absPanel.setWidgetPosition( drag, dragLeftPosition, getScaleTop( orderedWidgets ) ); |
68 |
67 |
|
} |
69 |
68 |
|
|
70 |
|
- |
protected void initVariables(int barHeight){ |
|
69 |
+ |
protected void initVariables( int barHeight ) { |
71 |
70 |
|
this.barHeight = barHeight; |
72 |
|
- |
startPosition = getScaleTop(orderedWidgets); |
73 |
|
- |
dragLeftPosition = (getBarWidth() - drag.getOffsetWidth())/2; |
|
71 |
+ |
startPosition = getScaleTop( orderedWidgets ); |
|
72 |
+ |
dragLeftPosition = (getBarWidth() - drag.getOffsetWidth()) / 2; |
74 |
73 |
|
} |
75 |
74 |
|
|
76 |
|
- |
protected int getScaleTop(ArrayList<Widget> widgets){ |
|
75 |
+ |
protected int getScaleTop( ArrayList<Widget> widgets ) { |
77 |
76 |
|
int sPosition = 0; |
78 |
|
- |
for (int i = 0; i < widgets.size(); i++){ |
79 |
|
- |
if (widgets.get(i) != scale){ |
80 |
|
- |
sPosition += widgets.get(i).getOffsetHeight(); |
|
77 |
+ |
for ( int i = 0; i < widgets.size(); i++ ) { |
|
78 |
+ |
if ( widgets.get( i ) != scale ) { |
|
79 |
+ |
sPosition += widgets.get( i ).getOffsetHeight(); |
81 |
80 |
|
} else { |
82 |
81 |
|
return sPosition; |
83 |
82 |
|
} |
|
@@ -85,49 +84,49 @@ |
85 |
84 |
|
return sPosition; |
86 |
85 |
|
} |
87 |
86 |
|
|
88 |
|
- |
protected void placeWidgets(ArrayList<Widget> widgets){ |
|
87 |
+ |
protected void placeWidgets( ArrayList<Widget> widgets ) { |
89 |
88 |
|
int tmpPosition = 0; |
90 |
89 |
|
int barWidth = getBarWidth(); |
91 |
|
- |
for (int i = 0; i < widgets.size(); i++){ |
92 |
|
- |
if (widgets.get(i) == scale){ |
93 |
|
- |
absPanel.setWidgetPosition(widgets.get(i), (barWidth - scaleSize)/2, tmpPosition); |
|
90 |
+ |
for ( int i = 0; i < widgets.size(); i++ ) { |
|
91 |
+ |
if ( widgets.get( i ) == scale ) { |
|
92 |
+ |
absPanel.setWidgetPosition( widgets.get( i ), (barWidth - scaleSize) / 2, tmpPosition ); |
94 |
93 |
|
} else { |
95 |
|
- |
absPanel.setWidgetPosition(widgets.get(i), (barWidth - widgets.get(i).getOffsetWidth())/2, tmpPosition); |
|
94 |
+ |
absPanel.setWidgetPosition( widgets.get( i ), (barWidth - widgets.get( i ).getOffsetWidth()) / 2, tmpPosition ); |
96 |
95 |
|
} |
97 |
|
- |
tmpPosition += widgets.get(i).getOffsetHeight(); |
|
96 |
+ |
tmpPosition += widgets.get( i ).getOffsetHeight(); |
98 |
97 |
|
} |
99 |
98 |
|
} |
100 |
99 |
|
|
101 |
|
- |
public void setDragPosition(int position){ |
|
100 |
+ |
public void setDragPosition( int position ) { |
102 |
101 |
|
position = startPosition + position; |
103 |
|
- |
absPanel.setWidgetPosition(drag, dragLeftPosition, position); |
|
102 |
+ |
absPanel.setWidgetPosition( drag, dragLeftPosition, position ); |
104 |
103 |
|
} |
105 |
104 |
|
|
106 |
|
- |
public int getScaleTouchPosition(MouseEvent event) { |
107 |
|
- |
return event.getRelativeY(this.getElement()) - startPosition - drag.getOffsetHeight()/2; |
|
105 |
+ |
public int getScaleTouchPosition( MouseEvent event ) { |
|
106 |
+ |
return event.getRelativeY( this.getElement() ) - startPosition - drag.getOffsetHeight() / 2; |
108 |
107 |
|
} |
109 |
108 |
|
|
110 |
109 |
|
public int getDragPosition() { |
111 |
|
- |
return absPanel.getWidgetTop(drag) - startPosition; |
|
110 |
+ |
return absPanel.getWidgetTop( drag ) - startPosition; |
112 |
111 |
|
} |
113 |
112 |
|
|
114 |
|
- |
public void putMark(Mark mark, int markPosition) { |
115 |
|
- |
int markX = (this.barWidth - mark.getMarkWidth()) / 2; |
116 |
|
- |
this.absPanel.add(mark, markX, startPosition + markPosition + drag.getOffsetHeight()/2); |
|
113 |
+ |
public void putMark( Mark mark, int markPosition ) { |
|
114 |
+ |
int markX = (this.barWidth - mark.getMarkWidth()) / 2; |
|
115 |
+ |
this.absPanel.add( mark, markX, startPosition + markPosition + drag.getOffsetHeight() / 2 ); |
117 |
116 |
|
} |
118 |
117 |
|
|
119 |
|
- |
public Orientation getOrientation(){ |
|
118 |
+ |
public Orientation getOrientation() { |
120 |
119 |
|
return Orientation.VERTICAL; |
121 |
120 |
|
} |
122 |
121 |
|
|
123 |
122 |
|
@Override |
124 |
|
- |
public void setHeight(String height) { |
125 |
|
- |
super.setHeight(height); |
126 |
|
- |
if ( this.isAttached()) { |
127 |
|
- |
presenter.setBarPixelSize(this.getOffsetHeight()); |
|
123 |
+ |
public void setHeight( String height ) { |
|
124 |
+ |
super.setHeight( height ); |
|
125 |
+ |
if ( this.isAttached() ) { |
|
126 |
+ |
presenter.setBarPixelSize( this.getOffsetHeight() ); |
128 |
127 |
|
presenter.processParams(); |
129 |
128 |
|
reDrawMarks(); |
130 |
|
- |
setValue(getValue()); |
|
129 |
+ |
setValue( getValue() ); |
131 |
130 |
|
} |
132 |
131 |
|
} |
133 |
132 |
|
|
|
@@ -136,12 +135,11 @@ |
136 |
135 |
|
* Width of horizontal sliderbar is automatically calculated on base of height of components which are included in widget |
137 |
136 |
|
*/ |
138 |
137 |
|
@Override |
139 |
|
- |
public void setWidth(String width) { |
140 |
|
- |
super.setWidth(getBarWidth() + "px"); |
|
138 |
+ |
public void setWidth( String width ) { |
|
139 |
+ |
super.setWidth( getBarWidth() + "px" ); |
141 |
140 |
|
} |
142 |
141 |
|
|
143 |
|
- |
public void setScaleWidget(Widget scaleWidget, int scaleWidth){ |
144 |
|
- |
super.setScaleWidget(scaleWidget, scaleWidth); |
|
142 |
+ |
public void setScaleWidget( Widget scaleWidget, int scaleWidth ) { |
|
143 |
+ |
super.setScaleWidget( scaleWidget, scaleWidth ); |
145 |
144 |
|
} |
146 |
|
- |
|
147 |
145 |
|
} |