-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawInfo.pde
100 lines (88 loc) · 2.52 KB
/
drawInfo.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
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
void loadClientInfo()
{
//clear();
background(255);
mainLayout();
boolean flag = false;
for (int i = 0; i < client.length; i++)
{
println("Searching");
XML idElement = client[i].getChild("id");
id = idElement.getContent();
if (id.equals(val))
{
println("Found");
flag = true;
XML nameElement = client[i].getChild("name");
name = nameElement.getContent();
XML phoneElement = client[i].getChild("phone");
phone = phoneElement.getContent();
XML emailElement = client[i].getChild("email");
email = emailElement.getContent();
XML addressElement = client[i].getChild("address");
address = addressElement.getContent();
loadAvatar();
drawClientInfo(id, name, phone, email, address);
return;
}
}
if (flag == false)
{
// clear();
// textSize(32); textAlign(LEFT);
// fill(255, 0, 0);
// text("ID: " + val + "\n"
// + "ID NOT FOUND", 10, 50);
name = "NOT FOUND";
loadAvatar();
drawClientInfo(val, name, "", "", "");
}
}
void drawClientInfo(String _id, String _name, String _phone, String _email, String _address)
{
namePosW = avaPW*2 + avaW;
namePosH = avaPH + avaH/3;
idPosW = namePosW;// under Avatar: avaPW + avaW/2;
idPosH = namePosH + avaH/3;// under Avatar: avaPH + avaH + 50;
infoPosW = namePosW;
infoPosH = bannerH + 60;
infoLength = width - (infoPosW + 150);
textSize(50); textAlign(LEFT);
//fill(255);
//text(_name, namePosW, namePosH);
strokeText(_name, namePosW, namePosH, 255, 0);
textSize(32); textAlign(LEFT);
// fill(255);
// text("("+_id+")", idPosW, idPosH);
strokeText("("+_id+")", idPosW, idPosH, 255, 0);
textSize(32);
fill(0, 0, 255);
textAlign(LEFT);
text("Phone: " + "\n"
+ "Email: " + "\n"
+ "Address: ", infoPosW, infoPosH);
fill(0, 204, 204);
text(_phone + "\n"
+ _email + "\n"
+ _address, infoPosW + 140, infoPosH - 30, infoLength, height);
}
void loadAvatar()
{
avaW = width/8;
avaH = width/8;
avaPW = width/15;
avaPH = bannerH-width/8+40;
stroke(0);strokeCap(ROUND);strokeWeight(10);noFill();
rect(avaPW-5, avaPH-5, avaW+10, avaH+10);
stroke(255);strokeCap(ROUND);strokeWeight(10);noFill();
rect(avaPW-4, avaPH-4, avaW+8, avaH+8);
ava = loadImage("photo/" + id + ".jpg");
if (ava != null)
{
image(ava, avaPW, avaPH, avaW, avaH);
}
else
{
image(noAva, avaPW, avaPH, avaW, avaH);
}
}