Source Code Cross Referenced for HSSFFont.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hssf » usermodel » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » poi 3.0.2 beta2 » org.apache.poi.hssf.usermodel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:           Licensed to the Apache Software Foundation (ASF) under one or more
003:           contributor license agreements.  See the NOTICE file distributed with
004:           this work for additional information regarding copyright ownership.
005:           The ASF licenses this file to You under the Apache License, Version 2.0
006:           (the "License"); you may not use this file except in compliance with
007:           the License.  You may obtain a copy of the License at
008:
009:               http://www.apache.org/licenses/LICENSE-2.0
010:
011:           Unless required by applicable law or agreed to in writing, software
012:           distributed under the License is distributed on an "AS IS" BASIS,
013:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:           See the License for the specific language governing permissions and
015:           limitations under the License.
016:        ==================================================================== */
017:
018:        /*
019:         * HSSFFont.java
020:         *
021:         * Created on December 9, 2001, 10:34 AM
022:         */
023:        package org.apache.poi.hssf.usermodel;
024:
025:        import org.apache.poi.hssf.record.FontRecord;
026:
027:        /**
028:         * Represents a Font used in a workbook.
029:         *
030:         * @version 1.0-pre
031:         * @author  Andrew C. Oliver
032:         * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createFont()
033:         * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short)
034:         * @see org.apache.poi.hssf.usermodel.HSSFCellStyle#setFont(HSSFFont)
035:         */
036:
037:        public class HSSFFont {
038:
039:            /**
040:             * Arial font
041:             */
042:
043:            public final static String FONT_ARIAL = "Arial";
044:
045:            /**
046:             * Normal boldness (not bold)
047:             */
048:
049:            public final static short BOLDWEIGHT_NORMAL = 0x190;
050:
051:            /**
052:             * Bold boldness (bold)
053:             */
054:
055:            public final static short BOLDWEIGHT_BOLD = 0x2bc;
056:
057:            /**
058:             * normal type of black color.
059:             */
060:
061:            public final static short COLOR_NORMAL = 0x7fff;
062:
063:            /**
064:             * Dark Red color
065:             */
066:
067:            public final static short COLOR_RED = 0xa;
068:
069:            /**
070:             * no type offsetting (not super or subscript)
071:             */
072:
073:            public final static short SS_NONE = 0;
074:
075:            /**
076:             * superscript
077:             */
078:
079:            public final static short SS_SUPER = 1;
080:
081:            /**
082:             * subscript
083:             */
084:
085:            public final static short SS_SUB = 2;
086:
087:            /**
088:             * not underlined
089:             */
090:
091:            public final static byte U_NONE = 0;
092:
093:            /**
094:             * single (normal) underline
095:             */
096:
097:            public final static byte U_SINGLE = 1;
098:
099:            /**
100:             * double underlined
101:             */
102:
103:            public final static byte U_DOUBLE = 2;
104:
105:            /**
106:             * accounting style single underline
107:             */
108:
109:            public final static byte U_SINGLE_ACCOUNTING = 0x21;
110:
111:            /**
112:             * accounting style double underline
113:             */
114:
115:            public final static byte U_DOUBLE_ACCOUNTING = 0x22;
116:
117:            /**
118:             * ANSI character set
119:             */
120:            public final static byte ANSI_CHARSET = 0;
121:
122:            /**
123:             * Default character set.
124:             */
125:            public final static byte DEFAULT_CHARSET = 1;
126:
127:            /**
128:             * Symbol character set
129:             */
130:            public final static byte SYMBOL_CHARSET = 2;
131:
132:            private FontRecord font;
133:            private short index;
134:
135:            /** Creates a new instance of HSSFFont */
136:
137:            protected HSSFFont(short index, FontRecord rec) {
138:                font = rec;
139:                this .index = index;
140:            }
141:
142:            /**
143:             * set the name for the font (i.e. Arial)
144:             * @param name  String representing the name of the font to use
145:             * @see #FONT_ARIAL
146:             */
147:
148:            public void setFontName(String name) {
149:                font.setFontName(name);
150:                font.setFontNameLength((byte) name.length());
151:            }
152:
153:            /**
154:             * get the name for the font (i.e. Arial)
155:             * @return String representing the name of the font to use
156:             * @see #FONT_ARIAL
157:             */
158:
159:            public String getFontName() {
160:                return font.getFontName();
161:            }
162:
163:            /**
164:             * get the index within the HSSFWorkbook (sequence within the collection of Font objects)
165:             * @return unique index number of the underlying record this Font represents (probably you don't care
166:             *  unless you're comparing which one is which)
167:             */
168:
169:            public short getIndex() {
170:                return index;
171:            }
172:
173:            /**
174:             * set the font height in unit's of 1/20th of a point.  Maybe you might want to
175:             * use the setFontHeightInPoints which matches to the familiar 10, 12, 14 etc..
176:             * @param height height in 1/20ths of a point
177:             * @see #setFontHeightInPoints(short)
178:             */
179:
180:            public void setFontHeight(short height) {
181:                font.setFontHeight(height);
182:            }
183:
184:            /**
185:             * set the font height
186:             * @param height height in the familiar unit of measure - points
187:             * @see #setFontHeight(short)
188:             */
189:
190:            public void setFontHeightInPoints(short height) {
191:                font.setFontHeight((short) (height * 20));
192:            }
193:
194:            /**
195:             * get the font height in unit's of 1/20th of a point.  Maybe you might want to
196:             * use the getFontHeightInPoints which matches to the familiar 10, 12, 14 etc..
197:             * @return short - height in 1/20ths of a point
198:             * @see #getFontHeightInPoints()
199:             */
200:
201:            public short getFontHeight() {
202:                return font.getFontHeight();
203:            }
204:
205:            /**
206:             * get the font height
207:             * @return short - height in the familiar unit of measure - points
208:             * @see #getFontHeight()
209:             */
210:
211:            public short getFontHeightInPoints() {
212:                return (short) (font.getFontHeight() / 20);
213:            }
214:
215:            /**
216:             * set whether to use italics or not
217:             * @param italic italics or not
218:             */
219:
220:            public void setItalic(boolean italic) {
221:                font.setItalic(italic);
222:            }
223:
224:            /**
225:             * get whether to use italics or not
226:             * @return italics or not
227:             */
228:
229:            public boolean getItalic() {
230:                return font.isItalic();
231:            }
232:
233:            /**
234:             * set whether to use a strikeout horizontal line through the text or not
235:             * @param strikeout or not
236:             */
237:
238:            public void setStrikeout(boolean strikeout) {
239:                font.setStrikeout(strikeout);
240:            }
241:
242:            /**
243:             * get whether to use a strikeout horizontal line through the text or not
244:             * @return strikeout or not
245:             */
246:
247:            public boolean getStrikeout() {
248:                return font.isStruckout();
249:            }
250:
251:            /**
252:             * set the color for the font
253:             * @param color to use
254:             * @see #COLOR_NORMAL Note: Use this rather than HSSFColor.AUTOMATIC for default font color
255:             * @see #COLOR_RED
256:             */
257:
258:            public void setColor(short color) {
259:                font.setColorPaletteIndex(color);
260:            }
261:
262:            /**
263:             * get the color for the font
264:             * @return color to use
265:             * @see #COLOR_NORMAL
266:             * @see #COLOR_RED
267:             * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
268:             */
269:            public short getColor() {
270:                return font.getColorPaletteIndex();
271:            }
272:
273:            /**
274:             * set the boldness to use
275:             * @param boldweight
276:             * @see #BOLDWEIGHT_NORMAL
277:             * @see #BOLDWEIGHT_BOLD
278:             */
279:
280:            public void setBoldweight(short boldweight) {
281:                font.setBoldWeight(boldweight);
282:            }
283:
284:            /**
285:             * get the boldness to use
286:             * @return boldweight
287:             * @see #BOLDWEIGHT_NORMAL
288:             * @see #BOLDWEIGHT_BOLD
289:             */
290:
291:            public short getBoldweight() {
292:                return font.getBoldWeight();
293:            }
294:
295:            /**
296:             * set normal,super or subscript.
297:             * @param offset type to use (none,super,sub)
298:             * @see #SS_NONE
299:             * @see #SS_SUPER
300:             * @see #SS_SUB
301:             */
302:
303:            public void setTypeOffset(short offset) {
304:                font.setSuperSubScript(offset);
305:            }
306:
307:            /**
308:             * get normal,super or subscript.
309:             * @return offset type to use (none,super,sub)
310:             * @see #SS_NONE
311:             * @see #SS_SUPER
312:             * @see #SS_SUB
313:             */
314:
315:            public short getTypeOffset() {
316:                return font.getSuperSubScript();
317:            }
318:
319:            /**
320:             * set type of text underlining to use
321:             * @param underline type
322:             * @see #U_NONE
323:             * @see #U_SINGLE
324:             * @see #U_DOUBLE
325:             * @see #U_SINGLE_ACCOUNTING
326:             * @see #U_DOUBLE_ACCOUNTING
327:             */
328:
329:            public void setUnderline(byte underline) {
330:                font.setUnderline(underline);
331:            }
332:
333:            /**
334:             * get type of text underlining to use
335:             * @return underlining type
336:             * @see #U_NONE
337:             * @see #U_SINGLE
338:             * @see #U_DOUBLE
339:             * @see #U_SINGLE_ACCOUNTING
340:             * @see #U_DOUBLE_ACCOUNTING
341:             */
342:
343:            public byte getUnderline() {
344:                return font.getUnderline();
345:            }
346:
347:            /**
348:             * get character-set to use.
349:             * @return character-set
350:             * @see #ANSI_CHARSET
351:             * @see #DEFAULT_CHARSET
352:             * @see #SYMBOL_CHARSET
353:             */
354:            public byte getCharSet() {
355:                return font.getCharset();
356:            }
357:
358:            /**
359:             * set character-set to use.
360:             * @see #ANSI_CHARSET
361:             * @see #DEFAULT_CHARSET
362:             * @see #SYMBOL_CHARSET
363:             */
364:            public void setCharSet(byte charset) {
365:                font.setCharset(charset);
366:            }
367:
368:            public String toString() {
369:                return "org.apache.poi.hssf.usermodel.HSSFFont{" + font + "}";
370:            }
371:
372:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.