/
InteractiveImage.pde
59 lines (52 loc) · 1.45 KB
/
InteractiveImage.pde
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
class InteractiveImage implements Comparable {
int _depth;
PImage img;
XMLElement xmlData;
public int getX() { return xmlData.getIntAttribute("x"); }
public int getY() { return xmlData.getIntAttribute("y"); }
//public int getDepth() { return xmlData.getIntAttribute("depth"); }
public int getDepth() { return _depth; }
public int getId() { return xmlData.getIntAttribute("id"); }
public void setX(int val) {
xmlData.setAttribute("x", str(val));
println(" xml x "+val);
}
public void setY(int val) {
xmlData.setAttribute("y", str(val));
println(" xml y "+val);
}
public void setDepth(int val) {
print(" depth "+val);
_depth = val;
}
public int compareTo(Object other)
{
int otherDepth = ((InteractiveImage) other).getDepth();
if(otherDepth > _depth) {
return -1;
} else {
return 1;
}
//return getDepth() - otherDepth;
}
public void setXMLData(XMLElement s)
{
xmlData = s;
//println(" setXMLData "+xmlData.getAttribute("x")+" "+xmlData.getAttribute("y"));
println(" setXMLData "+s);
setX(xmlData.getIntAttribute("x"));
setY(xmlData.getIntAttribute("y"));
setDepth(xmlData.getIntAttribute("depth"));
}
public boolean isClicked(int mx, int my)
{
int x = getX();
int y = getY();
if(mx > x && mx < x + img.width) {
if(my > y && my < y + img.height){
return true;
}
}
return false;
}
}