ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/DBReporter/IscreamLayout.java
Revision: 1.22
Committed: Sun Jan 7 20:31:13 2001 UTC (24 years, 11 months ago) by pjm2
Branch: MAIN
Changes since 1.21: +1 -1 lines
Log Message:
Centered the whole shtml pages.

File Contents

# Content
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 * @version $Id: IscreamLayout.java,v 1.1 2000/12/11 16:34:16 pjm2 Exp $
13 */
14 public class IscreamLayout {
15
16 //---FINAL ATTRIBUTES---
17
18 /**
19 * The current CVS revision of this class
20 */
21 public final String REVISION = "$Revision: 1.1 $";
22
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 http-equiv=\"pragma\" content=\"no-cache\">");
37 bw.write("<meta http-equiv=\"cache-control\" content=\"no-cache\">");
38 bw.write("<meta name=\"description\" content=\""+metaDescription+"\">");
39 bw.write("<meta name=\"keywords\" content=\""+metaKeywords+"\">");
40 bw.write("<meta name=\"generator\" content=\"pjm2's DBReporterMain\">");
41 bw.write("</head>");
42 bw.write("<body bgcolor=\"#ffffff\" link=\"#0000ff\" alink=\"#3333cc\" vlink=\"#3333cc\" text=\"#000066\">");
43 bw.write("<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\" align=\"center\">");
44 bw.write(" <tr>");
45 bw.write(" <td valign=\"top\">");
46 bw.write("");
47 bw.newLine();
48 bw.flush();
49 }
50
51 public static void printLeftMenu(BufferedWriter bw) throws IOException{
52 bw.newLine();
53 bw.write("<!--#include virtual=\"../left.inc\" -->");
54 bw.newLine();
55 bw.write("</td><td valign=\"top\">");
56 bw.newLine();
57 bw.flush();
58 }
59
60 public static void printTitle(BufferedWriter bw, String title) throws IOException{
61 bw.newLine();
62 bw.write("<!--#include virtual=\"../title.inc\" -->");
63 bw.newLine();
64 bw.newLine();
65 bw.write("<h3>"+title+"</h3>");
66 bw.newLine();
67 bw.flush();
68 }
69
70 public static void printMachines(BufferedWriter bw, LinkedList list) throws IOException{
71 bw.write("<table border=\"0\" align=\"center\">");
72
73 Iterator it = list.iterator();
74 while (it.hasNext()){
75 ReportPage rp = (ReportPage)it.next();
76 bw.write("<tr><td><font size=\"4\"><a href=\"../"+rp.getWhen()+rp.getMachineName()+"."+rp.getReport()+".shtml\">"+rp.getMachineName()+"</a></font></td></tr>");
77 }
78
79 bw.write("</table>");
80 bw.flush();
81 }
82
83 public static void printGraph(BufferedWriter bw, String filename, int width, int height, int type, long startDate, long endDate) throws IOException{
84
85 String graphTitle = "Unknown time period";
86 String xAxisTitle = "Time";
87 String yAxisTitle = "Value";
88 String scaleRow = " <tr><td>&nbsp;</td><td align=\"left\">"+DateUtils.dateString(startDate)+"</td><td align=\"right\">"+DateUtils.dateString(endDate)+"</td></tr>";
89 int colspan = 2;
90
91 switch (type) {
92 case ReportPage.HOUR:
93 graphTitle = "Hourly report from "+DateUtils.dateString(startDate)+" to "+DateUtils.dateString(endDate);
94 scaleRow = " <tr><td>&nbsp;</td>";
95 for (long i = startDate; i < endDate; i+=DateUtils.secsPerHour/6){
96 scaleRow += "<td align=\"left\" width=\""+(100/colspan)+"%\"><font size=\"2\">&gt;"+DateUtils.timeString(i)+"</font></td>";
97 }
98 scaleRow += "</tr>";
99 colspan = 6;
100 break;
101 case ReportPage.DAY:
102 graphTitle = "24 hour report from "+DateUtils.dateString(startDate)+" to "+DateUtils.dateString(endDate);
103 scaleRow = " <tr><td>&nbsp;</td>";
104 for (int i = 0; i < 24; i++){
105 scaleRow += "<td align=\"center\" width=\""+(100/colspan)+"%\"><font size=\"2\">"+i+"</font></td>";
106 }
107 scaleRow += "</tr>";
108 colspan = 24;
109 break;
110 case ReportPage.WEEK:
111 graphTitle = "7 day report from "+DateUtils.shortDateString(startDate)+" to "+DateUtils.shortDateString(endDate);
112 colspan = 7;
113 scaleRow = " <tr><td>&nbsp;</td>";
114 for (long i = startDate; i < endDate; i+=DateUtils.secsPerDay){
115 scaleRow += "<td align=\"center\" width=\""+(100/colspan)+"%\">"+DateUtils.dayName(i)+"</td>";
116 }
117 scaleRow += "</tr>";
118 break;
119 case ReportPage.MONTH:
120 graphTitle = "30 day report from "+DateUtils.shortDateString(startDate)+" to "+DateUtils.shortDateString(endDate);
121 scaleRow = " <tr><td>&nbsp;</td><td align=\"left\">"+DateUtils.shortDateString(startDate)+"</td><td align=\"right\">"+DateUtils.shortDateString(endDate)+"</td></tr>";
122 colspan = 2;
123 break;
124 default:
125 // Do nothing, leave values as they are.
126 }
127
128 bw.write("<table border=\"0\">");
129 bw.write(" <tr><td>&nbsp;</td><td colspan=\""+colspan+"\"><b>"+graphTitle+"</b></td></tr>");
130 bw.write(" <tr><td valign=\"top\" align=\"right\">max</td><td colspan=\""+colspan+"\" rowspan=\"3\"><img src=\""+filename+"\" width=\""+width+"\" height=\""+height+"\"></td></tr><tr><td valign=\"middle\" align=\"right\">"+yAxisTitle+"</td></tr><tr><td valign=\"bottom\" align=\"right\">min</td></tr>");
131 bw.write(scaleRow);
132 bw.write("</table>");
133 bw.newLine();
134 bw.flush();
135 }
136
137 public static void printTable(BufferedWriter bw, PlotData pd) throws IOException{
138
139 bw.write("<table border=\"0\" align=\"center\">");
140
141 bw.write("<tr bgcolor=\"black\"><td><font color=\"white\">Date</font></td><td><font color=\"white\">Value</font></td></tr>");
142
143 // Alternating row colours.
144 String rowColour1 = "#ccccff";
145 String rowColour2 = "#ffffff";
146
147 String rowColour = rowColour1;
148
149 Iterator it = pd.iterator();
150 while (it.hasNext()){
151 Point2D p = (Point2D)it.next();
152 double x = p.getX();
153 double y = p.getY();
154
155 if (rowColour.equals(rowColour1)){
156 rowColour = rowColour2;
157 }
158 else {
159 rowColour = rowColour1;
160 }
161
162 bw.write("<tr bgcolor=\""+rowColour+"\"><td>"+x+"</td><td>"+y+"</td></tr>");
163 }
164
165 bw.write("</table>");
166 bw.flush();
167 }
168
169 public static void printBottom(BufferedWriter bw) throws IOException{
170 bw.newLine();
171 bw.write("<!--#include virtual=\"../bottom.inc\" -->");
172 bw.newLine();
173 bw.newLine();
174 bw.flush();
175 }
176
177
178
179 //---CONSTRUCTORS---
180
181
182 //---PUBLIC METHODS---
183
184 /**
185 * Overrides the {@link java.lang.Object#toString() Object.toString()}
186 * method to provide clean logging (every class should have this).
187 *
188 * @return the name of this class and its CVS revision
189 */
190 public String toString() {
191 return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
192 }
193
194 //---PRIVATE METHODS---
195
196 //---ACCESSOR/MUTATOR METHODS---
197
198 //---ATTRIBUTES---
199
200 //---STATIC ATTRIBUTES---
201
202 }