Source Code Cross Referenced for Measurer.java in  » XML-UI » XUI » net » xoetrope » xui » helper » 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 » XUI » net.xoetrope.xui.helper 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.xui.helper;
002:
003:        import java.awt.Container;
004:
005:        /**
006:         * <p>A helper class to assist in positioning rows and columns of
007:         * components within a container. The containers width is divided into columns
008:         * and the height is divided into rows. Each cell is padded on either side.<br>
009:         * No attempt is made to constrain the measurements. Therefore if an attempt is
010:         * made to call nextX or nextY more times than there are rows or columns
011:         * respectively then dimensions beyond the bounds on the container will be
012:         * returned.</p>
013:         * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003<br>
014:         * License:      see license.txt
015:         * @version $Revision: 1.22 $
016:         */
017:        public class Measurer {
018:            private int width;
019:            private int height;
020:            private int x;
021:            private int y;
022:            private int padX;
023:            private int padY;
024:            private int cellWidth;
025:            private int cellHeight;
026:
027:            /**
028:             * Constructs a new Measurer.
029:             * @param cont the container to be dividied
030:             * @param rows the number of rows into which the container's height is divided
031:             * @param cols the number of columns into which the container's width is divided
032:             * @param horzPadding the amount of padding on the left and right of the cell
033:             * @param vertPadding the amount of padding on the top and bottom of the cell
034:             */
035:            public Measurer(Container cont, int rows, int cols,
036:                    int horzPadding, int vertPadding) {
037:                width = cont.getSize().width;
038:                height = cont.getSize().height;
039:
040:                padX = horzPadding;
041:                padY = vertPadding;
042:
043:                // Calculate padding on either side of the cell object.
044:                cellWidth = width / cols;
045:                cellHeight = height / rows;
046:
047:                // Simplify the nextX, nextY methods by allowing uniform incrementing, without
048:                // a special initail case.
049:                x = -cellWidth;
050:                y = -cellHeight;
051:            }
052:
053:            /**
054:             * Get the left hand coordinate. The coordinate includes the cell padding
055:             * @return the new coordinate
056:             */
057:            public int getNextX() {
058:                x += cellWidth;
059:                return x + padX;
060:            }
061:
062:            /**
063:             * Get the top coordinate. The coordinate includes the cell padding
064:             * @return the new coordinate
065:             */
066:            public int getNextY() {
067:                y += cellHeight;
068:                return y + padY;
069:            }
070:
071:            /**
072:             * Get the cell width including padding
073:             * @return the cell width
074:             */
075:            public int getCellWidth() {
076:                return cellWidth;
077:            }
078:
079:            /**
080:             * Get the cell width including padding
081:             * @return the cell height
082:             */
083:            public int getCellHeight() {
084:                return cellHeight;
085:            }
086:
087:            /**
088:             * Get the cell width including padding (the cell width less the padding)
089:             * @return the cell width
090:             */
091:            public int getWidth() {
092:                return cellWidth - 2 * padX;
093:            }
094:
095:            /**
096:             * Get the cell content's height (the cell height less the padding)
097:             * @return the cell height
098:             */
099:            public int getHeight() {
100:                return cellHeight - 2 * padY;
101:            }
102:
103:            /**
104:             * Get the remaining width available for a component, taking account of the
105:             * required padding
106:             * @return the remaining width
107:             */
108:            public int getRemainingWidth() {
109:                return width - x - cellWidth - 2 * padX;
110:            }
111:
112:            /**
113:             * Get the remaining height available for a component, taking account of the
114:             * required padding
115:             * @return the remaining height
116:             */
117:            public int getRemainingHeight() {
118:                return height - y - cellHeight - 2 * padY;
119:            }
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.