-
Notifications
You must be signed in to change notification settings - Fork 0
/
Slider.pde
48 lines (43 loc) · 1.15 KB
/
Slider.pde
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
class Slider
{
// The slider class contains and runs all of the code relating to the slider. This includes
// the buttons for incrementing and decrementing its position.
//
// In order to run these classes in the main, all that needs to be called is slider.draw()
//
//The slider can be manipulated using the left and right arrow keys
private int numberOfDays;
public SliderBox box;
private SliderRail rail = new SliderRail();
private SliderMinusButton minusButton = new SliderMinusButton();
private SliderPlusButton plusButton = new SliderPlusButton();
private MapSliderBoundary boundary = new MapSliderBoundary();
Slider(int numberOfDays, ColorGroup colors)
{
this.numberOfDays=numberOfDays;
box = new SliderBox(colors);
}
int getNumberOfDays()
{
return numberOfDays;
}
SliderBox getSliderBox()
{
return box;
}
void draw()
{
rail.draw();
minusButton.draw();
plusButton.draw();
box.draw();
box.move();
minusButton.pressed(box);
plusButton.pressed(box);
boundary.draw();
}
int getBoxLocation()
{
return ((box.getX()+SLIDERBOX_WIDTH/2)-(MARGIN_X))/(SLIDERRAIL_WIDTH/numberOfDays);
}
}