-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlace.java
More file actions
47 lines (45 loc) · 1.12 KB
/
Place.java
File metadata and controls
47 lines (45 loc) · 1.12 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
//Code written by Christian Neij
import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;
public abstract class Place extends Polygon{
protected String placeName;
protected Category category;
protected Position pos;
private boolean selected = false;
public Place(String name, Category category, int x, int y) {
super(x-15,y-30,x+15,y-30,x,y);
placeName = name;
this.category = category;
setFill(this.category.getColor());
pos = new Position(x,y);
}
public Position getPosition() {
return pos;
}
public String getName() {
return placeName;
}
public Category getCategory() {
return category;
}
public boolean isSelected() {
return selected;
}
public void changeSelectionStatus(boolean select) {
if(select) selected = true;
else selected = false;
//selected = !selected;
changeColour();
}
private void changeColour() {
if(selected) {
setFill(Color.YELLOW);
setStroke(Color.BLACK);
}else if(!selected) {
setFill(this.category.getColor());
setStroke(this.category.getColor());
}
}
@Override
public abstract String toString();
}