Fields Summary |
---|
protected String | image_suffix |
protected String | thumb_suffix |
public static final String | CAPTIONS_FILEThe captions file (created by hand) |
protected BufferedReader | capA reader for the captions file |
protected HashMap | mapThe map from filename to caption |
Vector | namesVector for listing names for sorting |
public static final String | OUTPUTFILEThe output file that we create |
PrintWriter | outThe main output stream |
Properties | ppropsProperties |
String | PROPS_FILEProperties file |
public String | bgcolorThe background color for the page |
String | titleThe title of this show |
Methods Summary |
---|
void | BEGIN()Write the HTML headers
println("<HTML>");
println("<HEAD>");
println(" <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">");
println(" <META NAME=\"GENERATOR\" CONTENT=\"Java ImageIndex\">");
println(" <TITLE>" + title + "</TITLE>");
println("</HEAD>");
println("<BODY BGCOLOR=\"" + pprops.get("bgcolor") + "\">");
println("<H1>" + title + "</H1>");
println("<P>All files are Copyright ©: All rights reserved.");
println("</P>");
println("<HR>");
|
void | END()Write the trailers and a signature
System.out.println("Finishing the HTML");
println("</UL>");
println("<P>This file generated by the Java program ");
print("<A HREF=\"ImageIndex.java\">ImageIndex</A> at ");
println(new Date().toString());
println("</P>");
println("</BODY>");
println("</HTML>");
|
void | close()Close open files
System.out.println("Closing output files...");
if (out != null)
out.close();
|
public static void | main(java.lang.String[] av)Make an index
ImageIndex mi = new ImageIndex();
try {
mi.open(CAPTIONS_FILE, OUTPUTFILE); // open files
mi.read(); // read caption file
mi.BEGIN(); // print HTML header
mi.process(); // do bulk of work
mi.END(); // print trailer.
mi.close(); // close files
} catch (IOException e) {
System.err.println(e);
}
|
void | mkLink(java.lang.String href, java.lang.String descrip)
// System.out.println(href + "==>" + descrip);
String thumbnail = href + thumb_suffix;
String image = href + image_suffix;
print("<tr><td>");
print("<a href=\"" + image + "\">");
print("<img src=\"" + thumbnail + "\"></a>");
print("</td><td>");
print("<a href=\"" + image + "\">");
print(descrip + "</a>");
print("</td></tr>");
println();
|
void | open(java.lang.String captions, java.lang.String outFile)Open the files
cap = new BufferedReader(new FileReader(captions));
out = new PrintWriter(new FileWriter(outFile));
pprops = new FileProperties(PROPS_FILE);
title = pprops.getProperty("title");
thumb_suffix = pprops.getProperty("thumb_suffix");
image_suffix = pprops.getProperty("image_suffix");
|
void | print(java.lang.String s)Convenience routine for out.print
out.print(s);
|
void | println(java.lang.String s)Convenience routine for out.println
out.println(s);
|
void | println()
out.println();
|
void | process()Do the bulk of the work
System.out.println("Generating HTML...");
println("<table>");
String fn;
for (int i=0; i<names.size(); i++) {
fn = (String)names.elementAt(i);
mkLink(fn, (String)map.get(fn));
}
println("</table>");
System.out.println("*** process - done ***");
|
void | read()read the captions file
String line;
while ((line = cap.readLine()) != null) {
StringTokenizer st = new StringTokenizer(line, "\t");
String name = st.nextToken();
String desc = st.nextToken();
names.addElement(name);
map.put(name, desc);
}
cap.close();
|