KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > write > biff > WritableFontRecord


1 /*********************************************************************
2 *
3 * Copyright (C) 2002 Andrew Khan
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ***************************************************************************/

19
20 package jxl.write.biff;
21
22 import jxl.write.WriteException;
23 import jxl.biff.FontRecord;
24 import jxl.format.Font;
25
26 /**
27  * A writable Font record. This class intercepts any set accessor calls
28  * and throws and exception if the Font is already initialized
29  */

30 public class WritableFontRecord extends FontRecord
31 {
32   /**
33    * Constructor, used when creating a new font for writing out.
34    *
35    * @param bold the bold indicator
36    * @param ps the point size
37    * @param us the underline style
38    * @param fn the name
39    * @param it italicised indicator
40    * @param c the colour
41    * @param ss the script style
42    */

43   protected WritableFontRecord(String JavaDoc fn, int ps, int bold, boolean it,
44                          int us, int ci, int ss)
45   {
46     super(fn, ps, bold, it, us, ci, ss);
47   }
48
49   /**
50    * Publicly available copy constructor
51    *
52    * @param the font to copy
53    */

54   protected WritableFontRecord(Font f)
55   {
56     super(f);
57   }
58
59
60   /**
61    * Sets the point size for this font, if the font hasn't been initialized
62    *
63    * @param pointSize the point size
64    * @exception WriteException, if this font is already in use elsewhere
65    */

66   protected void setPointSize(int pointSize) throws WriteException
67   {
68     if (isInitialized())
69     {
70       throw new JxlWriteException(JxlWriteException.formatInitialized);
71     }
72
73     super.setFontPointSize(pointSize);
74   }
75
76   /**
77    * Sets the bold style for this font, if the font hasn't been initialized
78    *
79    * @param boldStyle the bold style
80    * @exception WriteException, if this font is already in use elsewhere
81    */

82   protected void setBoldStyle(int boldStyle) throws WriteException
83   {
84     if (isInitialized())
85     {
86       throw new JxlWriteException(JxlWriteException.formatInitialized);
87     }
88
89     super.setFontBoldStyle(boldStyle);
90   }
91
92   /**
93    * Sets the italic indicator for this font, if the font hasn't been
94    * initialized
95    *
96    * @param italic the italic flag
97    * @exception WriteException, if this font is already in use elsewhere
98    */

99   protected void setItalic(boolean italic) throws WriteException
100   {
101     if (isInitialized())
102     {
103       throw new JxlWriteException(JxlWriteException.formatInitialized);
104     }
105
106     super.setFontItalic(italic);
107   }
108
109   /**
110    * Sets the underline style for this font, if the font hasn't been
111    * initialized
112    *
113    * @param us the underline style
114    * @exception WriteException, if this font is already in use elsewhere
115    */

116   protected void setUnderlineStyle(int us) throws WriteException
117   {
118     if (isInitialized())
119     {
120       throw new JxlWriteException(JxlWriteException.formatInitialized);
121     }
122
123     super.setFontUnderlineStyle(us);
124   }
125
126   /**
127    * Sets the colour for this font, if the font hasn't been
128    * initialized
129    *
130    * @param colour the colour
131    * @exception WriteException, if this font is already in use elsewhere
132    */

133   protected void setColour(int colour) throws WriteException
134   {
135     if (isInitialized())
136     {
137       throw new JxlWriteException(JxlWriteException.formatInitialized);
138     }
139
140     super.setFontColour(colour);
141   }
142
143   /**
144    * Sets the script style (eg. superscript, subscript) for this font,
145    * if the font hasn't been initialized
146    *
147    * @param scriptStyle the colour
148    * @exception WriteException, if this font is already in use elsewhere
149    */

150   protected void setScriptStyle(int scriptStyle) throws WriteException
151   {
152     if (isInitialized())
153     {
154       throw new JxlWriteException(JxlWriteException.formatInitialized);
155     }
156
157     super.setFontScriptStyle(scriptStyle);
158   }
159
160   /**
161    * Sets the struck out flag
162    *
163    * @param so TRUE if the font is struck out, false otherwise
164    * @exception WriteException, if this font is already in use elsewhere
165    */

166   protected void setStruckout(boolean os) throws WriteException
167   {
168     if (isInitialized())
169     {
170       throw new JxlWriteException(JxlWriteException.formatInitialized);
171     }
172     super.setFontStruckout(os);
173   }
174 }
175
Popular Tags