forked from scottmcn204/Group27Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPin.pde
More file actions
73 lines (64 loc) · 1.69 KB
/
Pin.pde
File metadata and controls
73 lines (64 loc) · 1.69 KB
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
/**
* The Pin Class is used to represent a single pin on the MapScreen class.
* It is given discrete coordinates and a specific event from the MapScreen class.
* Contains a constructor along with methods to know when a mouse has clicked or hovered over it.
*/
class Pin {
final float CIRCLE_RADIUS = 15;
final float LINE_LENGTH = 6;
final int EVENT_NULL = 0;
int event;
private boolean hasBeenPressed;
float circleX;// xlocation of pin circle
float circleY; // y pos of pin circle
float lineX; // actual x cord of airport
float lineY;
color lineColor;
color fillColor;
Pin(float lineX, float lineY, int event)
{
this.lineX = lineX;
this.lineY = lineY;
this.event = event;
}
void setup() {
hasBeenPressed = false;
lineColor = color(0, 150, 255);
circleX = lineX;
circleY = (lineY)-LINE_LENGTH;//places circle ontop of line, creating pin
}
void draw() {
stroke(lineColor);
line(lineX, lineY, lineX, lineY+LINE_LENGTH);
if (hasBeenPressed) {
fill(fillColor);
} else {
fill(255, 100, 0);
}
circle(circleX, circleY, CIRCLE_RADIUS);
}
void mouseOver() {
lineColor = color(255);
//println("HOVER"+event);
}
void mouseNotOver() {
lineColor = color(0, 150, 255);
}
void mousePress() {
hasBeenPressed = true;
fillColor = color(0, 45, 90);
lineColor = color(0);
}
void mouseNotPressed() {
hasBeenPressed = false;
fillColor = color(255);
}
int getEvent(int mX, int mY) {
if (mX>(circleX-CIRCLE_RADIUS) && mX < circleX+ CIRCLE_RADIUS && mY >(circleY - CIRCLE_RADIUS) && mY < circleY +CIRCLE_RADIUS) {
return event;
}
else{
return EVENT_NULL;
}
}
}