|
@@ -12,53 +12,53 @@ |
12 |
12 |
|
return maxValue; |
13 |
13 |
|
} |
14 |
14 |
|
|
15 |
|
- |
public void setMaxValue(int maxValue) { |
|
15 |
+ |
public void setMaxValue( int maxValue ) { |
16 |
16 |
|
this.maxValue = maxValue; |
17 |
17 |
|
} |
18 |
18 |
|
|
19 |
|
- |
public void setAbsMaxLength(int absMaxLength) { |
|
19 |
+ |
public void setAbsMaxLength( int absMaxLength ) { |
20 |
20 |
|
this.absMaxLength = absMaxLength; |
21 |
21 |
|
} |
22 |
22 |
|
|
23 |
|
- |
protected void processParams(){ |
|
23 |
+ |
protected void processParams() { |
24 |
24 |
|
int usedAbsLength = absMaxLength; |
25 |
25 |
|
minPosition = 0; |
26 |
26 |
|
maxPosition = absMaxLength; |
27 |
|
- |
if (absMaxLength >= maxValue){ |
|
27 |
+ |
if ( absMaxLength >= maxValue ) { |
28 |
28 |
|
usedAbsLength = absMaxLength - absMaxLength % maxValue; |
29 |
29 |
|
minPosition = (absMaxLength - usedAbsLength) / 2; |
30 |
30 |
|
maxPosition = minPosition + usedAbsLength; |
31 |
31 |
|
} |
32 |
|
- |
step = usedAbsLength/maxValue; |
33 |
|
- |
if (step == 0){ |
|
32 |
+ |
step = usedAbsLength / maxValue; |
|
33 |
+ |
if ( step == 0 ) { |
34 |
34 |
|
step = 1; |
35 |
35 |
|
} |
36 |
|
- |
k = (double)usedAbsLength/maxValue; |
|
36 |
+ |
k = (double) usedAbsLength / maxValue; |
37 |
37 |
|
} |
38 |
38 |
|
|
39 |
|
- |
public int checkAbsPosition(int absPosition){ |
40 |
|
- |
if (absPosition < minPosition){ |
|
39 |
+ |
public int checkAbsPosition( int absPosition ) { |
|
40 |
+ |
if ( absPosition < minPosition ) { |
41 |
41 |
|
absPosition = minPosition; |
42 |
42 |
|
} |
43 |
|
- |
if (absPosition > maxPosition){ |
|
43 |
+ |
if ( absPosition > maxPosition ) { |
44 |
44 |
|
absPosition = maxPosition; |
45 |
45 |
|
} |
46 |
46 |
|
return absPosition; |
47 |
47 |
|
} |
48 |
48 |
|
|
49 |
|
- |
protected int clcValueByAbsPosition(int currentAbsPosition){ |
50 |
|
- |
currentAbsPosition = checkAbsPosition(currentAbsPosition) - minPosition; |
51 |
|
- |
int value = (int)Math.round((currentAbsPosition/k)); |
|
49 |
+ |
protected int clcValueByAbsPosition( int currentAbsPosition ) { |
|
50 |
+ |
currentAbsPosition = checkAbsPosition( currentAbsPosition ) - minPosition; |
|
51 |
+ |
int value = (int) Math.round( (currentAbsPosition / k) ); |
52 |
52 |
|
return value; |
53 |
53 |
|
} |
54 |
54 |
|
|
55 |
|
- |
protected int clcAbsPositionByValue(int value){ |
|
55 |
+ |
protected int clcAbsPositionByValue( int value ) { |
56 |
56 |
|
int absPosition; |
57 |
|
- |
if (k >= 1){ |
58 |
|
- |
absPosition = value * step; |
|
57 |
+ |
if ( k >= 1 ) { |
|
58 |
+ |
absPosition = value * step; |
59 |
59 |
|
} else { |
60 |
|
- |
absPosition = (int)Math.round(value * k); |
|
60 |
+ |
absPosition = (int) Math.round( value * k ); |
61 |
61 |
|
} |
62 |
|
- |
return absPosition + minPosition; |
|
62 |
+ |
return absPosition + minPosition; |
63 |
63 |
|
} |
64 |
64 |
|
} |