Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -1,64 +1,64 @@
1 - package org.litesoft.GWT.client.widgets.sliderbar.client.presenter;
2 -
3 - public class SliderBarCalculator {
4 - protected int maxValue;
5 - protected int absMaxLength;
6 - protected int minPosition, maxPosition;
7 -
8 - private int step;
9 - private double k;
10 -
11 - public int getMaxValue() {
12 - return maxValue;
13 - }
14 -
15 - public void setMaxValue( int maxValue ) {
16 - this.maxValue = maxValue;
17 - }
18 -
19 - public void setAbsMaxLength( int absMaxLength ) {
20 - this.absMaxLength = absMaxLength;
21 - }
22 -
23 - protected void processParams() {
24 - int usedAbsLength = absMaxLength;
25 - minPosition = 0;
26 - maxPosition = absMaxLength;
27 - if ( absMaxLength >= maxValue ) {
28 - usedAbsLength = absMaxLength - absMaxLength % maxValue;
29 - minPosition = (absMaxLength - usedAbsLength) / 2;
30 - maxPosition = minPosition + usedAbsLength;
31 - }
32 - step = usedAbsLength / maxValue;
33 - if ( step == 0 ) {
34 - step = 1;
35 - }
36 - k = (double) usedAbsLength / maxValue;
37 - }
38 -
39 - public int checkAbsPosition( int absPosition ) {
40 - if ( absPosition < minPosition ) {
41 - absPosition = minPosition;
42 - }
43 - if ( absPosition > maxPosition ) {
44 - absPosition = maxPosition;
45 - }
46 - return absPosition;
47 - }
48 -
49 - protected int clcValueByAbsPosition( int currentAbsPosition ) {
50 - currentAbsPosition = checkAbsPosition( currentAbsPosition ) - minPosition;
51 - int value = (int) Math.round( (currentAbsPosition / k) );
52 - return value;
53 - }
54 -
55 - protected int clcAbsPositionByValue( int value ) {
56 - int absPosition;
57 - if ( k >= 1 ) {
58 - absPosition = value * step;
59 - } else {
60 - absPosition = (int) Math.round( value * k );
61 - }
62 - return absPosition + minPosition;
63 - }
64 - }
1 + package org.litesoft.GWT.client.widgets.sliderbar.client.presenter;
2 +
3 + public class SliderBarCalculator {
4 + protected int maxValue;
5 + protected int absMaxLength;
6 + protected int minPosition, maxPosition;
7 +
8 + private int step;
9 + private double k;
10 +
11 + public int getMaxValue() {
12 + return maxValue;
13 + }
14 +
15 + public void setMaxValue( int maxValue ) {
16 + this.maxValue = maxValue;
17 + }
18 +
19 + public void setAbsMaxLength( int absMaxLength ) {
20 + this.absMaxLength = absMaxLength;
21 + }
22 +
23 + protected void processParams() {
24 + int usedAbsLength = absMaxLength;
25 + minPosition = 0;
26 + maxPosition = absMaxLength;
27 + if ( absMaxLength >= maxValue ) {
28 + usedAbsLength = absMaxLength - absMaxLength % maxValue;
29 + minPosition = (absMaxLength - usedAbsLength) / 2;
30 + maxPosition = minPosition + usedAbsLength;
31 + }
32 + step = usedAbsLength / maxValue;
33 + if ( step == 0 ) {
34 + step = 1;
35 + }
36 + k = (double) usedAbsLength / maxValue;
37 + }
38 +
39 + public int checkAbsPosition( int absPosition ) {
40 + if ( absPosition < minPosition ) {
41 + absPosition = minPosition;
42 + }
43 + if ( absPosition > maxPosition ) {
44 + absPosition = maxPosition;
45 + }
46 + return absPosition;
47 + }
48 +
49 + protected int clcValueByAbsPosition( int currentAbsPosition ) {
50 + currentAbsPosition = checkAbsPosition( currentAbsPosition ) - minPosition;
51 + int value = (int) Math.round( (currentAbsPosition / k) );
52 + return value;
53 + }
54 +
55 + protected int clcAbsPositionByValue( int value ) {
56 + int absPosition;
57 + if ( k >= 1 ) {
58 + absPosition = value * step;
59 + } else {
60 + absPosition = (int) Math.round( value * k );
61 + }
62 + return absPosition + minPosition;
63 + }
64 + }