Source Code Cross Referenced for Block.java in  » Ajax » dwr » jsx3 » vector » 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 » Ajax » dwr » jsx3.vector 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005 Joe Walker
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package jsx3.vector;
017:
018:        import org.directwebremoting.ScriptBuffer;
019:        import org.directwebremoting.proxy.ScriptProxy;
020:        import org.directwebremoting.proxy.io.Context;
021:
022:        /**
023:         * Defines a base class for GUI controls that implement both the cross-platform box profile painting introduced in
024:         3.2 and the cross-platform (VML/SVG) vector painting, also introduced in 3.2.
025:
026:         This class should be extended by custom GUI classes that will display vector elements.
027:         * @author Joe Walker [joe at getahead dot org]
028:         * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
029:         */
030:        public class Block extends jsx3.gui.Block {
031:            /**
032:             * All reverse ajax proxies need context to work from
033:             * @param scriptProxy The place we are writing scripts to
034:             * @param context The script that got us to where we are now
035:             */
036:            public Block(Context context, String extension,
037:                    ScriptProxy scriptProxy) {
038:                super (context, extension, scriptProxy);
039:            }
040:
041:            /**
042:             * Returns the vector canvas on which this control paints itself. If no canvas has already been created, then
043:            createVector() is called to create it.
044:             */
045:            @SuppressWarnings("unchecked")
046:            public jsx3.vector.Tag getCanvas() {
047:                String extension = "getCanvas().";
048:                try {
049:                    java.lang.reflect.Constructor<jsx3.vector.Tag> ctor = jsx3.vector.Tag.class
050:                            .getConstructor(Context.class, String.class,
051:                                    ScriptProxy.class);
052:                    return ctor.newInstance(this , extension, getScriptProxy());
053:                } catch (Exception ex) {
054:                    throw new IllegalArgumentException("Unsupported type: "
055:                            + jsx3.vector.Tag.class.getName());
056:                }
057:            }
058:
059:            /**
060:             * Returns the vector canvas on which this control paints itself. If no canvas has already been created, then
061:            createVector() is called to create it.
062:             * @param returnType The expected return type
063:             */
064:            @SuppressWarnings("unchecked")
065:            public <T> T getCanvas(Class<T> returnType) {
066:                String extension = "getCanvas().";
067:                try {
068:                    java.lang.reflect.Constructor<T> ctor = returnType
069:                            .getConstructor(Context.class, String.class,
070:                                    ScriptProxy.class);
071:                    return ctor.newInstance(this , extension, getScriptProxy());
072:                } catch (Exception ex) {
073:                    throw new IllegalArgumentException(
074:                            "Unsupported return type: " + returnType.getName());
075:                }
076:            }
077:
078:            /**
079:             * Creates the vector tag tree that will render this GUI control. Subclasses of this class should override this
080:            method to specify the manner in which they render.
081:
082:            The basic template for a method overriding this method is:
083:
084:            CustomVector.prototype.createVector = function() {
085:            var objCanvas = this.jsxsuper();
086:            // modify objCanvas, add children, etc.
087:            return objCanvas;
088:            };
089:
090:            This method should do the work of creating and updating the vector tree to the state when it is ready to be
091:            rendered on screen, but without calling updateVector() directly.
092:             */
093:            @SuppressWarnings("unchecked")
094:            public jsx3.vector.Tag createVector() {
095:                String extension = "createVector().";
096:                try {
097:                    java.lang.reflect.Constructor<jsx3.vector.Tag> ctor = jsx3.vector.Tag.class
098:                            .getConstructor(Context.class, String.class,
099:                                    ScriptProxy.class);
100:                    return ctor.newInstance(this , extension, getScriptProxy());
101:                } catch (Exception ex) {
102:                    throw new IllegalArgumentException("Unsupported type: "
103:                            + jsx3.vector.Tag.class.getName());
104:                }
105:            }
106:
107:            /**
108:             * Creates the vector tag tree that will render this GUI control. Subclasses of this class should override this
109:            method to specify the manner in which they render.
110:
111:            The basic template for a method overriding this method is:
112:
113:            CustomVector.prototype.createVector = function() {
114:            var objCanvas = this.jsxsuper();
115:            // modify objCanvas, add children, etc.
116:            return objCanvas;
117:            };
118:
119:            This method should do the work of creating and updating the vector tree to the state when it is ready to be
120:            rendered on screen, but without calling updateVector() directly.
121:             * @param returnType The expected return type
122:             */
123:            @SuppressWarnings("unchecked")
124:            public <T> T createVector(Class<T> returnType) {
125:                String extension = "createVector().";
126:                try {
127:                    java.lang.reflect.Constructor<T> ctor = returnType
128:                            .getConstructor(Context.class, String.class,
129:                                    ScriptProxy.class);
130:                    return ctor.newInstance(this , extension, getScriptProxy());
131:                } catch (Exception ex) {
132:                    throw new IllegalArgumentException(
133:                            "Unsupported return type: " + returnType.getName());
134:                }
135:            }
136:
137:            /**
138:             * Updates the pre-existing vector tree of this control on, for example, a resize or repaint event. Methods
139:            overriding this method should return true if the update is successful or false to
140:            force the vector tree to be completely recreated with createVector().
141:
142:            The basic template for a method overriding this method is:
143:
144:            CustomVector.prototype.updateVector = function(objVector) {
145:            this.jsxsuper(objVector);
146:            // modify objCanvas, modify children, etc.
147:            return true;
148:            };
149:             * @param objVector the root of the vector render tree.
150:             * @param callback <code>true</code> if the tree could be updated inline or <code>false</code> if it must be
151:            recreated by calling <code>createVector()</code>.
152:             */
153:            @SuppressWarnings("unchecked")
154:            public void updateVector(jsx3.vector.Tag objVector,
155:                    org.directwebremoting.proxy.Callback<Boolean> callback) {
156:                ScriptBuffer script = new ScriptBuffer();
157:                String callbackPrefix = "";
158:
159:                if (callback != null) {
160:                    callbackPrefix = "var reply = ";
161:                }
162:
163:                script.appendCall(callbackPrefix + getContextPath()
164:                        + "updateVector", objVector);
165:
166:                if (callback != null) {
167:                    String key = org.directwebremoting.extend.CallbackHelper
168:                            .saveCallback(callback, Boolean.class);
169:                    script
170:                            .appendCall("__System.activateCallback", key,
171:                                    "reply");
172:                }
173:
174:                getScriptProxy().addScript(script);
175:            }
176:
177:            /**
178:             * Instantiates and returns a new instance of jsx3.vector.Canvas. The implementation of
179:            createVector() in this class calls this method to create the base vector tag. This method may be
180:            overridden to provide a base tag of another type that Canvas.
181:             */
182:            @SuppressWarnings("unchecked")
183:            public jsx3.vector.Tag createCanvas() {
184:                String extension = "createCanvas().";
185:                try {
186:                    java.lang.reflect.Constructor<jsx3.vector.Tag> ctor = jsx3.vector.Tag.class
187:                            .getConstructor(Context.class, String.class,
188:                                    ScriptProxy.class);
189:                    return ctor.newInstance(this , extension, getScriptProxy());
190:                } catch (Exception ex) {
191:                    throw new IllegalArgumentException("Unsupported type: "
192:                            + jsx3.vector.Tag.class.getName());
193:                }
194:            }
195:
196:            /**
197:             * Instantiates and returns a new instance of jsx3.vector.Canvas. The implementation of
198:            createVector() in this class calls this method to create the base vector tag. This method may be
199:            overridden to provide a base tag of another type that Canvas.
200:             * @param returnType The expected return type
201:             */
202:            @SuppressWarnings("unchecked")
203:            public <T> T createCanvas(Class<T> returnType) {
204:                String extension = "createCanvas().";
205:                try {
206:                    java.lang.reflect.Constructor<T> ctor = returnType
207:                            .getConstructor(Context.class, String.class,
208:                                    ScriptProxy.class);
209:                    return ctor.newInstance(this , extension, getScriptProxy());
210:                } catch (Exception ex) {
211:                    throw new IllegalArgumentException(
212:                            "Unsupported return type: " + returnType.getName());
213:                }
214:            }
215:
216:            /**
217:             * Renders a cross-platform vector event handler. When an event of type strEvtType bubbles up to the
218:            HTML element rendered by objElm, the instance method of this object whose name is
219:            strMethod will be called with two parameters: the browser event wrapped in an instance of
220:            jsx3.gui.Event, and the native HTMLElement that defined the event handler.
221:             * @param strEvtType the event type, one of <code>jsx3.gui.Event.CLICK</code>, etc.
222:             * @param strMethod the instance method to call on this object when the event is received.
223:             * @param objElm the HTML element to which to add the event handler.
224:             */
225:            public void paintEventHandler(String strEvtType, String strMethod,
226:                    jsx3.vector.Tag objElm) {
227:                ScriptBuffer script = new ScriptBuffer();
228:                script.appendCall(getContextPath() + "paintEventHandler",
229:                        strEvtType, strMethod, objElm);
230:                getScriptProxy().addScript(script);
231:            }
232:
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.