Source Code Cross Referenced for OverrideGraphics2D.java in  » Development » proguard » proguard » gui » splash » 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 » Development » proguard » proguard.gui.splash 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ProGuard -- shrinking, optimization, obfuscation, and preverification
003:         *             of Java bytecode.
004:         *
005:         * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
006:         *
007:         * This program is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU General Public License as published by the Free
009:         * Software Foundation; either version 2 of the License, or (at your option)
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, but WITHOUT
013:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014:         * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
015:         * more details.
016:         *
017:         * You should have received a copy of the GNU General Public License along
018:         * with this program; if not, write to the Free Software Foundation, Inc.,
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         */
021:        package proguard.gui.splash;
022:
023:        import java.awt.*;
024:        import java.awt.RenderingHints.Key;
025:        import java.awt.font.*;
026:        import java.awt.geom.AffineTransform;
027:        import java.awt.image.*;
028:        import java.awt.image.renderable.RenderableImage;
029:        import java.text.AttributedCharacterIterator;
030:        import java.util.Map;
031:
032:        /**
033:         * This Graphics2D allows to fix some basic settings (Color, Font, Paint, Stroke,
034:         * XORMode) of a delegate Graphics2D, overriding any subsequent attempts to
035:         * change those settings.
036:         *
037:         * @author Eric Lafortune
038:         * @noinspection deprecation
039:         */
040:        final class OverrideGraphics2D extends Graphics2D {
041:            private final Graphics2D graphics;
042:
043:            private Color overrideColor;
044:            private Font overrideFont;
045:            private Paint overridePaint;
046:            private Stroke overrideStroke;
047:            private Color overrideXORMode;
048:
049:            private Color color;
050:            private Font font;
051:            private Paint paint;
052:            private Stroke stroke;
053:
054:            /**
055:             * Creates a new OverrideGraphics2D.
056:             * @param graphics the delegate Graphics2D.
057:             */
058:            public OverrideGraphics2D(Graphics2D graphics) {
059:                this .graphics = graphics;
060:                this .color = graphics.getColor();
061:                this .font = graphics.getFont();
062:                this .paint = graphics.getPaint();
063:                this .stroke = graphics.getStroke();
064:            }
065:
066:            /**
067:             * Fixes the Color of the Graphics2D.
068:             *
069:             * @param color the fixed Color, or <code>null</code> to undo the fixing.
070:             */
071:            public void setOverrideColor(Color color) {
072:                this .overrideColor = color;
073:                graphics.setColor(color != null ? color : this .color);
074:            }
075:
076:            /**
077:             * Fixes the Font of the Graphics2D.
078:             *
079:             * @param font the fixed Font, or <code>null</code> to undo the fixing.
080:             */
081:            public void setOverrideFont(Font font) {
082:                this .overrideFont = font;
083:                graphics.setFont(font != null ? font : this .font);
084:            }
085:
086:            /**
087:             * Fixes the Paint of the Graphics2D.
088:             *
089:             * @param paint the fixed Paint, or <code>null</code> to undo the fixing.
090:             */
091:            public void setOverridePaint(Paint paint) {
092:                this .overridePaint = paint;
093:                graphics.setPaint(paint != null ? paint : this .paint);
094:            }
095:
096:            /**
097:             * Fixes the Stroke of the Graphics2D.
098:             *
099:             * @param stroke the fixed Stroke, or <code>null</code> to undo the fixing.
100:             */
101:            public void setOverrideStroke(Stroke stroke) {
102:                this .overrideStroke = stroke;
103:                graphics.setStroke(stroke != null ? stroke : this .stroke);
104:            }
105:
106:            /**
107:             * Fixes the XORMode of the Graphics2D.
108:             *
109:             * @param color the fixed XORMode Color, or <code>null</code> to undo the fixing.
110:             */
111:            public void setOverrideXORMode(Color color) {
112:                this .overrideXORMode = color;
113:                if (color != null) {
114:                    graphics.setXORMode(color);
115:                } else {
116:                    graphics.setPaintMode();
117:                }
118:            }
119:
120:            // Implementations for Graphics2D.
121:
122:            public void setColor(Color color) {
123:                this .color = color;
124:                if (overrideColor == null) {
125:                    graphics.setColor(color);
126:                }
127:            }
128:
129:            public void setFont(Font font) {
130:                this .font = font;
131:                if (overrideFont == null) {
132:                    graphics.setFont(font);
133:                }
134:            }
135:
136:            public void setPaint(Paint paint) {
137:                this .paint = paint;
138:                if (overridePaint == null) {
139:                    graphics.setPaint(paint);
140:                }
141:            }
142:
143:            public void setStroke(Stroke stroke) {
144:                this .stroke = stroke;
145:                if (overrideStroke == null) {
146:                    graphics.setStroke(stroke);
147:                }
148:            }
149:
150:            public void setXORMode(Color color) {
151:                if (overrideXORMode == null) {
152:                    graphics.setXORMode(color);
153:                }
154:            }
155:
156:            public void setPaintMode() {
157:                if (overrideXORMode == null) {
158:                    graphics.setPaintMode();
159:                }
160:            }
161:
162:            public Color getColor() {
163:                return overrideColor != null ? color : graphics.getColor();
164:            }
165:
166:            public Font getFont() {
167:                return overrideFont != null ? font : graphics.getFont();
168:            }
169:
170:            public Paint getPaint() {
171:                return overridePaint != null ? paint : graphics.getPaint();
172:            }
173:
174:            public Stroke getStroke() {
175:                return overrideStroke != null ? stroke : graphics.getStroke();
176:            }
177:
178:            public Graphics create() {
179:                OverrideGraphics2D g = new OverrideGraphics2D(
180:                        (Graphics2D) graphics.create());
181:                g.setOverrideColor(overrideColor);
182:                g.setOverrideFont(overrideFont);
183:                g.setOverridePaint(overridePaint);
184:                g.setOverrideStroke(overrideStroke);
185:
186:                return g;
187:            }
188:
189:            public Graphics create(int x, int y, int width, int height) {
190:                OverrideGraphics2D g = new OverrideGraphics2D(
191:                        (Graphics2D) graphics.create(x, y, width, height));
192:                g.setOverrideColor(overrideColor);
193:                g.setOverrideFont(overrideFont);
194:                g.setOverridePaint(overridePaint);
195:                g.setOverrideStroke(overrideStroke);
196:
197:                return g;
198:            }
199:
200:            // Delegation for Graphics2D
201:
202:            public void addRenderingHints(Map hints) {
203:                graphics.addRenderingHints(hints);
204:            }
205:
206:            public void clearRect(int x, int y, int width, int height) {
207:                graphics.clearRect(x, y, width, height);
208:            }
209:
210:            public void clip(Shape s) {
211:                graphics.clip(s);
212:            }
213:
214:            public void clipRect(int x, int y, int width, int height) {
215:                graphics.clipRect(x, y, width, height);
216:            }
217:
218:            public void copyArea(int x, int y, int width, int height, int dx,
219:                    int dy) {
220:                graphics.copyArea(x, y, width, height, dx, dy);
221:            }
222:
223:            public void dispose() {
224:                graphics.dispose();
225:            }
226:
227:            public void draw(Shape s) {
228:                graphics.draw(s);
229:            }
230:
231:            public void draw3DRect(int x, int y, int width, int height,
232:                    boolean raised) {
233:                graphics.draw3DRect(x, y, width, height, raised);
234:            }
235:
236:            public void drawArc(int x, int y, int width, int height,
237:                    int startAngle, int arcAngle) {
238:                graphics.drawArc(x, y, width, height, startAngle, arcAngle);
239:            }
240:
241:            public void drawBytes(byte[] data, int offset, int length, int x,
242:                    int y) {
243:                graphics.drawBytes(data, offset, length, x, y);
244:            }
245:
246:            public void drawChars(char[] data, int offset, int length, int x,
247:                    int y) {
248:                graphics.drawChars(data, offset, length, x, y);
249:            }
250:
251:            public void drawGlyphVector(GlyphVector g, float x, float y) {
252:                graphics.drawGlyphVector(g, x, y);
253:            }
254:
255:            public boolean drawImage(Image img, int dx1, int dy1, int dx2,
256:                    int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor,
257:                    ImageObserver observer) {
258:                return graphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1,
259:                        sx2, sy2, bgcolor, observer);
260:            }
261:
262:            public boolean drawImage(Image img, int dx1, int dy1, int dx2,
263:                    int dy2, int sx1, int sy1, int sx2, int sy2,
264:                    ImageObserver observer) {
265:                return graphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1,
266:                        sx2, sy2, observer);
267:            }
268:
269:            public boolean drawImage(Image img, int x, int y, int width,
270:                    int height, Color bgcolor, ImageObserver observer) {
271:                return graphics.drawImage(img, x, y, width, height, bgcolor,
272:                        observer);
273:            }
274:
275:            public boolean drawImage(Image img, int x, int y, int width,
276:                    int height, ImageObserver observer) {
277:                return graphics.drawImage(img, x, y, width, height, observer);
278:            }
279:
280:            public boolean drawImage(Image img, int x, int y, Color bgcolor,
281:                    ImageObserver observer) {
282:                return graphics.drawImage(img, x, y, bgcolor, observer);
283:            }
284:
285:            public boolean drawImage(Image img, int x, int y,
286:                    ImageObserver observer) {
287:                return graphics.drawImage(img, x, y, observer);
288:            }
289:
290:            public boolean drawImage(Image img, AffineTransform xform,
291:                    ImageObserver obs) {
292:                return graphics.drawImage(img, xform, obs);
293:            }
294:
295:            public void drawImage(BufferedImage img, BufferedImageOp op, int x,
296:                    int y) {
297:                graphics.drawImage(img, op, x, y);
298:            }
299:
300:            public void drawLine(int x1, int y1, int x2, int y2) {
301:                graphics.drawLine(x1, y1, x2, y2);
302:            }
303:
304:            public void drawOval(int x, int y, int width, int height) {
305:                graphics.drawOval(x, y, width, height);
306:            }
307:
308:            public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
309:                graphics.drawPolygon(xPoints, yPoints, nPoints);
310:            }
311:
312:            public void drawPolygon(Polygon p) {
313:                graphics.drawPolygon(p);
314:            }
315:
316:            public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) {
317:                graphics.drawPolyline(xPoints, yPoints, nPoints);
318:            }
319:
320:            public void drawRect(int x, int y, int width, int height) {
321:                graphics.drawRect(x, y, width, height);
322:            }
323:
324:            public void drawRenderableImage(RenderableImage img,
325:                    AffineTransform xform) {
326:                graphics.drawRenderableImage(img, xform);
327:            }
328:
329:            public void drawRenderedImage(RenderedImage img,
330:                    AffineTransform xform) {
331:                graphics.drawRenderedImage(img, xform);
332:            }
333:
334:            public void drawRoundRect(int x, int y, int width, int height,
335:                    int arcWidth, int arcHeight) {
336:                graphics
337:                        .drawRoundRect(x, y, width, height, arcWidth, arcHeight);
338:            }
339:
340:            public void drawString(String s, float x, float y) {
341:                graphics.drawString(s, x, y);
342:            }
343:
344:            public void drawString(String str, int x, int y) {
345:                graphics.drawString(str, x, y);
346:            }
347:
348:            public void drawString(AttributedCharacterIterator iterator,
349:                    float x, float y) {
350:                graphics.drawString(iterator, x, y);
351:            }
352:
353:            public void drawString(AttributedCharacterIterator iterator, int x,
354:                    int y) {
355:                graphics.drawString(iterator, x, y);
356:            }
357:
358:            public boolean equals(Object obj) {
359:                return graphics.equals(obj);
360:            }
361:
362:            public void fill(Shape s) {
363:                graphics.fill(s);
364:            }
365:
366:            public void fill3DRect(int x, int y, int width, int height,
367:                    boolean raised) {
368:                graphics.fill3DRect(x, y, width, height, raised);
369:            }
370:
371:            public void fillArc(int x, int y, int width, int height,
372:                    int startAngle, int arcAngle) {
373:                graphics.fillArc(x, y, width, height, startAngle, arcAngle);
374:            }
375:
376:            public void fillOval(int x, int y, int width, int height) {
377:                graphics.fillOval(x, y, width, height);
378:            }
379:
380:            public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
381:                graphics.fillPolygon(xPoints, yPoints, nPoints);
382:            }
383:
384:            public void fillPolygon(Polygon p) {
385:                graphics.fillPolygon(p);
386:            }
387:
388:            public void fillRect(int x, int y, int width, int height) {
389:                graphics.fillRect(x, y, width, height);
390:            }
391:
392:            public void fillRoundRect(int x, int y, int width, int height,
393:                    int arcWidth, int arcHeight) {
394:                graphics
395:                        .fillRoundRect(x, y, width, height, arcWidth, arcHeight);
396:            }
397:
398:            public Color getBackground() {
399:                return graphics.getBackground();
400:            }
401:
402:            public Shape getClip() {
403:                return graphics.getClip();
404:            }
405:
406:            public Rectangle getClipBounds() {
407:                return graphics.getClipBounds();
408:            }
409:
410:            public Rectangle getClipBounds(Rectangle r) {
411:                return graphics.getClipBounds(r);
412:            }
413:
414:            public Rectangle getClipRect() {
415:                return graphics.getClipRect();
416:            }
417:
418:            public Composite getComposite() {
419:                return graphics.getComposite();
420:            }
421:
422:            public GraphicsConfiguration getDeviceConfiguration() {
423:                return graphics.getDeviceConfiguration();
424:            }
425:
426:            public FontMetrics getFontMetrics() {
427:                return graphics.getFontMetrics();
428:            }
429:
430:            public FontMetrics getFontMetrics(Font f) {
431:                return graphics.getFontMetrics(f);
432:            }
433:
434:            public FontRenderContext getFontRenderContext() {
435:                return graphics.getFontRenderContext();
436:            }
437:
438:            public Object getRenderingHint(Key hintKey) {
439:                return graphics.getRenderingHint(hintKey);
440:            }
441:
442:            public RenderingHints getRenderingHints() {
443:                return graphics.getRenderingHints();
444:            }
445:
446:            public AffineTransform getTransform() {
447:                return graphics.getTransform();
448:            }
449:
450:            public int hashCode() {
451:                return graphics.hashCode();
452:            }
453:
454:            public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
455:                return graphics.hit(rect, s, onStroke);
456:            }
457:
458:            public boolean hitClip(int x, int y, int width, int height) {
459:                return graphics.hitClip(x, y, width, height);
460:            }
461:
462:            public void rotate(double theta) {
463:                graphics.rotate(theta);
464:            }
465:
466:            public void rotate(double theta, double x, double y) {
467:                graphics.rotate(theta, x, y);
468:            }
469:
470:            public void scale(double sx, double sy) {
471:                graphics.scale(sx, sy);
472:            }
473:
474:            public void setBackground(Color color) {
475:                graphics.setBackground(color);
476:            }
477:
478:            public void setClip(int x, int y, int width, int height) {
479:                graphics.setClip(x, y, width, height);
480:            }
481:
482:            public void setClip(Shape clip) {
483:                graphics.setClip(clip);
484:            }
485:
486:            public void setComposite(Composite comp) {
487:                graphics.setComposite(comp);
488:            }
489:
490:            public void setRenderingHint(Key hintKey, Object hintValue) {
491:                graphics.setRenderingHint(hintKey, hintValue);
492:            }
493:
494:            public void setRenderingHints(Map hints) {
495:                graphics.setRenderingHints(hints);
496:            }
497:
498:            public void setTransform(AffineTransform Tx) {
499:                graphics.setTransform(Tx);
500:            }
501:
502:            public void shear(double shx, double shy) {
503:                graphics.shear(shx, shy);
504:            }
505:
506:            public String toString() {
507:                return graphics.toString();
508:            }
509:
510:            public void transform(AffineTransform Tx) {
511:                graphics.transform(Tx);
512:            }
513:
514:            public void translate(double tx, double ty) {
515:                graphics.translate(tx, ty);
516:            }
517:
518:            public void translate(int x, int y) {
519:                graphics.translate(x, y);
520:            }
521:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.