Source Code Cross Referenced for FlowLayoutCG.java in  » Swing-Library » wings3 » org » wings » plaf » css » 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 » Swing Library » wings3 » org.wings.plaf.css 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2000,2005 wingS development team.
003:         *
004:         * This file is part of wingS (http://wingsframework.org).
005:         *
006:         * wingS is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU Lesser General Public License
008:         * as published by the Free Software Foundation; either version 2.1
009:         * of the License, or (at your option) any later version.
010:         *
011:         * Please see COPYING for the complete licence.
012:         */
013:        package org.wings.plaf.css;
014:
015:        import org.wings.SComponent;
016:        import org.wings.SConstants;
017:        import org.wings.SFlowLayout;
018:        import org.wings.SLayoutManager;
019:        import org.wings.io.Device;
020:        import org.wings.util.SStringBuilder;
021:
022:        import java.awt.*;
023:        import java.io.IOException;
024:        import java.util.Iterator;
025:        import java.util.List;
026:
027:        public class FlowLayoutCG extends AbstractLayoutCG {
028:            private static final long serialVersionUID = 1L;
029:
030:            /**
031:             * @param d the device to write the code to
032:             * @param l the layout manager
033:             * @throws IOException
034:             */
035:            public void write(Device d, SLayoutManager l) throws IOException {
036:                final SFlowLayout layout = (SFlowLayout) l;
037:                final Insets insets = convertGapsToInset(layout.getHgap(),
038:                        layout.getVgap());
039:                final List components = layout.getComponents();
040:                final int alignment = layout.getAlignment();
041:
042:                openLayouterBody(d, layout);
043:                d.print("<tr><td");
044:                Utils.printDivHorizontalAlignment(d,
045:                        alignment != SConstants.NO_ALIGN ? alignment
046:                                : SConstants.LEFT_ALIGN);
047:                Utils.printDivVerticalAlignment(d, SConstants.TOP_ALIGN);
048:                if (alignment == SConstants.CENTER) {
049:                    // Cheat -- margin left/right to simulate center float. Will not wrap
050:                    d.print(" style=\"margin-left:auto; margin-right:auto\"");
051:                } else {
052:                    d.print(" style=\"width:100%\""); // gecko bug workaround: inherit surrounding panel bg color.
053:                }
054:                d.print(" class=\"SFlowLayout\">");
055:
056:                final String alignmentStyle;
057:                if (alignment == SConstants.LEFT) {
058:                    alignmentStyle = "float:left;";
059:                } else if (alignment == SConstants.RIGHT) {
060:                    alignmentStyle = "float:right;";
061:                } else if (alignment == SConstants.CENTER) {
062:                    alignmentStyle = "float:left; "; // Floating does not work with center :-(
063:                } else {
064:                    alignmentStyle = "";
065:                }
066:
067:                if (alignment == SConstants.CENTER) {
068:                    d.print("<table><tr><td>");
069:                }
070:
071:                if (components.size() > 1) {
072:                    /* We need two spacer divs (end/beginning) so that the sourrounding flow layout takes up
073:                       the whole space instead of 0px heigth. See http://www.alistapart.com/articles/practicalcss/. 
074:                       The nbsp's are only needed for firefox... */
075:                    d.print("<div class=\"spacer\"></div>");
076:
077:                    for (int x = 0, y = components.size(); x < y; x++) {
078:                        printComponent(d, (SComponent) components.get(x),
079:                                alignmentStyle, insets);
080:                    }
081:
082:                    /* Second spacer. See upper. */
083:                    d.print("<div class=\"spacer\"></div>");
084:                } else if (components.size() == 1) {
085:                    // Special handling of trivial case
086:                    //
087:                    // Why: FlowLayout may be default for many containers.
088:                    // BUT: The effect is that in MSIE oversized, floating componentns DO NOT lead to a scrollbar
089:                    //
090:                    // Try this:
091:                    //    <TABLE><TR style="background-color:yellow; border:5px solid red" ><TD>
092:                    //        <DIV style="WIDTH: 100%" align=left >
093:                    //          <DIV class=spacer></DIV>
094:                    //      <DIV style="FLOAT: left; border:2px solid blue;">
095:                    //     <table width="1000" heigth=10 bgcolor="#ff000"><tr>
096:                    //     <td align=center>1000px widht</td></tr></table>
097:                    //      </div>
098:                    //      <DIV class=spacer></DIV>
099:                    //     </div>
100:                    //    </td></tr></table>
101:                    printComponent(d, (SComponent) components.get(0), "",
102:                            insets);
103:                }
104:
105:                if (alignment == SConstants.CENTER) {
106:                    d.print("</td></tr></table>");
107:                }
108:
109:                d.print("</td></tr>");
110:                closeLayouterBody(d, layout);
111:            }
112:
113:            private void printComponent(Device d, SComponent component,
114:                    String alignmentStlye, Insets insets) throws IOException {
115:                if (component.isVisible()) {
116:                    Utils.printNewline(d, component);
117:                    d.print("<div");
118:                    Utils.optAttribute(d, "style", Utils
119:                            .createInlineStylesForInsets(new SStringBuilder(
120:                                    alignmentStlye), insets));
121:                    d.print(">");
122:                    component.write(d); // Render contained component
123:                    Utils.printNewline(d, component);
124:                    d.print("</div>");
125:                }
126:            }
127:
128:            protected int getLayoutHGap(SLayoutManager layout) {
129:                SFlowLayout flowLayout = (SFlowLayout) layout;
130:                return flowLayout.getHgap();
131:            }
132:
133:            protected int getLayoutVGap(SLayoutManager layout) {
134:                SFlowLayout flowLayout = (SFlowLayout) layout;
135:                return flowLayout.getVgap();
136:            }
137:
138:            protected int getLayoutBorder(SLayoutManager layout) {
139:                SFlowLayout flowLayout = (SFlowLayout) layout;
140:                return flowLayout.getBorder();
141:            }
142:
143:            protected int layoutOversize(SLayoutManager layout) {
144:                return 0;
145:            }
146:
147:            public int getDefaultLayoutCellHAlignment() {
148:                return SConstants.NO_ALIGN; // Don't knoff.
149:            }
150:
151:            public int getDefaultLayoutCellVAlignment() {
152:                return SConstants.NO_ALIGN; // Don't knoff.
153:            }
154:
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.