Source Code Cross Referenced for FillLayout.java in  » Ajax » MyGWT » net » mygwt » ui » client » widget » layout » 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 » MyGWT » net.mygwt.ui.client.widget.layout 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *     Darrell Meyer <darrell@mygwt.net> - derived implementation
011:         *******************************************************************************/package net.mygwt.ui.client.widget.layout;
012:
013:        import net.mygwt.ui.client.MyDOM;
014:        import net.mygwt.ui.client.Style;
015:        import net.mygwt.ui.client.util.Rectangle;
016:        import net.mygwt.ui.client.widget.Layout;
017:        import net.mygwt.ui.client.widget.WidgetContainer;
018:
019:        import com.google.gwt.user.client.Element;
020:        import com.google.gwt.user.client.ui.Widget;
021:
022:        /**
023:         * <code>FillLayout</code> lays out widgets in a single row or column, forcing
024:         * them to be the same size.
025:         */
026:        public class FillLayout extends Layout {
027:
028:            int margin = 0;
029:            int spacing = 0;
030:            int type = Style.HORIZONTAL;
031:
032:            /**
033:             * Creates a new layout instance.
034:             */
035:            public FillLayout() {
036:
037:            }
038:
039:            /**
040:             * Creates a new instance with the given margin.
041:             * 
042:             * @param margin the margin in pixels
043:             */
044:            public FillLayout(int margin) {
045:                this .margin = margin;
046:            }
047:
048:            /**
049:             * Returns the margin.
050:             * 
051:             * @return the margin
052:             */
053:            public int getMargin() {
054:                return margin;
055:            }
056:
057:            /**
058:             * Returns the spacing.
059:             * 
060:             * @return the spacing in pixels
061:             */
062:            public int getSpacing() {
063:                return spacing;
064:            }
065:
066:            /**
067:             * Returns the type.
068:             * 
069:             * @return the type
070:             */
071:            public int getType() {
072:                return type;
073:            }
074:
075:            /**
076:             * Sets the number of pixels of margin that will be placed along the edges of
077:             * the layout. The default value is 0.
078:             * 
079:             * @param margin the margin in pixels
080:             */
081:            public void setMargin(int margin) {
082:                this .margin = margin;
083:            }
084:
085:            /**
086:             * Sets the number of pixels between the edge of one cell and the edge of its
087:             * neighbouring cell. The default value is 0.
088:             * 
089:             * @param spacing the spacing in pixels.
090:             */
091:            public void setSpacing(int spacing) {
092:                this .spacing = spacing;
093:            }
094:
095:            /**
096:             * Sets how widgets will be positioned within the layout. The default value is
097:             * HORIZONTAL.
098:             * 
099:             * @param type the type
100:             */
101:            public void setType(int type) {
102:                this .type = type;
103:            }
104:
105:            protected void onLayout(WidgetContainer container, Element target) {
106:                super .onLayout(container, target);
107:
108:                int count = container.getWidgetCount();
109:                if (count < 1) {
110:                    return;
111:                }
112:
113:                for (int i = 0; i < count; i++) {
114:                    Widget w = container.getWidget(i);
115:                    MyDOM.makePositionable(w.getElement(), count != 1);
116:                }
117:
118:                Element ct = container.getLayoutTarget();
119:
120:                Rectangle rect = MyDOM.getBounds(ct, true);
121:
122:                int width = rect.width - margin * 2;
123:                int height = rect.height - margin * 2;
124:
125:                if (type == Style.HORIZONTAL) {
126:                    width -= (count - 1) * spacing;
127:                    int x = rect.x + margin, extra = width % count;
128:                    int y = rect.y + margin, cellWidth = width / count;
129:                    x -= MyDOM.getScrollLeft(ct);
130:                    y -= MyDOM.getScrollTop(ct);
131:                    for (int i = 0; i < count; i++) {
132:                        Widget child = container.getWidget(i);
133:                        int childWidth = cellWidth;
134:                        if (i == 0) {
135:                            childWidth += extra / 2;
136:                        } else {
137:                            if (i == count - 1)
138:                                childWidth += (extra + 1) / 2;
139:                        }
140:                        setBounds(child, x, y, childWidth, height);
141:                        x += childWidth + spacing;
142:                    }
143:                } else {
144:                    height -= (count - 1) * spacing;
145:                    int x = rect.x + margin, cellHeight = height / count;
146:                    int y = rect.y + margin, extra = height % count;
147:                    x -= MyDOM.getScrollLeft(ct);
148:                    y -= MyDOM.getScrollTop(ct);
149:                    for (int i = 0; i < count; i++) {
150:                        Widget child = container.getWidget(i);
151:                        int childHeight = cellHeight;
152:                        if (i == 0) {
153:                            childHeight += extra / 2;
154:                        } else {
155:                            if (i == count - 1)
156:                                childHeight += (extra + 1) / 2;
157:                        }
158:                        setBounds(child, x, y, width, childHeight);
159:                        y += childHeight + spacing;
160:                    }
161:                }
162:            }
163:
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.