-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPOI.java
More file actions
252 lines (223 loc) · 6.33 KB
/
Copy pathPOI.java
File metadata and controls
252 lines (223 loc) · 6.33 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
package com.cs2212;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.*;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.*;
/**
* The POI class represents a point of interest.
*/
public class POI {
private int id;
private String layerId;
private long xcoord;
private long ycoord;
private String roomNum;
private String name;
private String description;
private boolean builtIn;
private boolean isActive;
private JLabel POILbl;
private mainscreen mainframe;
private boolean isFavourite;
/** Creates a new POI with the given parameters and initializes its flags.
* @param id The ID of the POI
* @param layerId The ID of the layer the POI belongs to
* @param xCoord The X-coordinate of the POI in the map
* @param yCoord The Y-coordinate of the POI in the map
* @param roomNum The room number of the POI
* @param name The name of the POI
* @param description The description of the POI
* @param builtIn Whether the POI is built-in or not
*/
public POI(int id, String layerId, long xCoord, long yCoord, String roomNum, String name, String description, boolean builtIn) {
this.id = id;
this.layerId = layerId;
this.xcoord = xCoord;
this.ycoord = yCoord;
this.roomNum = roomNum;
this.name = name;
this.description = description;
this.builtIn = builtIn;
this.isActive = false;
this.isFavourite = false;
try {
BufferedImage POI_IMG = ImageIO.read(getClass().getResource("images/poi.png"));
Image SCALED_POI_IMG = POI_IMG.getScaledInstance(25, 40, Image.SCALE_SMOOTH);
// Create a label to hold the POI image and set its bounds
POILbl = new JLabel(new ImageIcon(SCALED_POI_IMG));
POILbl.setBounds((int)xcoord, (int)ycoord, 25, 40);
POILbl.setToolTipText("POI: " + this.name +"\nRm Num: " + this.roomNum + "\nDescription: " + this.description);
POILbl.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
mainframe.displayPOI(id);
}
});
}
catch(IOException e){
System.out.println(e.getMessage());
}
}
/** Returns the label that holds the POI image.
* @return the label that holds the POI image.
*/
public JLabel getLbl(){
return this.POILbl;
}
/**
Returns the ID of the POI.
@return the ID of the POI.
*/
public int getId() {
return id;
}
/**
* Returns the layer ID of the POI.
* @return the layer ID of the POI.
*/
public String getLayerId() {
return layerId;
}
/**
* Returns the x-coordinate of the POI.
* @return the x-coordinate of the POI.
*/
public long getXCoord() {
return xcoord;
}
/**
* Returns the y-coordinate of the POI.
* @return the y-coordinate of the POI.
*/
public long getYCoord() {
return ycoord;
}
/**
* Returns the roomNum of the POI.
* @return the roomNum of the POI.
*/
public String getRoomNum() {
return roomNum;
}
/**
* Returns the name of the POI.
* @return the name of the POI.
*/
public String getName() {
return name;
}
/**
* Returns a boolean that measure if the POI is a favourite
* @return a boolean that measure if the POI is a favourite
*/
public boolean getFavourite() {
return isFavourite;
}
/**
* Flips the boolean of isFavourite variable
*/
public void setFavourite() {
isFavourite = !isFavourite;
}
/**
* Returns the description of the POI.
* @return the description of the POI.
*/
public String getDescription() {
return description;
}
/**
* Returns a boolean that measure if the POI is a built in variable
* @return a boolean that measure if the POI is a built in variable
*/
public boolean isBuiltIn() {
return builtIn;
}
/**
* Sets the layer ID of the POI.
* @param id the layer ID to be set.
*/
public void setLayerId(String id) {
layerId = id;
}
/**
* Sets the X-coordinate of the POI.
* @param x the X-coordinate to be set.
*/
public void setXCoord(long x) {
xcoord = x;
}
/**
* Sets the Y-coordinate of the POI.
* @param y the Y-coordinate to be set.
*/
public void setYCoord(long y) {
ycoord = y;
}
/**
* Sets the room number of the POI.
* @param num the room number to be set.
*/
public void setRoomNum(String num) {
roomNum = num;
}
/**
* Sets the name of the POI.
* @param n the name to be set.
*/
public void setName(String n) {
name = n;
}
/**
* Sets the description of the POI.
* @param desc the description to be set.
*/
public void setDescription(String desc) {
description = desc;
}
/**
* Returns a boolean indicating whether the POI is active or not.
* @return a boolean indicating whether the POI is active or not.
*/
public boolean isActive() {
return isActive;
}
/**
* Sets the active status of the POI.
*/
public void setActive() {
isActive = !isActive;
}
/**
* Sets the mainframe of the POI.
* @param mainframe the mainframe to be set.
*/
public void setMainframe(mainscreen mainframe) {
this.mainframe = mainframe;
}
/**
* Returns the name of the POI.
* @return the name of the POI.
*/
public String checkBoxText() {
return name;
}
@Override
public String toString() {
String layer = this.getLayerId().substring(0,1);
if (layer.equals("a")) {
return "AH: " + name;
} else if (layer.equals("m")) {
return "MC: " + name;
} else if (layer.equals("h")){
return "HSB: " + name;
}
return name;
}
}