-
Notifications
You must be signed in to change notification settings - Fork 0
/
Radius.java
93 lines (83 loc) · 2.58 KB
/
Radius.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package study.amadey.customview;
import android.graphics.RectF;
import java.time.Clock;
final class Radius {
private RectF clockFrame;
Radius() {}
void setClockFrame(RectF clockFrame){
this.clockFrame = clockFrame;
}
/**
* Determines total radius of clock face which will contain spinning clock hand and time labels.
*
* @return
* returns total radius of clock face
*/
int getTotalClockRadius() {
return (int) clockFrame.width() / 2;
}
/**
* Determines radius of zooming in for a time label when clock hand is pointing at it.
*
* @return
* returns radius of zooming in
*/
int getZoomingRadius() {
return (int) (clockFrame.width() / 25);
}
/**
* Determines radius of drawing for time label.
*
* @param clockElement
* determines type of drawing clock element
* @param drawBigMinuteRadius
* determines whether radius of minute time label must be big or small
* @return
* returns time label radius
*/
int getTimeLabelRadius(ClockElement clockElement, boolean drawBigMinuteRadius) {
switch (clockElement) {
case HOUR:
return getRadiusOfHourCircle();
case MINUTE:
return drawBigMinuteRadius ? getBigRadiusOfMinuteCircle() : getSmallRadiusOfMinuteCircle();
default:
return 0;
}
}
private int getRadiusOfHourCircle() {
return (int) clockFrame.width() / 50;
}
private int getBigRadiusOfMinuteCircle() {
return (int) clockFrame.width() / 70;
}
private int getSmallRadiusOfMinuteCircle() {
return (int) clockFrame.width() / 150;
}
/**
* Determines radius of spinning of a clock hand depending on
* {@code clockElement} type.
*
* @param clockElement
* determines clock hand type
*
* @return
* radius of spinning of a clock hand
*/
int getRadiusOfSpinning(ClockElement clockElement) {
switch (clockElement) {
case HOUR:
return getRadiusOfSpinningOfHourHand();
case MINUTE:
return getRadiusOfSpinningOfMinuteHand();
default:
return 0;
}
}
private int getRadiusOfSpinningOfHourHand() {
return getTotalClockRadius() - ((getTotalClockRadius() / 10) * 3);
}
private int getRadiusOfSpinningOfMinuteHand() {
return getTotalClockRadius() - getTotalClockRadius() / 10;
}
}