Source Code Cross Referenced for WingFont.java in  » Web-Framework » wingS » com » javujavu » javux » wings » 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 » Web Framework » wingS » com.javujavu.javux.wings 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *	Javu WingS - Lightweight Java Component Set
003:         *	Copyright (c) 2005-2007 Krzysztof A. Sadlocha
004:         *	e-mail: ksadlocha@programics.com
005:         *
006:         *	This library is free software; you can redistribute it and/or
007:         *	modify it under the terms of the GNU Lesser General Public
008:         *	License as published by the Free Software Foundation; either
009:         *	version 2.1 of the License, or (at your option) any later version.
010:         *
011:         *	This library is distributed in the hope that it will be useful,
012:         *	but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *	Lesser General Public License for more details.
015:         *
016:         *	You should have received a copy of the GNU Lesser General Public
017:         *	License along with this library; if not, write to the Free Software
018:         *	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         */
020:
021:        package com.javujavu.javux.wings;
022:
023:        import java.awt.Font;
024:        import java.awt.FontMetrics;
025:        import java.awt.Graphics;
026:        import java.awt.Toolkit;
027:
028:        /**
029:         * This class extends <code>Font</code> functionality with underline
030:         * and antialias style. 
031:         * <br>
032:         * <b>This is one of the core WingS classes required by all the components</b><br>
033:         * <br>
034:         * <b>This class is thread safe.</b>
035:         **/
036:        public class WingFont {
037:            protected Font font;
038:            protected boolean underline;
039:            protected boolean antialias;
040:
041:            protected FontMetrics fm;
042:            protected char[] ch;
043:
044:            public WingFont(Font font) {
045:                this (font, false, false);
046:            }
047:
048:            public WingFont(String name, int style, int size,
049:                    boolean underline, boolean antialias) {
050:                this (new Font(name, style, size), underline, antialias);
051:            }
052:
053:            public WingFont(Font font, boolean underline, boolean antialias) {
054:                this .font = font;
055:                this .underline = underline;
056:                this .antialias = antialias;
057:            }
058:
059:            public Font getFont() {
060:                return font;
061:            }
062:
063:            public boolean isUnderline() {
064:                return underline;
065:            }
066:
067:            public boolean isAntialias() {
068:                return antialias;
069:            }
070:
071:            protected FontMetrics metrics() {
072:                if (fm == null) {
073:                    fm = Toolkit.getDefaultToolkit().getFontMetrics(font);
074:                }
075:                return fm;
076:            }
077:
078:            public int getAscent() {
079:                return metrics().getAscent();
080:            }
081:
082:            public int getDescent() {
083:                return metrics().getDescent();
084:            }
085:
086:            public int stringWidth(String s) {
087:                if (antialias)
088:                    return WingToolkit.the().stringWidth(this , s);
089:                return metrics().stringWidth(s);
090:            }
091:
092:            public int charsWidth(char[] data, int offset, int length) {
093:                if (antialias)
094:                    return WingToolkit.the().charsWidth(this , data, offset,
095:                            length);
096:                return metrics().charsWidth(data, offset, length);
097:            }
098:
099:            public int getHeight() {
100:                return metrics().getHeight();
101:            }
102:
103:            public void drawString(Graphics g, String s, int x, int y) {
104:                WingToolkit.the().setTextAntialias(g, antialias);
105:                g.drawString(s, x, y);
106:                if (underline) {
107:                    g.drawLine(x, y + 1, x + stringWidth(s), y + 1);
108:                }
109:            }
110:
111:            public void drawChars(Graphics g, char[] data, int offset,
112:                    int length, int x, int y) {
113:                drawChars(g, data, offset, length, x, y, true);
114:            }
115:
116:            public void drawChars(Graphics g, char[] data, int offset,
117:                    int length, int x, int y, boolean first) {
118:                if (first)
119:                    WingToolkit.the().setTextAntialias(g, antialias);
120:                g.drawChars(data, offset, length, x, y);
121:                if (underline) {
122:                    g.drawLine(x, y + 1, x + charsWidth(data, offset, length),
123:                            y + 1);
124:                }
125:            }
126:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.