-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoomView.java
103 lines (91 loc) · 3.37 KB
/
RoomView.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
94
95
96
97
98
99
100
101
102
103
import jason.environment.grid.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
public class RoomView extends GridWorldView {
RoomModel roomModel;
public RoomView(RoomModel model) {
super(model, "Domestic Health Assistant", 1200);
roomModel = model;
defaultFont = new Font("Roboto", Font.BOLD, 10);
setVisible(true);
setBackground(new Color(240, 231, 196));
repaint();
}
//Drawing the objects (and static agent patient) on the grid
@Override
public void draw(Graphics g, int x, int y, int object) {
Location locAgent = roomModel.getAgPos(0);
super.drawAgent(g, x, y, Color.lightGray, -1);
switch (object) {
case RoomModel.CABINET:
if (locAgent.equals(roomModel.locCabinet)) {
super.drawAgent(g, x, y, Color.yellow, -1);
}
g.setColor(Color.black);
drawString(g, x, y, defaultFont, "CABINET ("+roomModel.availableMeds+" Meds)");
break;
case RoomModel.DOOR:
super.drawAgent(g, x, y, Color.lightGray, -1);
g.setColor(Color.BLUE);
drawString(g, x, y, new Font("Arial", Font.BOLD, 16), "DOOR");
break;
case RoomModel.PATIENT:
if (locAgent.equals(roomModel.locPatient)) {
super.drawAgent(g, x, y, Color.yellow, -1);
}
String o = "Patient";
if (roomModel.sipCount > 0) {
o += " ("+roomModel.sipCount+")";
}
g.setColor(Color.black);
drawString(g, x, y, defaultFont, o);
break;
case RoomModel.PHONE:
super.drawAgent(g, x, y, Color.lightGray, -1);
g.setColor(Color.RED);
drawString(g, x, y, new Font("Roboto", Font.BOLD, 16), "PHONE");
break;
}
super.drawObstacle(g, 7, 7);
//super.drawObstacle(g, 5, 1);
repaint();
}
//Drawing the dynamic agents
@Override
public void drawAgent(Graphics g, int x, int y, Color color, int id) {
Location locNurse1 = roomModel.getAgPos(0);
if (!locNurse1.equals(roomModel.locPatient) && !locNurse1.equals(roomModel.locCabinet)) {
color = Color.orange;
if (roomModel.isGiveMed) color = Color.yellow;
super.drawAgent(g, x, y, color, -1);
g.setColor(Color.black);
drawString(g, x, y, defaultFont, "Nurse1");
}
if (id == 1) {
color = Color.red;
super.drawAgent(g, x, y, color, -1);
g.setColor(Color.black);
if(roomModel.call.equals(" ") && roomModel.untrust.equals(" ")){
drawString(g, x, y, defaultFont,"SOS");
}else if(roomModel.call.equals("Calling 911")){
drawString(g, x, y, defaultFont, roomModel.call);
}else if(roomModel.untrust.equals("AG untrusted")){
drawString(g, x, y, defaultFont, roomModel.untrust);
}
}
if (id == 2) {
color = Color.orange;
super.drawAgent(g, x, y, color, -1);
g.setColor(Color.black);
drawString(g, x, y, defaultFont, "Nurse2");
}
if (id == 3) {
Location locPayManager = roomModel.getAgPos(id);
color = Color.green;
super.drawAgent(g, x, y, color, -1);
g.setColor(Color.black);
drawString(g, x, y, defaultFont, "PayManager (" +roomModel.money+" $)");
}
}
}