Source Code Cross Referenced for PaintServerReference.java in  » 6.0-JDK-Modules » j2me » com » sun » perseus » model » 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 » 6.0 JDK Modules » j2me » com.sun.perseus.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:        package com.sun.perseus.model;
027:
028:        import org.w3c.dom.DOMException;
029:
030:        import com.sun.perseus.j2d.RGB;
031:        import com.sun.perseus.j2d.Transform;
032:
033:        import com.sun.perseus.j2d.PaintDef;
034:        import com.sun.perseus.j2d.PaintServer;
035:        import com.sun.perseus.j2d.PaintTarget;
036:
037:        /**
038:         * The <code>PaintServerReference</code> object is used to handle
039:         * references from a <code>GraphicsNode</code> to an actual 
040:         * <code>Paint</code> implementation. This is needed because
041:         * paint references are not always resolved, for example when 
042:         * a document has forward references to paint servers.
043:         *
044:         * @version $Id: PaintServerReference.java,v 1.5 2006/06/29 10:47:33 ln156897 Exp $
045:         */
046:        public class PaintServerReference {
047:            /**
048:             * Paint used when the paint server reference has not been resolved
049:             * yet. Fully transparent black.
050:             */
051:            static final RGB UNRESOLVED_PAINT = new RGB(0, 0, 0);
052:
053:            static class Unresolved implements  IDRef, PaintServer {
054:                /**
055:                 * The referenced id.
056:                 */
057:                String idRef;
058:
059:                /**
060:                 * The CompositeGraphicsNode using this paint server reference.
061:                 */
062:                PaintTarget paintTarget;
063:
064:                /**
065:                 * The requested paintType, i.e., the paint traitName.
066:                 */
067:                String paintType;
068:
069:                /**
070:                 * @param ownerDocument the document this reference is part of.
071:                 * @param paintTarget the node which references the paint server.
072:                 * @param paintType the name of the paint trait (e.g., "fill" or 
073:                 *        "stroke")
074:                 * @param idRef the value of the referenced paint server id.
075:                 * @param IllegalArgumentException if ownerDocument, referencingNode,
076:                 *        or idRef is null.
077:                 */
078:                public Unresolved(final DocumentNode ownerDocument,
079:                        final PaintTarget paintTarget, final String paintType,
080:                        final String idRef) {
081:                    if (ownerDocument == null || paintTarget == null
082:                            || idRef == null || paintType == null) {
083:                        throw new IllegalArgumentException();
084:                    }
085:
086:                    this .paintTarget = paintTarget;
087:                    this .idRef = idRef;
088:                    this .paintType = paintType;
089:                    ownerDocument.resolveIDRef(this , idRef);
090:                }
091:
092:                /**
093:                 * <code>IDRef</code> implementation.
094:                 *
095:                 * @param ref the resolved referenced (mapped from the id passed to 
096:                 *        the setIdRef method).
097:                 */
098:                public void resolveTo(final ElementNode ref) {
099:                    if (!(ref instanceof  PaintServer)) {
100:                        throw new DOMException(
101:                                DOMException.INVALID_STATE_ERR,
102:                                Messages
103:                                        .formatMessage(
104:                                                Messages.ERROR_INVALID_PAINT_SERVER_REFERENCE,
105:                                                new String[] { idRef,
106:                                                        ref.getNamespaceURI(),
107:                                                        ref.getLocalName() }));
108:                    }
109:
110:                    paintTarget.onPaintServerUpdate(paintType,
111:                            (PaintServer) ref);
112:                }
113:
114:                /**
115:                 * @return the PaintDef generated by the server.
116:                 */
117:                public PaintDef getPaintDef() {
118:                    return UNRESOLVED_PAINT;
119:                }
120:
121:                /**
122:                 * @param paintType a key that the PaintTarget can use to characterize 
123:                 *        its interest in the PaintServer. For example, a PaintTarget 
124:                 *        may be interested in the Paint both for stroking and filling 
125:                 *        purposes.
126:                 * @param paintTarget the PaintServerTarget listening to changes to the
127:                 *        paint generated by this PaintServer.
128:                 */
129:                public void setPaintTarget(final String paintType,
130:                        final PaintTarget paintTarget) {
131:                    if (paintTarget != this .paintTarget) {
132:                        throw new Error();
133:                    }
134:                }
135:
136:                /**
137:                 * Called when the PaintServer is no longer used
138:                 */
139:                public void dispose() {
140:                }
141:            }
142:
143:            /**
144:             * If the requested idRef is resolved, this method checks it is a reference
145:             * to a PaintServer and returns that PaintServer.
146:             *
147:             * If the resquested idRef cannot be resolved, then the method returns and 
148:             * PaintServerReference.Unresolved instance.
149:             *
150:             * @param doc the Document scope.
151:             * @param paintTarget the PaintServer observer.
152:             * @param traitName the name of the trait for which the server is seeked.
153:             * @param idRef the id of the paint server reference.
154:             */
155:            public static PaintServer resolve(final DocumentNode doc,
156:                    final PaintTarget paintTarget, final String traitName,
157:                    final String idRef) {
158:                // Check if the paint server reference is already resolved.
159:                ElementNode ref = (ElementNode) doc.getElementById(idRef);
160:                if (ref != null) {
161:                    if (!(ref instanceof  PaintElement)) {
162:                        throw new DOMException(
163:                                DOMException.INVALID_STATE_ERR,
164:                                Messages
165:                                        .formatMessage(
166:                                                Messages.ERROR_INVALID_PAINT_SERVER_REFERENCE,
167:                                                new String[] { idRef,
168:                                                        ref.getNamespaceURI(),
169:                                                        ref.getLocalName() }));
170:                    } else {
171:                        return ((PaintElement) ref).getPaintServer(traitName,
172:                                paintTarget);
173:                    }
174:                }
175:
176:                // The paint server reference is not resolved yet. We create an 
177:                // unresolved PaintServer.
178:                return new PaintServerReference.Unresolved(doc, paintTarget,
179:                        traitName, idRef);
180:            }
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.