Source Code Cross Referenced for Graphics.java in  » Apache-Harmony-Java-SE » java-package » java » awt » 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 » Apache Harmony Java SE » java package » java.awt 
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:         * @author Alexey A. Petrenko
019:         * @version $Revision$
020:         */package java.awt;
021:
022:        import java.awt.image.ImageObserver;
023:        import java.text.AttributedCharacterIterator;
024:
025:        public abstract class Graphics {
026:
027:            // Constructors
028:
029:            protected Graphics() {
030:            }
031:
032:            // Public methods
033:
034:            public Graphics create(int x, int y, int width, int height) {
035:                Graphics res = create();
036:                res.translate(x, y);
037:                res.clipRect(0, 0, width, height);
038:                return res;
039:            }
040:
041:            public void draw3DRect(int x, int y, int width, int height,
042:                    boolean raised) {
043:                // Note: lighter/darker colors should be used to draw 3d rect.
044:                // The resulting rect is (width+1)x(height+1). Stroke and paint attributes of
045:                // the Graphics2D should be reset to the default values.
046:                // fillRect is used instead of drawLine to bypass stroke
047:                // reset/set and rasterization.
048:
049:                Color color = getColor();
050:                Color colorUp, colorDown;
051:                if (raised) {
052:                    colorUp = color.brighter();
053:                    colorDown = color.darker();
054:                } else {
055:                    colorUp = color.darker();
056:                    colorDown = color.brighter();
057:                }
058:
059:                setColor(colorUp);
060:                fillRect(x, y, width, 1);
061:                fillRect(x, y + 1, 1, height);
062:
063:                setColor(colorDown);
064:                fillRect(x + width, y, 1, height);
065:                fillRect(x + 1, y + height, width, 1);
066:            }
067:
068:            public void drawBytes(byte[] bytes, int off, int len, int x, int y) {
069:                drawString(new String(bytes, off, len), x, y);
070:            }
071:
072:            public void drawChars(char[] chars, int off, int len, int x, int y) {
073:                drawString(new String(chars, off, len), x, y);
074:            }
075:
076:            public void drawPolygon(Polygon p) {
077:                drawPolygon(p.xpoints, p.ypoints, p.npoints);
078:            }
079:
080:            public void drawRect(int x, int y, int width, int height) {
081:                int[] xpoints = { x, x, x + width, x + width };
082:                int[] ypoints = { y, y + height, y + height, y };
083:
084:                drawPolygon(xpoints, ypoints, 4);
085:            }
086:
087:            public void fill3DRect(int x, int y, int width, int height,
088:                    boolean raised) {
089:                // Note: lighter/darker colors should be used to draw 3d rect.
090:                // The resulting rect is (width)x(height), same as fillRect.
091:                // Stroke and paint attributes of the Graphics2D should be reset
092:                // to the default values. fillRect is used instead of drawLine to
093:                // bypass stroke reset/set and line rasterization.
094:
095:                Color color = getColor();
096:                Color colorUp, colorDown;
097:                if (raised) {
098:                    colorUp = color.brighter();
099:                    colorDown = color.darker();
100:                    setColor(color);
101:                } else {
102:                    colorUp = color.darker();
103:                    colorDown = color.brighter();
104:                    setColor(colorUp);
105:                }
106:
107:                width--;
108:                height--;
109:                fillRect(x + 1, y + 1, width - 1, height - 1);
110:
111:                setColor(colorUp);
112:                fillRect(x, y, width, 1);
113:                fillRect(x, y + 1, 1, height);
114:
115:                setColor(colorDown);
116:                fillRect(x + width, y, 1, height);
117:                fillRect(x + 1, y + height, width, 1);
118:            }
119:
120:            public void fillPolygon(Polygon p) {
121:                fillPolygon(p.xpoints, p.ypoints, p.npoints);
122:            }
123:
124:            @Override
125:            public void finalize() {
126:            }
127:
128:            public Rectangle getClipBounds(Rectangle r) {
129:                Shape clip = getClip();
130:
131:                if (clip != null) {
132:                    // TODO: Can we get shape bounds without creating Rectangle object?
133:                    Rectangle b = clip.getBounds();
134:                    r.x = b.x;
135:                    r.y = b.y;
136:                    r.width = b.width;
137:                    r.height = b.height;
138:                }
139:
140:                return r;
141:            }
142:
143:            /**
144:             * @deprecated Use {@link #getClipBounds()}
145:             */
146:            @Deprecated
147:            public Rectangle getClipRect() {
148:                return getClipBounds();
149:            }
150:
151:            public FontMetrics getFontMetrics() {
152:                return getFontMetrics(getFont());
153:            }
154:
155:            public boolean hitClip(int x, int y, int width, int height) {
156:                // TODO: Create package private method Rectangle.intersects(int, int, int, int);
157:                return getClipBounds().intersects(
158:                        new Rectangle(x, y, width, height));
159:            }
160:
161:            @Override
162:            public String toString() {
163:                // TODO: Think about string representation of Graphics.
164:                return "Graphics"; //$NON-NLS-1$
165:            }
166:
167:            // Abstract methods
168:
169:            public abstract void clearRect(int x, int y, int width, int height);
170:
171:            public abstract void clipRect(int x, int y, int width, int height);
172:
173:            public abstract void copyArea(int sx, int sy, int width,
174:                    int height, int dx, int dy);
175:
176:            public abstract Graphics create();
177:
178:            public abstract void dispose();
179:
180:            public abstract void drawArc(int x, int y, int width, int height,
181:                    int sa, int ea);
182:
183:            public abstract boolean drawImage(Image img, int x, int y,
184:                    Color bgcolor, ImageObserver observer);
185:
186:            public abstract boolean drawImage(Image img, int x, int y,
187:                    ImageObserver observer);
188:
189:            public abstract boolean drawImage(Image img, int x, int y,
190:                    int width, int height, Color bgcolor, ImageObserver observer);
191:
192:            public abstract boolean drawImage(Image img, int x, int y,
193:                    int width, int height, ImageObserver observer);
194:
195:            public abstract boolean drawImage(Image img, int dx1, int dy1,
196:                    int dx2, int dy2, int sx1, int sy1, int sx2, int sy2,
197:                    Color bgcolor, ImageObserver observer);
198:
199:            public abstract boolean drawImage(Image img, int dx1, int dy1,
200:                    int dx2, int dy2, int sx1, int sy1, int sx2, int sy2,
201:                    ImageObserver observer);
202:
203:            public abstract void drawLine(int x1, int y1, int x2, int y2);
204:
205:            public abstract void drawOval(int x, int y, int width, int height);
206:
207:            public abstract void drawPolygon(int[] xpoints, int[] ypoints,
208:                    int npoints);
209:
210:            public abstract void drawPolyline(int[] xpoints, int[] ypoints,
211:                    int npoints);
212:
213:            public abstract void drawRoundRect(int x, int y, int width,
214:                    int height, int arcWidth, int arcHeight);
215:
216:            public abstract void drawString(
217:                    AttributedCharacterIterator iterator, int x, int y);
218:
219:            public abstract void drawString(String str, int x, int y);
220:
221:            public abstract void fillArc(int x, int y, int width, int height,
222:                    int sa, int ea);
223:
224:            public abstract void fillOval(int x, int y, int width, int height);
225:
226:            public abstract void fillPolygon(int[] xpoints, int[] ypoints,
227:                    int npoints);
228:
229:            public abstract void fillRect(int x, int y, int width, int height);
230:
231:            public abstract void fillRoundRect(int x, int y, int width,
232:                    int height, int arcWidth, int arcHeight);
233:
234:            public abstract Shape getClip();
235:
236:            public abstract Rectangle getClipBounds();
237:
238:            public abstract Color getColor();
239:
240:            public abstract Font getFont();
241:
242:            public abstract FontMetrics getFontMetrics(Font font);
243:
244:            public abstract void setClip(int x, int y, int width, int height);
245:
246:            public abstract void setClip(Shape clip);
247:
248:            public abstract void setColor(Color c);
249:
250:            public abstract void setFont(Font font);
251:
252:            public abstract void setPaintMode();
253:
254:            public abstract void setXORMode(Color color);
255:
256:            public abstract void translate(int x, int y);
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.