-
Notifications
You must be signed in to change notification settings - Fork 6
/
HoboCodes.pde
96 lines (81 loc) · 3.06 KB
/
HoboCodes.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
// Author: "Golan Levin" <[email protected]>, 01 August, 2011
//================================================================
// Code in this file is NOT USED OR REQUIRED by the QR_STENCILER program.
// It was used to process the 100 QR hobo codes that accompany QR_STENCILER.
// Feel free to delete this file.
// in keyPressed():
// QRImageFilename = getNextHoboFile();
// QR = loadImage (QRImageFilename);
// println("Loading:\t" + QRImageFilename);
ArrayList<String> hoboQRFiles;
int currentHoboFileIndex;
//===============================================================
void loadHoboFileList(){
hoboQRFiles = new ArrayList<String>();
currentHoboFileIndex = 0;
String aFilename;
String myPath = sketchPath() + "/data/QR_hobo_codes/";
File aFolder = new File(myPath);
File[] listOfFiles = aFolder.listFiles();
int count = 0;
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
aFilename = listOfFiles[i].getName();
if (aFilename.endsWith (".png")) {
aFilename = myPath + aFilename;
hoboQRFiles.add(aFilename);
}
}
}
}
//===============================================================
String getNextHoboFile(){
String hoboFilename = QRDefaultImageFilename;
if (currentHoboFileIndex < hoboQRFiles.size()){
hoboFilename = hoboQRFiles.get(currentHoboFileIndex);
currentHoboFileIndex = currentHoboFileIndex+1;
}
return hoboFilename;
}
//===============================================================
void generateHoboCodeHtml() {
// generates a fragment of an HTML table to present all of the QR hobo codes.
String aFilename;
String myPath = sketchPath() + "/data/QR_hobo_codes/";
File aFolder = new File(myPath);
File[] listOfFiles = aFolder.listFiles();
int count = 0;
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
aFilename = listOfFiles[i].getName();
if (aFilename.endsWith (".png")) {
String aPDFFile = aFilename.substring(0, aFilename.lastIndexOf('.')) + ".pdf";
String transcription = aFilename.substring(0, aFilename.lastIndexOf('.'));
String newTranscription = "";
for (int j=0; j<transcription.length(); j++) {
char c = transcription.charAt(j);
if (c == '_') {
c = ' ';
}
newTranscription += c;
}
if (count%4 == 0) {
println("<tr>");
}
print("\t<td width=\"125\" align=\"center\" valign=\"top\">");
print("<a href=\"QR_hobo_codes/" + aFilename + "\">");
print("<img \n\t\tsrc=\"QR_hobo_codes/" + aFilename + "\" ");
print("width=\"108\" height=\"108\" border=\"0\" /></a><br />");
print("<em>" + newTranscription + "</em><br />");
println();
print("\t\t<a href=\"QR_hobo_codes/" + aFilename + "\">png</a> | ");
print("<a href=\"QR_hobo_codes/" + aPDFFile + "\">stencil</a></td>");
println();
if ((count%4 == 3) || (i==(listOfFiles.length - 1))) {
println("</tr>");
}
count++;
}
}
}
}