1 14 package org.compiere.print; 15 16 import java.awt.*; 17 import java.util.*; 18 19 import org.compiere.model.*; 20 import org.compiere.util.*; 21 22 28 public class MPrintTableFormat extends X_AD_PrintTableFormat 29 { 30 36 private MPrintTableFormat (Properties ctx, int AD_PrintTableFormat_ID) 37 { 38 super (ctx, AD_PrintTableFormat_ID); 39 Log.trace(Log.l4_Data, "MPrintTableFormat ID=" + AD_PrintTableFormat_ID); 40 if (AD_PrintTableFormat_ID == 0) 41 { 42 } 43 } 45 46 47 private Font standard_Font = new Font(null); 48 49 private Font pageHeader_Font; 50 private Font pageFooter_Font; 51 private Color pageHeaderFG_Color; 52 private Color pageHeaderBG_Color; 53 private Color pageFooterFG_Color; 54 private Color pageFooterBG_Color; 55 56 private Font parameter_Font; 57 private Color parameter_Color; 58 59 private Font header_Font; 60 private Color headerFG_Color; 61 private Color headerBG_Color; 62 private Color hdrLine_Color; 63 private Stroke header_Stroke; 65 private Font funct_Font; 66 private Color functFG_Color; 67 private Color functBG_Color; 68 69 private Color lineH_Color; 70 private Color lineV_Color; 71 private Stroke lineH_Stroke; private Stroke lineV_Stroke = new BasicStroke(0.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 1.0f, 73 new float[]{2.0f, 2.0f}, 0.0f); private boolean paintBoundaryLines = true; 76 private boolean paintVLines = true; 77 private boolean paintHLines = true; 78 private boolean printFunctionSymbols = true; 79 80 81 82 86 public void setStandard_Font(Font standard_Font) 87 { 88 if (standard_Font != null) 89 this.standard_Font = standard_Font; 90 } 91 92 96 public Font getStandard_Font() 97 { 98 return standard_Font; 99 } 100 101 105 public Font getHeader_Font() 106 { 107 if (header_Font != null) 108 return header_Font; 109 int i = getHdr_PrintFont_ID(); 110 if (i != 0) 111 header_Font = MPrintFont.get(i).getFont(); 112 if (header_Font == null) 113 header_Font = new Font (standard_Font.getName(), Font.BOLD, standard_Font.getSize()); 114 return header_Font; 115 } 116 117 121 public Font getFunct_Font() 122 { 123 if (funct_Font != null) 124 return funct_Font; 125 int i = getFunct_PrintFont_ID(); 126 if (i != 0) 127 funct_Font = MPrintFont.get(i).getFont(); 128 if (funct_Font == null) 129 funct_Font = new Font (standard_Font.getName(), Font.BOLD|Font.ITALIC, standard_Font.getSize()); 130 return funct_Font; 131 } 132 133 134 public Font getPageHeader_Font() 135 { 136 if (pageHeader_Font == null) 137 pageHeader_Font = new Font (standard_Font.getName(), Font.BOLD, standard_Font.getSize()); 138 return pageHeader_Font; 139 } 140 public Font getParameter_Font() 141 { 142 if (parameter_Font == null) 143 parameter_Font = new Font (standard_Font.getName(), Font.ITALIC, standard_Font.getSize()); 144 return parameter_Font; 145 } 146 public Font getPageFooter_Font() 147 { 148 if (pageFooter_Font == null) 149 pageFooter_Font = new Font (standard_Font.getName(), Font.PLAIN, standard_Font.getSize()-2); 150 return pageFooter_Font; 151 } 152 153 154 158 public Color getHeaderFG_Color() 159 { 160 if (headerFG_Color != null) 161 return headerFG_Color; 162 int i = getHdrTextFG_PrintColor_ID(); 163 if (i != 0) 164 headerFG_Color = MPrintColor.get(i).getColor(); 165 if (headerFG_Color == null) 166 headerFG_Color = MPrintColor.blackBlue; 167 return headerFG_Color; 168 } 169 170 174 public Color getHeaderBG_Color() 175 { 176 if (headerBG_Color != null) 177 return headerBG_Color; 178 int i = getHdrTextBG_PrintColor_ID(); 179 if (i != 0) 180 headerBG_Color = MPrintColor.get(i).getColor(); 181 if (headerBG_Color == null) 182 headerBG_Color = Color.cyan; 183 return headerBG_Color; 184 } 185 186 190 public Color getHeaderLine_Color() 191 { 192 if (hdrLine_Color != null) 193 return hdrLine_Color; 194 int i = getHdrLine_PrintColor_ID(); 195 if (i != 0) 196 hdrLine_Color = MPrintColor.get(i).getColor(); 197 if (hdrLine_Color == null) 198 hdrLine_Color = MPrintColor.blackBlue; 199 return hdrLine_Color; 200 } 201 202 206 public Color getFunctBG_Color() 207 { 208 if (functBG_Color != null) 209 return functBG_Color; 210 int i = getFunctBG_PrintColor_ID(); 211 if (i != 0) 212 functBG_Color = MPrintColor.get(i).getColor(); 213 if (functBG_Color == null) 214 functBG_Color = Color.white; 215 return functBG_Color; 216 } 217 218 222 public Color getFunctFG_Color() 223 { 224 if (functFG_Color != null) 225 return functFG_Color; 226 int i = getFunctFG_PrintColor_ID(); 227 if (i != 0) 228 functFG_Color = MPrintColor.get(i).getColor(); 229 if (functFG_Color == null) 230 functFG_Color = MPrintColor.darkGreen; 231 return functFG_Color; 232 } 233 234 235 public Color getPageHeaderFG_Color() 236 { 237 if (pageHeaderFG_Color == null) 238 pageHeaderFG_Color = MPrintColor.blackBlue; 239 return pageHeaderFG_Color; 240 } 241 public Color getPageHeaderBG_Color() 242 { 243 if (pageHeaderBG_Color == null) 244 pageHeaderBG_Color = Color.white; 245 return pageHeaderBG_Color; 246 } 247 public Color getPageFooterFG_Color() 248 { 249 if (pageFooterFG_Color == null) 250 pageFooterFG_Color = MPrintColor.blackBlue; 251 return pageFooterFG_Color; 252 } 253 public Color getPageFooterBG_Color() 254 { 255 if (pageFooterBG_Color == null) 256 pageFooterBG_Color = Color.white; 257 return pageFooterBG_Color; 258 } 259 public Color getParameter_Color() 260 { 261 if (parameter_Color == null) 262 parameter_Color = Color.darkGray; 263 return parameter_Color; 264 } 265 266 267 271 public Color getHLine_Color() 272 { 273 if (lineH_Color != null) 274 return lineH_Color; 275 int i = getLine_PrintColor_ID(); 276 if (i != 0) 277 lineH_Color = MPrintColor.get(i).getColor(); 278 if (lineH_Color == null) 279 lineH_Color = Color.lightGray; 280 return lineH_Color; 281 } 282 286 public Color getVLine_Color() 287 { 288 if (lineV_Color != null) 289 return lineV_Color; 290 int i = getLine_PrintColor_ID(); 291 if (i != 0) 292 lineV_Color = MPrintColor.get(i).getColor(); 293 if (lineV_Color == null) 294 lineV_Color = Color.lightGray; 295 return lineV_Color; 296 } 297 298 299 300 public Stroke getHLine_Stroke() 301 { 302 if (lineH_Stroke == null) 303 lineH_Stroke = new BasicStroke(1.0f); return lineH_Stroke; 305 } 306 public Stroke getVLine_Stroke() 307 { 308 if (lineV_Stroke == null) 309 lineV_Stroke = new BasicStroke(0.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 1.0f, 310 new float[]{2.0f, 2.0f}, 0.0f); 311 return lineV_Stroke; 312 } 313 public Stroke getHeader_Stroke() 314 { 315 if (header_Stroke == null) 316 header_Stroke = new BasicStroke(2.0f); return header_Stroke; 318 } 319 320 321 322 323 private static CCache s_cache = new CCache("printTableFormat", 3); 324 325 331 static public MPrintTableFormat get (int AD_PrintTableFormat_ID, Font standard_font) 332 { 333 Integer ii = new Integer (AD_PrintTableFormat_ID); 334 MPrintTableFormat tf = (MPrintTableFormat)s_cache.get(ii); 335 if (tf == null) 336 { 337 tf = new MPrintTableFormat (Env.getCtx (), AD_PrintTableFormat_ID); 338 s_cache.put(ii, tf); 339 } 340 tf.setStandard_Font(standard_font); 341 return tf; 342 } 344 350 static public MPrintTableFormat get (int AD_PrintTableFormat_ID, int AD_PrintFont_ID) 351 { 352 return get (AD_PrintTableFormat_ID, MPrintFont.get (AD_PrintFont_ID).getFont()); 353 } 355 } | Popular Tags |