ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/DBReporter/IscreamLayout.java
Revision: 1.10
Committed: Sun Jan 7 13:58:05 2001 UTC (24 years, 11 months ago) by pjm2
Branch: MAIN
Changes since 1.9: +3 -3 lines
Log Message:
The weekly report now uses short day names.

File Contents

# User Rev Content
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 pjm2 1.3 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 pjm2 1.6 String scaleRow = " <tr><td>&nbsp;</td><td align=\"left\">"+DateUtils.dateString(startDate)+"</td><td align=\"right\">"+DateUtils.dateString(endDate)+"</td></tr>";
74 pjm2 1.9 int colspan = 2;
75 pjm2 1.3
76     switch (type) {
77     case ReportPage.HOUR:
78 pjm2 1.6 graphTitle = "Hourly report from "+DateUtils.dateString(startDate)+" to "+DateUtils.dateString(endDate);
79 pjm2 1.9 scaleRow = " <tr><td>&nbsp;</td>";
80 pjm2 1.8 for (long i = startDate; i < endDate; i+=DateUtils.secsPerHour/6){
81 pjm2 1.10 scaleRow += "<td><font size=\"2\">"+DateUtils.timeString(i)+"</font></td>";
82 pjm2 1.8 }
83     scaleRow += "</tr>";
84 pjm2 1.9 colspan = 6;
85 pjm2 1.3 break;
86     case ReportPage.DAY:
87 pjm2 1.6 graphTitle = "24 hour report from "+DateUtils.dateString(startDate)+" to "+DateUtils.dateString(endDate);
88 pjm2 1.9 scaleRow = " <tr><td>&nbsp;</td>";
89 pjm2 1.8 for (int i = 0; i < 24; i++){
90 pjm2 1.10 scaleRow += "<td><font size=\"2\">"+i+"</font></td>";
91 pjm2 1.8 }
92     scaleRow += "</tr>";
93 pjm2 1.9 colspan = 24;
94 pjm2 1.3 break;
95     case ReportPage.WEEK:
96 pjm2 1.7 graphTitle = "7 day report from "+DateUtils.shortDateString(startDate)+" to "+DateUtils.shortDateString(endDate);
97 pjm2 1.9 scaleRow = " <tr><td>&nbsp;</td>";
98 pjm2 1.8 for (long i = startDate; i < endDate; i+=DateUtils.secsPerDay){
99 pjm2 1.10 scaleRow += "<td>"+DateUtils.dayName(i)+"</td>";
100 pjm2 1.8 }
101     scaleRow += "</tr>";
102 pjm2 1.9 colspan = 7;
103 pjm2 1.3 break;
104     case ReportPage.MONTH:
105 pjm2 1.7 graphTitle = "30 day report from "+DateUtils.shortDateString(startDate)+" to "+DateUtils.shortDateString(endDate);
106 pjm2 1.8 scaleRow = " <tr><td>&nbsp;</td><td align=\"left\">"+DateUtils.shortDateString(startDate)+"</td><td align=\"right\">"+DateUtils.shortDateString(endDate)+"</td></tr>";
107 pjm2 1.9 colspan = 2;
108 pjm2 1.3 break;
109     default:
110 pjm2 1.6 // Do nothing, leave values as they are.
111 pjm2 1.3 }
112    
113 pjm2 1.1 bw.write("<table border=\"0\">");
114 pjm2 1.9 bw.write(" <tr><td>&nbsp;</td><td colspan=\""+colspan+"\"><b>"+graphTitle+"</b></td></tr>");
115     bw.write(" <tr><td>"+yAxisTitle+"</td><td colspan=\""+colspan+"\"><img src=\""+filename+"\" width=\""+width+"\" height=\""+height+"\"></td></tr>");
116 pjm2 1.3 bw.write(scaleRow);
117 pjm2 1.1 bw.write("</table>");
118     bw.newLine();
119     bw.flush();
120     }
121    
122     public static void printTable(BufferedWriter bw, PlotData pd) throws IOException{
123 pjm2 1.4
124 pjm2 1.1 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 pjm2 1.4 // Alternating row colours.
129 pjm2 1.1 String rowColour1 = "#ccccff";
130     String rowColour2 = "#ffffff";
131    
132     String rowColour = rowColour1;
133    
134     Iterator it = pd.iterator();
135     while (it.hasNext()){
136     Point2D p = (Point2D)it.next();
137     double x = p.getX();
138     double y = p.getY();
139    
140     if (rowColour.equals(rowColour1)){
141     rowColour = rowColour2;
142     }
143     else {
144     rowColour = rowColour1;
145     }
146    
147     bw.write("<tr bgcolor=\""+rowColour+"\"><td>"+x+"</td><td>"+y+"</td></tr>");
148     }
149    
150     bw.write("</table>");
151     bw.flush();
152     }
153    
154     public static void printBottom(BufferedWriter bw) throws IOException{
155     bw.newLine();
156 pjm2 1.2 bw.write("<!--#include virtual=\"../bottom.inc\" -->");
157 pjm2 1.1 bw.newLine();
158     bw.newLine();
159     bw.flush();
160     }
161    
162    
163    
164     //---CONSTRUCTORS---
165    
166    
167     //---PUBLIC METHODS---
168    
169     /**
170     * Overrides the {@link java.lang.Object#toString() Object.toString()}
171     * method to provide clean logging (every class should have this).
172     *
173     * @return the name of this class and its CVS revision
174     */
175     public String toString() {
176     return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
177     }
178    
179     //---PRIVATE METHODS---
180    
181     //---ACCESSOR/MUTATOR METHODS---
182    
183     //---ATTRIBUTES---
184    
185     //---STATIC ATTRIBUTES---
186    
187     }