Source Code Cross Referenced for CompositeShapePainter.java in  » Graphic-Library » batik » org » apache » batik » gvt » 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 » Graphic Library » batik » org.apache.batik.gvt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Licensed to the Apache Software Foundation (ASF) under one or more
004:           contributor license agreements.  See the NOTICE file distributed with
005:           this work for additional information regarding copyright ownership.
006:           The ASF licenses this file to You under the Apache License, Version 2.0
007:           (the "License"); you may not use this file except in compliance with
008:           the License.  You may obtain a copy of the License at
009:
010:               http://www.apache.org/licenses/LICENSE-2.0
011:
012:           Unless required by applicable law or agreed to in writing, software
013:           distributed under the License is distributed on an "AS IS" BASIS,
014:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:           See the License for the specific language governing permissions and
016:           limitations under the License.
017:
018:         */
019:        package org.apache.batik.gvt;
020:
021:        import java.awt.Graphics2D;
022:        import java.awt.Shape;
023:        import java.awt.geom.Area;
024:        import java.awt.geom.Point2D;
025:        import java.awt.geom.Rectangle2D;
026:
027:        /**
028:         * A shape painter which consists of multiple shape painters.
029:         *
030:         * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
031:         * @version $Id: CompositeShapePainter.java 479564 2006-11-27 09:56:57Z dvholten $
032:         */
033:        public class CompositeShapePainter implements  ShapePainter {
034:
035:            /**
036:             * The shape associated with this painter
037:             */
038:            protected Shape shape;
039:
040:            /**
041:             * The enclosed <tt>ShapePainter</tt>s of this composite shape painter.
042:             */
043:            protected ShapePainter[] painters;
044:
045:            /**
046:             * The number of shape painter.
047:             */
048:            protected int count;
049:
050:            /**
051:             * Constructs a new empty <tt>CompositeShapePainter</tt>.
052:             */
053:            public CompositeShapePainter(Shape shape) {
054:                if (shape == null) {
055:                    throw new IllegalArgumentException();
056:                }
057:                this .shape = shape;
058:            }
059:
060:            /**
061:             * Adds the specified shape painter to the shape painter..
062:             *
063:             * @param shapePainter the shape painter to add
064:             */
065:            public void addShapePainter(ShapePainter shapePainter) {
066:                if (shapePainter == null) {
067:                    return;
068:                }
069:                if (shape != shapePainter.getShape()) {
070:                    shapePainter.setShape(shape);
071:                }
072:                if (painters == null) {
073:                    painters = new ShapePainter[2];
074:                }
075:                if (count == painters.length) {
076:                    ShapePainter[] newPainters = new ShapePainter[count + count
077:                            / 2 + 1];
078:                    System.arraycopy(painters, 0, newPainters, 0, count);
079:                    painters = newPainters;
080:                }
081:                painters[count++] = shapePainter;
082:            }
083:
084:            /**
085:             * Sets to the specified index, the specified ShapePainter.
086:             *
087:             * @param index the index where to set the ShapePainter
088:             * @param shapePainter the ShapePainter to set
089:             */
090:            /*    public void setShapePainter(int index, ShapePainter shapePainter) {
091:                if (shapePainter == null) {
092:                    return;
093:                }
094:                if (this.shape != shapePainter.getShape()) {
095:                    shapePainter.setShape(shape);
096:                }
097:                if (painters == null || index >= painters.length) {
098:                    throw new IllegalArgumentException("Bad index: "+index);
099:                }
100:                painters[index] = shapePainter;
101:                }*/
102:
103:            /**
104:             * Returns the shape painter at the specified index.
105:             *
106:             * @param index the index of the shape painter to return
107:             */
108:            public ShapePainter getShapePainter(int index) {
109:                return painters[index];
110:            }
111:
112:            /**
113:             * Returns the number of shape painter of this composite shape painter.
114:             */
115:            public int getShapePainterCount() {
116:                return count;
117:            }
118:
119:            /**
120:             * Paints the specified shape using the specified Graphics2D.
121:             *
122:             * @param g2d the Graphics2D to use
123:             */
124:            public void paint(Graphics2D g2d) {
125:                if (painters != null) {
126:                    for (int i = 0; i < count; ++i) {
127:                        painters[i].paint(g2d);
128:                    }
129:                }
130:            }
131:
132:            /**
133:             * Returns the area painted by this shape painter.
134:             */
135:            public Shape getPaintedArea() {
136:                if (painters == null)
137:                    return null;
138:                Area paintedArea = new Area();
139:                for (int i = 0; i < count; ++i) {
140:                    Shape s = painters[i].getPaintedArea();
141:                    if (s != null) {
142:                        paintedArea.add(new Area(s));
143:                    }
144:                }
145:                return paintedArea;
146:            }
147:
148:            /**
149:             * Returns the bounds of the area painted by this shape painter
150:             */
151:            public Rectangle2D getPaintedBounds2D() {
152:                if (painters == null)
153:                    return null;
154:
155:                Rectangle2D bounds = null;
156:                for (int i = 0; i < count; ++i) {
157:                    Rectangle2D pb = painters[i].getPaintedBounds2D();
158:                    if (pb == null)
159:                        continue;
160:                    if (bounds == null)
161:                        bounds = (Rectangle2D) pb.clone();
162:                    else
163:                        bounds.add(pb);
164:                }
165:                return bounds;
166:            }
167:
168:            /**
169:             * Returns true if pt is in the area painted by this shape painter
170:             */
171:            public boolean inPaintedArea(Point2D pt) {
172:                if (painters == null)
173:                    return false;
174:                for (int i = 0; i < count; ++i) {
175:                    if (painters[i].inPaintedArea(pt))
176:                        return true;
177:                }
178:                return false;
179:            }
180:
181:            /**
182:             * Returns the area covered by this shape painter (even if nothing
183:             * is painted there).
184:             */
185:            public Shape getSensitiveArea() {
186:                if (painters == null)
187:                    return null;
188:                Area paintedArea = new Area();
189:                for (int i = 0; i < count; ++i) {
190:                    Shape s = painters[i].getSensitiveArea();
191:                    if (s != null) {
192:                        paintedArea.add(new Area(s));
193:                    }
194:                }
195:                return paintedArea;
196:            }
197:
198:            /**
199:             * Returns the bounds of the area painted by this shape painter
200:             */
201:            public Rectangle2D getSensitiveBounds2D() {
202:                if (painters == null)
203:                    return null;
204:
205:                Rectangle2D bounds = null;
206:                for (int i = 0; i < count; ++i) {
207:                    Rectangle2D pb = painters[i].getSensitiveBounds2D();
208:                    if (bounds == null)
209:                        bounds = (Rectangle2D) pb.clone();
210:                    else
211:                        bounds.add(pb);
212:                }
213:                return bounds;
214:            }
215:
216:            /**
217:             * Returns true if pt is in the area painted by this shape painter
218:             */
219:            public boolean inSensitiveArea(Point2D pt) {
220:                if (painters == null)
221:                    return false;
222:                for (int i = 0; i < count; ++i) {
223:                    if (painters[i].inSensitiveArea(pt))
224:                        return true;
225:                }
226:                return false;
227:            }
228:
229:            /**
230:             * Sets the Shape this shape painter is associated with.
231:             *
232:             * @param shape new shape this painter should be associated with.
233:             * Should not be null.
234:             */
235:            public void setShape(Shape shape) {
236:                if (shape == null) {
237:                    throw new IllegalArgumentException();
238:                }
239:                if (painters != null) {
240:                    for (int i = 0; i < count; ++i) {
241:                        painters[i].setShape(shape);
242:                    }
243:                }
244:                this .shape = shape;
245:            }
246:
247:            /**
248:             * Gets the Shape this shape painter is associated with.
249:             *
250:             * @return shape associated with this painter
251:             */
252:            public Shape getShape() {
253:                return shape;
254:            }
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.