| 1 |
pjm2 |
1.1 |
//---PACKAGE DECLARATION--- |
| 2 |
|
|
|
| 3 |
|
|
//---IMPORTS--- |
| 4 |
|
|
import java.io.*; |
| 5 |
|
|
import java.util.*; |
| 6 |
|
|
import java.awt.geom.*; |
| 7 |
|
|
|
| 8 |
|
|
/** |
| 9 |
|
|
* Provides common i-screamed SHTML layout themes for the historical reports. |
| 10 |
|
|
* |
| 11 |
|
|
* @author $Author: pjm2 $ |
| 12 |
pjm2 |
1.2 |
* @version $Id: IscreamLayout.java,v 1.1 2000/12/11 16:34:16 pjm2 Exp $ |
| 13 |
pjm2 |
1.1 |
*/ |
| 14 |
|
|
public class IscreamLayout { |
| 15 |
|
|
|
| 16 |
|
|
//---FINAL ATTRIBUTES--- |
| 17 |
|
|
|
| 18 |
|
|
/** |
| 19 |
|
|
* The current CVS revision of this class |
| 20 |
|
|
*/ |
| 21 |
pjm2 |
1.2 |
public final String REVISION = "$Revision: 1.1 $"; |
| 22 |
pjm2 |
1.1 |
|
| 23 |
|
|
//---STATIC METHODS--- |
| 24 |
|
|
|
| 25 |
|
|
public static void printDocType(BufferedWriter bw) throws IOException{ |
| 26 |
|
|
bw.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"); |
| 27 |
|
|
bw.newLine(); |
| 28 |
|
|
bw.newLine(); |
| 29 |
|
|
bw.flush(); |
| 30 |
|
|
} |
| 31 |
|
|
|
| 32 |
|
|
public static void printHeader(BufferedWriter bw, String title, String metaDescription, String metaKeywords) throws IOException{ |
| 33 |
|
|
bw.write("<html>"); |
| 34 |
|
|
bw.write("<head>"); |
| 35 |
|
|
bw.write("<title>"+title+"</title>"); |
| 36 |
|
|
bw.write("<meta name=\"description\" content=\""+metaDescription+"\">"); |
| 37 |
|
|
bw.write("<meta name=\"keywords\" content=\""+metaKeywords+"\">"); |
| 38 |
|
|
bw.write("<meta name=\"generator\" content=\"pjm2's DBReporterMain\">"); |
| 39 |
|
|
bw.write("</head>"); |
| 40 |
|
|
bw.write("<body bgcolor=\"#ffffff\" link=\"#0000ff\" alink=\"#3333cc\" vlink=\"#3333cc\" text=\"#000066\">"); |
| 41 |
|
|
bw.write("<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">"); |
| 42 |
|
|
bw.write(" <tr>"); |
| 43 |
|
|
bw.write(" <td valign=\"top\">"); |
| 44 |
|
|
bw.write(""); |
| 45 |
|
|
bw.newLine(); |
| 46 |
|
|
bw.flush(); |
| 47 |
|
|
} |
| 48 |
|
|
|
| 49 |
|
|
public static void printLeftMenu(BufferedWriter bw) throws IOException{ |
| 50 |
|
|
bw.newLine(); |
| 51 |
pjm2 |
1.2 |
bw.write("<!--#include virtual=\"../left.inc\" -->"); |
| 52 |
pjm2 |
1.1 |
bw.newLine(); |
| 53 |
|
|
bw.write("</td><td valign=\"top\">"); |
| 54 |
|
|
bw.newLine(); |
| 55 |
|
|
bw.flush(); |
| 56 |
|
|
} |
| 57 |
|
|
|
| 58 |
|
|
public static void printTitle(BufferedWriter bw, String title) throws IOException{ |
| 59 |
|
|
bw.newLine(); |
| 60 |
pjm2 |
1.2 |
bw.write("<!--#include virtual=\"../title.inc\" -->"); |
| 61 |
pjm2 |
1.1 |
bw.newLine(); |
| 62 |
|
|
bw.newLine(); |
| 63 |
|
|
bw.write("<h3>"+title+"</h3>"); |
| 64 |
|
|
bw.newLine(); |
| 65 |
|
|
bw.flush(); |
| 66 |
|
|
} |
| 67 |
|
|
|
| 68 |
|
|
public static void printGraph(BufferedWriter bw, String filename, int width, int height) throws IOException{ |
| 69 |
|
|
bw.write("<table border=\"0\">"); |
| 70 |
|
|
bw.write(" <tr><td> </td><td colspan=\"2\"><b>Visual representation of the last 7 days</b></td></tr>"); |
| 71 |
|
|
bw.write(" <tr><td>y axis</td><td colspan=\"2\"><img src=\""+filename+"\" width=\""+width+"\" height=\""+height+"\"></td></tr>"); |
| 72 |
|
|
bw.write(" <tr><td> </td><td align=\"left\">7 days ago</td><td align=\"right\">now</td>"); |
| 73 |
|
|
bw.write("</table>"); |
| 74 |
|
|
bw.newLine(); |
| 75 |
|
|
bw.flush(); |
| 76 |
|
|
} |
| 77 |
|
|
|
| 78 |
|
|
public static void printTable(BufferedWriter bw, PlotData pd) throws IOException{ |
| 79 |
|
|
bw.write("<table border=\"0\" align=\"center\">"); |
| 80 |
|
|
|
| 81 |
|
|
bw.write("<tr bgcolor=\"black\"><td><font color=\"white\">Date</font></td><td><font color=\"white\">Value</font></td></tr>"); |
| 82 |
|
|
|
| 83 |
|
|
String rowColour1 = "#ccccff"; |
| 84 |
|
|
String rowColour2 = "#ffffff"; |
| 85 |
|
|
|
| 86 |
|
|
String rowColour = rowColour1; |
| 87 |
|
|
|
| 88 |
|
|
Iterator it = pd.iterator(); |
| 89 |
|
|
while (it.hasNext()){ |
| 90 |
|
|
Point2D p = (Point2D)it.next(); |
| 91 |
|
|
double x = p.getX(); |
| 92 |
|
|
double y = p.getY(); |
| 93 |
|
|
|
| 94 |
|
|
if (rowColour.equals(rowColour1)){ |
| 95 |
|
|
rowColour = rowColour2; |
| 96 |
|
|
} |
| 97 |
|
|
else { |
| 98 |
|
|
rowColour = rowColour1; |
| 99 |
|
|
} |
| 100 |
|
|
|
| 101 |
|
|
bw.write("<tr bgcolor=\""+rowColour+"\"><td>"+x+"</td><td>"+y+"</td></tr>"); |
| 102 |
|
|
} |
| 103 |
|
|
|
| 104 |
|
|
bw.write("</table>"); |
| 105 |
|
|
bw.flush(); |
| 106 |
|
|
} |
| 107 |
|
|
|
| 108 |
|
|
public static void printBottom(BufferedWriter bw) throws IOException{ |
| 109 |
|
|
bw.newLine(); |
| 110 |
pjm2 |
1.2 |
bw.write("<!--#include virtual=\"../bottom.inc\" -->"); |
| 111 |
pjm2 |
1.1 |
bw.newLine(); |
| 112 |
|
|
bw.newLine(); |
| 113 |
|
|
bw.flush(); |
| 114 |
|
|
} |
| 115 |
|
|
|
| 116 |
|
|
|
| 117 |
|
|
|
| 118 |
|
|
//---CONSTRUCTORS--- |
| 119 |
|
|
|
| 120 |
|
|
|
| 121 |
|
|
//---PUBLIC METHODS--- |
| 122 |
|
|
|
| 123 |
|
|
/** |
| 124 |
|
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
| 125 |
|
|
* method to provide clean logging (every class should have this). |
| 126 |
|
|
* |
| 127 |
|
|
* @return the name of this class and its CVS revision |
| 128 |
|
|
*/ |
| 129 |
|
|
public String toString() { |
| 130 |
|
|
return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
| 131 |
|
|
} |
| 132 |
|
|
|
| 133 |
|
|
//---PRIVATE METHODS--- |
| 134 |
|
|
|
| 135 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
| 136 |
|
|
|
| 137 |
|
|
//---ATTRIBUTES--- |
| 138 |
|
|
|
| 139 |
|
|
//---STATIC ATTRIBUTES--- |
| 140 |
|
|
|
| 141 |
|
|
} |