Source Code Cross Referenced for TableLayoutConstraints.java in  » Content-Management-System » contelligent » de » finix » contelligent » client » util » 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 » Content Management System » contelligent » de.finix.contelligent.client.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2006 C:1 Financial Services GmbH
003:         *
004:         * This software is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License Version 2.1, as published by the Free Software Foundation.
007:         *
008:         * This software is distributed in the hope that it will be useful,
009:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
010:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011:         * Lesser General Public License for more details.
012:         *
013:         * You should have received a copy of the GNU Lesser General Public
014:         * License along with this library; if not, write to the Free Software
015:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016:         */
017:
018:        package de.finix.contelligent.client.util;
019:
020:        import java.util.StringTokenizer;
021:
022:        public class TableLayoutConstraints implements  TableLayoutConstants {
023:
024:            /** Cell in which the upper left corner of the component lays */
025:            public int col1, row1;
026:
027:            /** Cell in which the lower right corner of the component lays */
028:            public int col2, row2;
029:
030:            /** Horizontal justification if component occupies just one cell */
031:            public int hAlign;
032:
033:            /** Verical justification if component occupies just one cell */
034:            public int vAlign;
035:
036:            /**
037:             * Constructs an TableLayoutConstraints with the default settings. This
038:             * constructor is equivalent to TableLayoutConstraints(0, 0, 0, 0, FULL,
039:             * FULL).
040:             */
041:
042:            public TableLayoutConstraints() {
043:                col1 = row1 = col2 = col2 = 0;
044:                hAlign = vAlign = FULL;
045:            }
046:
047:            /**
048:             * Constructs an TableLayoutConstraints from a string.
049:             * 
050:             * @param constraints
051:             *            indicates TableLayoutConstraints's position and justification
052:             *            as a string in the form "row, column" or "row, column,
053:             *            horizontal justification, vertical justification" or "row 1,
054:             *            column 1, row 2, column 2". It is also acceptable to delimit
055:             *            the paramters with spaces instead of commas.
056:             */
057:
058:            public TableLayoutConstraints(String constraints) {
059:                // Parse constraints using spaces or commas
060:                StringTokenizer st = new StringTokenizer(constraints, ", ");
061:                GenericTokenizer gt = new GenericTokenizer(st,
062:                        GenericTokenizer.IntegerDescriptor);
063:
064:                // Use default values for any parameter not specified or specified
065:                // incorrectly. The default parameters place the component in a single
066:                // cell at column 0, row 0. The component is fully justified.
067:                col1 = 0;
068:                row1 = 0;
069:                col2 = 0;
070:                row2 = 0;
071:                hAlign = FULL;
072:                vAlign = FULL;
073:
074:                for (int tokCnt = 0; gt.hasNext(); tokCnt++) {
075:                    Object token = gt.next();
076:                    if (token instanceof  Integer) {
077:                        int value = ((Integer) token).intValue();
078:                        switch (tokCnt) {
079:                        case 0:
080:                            // Get the first column (assume component is in only one
081:                            // column)
082:                            col1 = value;
083:                            col2 = col1;
084:                            break;
085:                        case 1:
086:                            // Get the first row (assume component is in only one row)
087:                            row1 = value;
088:                            row2 = row1;
089:                            break;
090:                        case 2:
091:                            // Get the second column
092:                            col2 = value;
093:                            break;
094:                        case 3:
095:                            // Get the second row
096:                            row2 = value;
097:                            break;
098:                        }
099:                    } else {
100:                        // assume it is a string then (nothing more has been specified!)
101:                        String string = (String) token;
102:                        if (tokCnt % 2 == 0) {
103:                            // if it is even, it must be specification for horizontally
104:                            // justification
105:                            // Check if token means horizontally justification the
106:                            // component
107:                            if (string.equalsIgnoreCase("L")) {
108:                                hAlign = LEFT;
109:                            } else if (string.equalsIgnoreCase("C")) {
110:                                hAlign = CENTER;
111:                            } else if (string.equalsIgnoreCase("F")) {
112:                                hAlign = FULL;
113:                            } else if (string.equalsIgnoreCase("R")) {
114:                                hAlign = RIGHT;
115:                            }
116:                        } else {
117:                            // if it is odd, it must be specification for vertical
118:                            // justification
119:                            if (string.equalsIgnoreCase("T")) {
120:                                vAlign = TOP;
121:                            } else if (string.equalsIgnoreCase("C")) {
122:                                vAlign = CENTER;
123:                            } else if (string.equalsIgnoreCase("F")) {
124:                                vAlign = FULL;
125:                            } else if (string.equalsIgnoreCase("B")) {
126:                                vAlign = BOTTOM;
127:                            }
128:                        }
129:                    }
130:                }
131:
132:                // Make sure row2 >= row1
133:                if (row2 < row1)
134:                    row2 = row1;
135:
136:                // Make sure col2 >= col1
137:                if (col2 < col1)
138:                    col2 = col1;
139:            }
140:
141:            /**
142:             * Constructs an TableLayoutConstraints a set of constraints.
143:             * 
144:             * @param col1
145:             *            column where upper-left cornor of the component is placed
146:             * @param row1
147:             *            row where upper-left cornor of the component is placed
148:             * @param col2
149:             *            column where lower-right cornor of the component is placed
150:             * @param row2
151:             *            row where lower-right cornor of the component is placed
152:             * @param hAlign
153:             *            horizontal justification of a component in a single cell
154:             * @param vAlign
155:             *            vertical justification of a component in a single cell
156:             */
157:
158:            public TableLayoutConstraints(int col1, int row1, int col2,
159:                    int row2, int hAlign, int vAlign) {
160:                this .col1 = col1;
161:                this .row1 = row1;
162:                this .col2 = col2;
163:                this .row2 = row2;
164:
165:                if ((hAlign < MIN_ALIGN) || (hAlign > MAX_ALIGN))
166:                    this .hAlign = FULL;
167:                else
168:                    this .hAlign = hAlign;
169:
170:                if ((vAlign < MIN_ALIGN) || (vAlign > MAX_ALIGN))
171:                    this .vAlign = FULL;
172:                else
173:                    this .vAlign = vAlign;
174:            }
175:
176:            /**
177:             * Gets a string representation of this TableLayoutConstraints.
178:             * 
179:             * @return a string in the form "row 1, column 1, row 2, column 2" or "row,
180:             *         column, horizontal justification, vertical justification"
181:             */
182:
183:            public String toString() {
184:                StringBuffer buffer = new StringBuffer();
185:
186:                buffer.append(row1);
187:                buffer.append(", ");
188:                buffer.append(col1);
189:                buffer.append(", ");
190:
191:                if ((row1 == row2) && (col1 == col2)) {
192:                    final char h[] = { 'L', 'C', 'F', 'R' };
193:                    final char v[] = { 'T', 'C', 'F', 'B' };
194:
195:                    buffer.append(h[hAlign]);
196:                    buffer.append(", ");
197:                    buffer.append(v[vAlign]);
198:                } else {
199:                    buffer.append(row2);
200:                    buffer.append(", ");
201:                    buffer.append(col2);
202:                }
203:
204:                return buffer.toString();
205:            }
206:
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.