Source Code Cross Referenced for FontArea.java in  » Chart » Chart2D_1.9.6k » net » sourceforge » chart2d » 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 » Chart » Chart2D_1.9.6k » net.sourceforge.chart2d 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Chart2D, a java library for drawing two dimensional charts.
003:         * Copyright (C) 2001 Jason J. Simas
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         *
018:         * The author of this library may be contacted at:
019:         * E-mail:  jjsimas@users.sourceforge.net
020:         * Street Address:  J J Simas, 887 Tico Road, Ojai, CA 93023-3555 USA
021:         */package net.sourceforge.chart2d;
022:
023:        import java.awt.*;
024:
025:        /**
026:         * Maintains a font to be used within an area.  Contains all variables for the
027:         * font, such as point, name, style, and color.  Builds a font from these
028:         * variable.  When building font, uses the lesser ratio of the area class.
029:         * This ensures proper growing and shrinking of the font respective to the
030:         * changing in the area's size.  Grows and shrinks if and only if max model
031:         * area auto size is disabled.
032:         */
033:        class FontArea extends Area {
034:
035:            private int fontPointModel;
036:            private String fontName;
037:            private int fontStyle;
038:            private Color fontColor;
039:            private Font font;
040:            private boolean needsUpdate;
041:
042:            /**
043:             * Builds a new FontArea with the default values.
044:             */
045:            FontArea() {
046:
047:                setFontPointModel(12);
048:                setFontName("SansSerif");
049:                setFontStyle(Font.PLAIN);
050:                setFontColor(Color.black);
051:                resetFontAreaModel(true);
052:                needsUpdate = true;
053:            }
054:
055:            /**
056:             * Changes the model font's point size.  This is the size that the font would
057:             * be if the maximum size of the area was equal to the model size of the area.
058:             * Otherwise, a ratio based on maximum size / model size is taken and applied
059:             * to this point, producing the actual font point.
060:             * @param p The new model font point.
061:             */
062:            final void setFontPointModel(int p) {
063:
064:                needsUpdate = true;
065:                fontPointModel = p;
066:            }
067:
068:            /**
069:             * Changes the name of this font.  This accepts the same values as
070:             * the Font classes constructor
071:             * <code>Font (String name, int style, int point)</code>.
072:             * @param n Then new name of the font.
073:             */
074:            final void setFontName(String n) {
075:
076:                needsUpdate = true;
077:                fontName = n;
078:            }
079:
080:            /**
081:             * Changes the style of this font.  This accepts the same values as
082:             * the Font classes constructor
083:             * <code>Font (String name, int style, int point)</code>.
084:             * @param s Then new style of the font.
085:             */
086:            final void setFontStyle(int s) {
087:
088:                needsUpdate = true;
089:                fontStyle = s;
090:            }
091:
092:            /**
093:             * Changes the color of this font.  This accepts all Color.* compatible
094:             * values.
095:             * @param c Then new color of the font.
096:             */
097:            final void setFontColor(Color c) {
098:
099:                needsUpdate = true;
100:                fontColor = c;
101:            }
102:
103:            /**
104:             * Returns the model font's point; not the actual font point.
105:             * @return The model font's point.
106:             */
107:            final int getFontPointModel() {
108:
109:                return fontPointModel;
110:            }
111:
112:            /**
113:             * Returns the name of this font.
114:             * @return Then name of the font.
115:             */
116:            final String getFontName() {
117:
118:                return fontName;
119:            }
120:
121:            /**
122:             * Returns the style of this font.
123:             * @return Then style of the font.
124:             */
125:            final int getFontStyle() {
126:
127:                return fontStyle;
128:            }
129:
130:            /**
131:             * Returns this font's color.
132:             * @return This font's color.
133:             */
134:            final Color getFontColor() {
135:
136:                return fontColor;
137:            }
138:
139:            /**
140:             * Returns a font built from the present variable values.  Updates
141:             * the font point based on the model font point, builds an font, and return
142:             * it.
143:             * @return The current font.
144:             */
145:            final Font getFont() {
146:
147:                updateFontArea();
148:                return font;
149:            }
150:
151:            /**
152:             * Indicates whether some property of this class has changed.
153:             * @return True if some property has changed.
154:             */
155:            final boolean getFontAreaNeedsUpdate() {
156:
157:                return (needsUpdate || getAreaNeedsUpdate());
158:            }
159:
160:            /**
161:             * Resets the model for this class.  The model is used for shrinking and
162:             * growing of its components based on the maximum size of this class.  If this
163:             * method is called, then the next time the maximum size is set, this classes
164:             * model maximum size will be made equal to the new maximum size.  Effectively
165:             * what this does is ensure that whenever this objects maximum size is equal
166:             * to the one given, then all of the components will take on their default
167:             * model sizes.  Note:  This is only useful when auto model max sizing is
168:             * disabled.
169:             * @param reset True causes the max model size to be set upon the next max
170:             * sizing.
171:             */
172:            final void resetFontAreaModel(boolean reset) {
173:
174:                needsUpdate = true;
175:                resetAreaModel(reset);
176:            }
177:
178:            /**
179:             * Updates all this classes variables.  First updates it's parent class, then
180:             * then updates its own variables.
181:             */
182:            final void updateFontArea() {
183:
184:                if (getFontAreaNeedsUpdate()) {
185:                    updateArea();
186:                    update();
187:                }
188:                needsUpdate = false;
189:            }
190:
191:            /**
192:             * Paints this class.  Updates all variables, then paints its parent, since
193:             * this class itself doesn't have anything to paint.
194:             * @param g2D The graphics context for calculations and painting.
195:             */
196:            void paintComponent(Graphics2D g2D) {
197:
198:                updateFontArea();
199:                super .paintComponent(g2D);
200:            }
201:
202:            private void update() {
203:
204:                int fontPoint = 0;
205:                if (fontPointModel > 0) {
206:                    fontPoint = applyRatio(fontPointModel, getRatio(LESSER));
207:                } else
208:                    fontPoint = 0;
209:                font = new Font(fontName, fontStyle, fontPoint);
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.