1 64 65 package com.jcorporate.expresso.services.html; 66 67 72 73 import java.io.PrintWriter ; 74 75 76 82 public class Heading 83 extends Text { 84 private int level = 1; 85 private String alignment = ("center"); 86 private String thisClass = (this.getClass().getName() + "."); 87 88 93 public Heading() 94 throws HtmlException { 95 super(); 96 } 97 98 104 public Heading(String newString) 105 throws HtmlException { 106 super(newString); 107 } 108 109 117 public Heading(String newString, int newLevel) 118 throws HtmlException { 119 super(newString); 120 level = newLevel; 121 } 122 123 131 public Heading(String newString, String newStyle) 132 throws HtmlException { 133 super(newString, newStyle); 134 } 135 136 145 public Heading(String newString, String newStyle, int newLevel) 146 throws HtmlException { 147 super(newString, newStyle); 148 level = newLevel; 149 } 150 151 158 protected void display(PrintWriter out, int depth) 159 throws HtmlException { 160 this.padWithTabs(out, depth); 161 out.print("<h" + level); 162 163 if (cSSClass != null) { 164 out.print(" class=\"" + cSSClass + "\""); 165 } 166 if (cSSID != null) { 167 out.print(" ID=\"" + cSSID + "\""); 168 } 169 170 out.print(" align=\"" + alignment + "\">"); 171 super.display(out, depth + 1); 172 this.padWithTabs(out, depth); 173 out.println("</h" + level + ">"); 174 setDisplayed(); 175 } 176 177 178 185 public synchronized void setAlignment(String newAlignment) 186 throws HtmlException { 187 String myName = (thisClass + "setAlignment(String)"); 188 189 if (newAlignment.equalsIgnoreCase("left")) { 190 alignment = newAlignment; 191 } else if (newAlignment.equalsIgnoreCase("right")) { 192 alignment = newAlignment; 193 } else if (newAlignment.equalsIgnoreCase("center")) { 194 alignment = newAlignment; 195 } else { 196 throw new HtmlException(myName + 197 ":Alignment must be left, right, or center for '" + 198 getName() + "'"); 199 } 200 } 201 202 203 } 204 205 | Popular Tags |