Source Code Cross Referenced for Drawable.java in  » Science » jcm1-source » edu » hws » jcm » draw » 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 » Science » jcm1 source » edu.hws.jcm.draw 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*************************************************************************
002:         *                                                                        *
003:         *   1) This source code file, in unmodified form, and compiled classes   *
004:         *      derived from it can be used and distributed without restriction,  *
005:         *      including for commercial use.  (Attribution is not required       *
006:         *      but is appreciated.)                                              *
007:         *                                                                        *
008:         *    2) Modified versions of this file can be made and distributed       *
009:         *       provided:  the modified versions are put into a Java package     *
010:         *       different from the original package, edu.hws;  modified          *
011:         *       versions are distributed under the same terms as the original;   *
012:         *       and the modifications are documented in comments.  (Modification *
013:         *       here does not include simply making subclasses that belong to    *
014:         *       a package other than edu.hws, which can be done without any      *
015:         *       restriction.)                                                    *
016:         *                                                                        *
017:         *   David J. Eck                                                         *
018:         *   Department of Mathematics and Computer Science                       *
019:         *   Hobart and William Smith Colleges                                    *
020:         *   Geneva, New York 14456,   USA                                        *
021:         *   Email: eck@hws.edu          WWW: http://math.hws.edu/eck/            *
022:         *                                                                        *
023:         *************************************************************************/package edu.hws.jcm.draw;
024:
025:        import java.awt.Graphics;
026:
027:        /**
028:         * A Drawable object can be added to a CoordinateRect, which is itself in 
029:         * a DisplayCanvas.  Its purpose is, generally, to draw something in the
030:         * rectangular area represented by the CoordinateRect.  The drawing can
031:         * use information in the CoordinateRect, which includes both the real
032:         * number coordinates and the pixel coordinates of the rectangular area.
033:         */
034:        abstract public class Drawable implements  java.io.Serializable {
035:
036:            /**
037:             * The CoordinateRect for the rectagular area where this
038:             * Drawable is drawn.  This is set automatically when the
039:             * Drawable is added to a CoordingteRect and should not be
040:             * changed.  (It will be changed automatically if the 
041:             * Drawable is removed from the CoordinateRect.)
042:             */
043:            protected CoordinateRect coords;
044:
045:            /**
046:             * The canvas on which this Drawable is drawn.  This is set
047:             * automatically when the Drawable is added to a CoordinateRect
048:             * and it should not be changed.  (It will be changed automatically
049:             * if the Drawable is removed from the CoordinateRect.)
050:             */
051:            protected DisplayCanvas canvas;
052:
053:            private boolean visible = true; // If visible is false, then the CoordinateRect
054:
055:            // that manages this Drawable will ignore it.
056:            // It will not call the draw() routine, so when
057:            // draw is called, it can be assumed that the
058:            // Drawable is visible.
059:
060:            /**
061:             * Draw this drawable in the graphics context g.  This is meant to
062:             * be called only by the CoordinateRect, coords, that manages this Drawable.
063:             * The coords contains information about the rectangular area in which
064:             * this Drawable is displayed, both in terms of pixels and in terms
065:             * of real (x,y)-coordinates.
066:             *    The value of coordsChanged is true if any of the values
067:             *  coords.getXmin(), coords.getXmax(), coords.getYmin(), coords.getYmax(), 
068:             * coords.getLeft(), coords.getRight(), coords.getTop(), coords.getBottom(), 
069:             * or coords.getGap() has changed.  Drawables that depend only on this
070:             * information can check the value of coordsChanged to see whether they
071:             * need to update any previously computed member variables that
072:             * depend on these values.  This method is meant to be called only by the system.
073:             * 
074:             * @param g The graphics context in which the Drawble is to be drawn.  (The drawing 
075:             *            can change the color in g, but should not permanently change font, painting mode, etc.
076:             *            Thus, every drawable is responsible for setting the color it wants to use.)
077:             * @param coordsChanged Indicates whether the CoordinateRect has changed.
078:             */
079:            abstract public void draw(Graphics g, boolean coordsChanged);
080:
081:            /**
082:             * Return true if this Drawable is visible, false if it is hidden.
083:             * A hidden Drawable is ignored by the CoordinateRect that manages it.
084:             */
085:            public boolean getVisible() {
086:                return visible;
087:            }
088:
089:            /**
090:             * Set the visibility of this Drawable.  If show is false, then
091:             * the Drawable is hidden.  If it is true, the Drawable is shown.
092:             */
093:            public void setVisible(boolean show) {
094:                if (show != visible) {
095:                    visible = show;
096:                    needsRedraw();
097:                }
098:            }
099:
100:            /**
101:             * This routine should be called if the appearance of the Drawable changes
102:             * so that the rectangular area that it occupies has to be redrawn.
103:             * The routine is generally meant to be called by the Drawable itself.
104:             * It will notify the DisplayCanvas, canvas, that the CoordinateRect,
105:             * coords, needs to be redrawn, where canvas and coords are the member
106:             * variables in this class.  If canvas is null, nothing happens, since
107:             * presumably the Drawable is not displayed anywhere in that case.
108:             */
109:            public void needsRedraw() {
110:                if (canvas != null)
111:                    canvas.doRedraw(coords);
112:            }
113:
114:            /**
115:             * Sets the values of member variables canvas and coords.  This is
116:             * designed to be called only by the CoordinateRect class.
117:             */
118:            protected void setOwnerData(DisplayCanvas canvas,
119:                    CoordinateRect coords) {
120:                this .canvas = canvas;
121:                this .coords = coords;
122:            }
123:
124:        } // end class Drawable
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.