KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lowagie > text > rtf > RtfTableCell


1 /*
2  * The contents of this file are subject to the Mozilla Public License Version 1.1
3  * (the "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.mozilla.org/MPL/
5  *
6  * Software distributed under the License is distributed on an "AS IS" basis,
7  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8  * for the specific language governing rights and limitations under the License.
9  *
10  * The Original Code is 'iText, a free JAVA-PDF library'.
11  *
12  * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
13  * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
14  * All Rights Reserved.
15  * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
16  * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
17  *
18  * Contributor(s): all the names of the contributors are added in the source code
19  * where applicable.
20  *
21  * Alternatively, the contents of this file may be used under the terms of the
22  * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
23  * provisions of LGPL are applicable instead of those above. If you wish to
24  * allow use of your version of this file only under the terms of the LGPL
25  * License and not to allow others to use your version of this file under
26  * the MPL, indicate your decision by deleting the provisions above and
27  * replace them with the notice and other provisions required by the LGPL.
28  * If you do not delete the provisions above, a recipient may use your version
29  * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
30  *
31  * This library is free software; you can redistribute it and/or modify it
32  * under the terms of the MPL as stated above or under the terms of the GNU
33  * Library General Public License as published by the Free Software Foundation;
34  * either version 2 of the License, or any later version.
35  *
36  * This library is distributed in the hope that it will be useful, but WITHOUT
37  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
38  * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
39  * details.
40  *
41  * If you didn't download this code from the following link, you should check if
42  * you aren't using an obsolete version:
43  * http://www.lowagie.com/iText/
44  */

45
46 package com.lowagie.text.rtf;
47
48 import java.util.Properties JavaDoc;
49
50 import com.lowagie.text.BadElementException;
51 import com.lowagie.text.Cell;
52 import com.lowagie.text.Element;
53
54 /**
55  * A <code>Cell</code> with extended style attributes
56  *
57  * ONLY FOR USE WITH THE RtfWriter NOT with the RtfWriter2.
58  * @deprecated Please move to the RtfWriter2 and associated classes. com.lowagie.text.rtf.table.RtfCell replaces the functionality of this class.
59  */

60 public class RtfTableCell extends Cell
61 {
62     /* Table border styles */
63     
64     /** Table border solid */
65     public static final int BORDER_UNDEFINED = 0;
66     
67     /** Table border solid */
68     public static final int BORDER_SINGLE = 1;
69     
70     /** Table border double thickness */
71     public static final int BORDER_DOUBLE_THICK = 2;
72     
73     /** Table border shadowed */
74     public static final int BORDER_SHADOWED = 3;
75     
76     /** Table border dotted */
77     public static final int BORDER_DOTTED = 4;
78     
79     /** Table border dashed */
80     public static final int BORDER_DASHED = 5;
81     
82     /** Table border hairline */
83     public static final int BORDER_HAIRLINE = 6;
84     
85     /** Table border double line */
86     public static final int BORDER_DOUBLE = 7;
87     
88     /** Table border dot dash line */
89     public static final int BORDER_DOT_DASH = 8;
90     
91     /** Table border dot dot dash line */
92     public static final int BORDER_DOT_DOT_DASH = 9;
93     
94     /** Table border triple line */
95     public static final int BORDER_TRIPLE = 10;
96
97     /** Table border line */
98     public static final int BORDER_THICK_THIN = 11;
99     
100     /** Table border line */
101     public static final int BORDER_THIN_THICK = 12;
102     
103     /** Table border line */
104     public static final int BORDER_THIN_THICK_THIN = 13;
105     
106     /** Table border line */
107     public static final int BORDER_THICK_THIN_MED = 14;
108     
109     /** Table border line */
110     public static final int BORDER_THIN_THICK_MED = 15;
111     
112     /** Table border line */
113     public static final int BORDER_THIN_THICK_THIN_MED = 16;
114     
115     /** Table border line */
116     public static final int BORDER_THICK_THIN_LARGE = 17;
117     
118     /** Table border line */
119     public static final int BORDER_THIN_THICK_LARGE = 18;
120     
121     /** Table border line */
122     public static final int BORDER_THIN_THICK_THIN_LARGE = 19;
123     
124     /** Table border line */
125     public static final int BORDER_WAVY = 20;
126     
127     /** Table border line */
128     public static final int BORDER_DOUBLE_WAVY = 21;
129     
130     /** Table border line */
131     public static final int BORDER_STRIPED = 22;
132     
133     /** Table border line */
134     public static final int BORDER_EMBOSS = 23;
135     
136     /** Table border line */
137     public static final int BORDER_ENGRAVE = 24;
138     
139     /* Instance variables */
140     private float topBorderWidth;
141     private float leftBorderWidth;
142     private float rightBorderWidth;
143     private float bottomBorderWidth;
144     private int topBorderStyle = 1;
145     private int leftBorderStyle = 1;
146     private int rightBorderStyle = 1;
147     private int bottomBorderStyle = 1;
148     
149 /**
150  * Constructs an empty <CODE>Cell</CODE> (for internal use only).
151  *
152  * @param dummy a dummy value
153  */

154
155     public RtfTableCell(boolean dummy) {
156         super(dummy);
157     }
158     
159 /**
160  * Constructs a <CODE>Cell</CODE> with a certain <CODE>Element</CODE>.
161  * <P>
162  * if the element is a <CODE>ListItem</CODE>, <CODE>Row</CODE> or
163  * <CODE>Cell</CODE>, an exception will be thrown.
164  *
165  * @param element the element
166  * @throws BadElementException when the creator was called with a <CODE>ListItem</CODE>, <CODE>Row</CODE> or <CODE>Cell</CODE>
167  */

168     public RtfTableCell(Element element) throws BadElementException {
169         super(element);
170     }
171     
172 /**
173  * Constructs a <CODE>Cell</CODE> with a certain content.
174  * <P>
175  * The <CODE>String</CODE> will be converted into a <CODE>Paragraph</CODE>.
176  *
177  * @param content a <CODE>String</CODE>
178  */

179     public RtfTableCell(String JavaDoc content) {
180         super(content);
181     }
182     
183 /**
184  * Returns a <CODE>Cell</CODE> that has been constructed taking in account
185  * the value of some <VAR>attributes</VAR>.
186  *
187  * @param attributes Some attributes
188  */

189
190     public RtfTableCell(Properties JavaDoc attributes) {
191         super(attributes);
192     }
193     
194     /**
195      * Set all four borders to <code>f</code> width
196      *
197      * @param f the desired width
198      */

199     public void setBorderWidth(float f) {
200         super.setBorderWidth(f);
201         topBorderWidth = f;
202         leftBorderWidth = f;
203         rightBorderWidth = f;
204         bottomBorderWidth = f;
205     }
206     
207     /**
208      * Set the top border to <code>f</code> width
209      *
210      * @param f the desired width
211      */

212     public void setTopBorderWidth(float f) {
213         topBorderWidth = f;
214     }
215     
216     /**
217      * Get the top border width
218      * @return a width
219      */

220     public float topBorderWidth() {
221         return topBorderWidth;
222     }
223     
224     /**
225      * Set the left border to <code>f</code> width
226      *
227      * @param f the desired width
228      */

229     public void setLeftBorderWidth(float f) {
230         leftBorderWidth = f;
231     }
232     
233     /**
234      * Get the left border width
235      * @return a width
236      */

237     public float leftBorderWidth() {
238         return leftBorderWidth;
239     }
240     
241     /**
242      * Set the right border to <code>f</code> width
243      *
244      * @param f the desired width
245      */

246     public void setRightBorderWidth(float f) {
247         rightBorderWidth = f;
248     }
249     
250     /**
251      * Get the right border width
252      * @return a width
253      */

254     public float rightBorderWidth() {
255         return rightBorderWidth;
256     }
257     
258     /**
259      * Set the bottom border to <code>f</code> width
260      *
261      * @param f the desired width
262      */

263     public void setBottomBorderWidth(float f) {
264         bottomBorderWidth = f;
265     }
266     
267     /**
268      * Get the bottom border width
269      * @return a width
270      */

271     public float bottomBorderWidth() {
272         return bottomBorderWidth;
273     }
274     
275     /**
276      * Set all four borders to style defined by <code>style</code>
277      *
278      * @param style the desired style
279      */

280     public void setBorderStyle(int style) {
281         topBorderStyle = style;
282         leftBorderStyle = style;
283         rightBorderStyle = style;
284         bottomBorderStyle = style;
285     }
286     
287     /**
288      * Set the top border to style defined by <code>style</code>
289      *
290      * @param style the desired style
291      */

292     public void setTopBorderStyle(int style) {
293         topBorderStyle = style;
294     }
295     
296     /**
297      * Get the top border style
298      * @return a style value
299      */

300     public int topBorderStyle() {
301         return topBorderStyle;
302     }
303     
304     /**
305      * Set the left border to style defined by <code>style</code>
306      *
307      * @param style the desired style
308      */

309     public void setLeftBorderStyle(int style) {
310         leftBorderStyle = style;
311     }
312     
313     /**
314      * Get the left border style
315      * @return a style value
316      */

317     public int leftBorderStyle() {
318         return leftBorderStyle;
319     }
320     
321     /**
322      * Set the right border to style defined by <code>style</code>
323      *
324      * @param style the desired style
325      */

326     public void setRightBorderStyle(int style) {
327         rightBorderStyle = style;
328     }
329     
330     /**
331      * Get the right border style
332      * @return a style value
333      */

334     public int rightBorderStyle() {
335         return rightBorderStyle;
336     }
337     
338     /**
339      * Set the bottom border to style defined by <code>style</code>
340      *
341      * @param style the desired style
342      */

343     public void setBottomBorderStyle(int style) {
344         bottomBorderStyle = style;
345     }
346     
347     /**
348      * Get the bottom border style
349      * @return a style value
350      */

351     public int bottomBorderStyle() {
352         return bottomBorderStyle;
353     }
354     
355     /**
356      * Get the RTF control word for <code>style</code>
357      * @param style a style value
358      * @return a byte array corresponding with a style control word
359      */

360     protected static byte[] getStyleControlWord(int style) {
361         switch(style)
362         {
363             case BORDER_UNDEFINED : return "brdrs".getBytes();
364             case BORDER_SINGLE : return "brdrs".getBytes();
365             case BORDER_DOUBLE_THICK : return "brdrth".getBytes();
366             case BORDER_SHADOWED : return "brdrsh".getBytes();
367             case BORDER_DOTTED : return "brdrdot".getBytes();
368             case BORDER_DASHED : return "brdrdash".getBytes();
369             case BORDER_HAIRLINE : return "brdrhair".getBytes();
370             case BORDER_DOUBLE : return "brdrdb".getBytes();
371             case BORDER_DOT_DASH : return "brdrdashd".getBytes();
372             case BORDER_DOT_DOT_DASH : return "brdrdashdd".getBytes();
373             case BORDER_TRIPLE : return "brdrtriple".getBytes();
374             case BORDER_THICK_THIN : return "brdrtnthsg".getBytes();
375             case BORDER_THIN_THICK : return "brdrthtnsg".getBytes();
376             case BORDER_THIN_THICK_THIN : return "brdrtnthtnsg".getBytes();
377             case BORDER_THICK_THIN_MED : return "brdrtnthmg".getBytes();
378             case BORDER_THIN_THICK_MED : return "brdrthtnmg".getBytes();
379             case BORDER_THIN_THICK_THIN_MED : return "brdrtnthtnmg".getBytes();
380             case BORDER_THICK_THIN_LARGE : return "brdrtnthlg".getBytes();
381             case BORDER_THIN_THICK_LARGE : return "brdrthtnlg".getBytes();
382             case BORDER_THIN_THICK_THIN_LARGE : return "brdrtnthtnlg".getBytes();
383             case BORDER_WAVY : return "brdrwavy".getBytes();
384             case BORDER_DOUBLE_WAVY : return "brdrwavydb".getBytes();
385             case BORDER_STRIPED : return "brdrdashdotstr".getBytes();
386             case BORDER_EMBOSS : return "brdremboss".getBytes();
387             case BORDER_ENGRAVE : return "brdrengrave".getBytes();
388         }
389         
390         return "brdrs".getBytes();
391     }
392 }
393
Popular Tags