📄 location.java
字号:
public class Location {
String name;
short[] points;
String info;
String image;
Location() {}
Location(String name) {
this.name = name;
}
Location(XMLElement elem) {
name = elem.getAttribute("name").getValue();
XMLElement point = elem.getSibling("point");
points = new short[point.getCounter()*2];
for (int i = 0; i < points.length; i += 2) {
points[i] = (short)point.getAttribute("x").getIntValue();
points[i+1] = (short)point.getAttribute("y").getIntValue();
point = point.getNextSibling();
}
XMLAttribute imageAttr = elem.getAttribute("image");
if (imageAttr != null) {
image = imageAttr.getValue();
}
info = elem.getValue();
}
int getWidth() {
int minX = Integer.MAX_VALUE;
int maxX = Integer.MIN_VALUE;
for (int i = 0; i < points.length; i += 2) {
if (points[i] < minX) {
minX = points[i];
}
if (points[i] > maxX) {
maxX = points[i];
}
}
return maxX - minX;
}
int getHeight() {
int minY = Integer.MAX_VALUE;
int maxY = Integer.MIN_VALUE;
for (int i = 1; i < points.length; i += 2) {
if (points[i] < minY) {
minY = points[i];
}
if (points[i] > maxY) {
maxY = points[i];
}
}
return maxY - minY;
}
int getCenterX() {
return (points[0] + points[points.length-2]) / 2;
}
int getCenterY() {
return (points[1] + points[points.length-1]) / 2;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -