Source Code Cross Referenced for Switch.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 com.sun.perseus.j2d.RenderGraphics;
029:
030:        import com.sun.perseus.util.SVGConstants;
031:
032:        import com.sun.perseus.j2d.Transform;
033:        import com.sun.perseus.j2d.Box;
034:
035:        /**
036:         * The <code>Switch</code> class is a simple extension of the 
037:         * <code>Group</code> class which stops rendering its children 
038:         * after one as rendered (i.e., the child's canRender method
039:         * returns true).
040:         * This implements the behavior required by the SVG Tiny
041:         * specification of the <code>&lt;switch&gt;</code> element.
042:         *
043:         * @version $Id: Switch.java,v 1.7 2006/06/29 10:47:35 ln156897 Exp $
044:         */
045:        public class Switch extends Group {
046:            /**
047:             * Constructor.
048:             *
049:             * @param ownerDocument this element's owner <code>DocumentNode</code>
050:             */
051:            public Switch(final DocumentNode ownerDocument) {
052:                super (ownerDocument);
053:            }
054:
055:            /**
056:             * @return the SVGConstants.SVG_SWITCH_TAG value
057:             */
058:            public String getLocalName() {
059:                return SVGConstants.SVG_SWITCH_TAG;
060:            }
061:
062:            /**
063:             * Used by <code>DocumentNode</code> to create a new instance from
064:             * a prototype <code>Switch</code>.
065:             *
066:             * @param doc the <code>DocumentNode</code> for which a new node is
067:             *        should be created.
068:             * @return a new <code>Switch</code> for the requested document.
069:             */
070:            public ElementNode newInstance(final DocumentNode doc) {
071:                return new Switch(doc);
072:            }
073:
074:            /**
075:             * Returns the <code>ModelNode</code>, if any, hit by the
076:             * point at coordinate x/y. 
077:             * 
078:             * @param pt the x/y coordinate. Should never be null and be
079:             *        of size two. If not, the behavior is unspecified.
080:             *        The coordinates are in viewport space.
081:             * @return the <tt>ModelNode</tt> hit at the given point or null
082:             *         if none was hit.
083:             */
084:            public ModelNode nodeHitAt(final float[] pt) {
085:                // If a node does not render, it is never hit
086:                if (canRenderState != 0) {
087:                    return null;
088:                }
089:
090:                // Check for a hit on children
091:                ModelNode c = lastChild;
092:                while (c != null) {
093:                    if ((c.canRenderState & CAN_RENDER_CONDITIONS_MET_BITS) == 0) {
094:                        return c.nodeHitAt(pt);
095:                    }
096:                    c = c.prevSibling;
097:                }
098:
099:                return null;
100:            }
101:
102:            /**
103:             * Returns the <code>ModelNode</code>, if any, hit by the
104:             * point at coordinate x/y in the proxy tree starting at 
105:             * proxy.
106:             * 
107:             * @param pt the x/y coordinate. Should never be null and be
108:             *        of size two. If not, the behavior is unspecified.
109:             *        The coordinates are in viewport space.
110:             * @param proxy the root of the proxy tree to test.
111:             * @return the <tt>ModelNode</tt> hit at the given point or null
112:             *         if none was hit.
113:             */
114:            ModelNode proxyNodeHitAt(final float[] pt,
115:                    final ElementNodeProxy proxy) {
116:                // If a node does not render, it is never hit
117:                if (canRenderState != 0) {
118:                    return null;
119:                }
120:
121:                // Check for a hit on the proxy's expanded children
122:                ElementNodeProxy c = (ElementNodeProxy) proxy
123:                        .getLastExpandedChild();
124:                while (c != null) {
125:                    if ((c.proxied.canRenderState & CAN_RENDER_CONDITIONS_MET_BITS) == 0) {
126:                        return c.nodeHitAt(pt);
127:                    }
128:                    c = (ElementNodeProxy) c.prevSibling;
129:                }
130:
131:                return null;
132:            }
133:
134:            /**
135:             * @param rg this method paints this node into the input 
136:             *        <tt>RenderGraphics</tt>
137:             */
138:            public void paint(final RenderGraphics rg) {
139:                if (canRenderState != 0) {
140:                    return;
141:                }
142:
143:                if (firstChild == null) {
144:                    return;
145:                }
146:
147:                //
148:                // Only go up to the first child which
149:                // renders
150:                //
151:                ElementNode c = firstChild;
152:                while (c != null) {
153:                    // Paint child
154:                    c.paint(rg);
155:
156:                    // Exit the loop if the child rendered
157:                    if ((c.canRenderState & CAN_RENDER_CONDITIONS_MET_BITS) == 0) {
158:                        break;
159:                    }
160:
161:                    c = (ElementNode) c.nextSibling;
162:                }
163:            }
164:
165:            /**
166:             * @param bbox the bounding box to which this node's bounding box should be
167:             *        appended. That bounding box is in the target coordinate space. It 
168:             *        may be null, in which case this node should create a new one.
169:             * @param t the transform to apply from the node's coordinate space to 
170:             *        the target coordinate space. May be null for the identity 
171:             *        transform.
172:             * @return the node's bounding box in the target coordinate space.
173:             */
174:            public Box addBBox(Box bbox, final Transform t) {
175:                ModelNode c = getFirstChildNode();
176:                while (c != null) {
177:                    if ((c.canRenderState & CAN_RENDER_CONDITIONS_MET_BITS) == 0) {
178:                        bbox = c.addBBox(bbox, c.appendTransform(t, null));
179:                        break;
180:                    }
181:                    c = c.nextSibling;
182:                }
183:
184:                return bbox;
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.