Subversion Repository Public Repository

litesoft

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

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