| 48 |
|
|
| 49 |
|
public static void printLeftMenu(BufferedWriter bw) throws IOException{ |
| 50 |
|
bw.newLine(); |
| 51 |
< |
bw.write("<!--#include virtual=\"left.inc\" -->"); |
| 51 |
> |
bw.write("<!--#include virtual=\"../left.inc\" -->"); |
| 52 |
|
bw.newLine(); |
| 53 |
|
bw.write("</td><td valign=\"top\">"); |
| 54 |
|
bw.newLine(); |
| 57 |
|
|
| 58 |
|
public static void printTitle(BufferedWriter bw, String title) throws IOException{ |
| 59 |
|
bw.newLine(); |
| 60 |
< |
bw.write("<!--#include virtual=\"title.inc\" -->"); |
| 60 |
> |
bw.write("<!--#include virtual=\"../title.inc\" -->"); |
| 61 |
|
bw.newLine(); |
| 62 |
|
bw.newLine(); |
| 63 |
|
bw.write("<h3>"+title+"</h3>"); |
| 65 |
|
bw.flush(); |
| 66 |
|
} |
| 67 |
|
|
| 68 |
< |
public static void printGraph(BufferedWriter bw, String filename, int width, int height) throws IOException{ |
| 68 |
> |
public static void printGraph(BufferedWriter bw, String filename, int width, int height, int type, long startDate, long endDate) throws IOException{ |
| 69 |
> |
|
| 70 |
> |
String graphTitle = "Unknown time period"; |
| 71 |
> |
String xAxisTitle = "Time"; |
| 72 |
> |
String yAxisTitle = "Value"; |
| 73 |
> |
String scaleRow = " <tr><td> </td><td align=\"left\">"+DateUtils.dateString(startDate)+"</td><td align=\"right\">"+DateUtils.dateString(endDate)+"</td></tr>"; |
| 74 |
> |
int colspan = 2; |
| 75 |
> |
|
| 76 |
> |
switch (type) { |
| 77 |
> |
case ReportPage.HOUR: |
| 78 |
> |
graphTitle = "Hourly report from "+DateUtils.dateString(startDate)+" to "+DateUtils.dateString(endDate); |
| 79 |
> |
scaleRow = " <tr><td> </td>"; |
| 80 |
> |
for (long i = startDate; i < endDate; i+=DateUtils.secsPerHour/6){ |
| 81 |
> |
scaleRow += "<td><font size=\"2\">"+DateUtils.timeString(i)+"</font></td>"; |
| 82 |
> |
} |
| 83 |
> |
scaleRow += "</tr>"; |
| 84 |
> |
colspan = 6; |
| 85 |
> |
break; |
| 86 |
> |
case ReportPage.DAY: |
| 87 |
> |
graphTitle = "24 hour report from "+DateUtils.dateString(startDate)+" to "+DateUtils.dateString(endDate); |
| 88 |
> |
scaleRow = " <tr><td> </td>"; |
| 89 |
> |
for (int i = 0; i < 24; i++){ |
| 90 |
> |
scaleRow += "<td><font size=\"2\">"+i+"</font></td>"; |
| 91 |
> |
} |
| 92 |
> |
scaleRow += "</tr>"; |
| 93 |
> |
colspan = 24; |
| 94 |
> |
break; |
| 95 |
> |
case ReportPage.WEEK: |
| 96 |
> |
graphTitle = "7 day report from "+DateUtils.shortDateString(startDate)+" to "+DateUtils.shortDateString(endDate); |
| 97 |
> |
scaleRow = " <tr><td> </td>"; |
| 98 |
> |
for (long i = startDate; i < endDate; i+=DateUtils.secsPerDay){ |
| 99 |
> |
scaleRow += "<td>"+DateUtils.dayName(i)+"</td>"; |
| 100 |
> |
} |
| 101 |
> |
scaleRow += "</tr>"; |
| 102 |
> |
colspan = 7; |
| 103 |
> |
break; |
| 104 |
> |
case ReportPage.MONTH: |
| 105 |
> |
graphTitle = "30 day report from "+DateUtils.shortDateString(startDate)+" to "+DateUtils.shortDateString(endDate); |
| 106 |
> |
scaleRow = " <tr><td> </td><td align=\"left\">"+DateUtils.shortDateString(startDate)+"</td><td align=\"right\">"+DateUtils.shortDateString(endDate)+"</td></tr>"; |
| 107 |
> |
colspan = 2; |
| 108 |
> |
break; |
| 109 |
> |
default: |
| 110 |
> |
// Do nothing, leave values as they are. |
| 111 |
> |
} |
| 112 |
> |
|
| 113 |
|
bw.write("<table border=\"0\">"); |
| 114 |
< |
bw.write(" <tr><td> </td><td colspan=\"2\"><b>Visual representation of the last 7 days</b></td></tr>"); |
| 115 |
< |
bw.write(" <tr><td>y axis</td><td colspan=\"2\"><img src=\""+filename+"\" width=\""+width+"\" height=\""+height+"\"></td></tr>"); |
| 116 |
< |
bw.write(" <tr><td> </td><td align=\"left\">7 days ago</td><td align=\"right\">now</td>"); |
| 114 |
> |
bw.write(" <tr><td> </td><td colspan=\""+colspan+"\"><b>"+graphTitle+"</b></td></tr>"); |
| 115 |
> |
bw.write(" <tr><td valign="top">max</td><td colspan=\""+colspan+"\" rowspan=\"3\"><img src=\""+filename+"\" width=\""+width+"\" height=\""+height+"\"></td><td valign="middle">"+yAxisTitle+"</td><td valign="bottom">min</td></tr>"); |
| 116 |
> |
bw.write(scaleRow); |
| 117 |
|
bw.write("</table>"); |
| 118 |
|
bw.newLine(); |
| 119 |
|
bw.flush(); |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
public static void printTable(BufferedWriter bw, PlotData pd) throws IOException{ |
| 123 |
+ |
|
| 124 |
|
bw.write("<table border=\"0\" align=\"center\">"); |
| 125 |
|
|
| 126 |
|
bw.write("<tr bgcolor=\"black\"><td><font color=\"white\">Date</font></td><td><font color=\"white\">Value</font></td></tr>"); |
| 127 |
|
|
| 128 |
+ |
// Alternating row colours. |
| 129 |
|
String rowColour1 = "#ccccff"; |
| 130 |
|
String rowColour2 = "#ffffff"; |
| 131 |
|
|
| 153 |
|
|
| 154 |
|
public static void printBottom(BufferedWriter bw) throws IOException{ |
| 155 |
|
bw.newLine(); |
| 156 |
< |
bw.write("<!--#include virtual=\"bottom.inc\" -->"); |
| 156 |
> |
bw.write("<!--#include virtual=\"../bottom.inc\" -->"); |
| 157 |
|
bw.newLine(); |
| 158 |
|
bw.newLine(); |
| 159 |
|
bw.flush(); |