Source Code Cross Referenced for Object2D.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:        import java.awt.image.*;
025:        import javax.swing.*;
026:
027:        /**
028:         * An abstract class for the common methods of Chart2D, Clocks2D, and Progress2D objects.
029:         * An Object2D object is one with an enclosing area and a title.
030:         * Changes through its set methods are updated upon next repaint() or getImage() calls.
031:         */
032:        public abstract class Object2D extends JComponent {
033:
034:            /**
035:             * The default is new Dimension (1024, 768).
036:             */
037:            public static final Dimension MAX_SIZE_DEFAULT = new Dimension(
038:                    1024, 768);
039:
040:            /**
041:             * The default is new Dimension (1, 1).
042:             */
043:            public static final Dimension MIN_SIZE_DEFAULT = new Dimension(1, 1);
044:
045:            private Object2DProperties object2DProps;
046:            private boolean needsUpdate;
047:
048:            /**
049:             * Creates an Object2D object with its defaults.
050:             * An Object2DProperties object must be set for this object before it is used.
051:             */
052:            public Object2D() {
053:
054:                needsUpdate = true;
055:                setMaximumSize(MAX_SIZE_DEFAULT);
056:                setMinimumSize(MIN_SIZE_DEFAULT);
057:            }
058:
059:            /**
060:             * Sets the Object2DProperties for this Object2D.
061:             * @param props The Object2DProperties.
062:             */
063:            public final void setObject2DProperties(Object2DProperties props) {
064:
065:                needsUpdate = true;
066:                props.addObject2D(this );
067:                if (object2DProps != null)
068:                    object2DProps.removeObject2D(this );
069:                object2DProps = props;
070:            }
071:
072:            /**
073:             * Sets a custom preferred size for the chart.
074:             * This custom size will override the preferred size calculations that normally occurr.
075:             * If null is passed, the preferred size calculations will be reinstated.
076:             * @param size  The custom preferred size for this chart.
077:             */
078:            public abstract void setPreferredSize(Dimension size);
079:
080:            /**
081:             * Sets the maximum size of this object.
082:             * @param size The maximum size.
083:             */
084:            public final void setMaximumSize(Dimension size) {
085:
086:                needsUpdate = true;
087:                super .setMaximumSize(size);
088:            }
089:
090:            /**
091:             * Sets the minimum size of this object.
092:             * @param size The minimum size.
093:             */
094:            public final void setMinimumSize(Dimension size) {
095:
096:                needsUpdate = true;
097:                super .setMinimumSize(size);
098:            }
099:
100:            /**
101:             * Gets the Object2DProperties for this Object2D.
102:             * @return The Object2DProperties.
103:             */
104:            public final Object2DProperties getObject2DProperties() {
105:                return object2DProps;
106:            }
107:
108:            /**
109:             * Gets the preferred size of the chart.
110:             * The preferred size is within the maximum and minimum sizes of the chart.
111:             * Much calculation is performed when calling this method.
112:             * @return The preferred minimum size of the chart.
113:             */
114:            public abstract Dimension getPreferredSize();
115:
116:            /**
117:             * Gets whether this object needs to be updated with new properties.
118:             * @return If true then needs update.
119:             */
120:            final boolean getNeedsUpdateObject2D() {
121:                return (needsUpdate || object2DProps
122:                        .getObject2DNeedsUpdate(this ));
123:            }
124:
125:            /**
126:             * Gets the TitledArea of this Object2D.
127:             * @return The TitledArea.
128:             */
129:            abstract TitledArea getObjectArea();
130:
131:            /**
132:             * Validates the properties of this object.
133:             * If debug is true then prints a messages indicating whether each property is valid.
134:             * Returns true if all the properties were valid and false otherwise.
135:             * @param debug If true then will print status messages.
136:             * @return If true then valid.
137:             */
138:            final boolean validateObject2D(boolean debug) {
139:
140:                if (debug)
141:                    System.out.println("Validating Object2D");
142:
143:                boolean valid = true;
144:
145:                if (object2DProps == null) {
146:                    valid = false;
147:                    if (debug)
148:                        System.out.println("Object2DProperties is null");
149:                } else if (!object2DProps.validate(debug))
150:                    valid = false;
151:
152:                if (getMaximumSize() == null || getMaximumSize().height < 1
153:                        || getMaximumSize().width < 1
154:                        || getMaximumSize().height < getMinimumSize().height
155:                        || getMaximumSize().width < getMinimumSize().width) {
156:                    valid = false;
157:                    if (debug)
158:                        System.out.println("Problem with maximum size");
159:                }
160:                if (getMinimumSize() == null || getMinimumSize().height < 1
161:                        || getMinimumSize().width < 1) {
162:                    valid = false;
163:                    if (debug)
164:                        System.out.println("Problem with minimum size");
165:                }
166:
167:                if (debug) {
168:                    if (valid)
169:                        System.out.println("Object2D was valid");
170:                    else
171:                        System.out.println("Object2D was invalid");
172:                }
173:
174:                return valid;
175:            }
176:
177:            /**
178:             * Updates this object.
179:             */
180:            final void updateObject2D() {
181:
182:                if (getNeedsUpdateObject2D()) {
183:
184:                    needsUpdate = false;
185:                    object2DProps.updateObject2D(this );
186:
187:                    TitledArea object = (TitledArea) getObjectArea();
188:                    object.setAutoSizes(!object2DProps
189:                            .getObjectMagnifyWhenResize(), true);
190:                    object.setBorderExistence(object2DProps
191:                            .getObjectBorderExistence());
192:                    object.setBorderThicknessModel(object2DProps
193:                            .getObjectBorderThicknessModel());
194:                    object.setBorderColor(object2DProps.getObjectBorderColor());
195:                    object.setGapExistence(object2DProps
196:                            .getObjectGapExistence());
197:                    object.setGapThicknessModel(object2DProps
198:                            .getObjectGapThicknessModel());
199:                    object.setBackgroundExistence(object2DProps
200:                            .getObjectBackgroundExistence());
201:                    object.setBackgroundColor(object2DProps
202:                            .getObjectBackgroundColor());
203:                    object.setLightSource(object2DProps
204:                            .getObjectBackgroundLightSource());
205:                    object.setTitleExistence(object2DProps
206:                            .getObjectTitleExistence());
207:                    object.setTitle(object2DProps.getObjectTitleText());
208:                    object.setFontPointModel(object2DProps
209:                            .getObjectTitleFontPointModel());
210:                    object.setFontName(object2DProps.getObjectTitleFontName());
211:                    object
212:                            .setFontColor(object2DProps
213:                                    .getObjectTitleFontColor());
214:                    object
215:                            .setFontStyle(object2DProps
216:                                    .getObjectTitleFontStyle());
217:                    object.setBetweenTitleAndSpaceGapExistence(object2DProps
218:                            .getObjectTitleBetweenRestGapExistence());
219:                    object
220:                            .setBetweenTitleAndSpaceGapThicknessModel(object2DProps
221:                                    .getObjectTitleBetweenRestGapThicknessModel());
222:                }
223:            }
224:
225:            /**
226:             * Gets a buffered image of the chart.
227:             * @return An image of this chart
228:             */
229:            public abstract BufferedImage getImage();
230:
231:            /**
232:             * Causes the object to reinintialize to it's preferred size.
233:             */
234:            public abstract void pack();
235:
236:            /**
237:             * Validates the properties of this object.
238:             * If debug is true then prints a messages indicating whether each property is valid.
239:             * Returns true if all the properties were valid and false otherwise.
240:             * @param debug If true then will print status messages.
241:             * @return If true then valid.
242:             */
243:            public abstract boolean validate(boolean debug);
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.