| 1 |
//---PACKAGE DECLARATION--- |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
//---IMPORTS--- |
| 6 |
|
| 7 |
import java.io.*; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
/** |
| 14 |
|
| 15 |
* Produces an SHTML document. |
| 16 |
|
| 17 |
* |
| 18 |
|
| 19 |
* @author $Author: pjm2 $ |
| 20 |
|
| 21 |
* @version $Id: SHTMLMaker.java,v 1.11 2001/01/07 21:09:31 pjm2 Exp $ |
| 22 |
|
| 23 |
*/ |
| 24 |
|
| 25 |
public class SHTMLMaker { |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
//---FINAL ATTRIBUTES--- |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
/** |
| 34 |
|
| 35 |
* The current CVS revision of this class |
| 36 |
|
| 37 |
*/ |
| 38 |
|
| 39 |
public final String REVISION = "$Revision: 1.11 $"; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
//---STATIC METHODS--- |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
//---CONSTRUCTORS--- |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public SHTMLMaker(String metaDescription, String metaKeywords, String title, String friendlyName, String graphFile, int width, int height, PlotData pd, int type, long startDate, long endDate){ |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
_metaDescription = metaDescription; |
| 56 |
|
| 57 |
_metaKeywords = metaKeywords; |
| 58 |
|
| 59 |
_title = title; |
| 60 |
|
| 61 |
_friendlyName = friendlyName; |
| 62 |
|
| 63 |
_graphFile = graphFile; |
| 64 |
|
| 65 |
_width = width; |
| 66 |
|
| 67 |
_height = height; |
| 68 |
|
| 69 |
_pd = pd; |
| 70 |
|
| 71 |
_type = type; |
| 72 |
|
| 73 |
_startDate = startDate; |
| 74 |
|
| 75 |
_endDate = endDate; |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
public void writePage(String filename) throws IOException{ |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
BufferedWriter bw = null; |
| 88 |
|
| 89 |
try { |
| 90 |
|
| 91 |
bw = new BufferedWriter(new FileWriter(filename)); |
| 92 |
|
| 93 |
} |
| 94 |
|
| 95 |
catch (IOException e){ |
| 96 |
|
| 97 |
System.out.println("Could not write to the SHTML page: "+e); |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
// Use the layout functions in SHTMLLayout... |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
IscreamLayout.printDocType(bw); |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
IscreamLayout.printHeader(bw, _title, _metaDescription, _metaKeywords); |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
IscreamLayout.printLeftMenu(bw); |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
IscreamLayout.printTitle(bw, _title+"<br>"+"("+_friendlyName+")"); |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
IscreamLayout.printGraph(bw, _graphFile, _width, _height, _type, _startDate, _endDate); |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
// Let's leave this bit out for now... |
| 128 |
|
| 129 |
//IscreamLayout.printTable(bw, _pd); |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
IscreamLayout.printBottom(bw); |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
bw.flush(); |
| 138 |
|
| 139 |
bw.close(); |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
System.out.println(" - Written SHTML page"); |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
//---PUBLIC METHODS--- |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
/** |
| 158 |
|
| 159 |
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
| 160 |
|
| 161 |
* method to provide clean logging (every class should have this). |
| 162 |
|
| 163 |
* |
| 164 |
|
| 165 |
* @return the name of this class and its CVS revision |
| 166 |
|
| 167 |
*/ |
| 168 |
|
| 169 |
public String toString() { |
| 170 |
|
| 171 |
return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
| 172 |
|
| 173 |
} |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
//---PRIVATE METHODS--- |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
//---ACCESSOR/MUTATOR METHODS--- |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
//---ATTRIBUTES--- |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
private String _metaDescription; |
| 190 |
|
| 191 |
private String _metaKeywords; |
| 192 |
|
| 193 |
private String _title; |
| 194 |
|
| 195 |
private String _friendlyName; |
| 196 |
|
| 197 |
private String _graphFile; |
| 198 |
|
| 199 |
private int _width; |
| 200 |
|
| 201 |
private int _height; |
| 202 |
|
| 203 |
private PlotData _pd; |
| 204 |
|
| 205 |
private int _type; |
| 206 |
|
| 207 |
private long _startDate; |
| 208 |
|
| 209 |
private long _endDate; |
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
//---STATIC ATTRIBUTES--- |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
} |
| 218 |
|