KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > print > MPrintTableFormat


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2002 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

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 /**
23  * Table Print Format
24  *
25  * @author Jorg Janke
26  * @version $Id: MPrintTableFormat.java,v 1.7 2003/07/06 18:43:01 jjanke Exp $
27  */

28 public class MPrintTableFormat extends X_AD_PrintTableFormat
29 {
30     /**
31      * Create Print Table Format
32      *
33      * @param ctx context
34      * @param AD_PrintTableFormat_ID table format
35      */

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     } // MPrintTableFormat
44

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; // -
64

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; // -
72
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); // |
74
//
75
private boolean paintBoundaryLines = true;
76     private boolean paintVLines = true;
77     private boolean paintHLines = true;
78     private boolean printFunctionSymbols = true;
79
80     /*************************************************************************/
81
82     /**
83      * Set Standard Font to derive other fonts if not defined
84      * @param standard_Font standard font
85      */

86     public void setStandard_Font(Font standard_Font)
87     {
88         if (standard_Font != null)
89             this.standard_Font = standard_Font;
90     }
91
92     /**
93      * Get Stndard Font
94      * @return stndard font
95      */

96     public Font getStandard_Font()
97     {
98         return standard_Font;
99     }
100
101     /**
102      * Get Table Header Font
103      * @return table header font or Bold standard font
104      */

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     /**
118      * Get Function Font
119      * @return function font or BoldItalic standard font
120      */

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     /**
155      * Get Header Foreground
156      * @return color or standard
157      */

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     /**
171      * Get Header BG Color
172      * @return color or standard
173      */

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     /**
187      * Get Header Line Color
188      * @return color or standard
189      */

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     /**
203      * Get Function BG Color
204      * @return color or standard
205      */

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     /**
219      * Get Function FG Color
220      * @return color or standard
221      */

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     /**
268      * Get Line Color
269      * @return color or standard
270      */

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     /**
283      * Get Line Color
284      * @return color or standard
285      */

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); // -
304
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); // -
317
return header_Stroke;
318     }
319
320
321     /*************************************************************************/
322
323     private static CCache s_cache = new CCache("printTableFormat", 3);
324
325     /**
326      * Get Table Format
327      * @param AD_PrintTableFormat_ID table format
328      * @param standard_font standard font
329      * @return Table Format
330      */

331     static public MPrintTableFormat get (int AD_PrintTableFormat_ID, Font standard_font)
332     {
333         Integer JavaDoc ii = new Integer JavaDoc (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     } // get
343

344     /**
345      * Get Table Format
346      * @param AD_PrintTableFormat_ID table format
347      * @param AD_PrintFont_ID standard font
348      * @return Table Format
349      */

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     } // get
354

355 } // MPrintTableForamt
356
Popular Tags