-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTop_House.pde
72 lines (69 loc) · 2.64 KB
/
Top_House.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
60
61
62
63
64
65
66
67
68
69
70
71
72
ArrayList <Toproom> trlist;
PVector thousepos = new PVector (1600, 50);
ArrayList <Toproom> trlist2;
PVector thousepos2 = new PVector (1600, 450);
float tnlistscale = 70;
float tnlistscale2 = 70;
void setuptr() {
trlist= new ArrayList <Toproom> ();
trlist2= new ArrayList <Toproom> ();
}
void drawtr() {
if (!bState[0]) {
trlist= new ArrayList <Toproom> ();
for (int i=0; i<thenlist.size(); i++) if (thenlist.get(i).room) trlist.add(new Toproom(thenlist.get(i), tnlistscale, thousepos));
}
for (int i=0; i<trlist.size(); i++) trlist.get(i).display();
for (int i=0; i<trlist.size(); i++) trlist.get(i).displayadj();
if (!bState[0]) {
trlist2= new ArrayList <Toproom> ();
for (int i=0; i<thenlist2.size(); i++) if (thenlist2.get(i).room) trlist2.add(new Toproom(thenlist2.get(i), tnlistscale2, thousepos2));
}
for (int i=0; i<trlist2.size(); i++) trlist2.get(i).display();
for (int i=0; i<trlist2.size(); i++) trlist2.get(i).displayadj();
}
class Toproom {
Node no;
float scale;
PVector postrans, possc, sizesc, posscmid;
ArrayList <PVector> adjpos;
Toproom(Node _no, float _scale, PVector _postrans) {
no=_no;
scale = _scale;
postrans=_postrans;
possc = new PVector(no.tpos.x*scale+postrans.x, no.tpos.y*scale+postrans.y);
sizesc = new PVector(no.tsize.x*scale, no.tsize.y*scale);
posscmid = new PVector (possc.x+(sizesc.x*.5), possc.y+(sizesc.y*.5));
adjpos = new ArrayList<PVector>();
for (int i=0; i<no.tadjacent.size(); i++) adjpos.add(new PVector ( (no.tpos.x+(no.tsize.x*.5))*scale+postrans.x, (no.tpos.y+(no.tsize.y*.5))*scale+postrans.y)) ;
}
void display() {
rectMode(CORNER);
colorMode(HSB, 1.0, 1.0, 1.0, 1.0);
if (no.select) fill(no.clr, 1, 1, 1);
else fill(no.clr, 1, 1, 0.1);
rect(possc.x, possc.y, sizesc.x, sizesc.y);
colorMode(RGB, 255, 255, 255);
pushMatrix();
if (no.tsize.x<1.0) {
translate(posscmid.x, posscmid.y);
rotate(-PI/2);
translate(-posscmid.x, -posscmid.y);
}
fill(0);
textSize(10);
if (no.code!=null) text(no.code, posscmid.x, posscmid.y);
popMatrix();
}
void displayadj() {
colorMode(RGB, 255, 255, 255);
stroke(200);
fill(0);
for (int j=0; j<no.tadjacent.size(); j++) {
text(no.tadjacent.get(j).code, +possc.x+10, possc.y+10*j+10);
float x2 = ((no.tadjacent.get(j).tpos.x+(no.tadjacent.get(j).tsize.x*.5))*scale)+postrans.x;
float y2 = ((no.tadjacent.get(j).tpos.y+(no.tadjacent.get(j).tsize.y*.5))*scale)+postrans.y;
line (posscmid.x, posscmid.y, x2, y2);
}
}
}