-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
96 lines (79 loc) · 1.9 KB
/
Node.java
File metadata and controls
96 lines (79 loc) · 1.9 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
*
* Wilhelm Ericsson
* Ruben Wilhelmsen
*
*/
import processing.core.PVector;
public class Node {
// A node object knows about its location in the grid
// as well as its size with the variables x,y,w,h
float x, y; // x,y location
float w, h; // width and height
float angle; // angle for oscillating brightness
PVector position;
int col, row;
Sprite content;
boolean isEmpty;
// ***************************************************
// Node Constructor
// Denna används för temporära jämförelser mellan Node objekt.
Node(float _posx, float _posy) {
this.position = new PVector(_posx, _posy);
}
// ***************************************************
// Används vid skapande av grid
Node(int _id_col, int _id_row, float _posx, float _posy) {
this.position = new PVector(_posx, _posy);
this.col = _id_col;
this.row = _id_row;
this.content = null;
this.isEmpty = true;
}
// ***************************************************
Node(float tempX, float tempY, float tempW, float tempH, float tempAngle) {
x = tempX;
y = tempY;
w = tempW;
h = tempH;
angle = tempAngle;
}
// ***************************************************
void addContent(Sprite s) {
if (this.isEmpty) {
this.content = s;
this.isEmpty = false;
}
}
void removeContent(){
if(!this.isEmpty){
content = null;
this.isEmpty = true;
}
}
// ***************************************************
boolean empty() {
return this.isEmpty;
}
// ***************************************************
Sprite content() {
return this.content;
}
@Override
public boolean equals(Object other){
boolean equal = false;
if(other instanceof Node){
Node temp = (Node)other;
equal = (row == temp.row && col == temp.col);
}
return equal;
}
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public String toString() {
return "{" + row + "," + col + "}";
}
}