ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/DBReporter/IscreamLayout.java
(Generate patch)

Comparing projects/cms/source/reports/DBReporter/IscreamLayout.java (file contents):
Revision 1.3 by pjm2, Sun Jan 7 12:49:28 2001 UTC vs.
Revision 1.28 by pjm2, Thu Jan 11 19:03:04 2001 UTC

# Line 1 | Line 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$
12 < * @version $Id$
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$";
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 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 <        bw.write("<!--#include virtual=\"../left.inc\" -->");
52 <        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 <        bw.write("<!--#include virtual=\"../title.inc\" -->");
61 <        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, 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>&nbsp;</td><td align=\"left\">"+startDate+"</td><td align=\"right\">"+endDate+"</td></tr>";
74 <        
75 <        switch (type) {
76 <            case ReportPage.HOUR:
77 <                graphTitle = "Hourly report from "+startDate+" to "+endDate;
78 <                break;
79 <            case ReportPage.DAY:
80 <                graphTitle = "24 hour report from "+startDate+" to "+endDate;
81 <                break;
82 <            case ReportPage.WEEK:
83 <                graphTitle = "7 day report from "+startDate+" to "+endDate;
84 <                break;
85 <            case ReportPage.MONTH:
86 <                graphTitle = "30 day report from "+startDate+" to "+endDate;
87 <                break;
88 <            default:
89 <                // Do nothing.
90 <        }
91 <        
92 <        bw.write("<table border=\"0\">");
93 <        bw.write(" <tr><td>&nbsp;</td><td colspan=\"2\"><b>"+graphTitle+"</b></td></tr>");
94 <        bw.write(" <tr><td>"+yAxisTitle+"</td><td colspan=\"2\"><img src=\""+filename+"\" width=\""+width+"\" height=\""+height+"\"></td></tr>");
95 <        bw.write(scaleRow);
96 <        bw.write("</table>");
97 <        bw.newLine();
98 <        bw.flush();
99 <    }
100 <    
101 <    public static void printTable(BufferedWriter bw, PlotData pd) throws IOException{
102 <        bw.write("<table border=\"0\"  align=\"center\">");
103 <        
104 <        bw.write("<tr bgcolor=\"black\"><td><font color=\"white\">Date</font></td><td><font color=\"white\">Value</font></td></tr>");
105 <        
106 <        String rowColour1 = "#ccccff";
107 <        String rowColour2 = "#ffffff";
108 <        
109 <        String rowColour = rowColour1;
110 <        
111 <        Iterator it = pd.iterator();
112 <        while (it.hasNext()){
113 <            Point2D p = (Point2D)it.next();
114 <            double x = p.getX();
115 <            double y = p.getY();
116 <            
117 <            if (rowColour.equals(rowColour1)){
118 <                rowColour = rowColour2;
119 <            }
120 <            else {
121 <                rowColour = rowColour1;
122 <            }
123 <            
124 <            bw.write("<tr bgcolor=\""+rowColour+"\"><td>"+x+"</td><td>"+y+"</td></tr>");
125 <        }
126 <        
127 <        bw.write("</table>");
128 <        bw.flush();
129 <    }
130 <    
131 <    public static void printBottom(BufferedWriter bw) throws IOException{
132 <        bw.newLine();
133 <        bw.write("<!--#include virtual=\"../bottom.inc\" -->");
134 <        bw.newLine();
135 <        bw.newLine();
136 <        bw.flush();
137 <    }
138 <    
139 <    
140 <
141 < //---CONSTRUCTORS---
142 <
143 <        
144 < //---PUBLIC METHODS---
145 <
146 <    /**
147 <     * Overrides the {@link java.lang.Object#toString() Object.toString()}
148 <     * method to provide clean logging (every class should have this).
149 <     *
150 <     * @return the name of this class and its CVS revision
151 <     */
152 <    public String toString() {
153 <        return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
154 <    }
155 <
156 < //---PRIVATE METHODS---
157 <
158 < //---ACCESSOR/MUTATOR METHODS---
159 <
160 < //---ATTRIBUTES---
161 <
162 < //---STATIC ATTRIBUTES---
163 <
164 < }
1 > //---PACKAGE DECLARATION---
2  
3 +
4  
5 + //---IMPORTS---
6  
7 + import java.io.*;
8  
9 + import java.util.*;
10  
11 + import java.awt.geom.*;
12  
13 +
14  
15 + /**
16  
17 + * Provides common i-screamed SHTML layout themes for the historical reports.
18  
19 + *
20  
21 + * @author  $Author$
22  
23 + * @version $Id$
24  
25 + */
26  
27 + public class IscreamLayout {
28  
29 +
30  
31 + //---FINAL ATTRIBUTES---
32  
33 +
34  
35 +    /**
36  
37 +     * The current CVS revision of this class
38  
39 +     */
40  
41 +    public final String REVISION = "$Revision$";
42  
43 +
44  
45 + //---STATIC METHODS---
46  
47 +
48  
49 +    public static void printDocType(BufferedWriter bw) throws IOException{
50  
51 +        bw.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">");
52  
53 +        bw.newLine();
54  
55 +        bw.newLine();
56  
57 +        bw.flush();
58  
59 +    }
60  
61 +    
62  
63 +    public static void printHeader(BufferedWriter bw, String title, String metaDescription, String metaKeywords) throws IOException{
64  
65 +        bw.write("<html>");
66  
67 +        bw.write("<head>");
68  
69 +        bw.write("<title>"+title+"</title>");
70  
71 +        bw.write("<meta http-equiv=\"pragma\" content=\"no-cache\">");
72  
73 +        bw.write("<meta http-equiv=\"cache-control\" content=\"no-cache\">");
74  
75 +        bw.write("<meta name=\"description\" content=\""+metaDescription+"\">");
76  
77 +        bw.write("<meta name=\"keywords\" content=\""+metaKeywords+"\">");
78  
79 +        bw.write("<meta name=\"generator\" content=\"pjm2's DBReporterMain\">");
80  
81 +        bw.write("</head>");
82  
83 +        bw.write("<body bgcolor=\"#ffffff\" link=\"#0000ff\" alink=\"#3333cc\" vlink=\"#3333cc\" text=\"#000066\">");
84  
85 +        bw.write("<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\">");
86  
87 +        bw.write(" <tr>");
88  
89 +        bw.write("  <td valign=\"top\">");
90  
91 +        bw.write("");
92  
93 +        bw.newLine();
94  
95 +        bw.flush();
96  
97 +    }
98  
99 +    
100  
101 +    public static void printLeftMenu(BufferedWriter bw) throws IOException{
102  
103 +        bw.newLine();
104  
105 +        bw.write("<!--#include virtual=\"../left.inc\" -->");
106  
107 +        bw.newLine();
108  
109 +        bw.flush();
110  
111 +    }
112  
113 +    
114  
115 +    public static void printTitle(BufferedWriter bw, String title) throws IOException{
116  
117 +        bw.newLine();
118  
119 +        bw.write("<!--#include virtual=\"../title.inc\" -->");
120  
121 +        bw.newLine();
122  
123 +        bw.newLine();
124  
125 +        bw.write("<h3>"+title+"</h3>");
126  
127 +        bw.newLine();
128  
129 +        bw.flush();
130  
131 +    }
132  
133 +    
134  
135 +    public static void printAllMachines(BufferedWriter bw, LinkedList list) throws IOException{
136  
137 +        bw.write("<table border=\"0\"  align=\"center\">");
138  
139 +        
140  
141 +        Iterator it = list.iterator();
142  
143 +        while (it.hasNext()){
144  
145 +            ReportPage rp = (ReportPage)it.next();            
146  
147 +            bw.write("<tr><td><font size=\"4\"><a href=\"../"+rp.getWhen()+rp.getMachineName()+"."+rp.getReport()+".shtml\">"+rp.getWhen()+rp.getMachineName()+"</a></font></td></tr>");
148  
149 +        }
150  
151 +        
152  
153 +        bw.write("</table>");
154  
155 +        bw.flush();
156  
157 +    }
158  
159 +    
160  
161 +    public static void printMachinesByTime(BufferedWriter bw, LinkedList list, String when) throws IOException{
162  
163 +        bw.write("<table border=\"0\"  align=\"center\">");
164  
165 +        
166  
167 +        Iterator it = list.iterator();
168  
169 +        while (it.hasNext()){
170  
171 +            ReportPage rp = (ReportPage)it.next();
172  
173 +            if (rp.getWhen().equals(when)){
174  
175 +                bw.write("<tr><td><font size=\"4\"><a href=\"../"+rp.getWhen()+rp.getMachineName()+"."+rp.getReport()+".shtml\">"+rp.getMachineName()+"</a></font></td></tr>");
176  
177 +            }
178  
179 +        }
180  
181 +        
182  
183 +        bw.write("</table>");
184  
185 +        bw.flush();
186  
187 +    }
188  
189 +    
190  
191 +    public static void printTimesByMachine(BufferedWriter bw, LinkedList list, String machine_name) throws IOException{
192  
193 +        bw.write("<table border=\"0\"  align=\"center\">");
194  
195 +        
196  
197 +        Iterator it = list.iterator();
198  
199 +        while (it.hasNext()){
200  
201 +            ReportPage rp = (ReportPage)it.next();
202  
203 +            if (rp.getMachineName().equals(machine_name)){
204  
205 +                bw.write("<tr><td><font size=\"4\"><a href=\"../"+rp.getWhen()+rp.getMachineName()+"."+rp.getReport()+".shtml\">"+rp.getWhen()+"</a></font></td></tr>");
206  
207 +            }
208  
209 +        }
210  
211 +        
212  
213 +        bw.write("</table>");
214  
215 +        bw.flush();
216  
217 +    }
218  
219 +
220  
221 +    public static void printGraph(BufferedWriter bw, String filename, int width, int height, int type, long startDate, long endDate) throws IOException{
222  
223 +        
224  
225 +        String graphTitle = "Unknown time period";
226  
227 +        String xAxisTitle = "Time";
228  
229 +        String yAxisTitle = "Value";
230  
231 +        String scaleRow = " <tr><td>&nbsp;</td><td align=\"left\">"+DateUtils.dateString(startDate)+"</td><td align=\"right\">"+DateUtils.dateString(endDate)+"</td></tr>";
232  
233 +        int colspan = 2;
234  
235 +        
236  
237 +        switch (type) {
238  
239 +            case ReportPage.HOUR:
240  
241 +                graphTitle = "Hourly report from "+DateUtils.dateString(startDate)+" to "+DateUtils.dateString(endDate);
242  
243 +                scaleRow = " <tr><td>&nbsp;</td>";
244  
245 +                for (long i = startDate; i < endDate; i+=DateUtils.secsPerHour/6){
246  
247 +                    scaleRow += "<td align=\"left\" width=\""+(100/colspan)+"%\"><font size=\"2\">&gt;"+DateUtils.timeString(i)+"</font></td>";
248  
249 +                }
250  
251 +                scaleRow += "</tr>";
252  
253 +                colspan = 6;
254  
255 +                break;
256  
257 +            case ReportPage.DAY:
258  
259 +                graphTitle = "24 hour report from "+DateUtils.dateString(startDate)+" to "+DateUtils.dateString(endDate);
260  
261 +                scaleRow = " <tr><td>&nbsp;</td>";
262  
263 +                for (int i = 0; i < 24; i++){
264  
265 +                    scaleRow += "<td align=\"center\" width=\""+(100/colspan)+"%\"><font size=\"2\">"+i+"</font></td>";
266  
267 +                }
268  
269 +                scaleRow += "</tr>";
270  
271 +                colspan = 24;
272  
273 +                break;
274  
275 +            case ReportPage.WEEK:
276  
277 +                graphTitle = "7 day report from "+DateUtils.shortDateString(startDate)+" to "+DateUtils.shortDateString(endDate);
278  
279 +                colspan = 7;
280  
281 +                scaleRow = " <tr><td>&nbsp;</td>";
282  
283 +                for (long i = startDate; i < endDate; i+=DateUtils.secsPerDay){
284  
285 +                    scaleRow += "<td align=\"center\" width=\""+(100/colspan)+"%\">"+DateUtils.dayName(i)+"</td>";
286  
287 +                }
288  
289 +                scaleRow += "</tr>";
290  
291 +                break;
292  
293 +            case ReportPage.MONTH:
294  
295 +                graphTitle = "30 day report from "+DateUtils.shortDateString(startDate)+" to "+DateUtils.shortDateString(endDate);
296  
297 +                scaleRow = " <tr><td>&nbsp;</td><td align=\"left\">"+DateUtils.shortDateString(startDate)+"</td><td align=\"right\">"+DateUtils.shortDateString(endDate)+"</td></tr>";
298  
299 +                colspan = 2;
300  
301 +                break;
302  
303 +            default:
304  
305 +                // Do nothing, leave values as they are.
306  
307 +        }
308  
309 +        
310  
311 +        bw.write("<table border=\"0\">");
312  
313 +        bw.write(" <tr><td>&nbsp;</td><td colspan=\""+colspan+"\"><b>"+graphTitle+"</b></td></tr>");
314  
315 +        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>");
316  
317 +        bw.write(scaleRow);
318  
319 +        bw.write("</table>");
320  
321 +        bw.newLine();
322  
323 +        bw.flush();
324  
325 +    }
326  
327 +    
328  
329 +    public static void printTable(BufferedWriter bw, PlotData pd) throws IOException{
330  
331 +
332  
333 +        bw.write("<table border=\"0\"  align=\"center\">");
334  
335 +        
336  
337 +        bw.write("<tr bgcolor=\"black\"><td><font color=\"white\">Date</font></td><td><font color=\"white\">Value</font></td></tr>");
338  
339 +        
340  
341 +        // Alternating row colours.
342  
343 +        String rowColour1 = "#ccccff";
344  
345 +        String rowColour2 = "#ffffff";
346  
347 +        
348  
349 +        String rowColour = rowColour1;
350  
351 +        
352  
353 +        Iterator it = pd.iterator();
354  
355 +        while (it.hasNext()){
356  
357 +            Point2D p = (Point2D)it.next();
358  
359 +            double x = p.getX();
360  
361 +            double y = p.getY();
362  
363 +            
364  
365 +            if (rowColour.equals(rowColour1)){
366  
367 +                rowColour = rowColour2;
368  
369 +            }
370  
371 +            else {
372  
373 +                rowColour = rowColour1;
374  
375 +            }
376  
377 +            
378  
379 +            bw.write("<tr bgcolor=\""+rowColour+"\"><td>"+x+"</td><td>"+y+"</td></tr>");
380  
381 +        }
382  
383 +        
384  
385 +        bw.write("</table>");
386  
387 +        bw.flush();
388  
389 +    }
390  
391 +    
392  
393 +    public static void printBottom(BufferedWriter bw) throws IOException{
394  
395 +        bw.newLine();
396  
397 +        bw.write("<!--#include virtual=\"../bottom.inc\" -->");
398  
399 +        bw.newLine();
400  
401 +        bw.newLine();
402  
403 +        bw.flush();
404  
405 +    }
406  
407 +    
408  
409 +    
410  
411 +
412  
413 + //---CONSTRUCTORS---
414  
415 +
416  
417 +        
418  
419 + //---PUBLIC METHODS---
420  
421 +
422  
423 +    /**
424  
425 +     * Overrides the {@link java.lang.Object#toString() Object.toString()}
426  
427 +     * method to provide clean logging (every class should have this).
428  
429 +     *
430  
431 +     * @return the name of this class and its CVS revision
432  
433 +     */
434  
435 +    public String toString() {
436  
437 +        return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
438  
439 +    }
440  
441 +
442  
443 + //---PRIVATE METHODS---
444  
445 +
446  
447 + //---ACCESSOR/MUTATOR METHODS---
448  
449 +
450  
451 + //---ATTRIBUTES---
452  
453 +
454  
455 + //---STATIC ATTRIBUTES---
456  
457 +
458  
459 + }
460  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines