Source Code Cross Referenced for HtmlGridBagLayout.java in  » J2EE » WiSerFramework » de » ug2t » channel » markup » html » 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 » J2EE » WiSerFramework » de.ug2t.channel.markup.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // @@
002:        // @@
003:        /*
004:         * Wi.Ser Framework
005:         *
006:         * Version: 1.8.1, 20-September-2007  
007:         * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
008:         *
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2 of the License, or (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library located in LGPL.txt in the 
021:         * license directory; if not, write to the 
022:         * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023:         * Boston, MA  02111-1307, USA.
024:         * 
025:         * If this agreement does not cover your requirements, please contact us
026:         * via email to get detailed information about the commercial license 
027:         * or our service offerings!
028:         *
029:         */
030:        // @@
031:        package de.ug2t.channel.markup.html;
032:
033:        import java.util.*;
034:
035:        import de.ug2t.channel.markup.generic.*;
036:        import de.ug2t.kernel.*;
037:
038:        /**
039:         * @author Dirk
040:         * 
041:         * date: 23.10.2003 project: JmcFrame_all
042:         * 
043:         * <p>
044:         * HtmlGridBagLayout is a lightweight implementaion of the Gridbag-Layout
045:         * functionality of Swing. It does not offer all functions of the original
046:         * Swing-Class. But most common functions like 'insets', 'anchor', 'position'
047:         * are supported.
048:         * </p>
049:         */
050:        final public class HtmlGridBagLayout implements  IKeView,
051:                IMuGenericLayoutManager {
052:            private HashMap pem_constraints = null;
053:            private MuGenericComponent pem_toLayout = null;
054:            private KeTable pem_table = null;
055:            private int pem_pad = 4;
056:
057:            public boolean pcmf_supportsCaching() {
058:                return (false);
059:            }
060:
061:            public void pcmf_clearCache() {
062:                throw (new UnsupportedOperationException());
063:            }
064:
065:            public void pcmf_activateCache(boolean xAc) {
066:                throw (new UnsupportedOperationException());
067:            }
068:
069:            /**
070:             * Constructs a layout-processor
071:             * 
072:             * @param xtoLayout
073:             *          the gui-object which children are subject to the layout-procedure
074:             */
075:            public HtmlGridBagLayout(MuGenericComponent xtoLayout) {
076:                this .pem_toLayout = xtoLayout;
077:                this .pcmf_layout();
078:            }
079:
080:            /**
081:             * Constructs a layout-processor
082:             */
083:            public HtmlGridBagLayout() {
084:            }
085:
086:            /**
087:             * <p>
088:             * Sets the gui-object which children a subject to the layout procedure
089:             * </p>
090:             * <p>
091:             * </p>
092:             * <p>
093:             * 
094:             * @param xtoLayout
095:             *          gui-object which children a subject to the layout procedure
096:             *          </p>
097:             */
098:            public void pcmf_setLayoutObj(MuGenericComponent xtoLayout) {
099:                this .pem_toLayout = xtoLayout;
100:                this .pcmf_layout();
101:            }
102:
103:            /**
104:             * <p>
105:             * Adds a gridBagConstraint
106:             * </p>
107:             * <p>
108:             * 
109:             * </p>
110:             * <p>
111:             * 
112:             * @param xObj
113:             *          object which connected to the constaint
114:             * @param xConst
115:             *          Constraint
116:             *          </p>
117:             */
118:            public void pcmf_addConstraints(MuGenericComponent xObj,
119:                    IMuGenericLayoutConstraints xConst) {
120:                if (this .pem_constraints == null)
121:                    this .pem_constraints = new HashMap();
122:
123:                this .pem_constraints.put(xObj, xConst);
124:
125:                return;
126:            }
127:
128:            /**
129:             * <p>
130:             * Adds a gridBagConstraint
131:             * </p>
132:             * <p>
133:             * 
134:             * </p>
135:             * <p>
136:             * 
137:             * @param xObj
138:             *          object which connected to the constaint
139:             * @param xConst
140:             *          Constraint
141:             *          </p>
142:             */
143:            public IMuGenericLayoutConstraints pcmf_removeConstraint(
144:                    MuGenericComponent xObj) {
145:                if (this .pem_constraints == null)
146:                    return (null);
147:
148:                return ((IMuGenericLayoutConstraints) this .pem_constraints
149:                        .remove(xObj));
150:            }
151:
152:            /**
153:             * <p>
154:             * Get an active constraint
155:             * </p>
156:             * <p>
157:             * 
158:             * @return constraint
159:             *         </p>
160:             *         <p>
161:             * @param xObj
162:             *          object which connected to the constaint
163:             *          </p>
164:             */
165:            public IMuGenericLayoutConstraints pcmf_getConstraints(
166:                    MuGenericComponent xObj) {
167:                if (this .pem_constraints == null)
168:                    return (null);
169:
170:                return ((IMuGenericLayoutConstraints) this .pem_constraints
171:                        .get(xObj));
172:            }
173:
174:            /**
175:             * <p>
176:             * Generates the html-string which contains html-representation of the object
177:             * referenced by the parameter
178:             * </p>
179:             * <p>
180:             * 
181:             * @return an objects which contains the html-string which is delivered by the
182:             *         objects toString method
183:             *         </p>
184:             *         <p>
185:             * @param xTreeEl
186:             *          object of which the html-string is generated
187:             *          </p>
188:             */
189:            public Object pcmf_execView(KeTreeElement xTreeEl) {
190:                return (xTreeEl.pcmf_execView());
191:            };
192:
193:            /**
194:             * <p>
195:             * Generates a html-string which contains all layouted components
196:             * </p>
197:             * <p>
198:             * 
199:             * @return an objects which contains the html-string which is delivered by the
200:             *         objects toString method
201:             *         </p>
202:             *         <p>
203:             * @param xTreeEl
204:             *          object of which the layouted html-string is generated
205:             *          </p>
206:             */
207:            public Object pcmf_output(KeTreeElement xTreeEl) {
208:                if (xTreeEl != null) {
209:                    this .pem_toLayout = (MuGenericComponent) xTreeEl;
210:                    this .pcmf_layout();
211:                }
212:                StringBuffer l_ret = new StringBuffer();
213:                l_ret
214:                        .append("<table width=\"100%\" height=\"100%\" cellpadding=\"0\" cellspacing=\"");
215:                l_ret.append(Integer.toString(pem_pad));
216:                l_ret.append("\">");
217:                Iterator l_it = null;
218:                KeTable.KeTableCellDescriptor l_desc = null;
219:                Object l_value = null;
220:                for (int i = 0; i < this .pem_table.pcmf_getRowCnt(); i++) {
221:                    l_it = this .pem_table.pcmf_getRowCellDescIt(i);
222:                    l_ret.append("<tr>");
223:                    while (l_it.hasNext()) {
224:                        l_desc = (KeTable.KeTableCellDescriptor) l_it.next();
225:                        l_value = l_desc.getPem_value();
226:                        if (l_value instanceof  KeTreeElement) {
227:                            if (l_value instanceof  MuGenericComponent) {
228:                                String l_align = ((MuGenericComponent) l_desc
229:                                        .getPem_value()).pcmf_getAlignHTML();
230:                                l_ret.append("<td ");
231:                                l_ret.append(l_align);
232:                                l_ret.append(" ");
233:                            } else
234:                                l_ret
235:                                        .append("<td valign=\"center\" align=\"center\" ");
236:
237:                            if (this .pem_constraints != null) {
238:                                MuGenericGridBagConstraints l_constr = (MuGenericGridBagConstraints) this .pem_constraints
239:                                        .get(l_value);
240:                                if (l_constr != null) {
241:                                    if (l_constr.pcm_weightx > 0) {
242:                                        l_ret.append("width=\"");
243:                                        l_ret
244:                                                .append(Integer
245:                                                        .toString(l_constr.pcm_weightx));
246:                                        l_ret.append("%\" ");
247:                                    }
248:                                    if (l_constr.pcm_weighty > 0) {
249:                                        l_ret.append("height=\"");
250:                                        l_ret
251:                                                .append(Integer
252:                                                        .toString(l_constr.pcm_weighty));
253:                                        l_ret.append("%\" ");
254:                                    }
255:                                    if (l_constr.pcm_insets != null) {
256:                                        String l_tpl = "style=\"padding: $Tpx $Rpx $Bpx $Lpx;\" ";
257:                                        l_tpl = KeTools
258:                                                .pcmf_stringSingleSubst(
259:                                                        l_tpl,
260:                                                        "$T",
261:                                                        Integer
262:                                                                .toString(l_constr.pcm_insets.top));
263:                                        l_tpl = KeTools
264:                                                .pcmf_stringSingleSubst(
265:                                                        l_tpl,
266:                                                        "$R",
267:                                                        Integer
268:                                                                .toString(l_constr.pcm_insets.right));
269:                                        l_tpl = KeTools
270:                                                .pcmf_stringSingleSubst(
271:                                                        l_tpl,
272:                                                        "$B",
273:                                                        Integer
274:                                                                .toString(l_constr.pcm_insets.bottom));
275:                                        l_tpl = KeTools
276:                                                .pcmf_stringSingleSubst(
277:                                                        l_tpl,
278:                                                        "$L",
279:                                                        Integer
280:                                                                .toString(l_constr.pcm_insets.left));
281:                                        l_ret.append(l_tpl);
282:                                    }
283:                                } else if (l_value instanceof  MuGenericComponent
284:                                        && ((MuGenericComponent) l_value)
285:                                                .pcmf_getTakeMaxSpace()) {
286:                                    MuGenericComponent l_gobj = (MuGenericComponent) l_value;
287:                                    if (l_gobj.pcmf_getVFill() == true
288:                                            && l_gobj.pcmf_getHFill() == true)
289:                                        l_ret
290:                                                .append("width=\"100%\" height=\"100%\" ");
291:                                    else if (l_gobj.pcmf_getHFill() == true
292:                                            && l_gobj.pcmf_getVFill() == false)
293:                                        l_ret.append("width=\"100%\" ");
294:                                    else if (l_gobj.pcmf_getVFill() == true
295:                                            && l_gobj.pcmf_getHFill() == false)
296:                                        l_ret.append("height=\"100%\" ");
297:                                }
298:                            } else if (l_value instanceof  MuGenericComponent
299:                                    && ((MuGenericComponent) l_value)
300:                                            .pcmf_getTakeMaxSpace()) {
301:                                MuGenericComponent l_gobj = (MuGenericComponent) l_value;
302:                                if (l_gobj.pcmf_getVFill() == true
303:                                        && l_gobj.pcmf_getHFill() == true)
304:                                    l_ret
305:                                            .append("width=\"100%\" height=\"100%\" ");
306:                                else if (l_gobj.pcmf_getHFill() == true
307:                                        && l_gobj.pcmf_getVFill() == false)
308:                                    l_ret.append("width=\"100%\" ");
309:                                else if (l_gobj.pcmf_getVFill() == true
310:                                        && l_gobj.pcmf_getHFill() == false)
311:                                    l_ret.append("height=\"100%\" ");
312:                            }
313:
314:                            if (l_desc.getPem_colspan() > 1) {
315:                                l_ret.append("colspan=\"");
316:                                l_ret.append(Integer.toString(l_desc
317:                                        .getPem_colspan()));
318:                                l_ret.append("\" ");
319:                            }
320:
321:                            if (l_desc.getPem_rowspan() > 1) {
322:                                l_ret.append("rowspan=\"");
323:                                l_ret.append(Integer.toString(l_desc
324:                                        .getPem_rowspan()));
325:                                l_ret.append("\"");
326:                            }
327:                            l_ret.append(">");
328:                            l_ret
329:                                    .append(((KeTreeElement) l_desc
330:                                            .getPem_value()).pcmf_execView()
331:                                            .toString());
332:                        } else
333:                            l_ret.append("<td>");
334:
335:                        l_ret.append("</td>");
336:                    }
337:                    l_ret.append("</tr>");
338:                }
339:                l_ret.append("</table>");
340:
341:                l_it = this .pem_toLayout.pcmf_getSubIterator();
342:                Object l_obj = null;
343:                while (l_it.hasNext()) {
344:                    l_obj = l_it.next();
345:                    if (l_obj instanceof  MuGenericEventChannel == true
346:                            || l_obj instanceof  MuGenericContextMenu == true)
347:                        l_ret.append(((MuGenericComponent) l_obj)
348:                                .pcmf_execView().toString());
349:                }
350:
351:                return (l_ret.toString());
352:            }
353:
354:            /**
355:             * <p>
356:             * Executes the layout process. Normally this function is called by the
357:             * framework only. There is no need to use it.
358:             * </p>
359:             * <p>
360:             * </p>
361:             * <p>
362:             * </p>
363:             */
364:            public void pcmf_layout() {
365:                int l_maxX = 0;
366:                int l_maxY = 0;
367:                MuGenericComponent l_guiObj = null;
368:                Object l_obj = null;
369:
370:                Iterator l_it = this .pem_toLayout.pcmf_getSubIterator();
371:                while (l_it.hasNext()) {
372:                    l_obj = l_it.next();
373:                    if (l_obj instanceof  MuGenericComponent == false
374:                            || l_obj instanceof  HtmlPageDecorator)
375:                        continue;
376:
377:                    l_guiObj = (MuGenericComponent) l_obj;
378:                    if (l_guiObj.pcmf_getXPos() > l_maxX)
379:                        l_maxX = l_guiObj.pcmf_getXPos();
380:                    if (l_guiObj.pcmf_getYPos() > l_maxY)
381:                        l_maxY = l_guiObj.pcmf_getYPos();
382:                }
383:                ;
384:
385:                if (this .pem_table == null)
386:                    this .pem_table = new KeTable(l_maxY + 1, l_maxX + 1);
387:                else
388:                    this .pem_table.pcmf_reset(l_maxY + 1, l_maxX + 1);
389:
390:                l_it = this .pem_toLayout.pcmf_getSubIterator();
391:                while (l_it.hasNext()) {
392:                    l_obj = l_it.next();
393:                    if (l_obj instanceof  MuGenericComponent == false
394:                            || l_obj instanceof  HtmlPageDecorator)
395:                        continue;
396:
397:                    l_guiObj = (MuGenericComponent) l_obj;
398:
399:                    if (l_guiObj.pcmf_getYPos() >= 0
400:                            && l_guiObj.pcmf_getXPos() >= 0) {
401:                        this .pem_table.pcmf_setValue(l_guiObj.pcmf_getYPos(),
402:                                l_guiObj.pcmf_getXPos(), l_guiObj);
403:                        this .pem_table.pcmf_spanCell(l_guiObj.pcmf_getYPos(),
404:                                l_guiObj.pcmf_getXPos(), l_guiObj.pcmf_getHi(),
405:                                l_guiObj.pcmf_getWi());
406:                    }
407:                }
408:                ;
409:                this .pem_table.pcmf_compact();
410:            }
411:
412:            /**
413:             * <p>
414:             * Generates a html-string which contains all layouted components
415:             * </p>
416:             * <p>
417:             * 
418:             * @return an objects which contains the html-string which is delivered by the
419:             *         objects toString method
420:             *         </p>
421:             *         <p>
422:             *         </p>
423:             */
424:            public String pcmf_getMarkupString() {
425:                return (this .pcmf_output(null).toString());
426:            }
427:
428:            /**
429:             * <p>
430:             * Sets the insets of the layout-cells. Insets are the gaps (in pixel) between
431:             * the cells border and the object which is displayed in the cell.
432:             * </p>
433:             * <p>
434:             * </p>
435:             * <p>
436:             * 
437:             * @param xIns
438:             *          gaps (in pixel) in all 4 directions
439:             *          </p>
440:             */
441:            public void pcmf_setInsets(int xIns) {
442:                this .pem_pad = xIns;
443:            }
444:
445:            /**
446:             * <p>
447:             * Does...
448:             * </p>
449:             * <p>
450:             * 
451:             * @return a Type with
452:             *         </p>
453:             *         <p>
454:             * @param
455:             *         </p>
456:             */
457:            protected void finalize() throws Throwable {
458:                this .pem_table.pcmf_delete();
459:            }
460:
461:            public boolean pcmf_supportContraints() {
462:                return (true);
463:            }
464:
465:            public boolean pcmf_supportDefaultInsets() {
466:                return (true);
467:            }
468:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.