Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/sliderbar/client/view/SliderBarHorizontal.java

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