Source Code Cross Referenced for CardLayoutConverter.java in  » XML-UI » swixml » org » swixml » layoutconverters » 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 » XML UI » swixml » org.swixml.layoutconverters 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*--
002:         Copyright (C) 2003-2007 Wolf Paulus.
003:         All rights reserved.
004:
005:         Redistribution and use in source and binary forms, with or without
006:         modification, are permitted provided that the following conditions
007:         are met:
008:
009:         1. Redistributions of source code must retain the above copyright
010:         notice, this list of conditions, and the following disclaimer.
011:
012:         2. Redistributions in binary form must reproduce the above copyright
013:         notice, this list of conditions, and the disclaimer that follows
014:         these conditions in the documentation and/or other materials provided
015:         with the distribution.
016:
017:         3. The end-user documentation included with the redistribution,
018:         if any, must include the following acknowledgment:
019:                "This product includes software developed by the
020:                 SWIXML Project (http://www.swixml.org/)."
021:         Alternately, this acknowledgment may appear in the software itself,
022:         if and wherever such third-party acknowledgments normally appear.
023:
024:         4. The name "Swixml" must not be used to endorse or promote products
025:         derived from this software without prior written permission. For
026:         written permission, please contact <info_AT_swixml_DOT_org>
027:
028:         5. Products derived from this software may not be called "Swixml",
029:         nor may "Swixml" appear in their name, without prior written
030:         permission from the Swixml Project Management.
031:
032:         THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
033:         WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
034:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
035:         DISCLAIMED.  IN NO EVENT SHALL THE SWIXML PROJECT OR ITS
036:         CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
037:         SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
038:         LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
039:         USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
040:         ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
041:         OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
042:         OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
043:         SUCH DAMAGE.
044:         ====================================================================
045:
046:         This software consists of voluntary contributions made by many
047:         individuals on behalf of the Swixml Project and was originally
048:         created by Wolf Paulus <wolf_AT_swixml_DOT_org>. For more information
049:         on the Swixml Project, please see <http://www.swixml.org/>.
050:         */
051:
052:        package org.swixml.layoutconverters;
053:
054:        import java.awt.CardLayout;
055:        import java.awt.LayoutManager;
056:        import java.util.StringTokenizer;
057:
058:        import org.jdom.Attribute;
059:        import org.jdom.Element;
060:        import org.swixml.LayoutConverter;
061:        import org.swixml.converters.Util;
062:
063:        /**
064:         * A layout converter for <code>java.awt.CardLayout</code>.
065:         * 
066:         * <p><b>Examples:</b></p>
067:         * <pre>
068:         * &lt;panel layout="CardLayout"&gt;
069:         *   &lt;panel constraints="card1" /&gt;
070:         *   &lt;panel constraints="card2" /&gt;
071:         * &lt;/panel&gt;
072:         * </pre>
073:         *
074:         * <pre>
075:         * &lt;panel layout="CardLayout(10,20)"&gt;
076:         *   &lt;panel constraints="firstCard" /&gt;
077:         *   &lt;panel constraints="secondCard" /&gt;
078:         * &lt;/panel&gt;
079:         * </pre>
080:         *
081:         * <pre>
082:         * &lt;panel&gt;
083:         *   &lt;layout type="CardLayout" hgap="10" vgap="20"/&gt;
084:         *   &lt;panel constraints="firstCard" /&gt;
085:         *   &lt;panel constraints="secondCard" /&gt;
086:         * &lt;/panel&gt;
087:         * </pre>
088:         * 
089:         * <p>Here is how to access the card layout manager of a component installed by SwixML
090:         * <code>(CardLayout)((Container)swingEngine.find("id_of_my_CLed_comp")).getLayout()</code></p>
091:         *
092:         * @author Karl Tauber
093:         * @author <a href="mailto:wolf@wolfpaulus.com">Wolf Paulus</a>
094:         */
095:        public class CardLayoutConverter implements  LayoutConverter {
096:
097:            /**
098:             * Returns "cardlayout".
099:             */
100:            public String getID() {
101:                return "cardlayout";
102:            }
103:
104:            /**
105:             * <p>Creates a CardLayout instance.</p>
106:             * 
107:             * <p><b>Examples for Valid XML attribute notations:</b></p>
108:             * <ul>
109:             * <li><code>layout="CardLayout"</code></li>
110:             * <li><code>layout="CardLayout(int hgap, int vgap)"</code></li>
111:             * </ul>
112:             */
113:            public LayoutManager convertLayoutAttribute(final Attribute attr) {
114:                StringTokenizer st = new StringTokenizer(attr.getValue(), "(,)");
115:                st.nextToken(); // skip layout type
116:
117:                int[] para = Util.ia(st);
118:                if (para.length < 2)
119:                    return new CardLayout();
120:                else
121:                    return new CardLayout(para[0], para[1]);
122:            }
123:
124:            /**
125:             * <p>Creates a CardLayout instance.</p>
126:             * 
127:             * <p><b>Attributes:</b></p>
128:             * <ul>
129:             * <li><code>hgap</code> (optional): The horizontal gap.</li>
130:             * <li><code>vgap</code> (optional): The vertical gap.</li>
131:             * </ul>
132:             * 
133:             * <p><b>Examples for Valid XML element notations:</b></p>
134:             * <ul>
135:             * <li><code>&lt;layout type="CardLayout"/&gt;</code></li>
136:             * <li><code>&lt;layout type="CardLayout" hgap="10" vgap="20"/&gt;</code></li>
137:             * </ul>
138:             */
139:            public LayoutManager convertLayoutElement(final Element element) {
140:                int hgap = Util.getInteger(element, "hgap", 0);
141:                int vgap = Util.getInteger(element, "vgap", 0);
142:                return new CardLayout(hgap, vgap);
143:            }
144:
145:            /**
146:             * Converts CardLayout constraints.
147:             * The attribute value is used as card name.
148:             * 
149:             * <p><b>Examples for Valid XML attribute notations:</b></p>
150:             * <ul>
151:             * <li><code>constraints="cardname"</code></li>
152:             * </ul>
153:             */
154:            public Object convertConstraintsAttribute(final Attribute attr) {
155:                //
156:                // CardLayout accepts only constraints of type String
157:                //
158:                return attr.getValue();
159:            }
160:
161:            /**
162:             * Returns always <code>null</code>.
163:             */
164:            public Object convertConstraintsElement(final Element element) {
165:                return null;
166:            }
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.