Source Code Cross Referenced for Region.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hssf » 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 » Collaboration » poi 3.0.2 beta2 » org.apache.poi.hssf.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:           Licensed to the Apache Software Foundation (ASF) under one or more
003:           contributor license agreements.  See the NOTICE file distributed with
004:           this work for additional information regarding copyright ownership.
005:           The ASF licenses this file to You under the Apache License, Version 2.0
006:           (the "License"); you may not use this file except in compliance with
007:           the License.  You may obtain a copy of the License at
008:
009:               http://www.apache.org/licenses/LICENSE-2.0
010:
011:           Unless required by applicable law or agreed to in writing, software
012:           distributed under the License is distributed on an "AS IS" BASIS,
013:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:           See the License for the specific language governing permissions and
015:           limitations under the License.
016:        ==================================================================== */
017:
018:        package org.apache.poi.hssf.util;
019:
020:        import org.apache.poi.hssf.record.MergeCellsRecord.MergedRegion;
021:
022:        /**
023:         * Represents a from/to row/col square.  This is a object primitive
024:         * that can be used to represent row,col - row,col just as one would use String
025:         * to represent a string of characters.  Its really only useful for HSSF though.
026:         *
027:         * @author  Andrew C. Oliver acoliver at apache dot org
028:         */
029:
030:        public class Region implements  Comparable {
031:            private int rowFrom;
032:            private short colFrom;
033:            private int rowTo;
034:            private short colTo;
035:
036:            /**
037:             * Creates a new instance of Region (0,0 - 0,0)
038:             */
039:
040:            public Region() {
041:            }
042:
043:            public Region(int rowFrom, short colFrom, int rowTo, short colTo) {
044:                this .rowFrom = rowFrom;
045:                this .rowTo = rowTo;
046:                this .colFrom = colFrom;
047:                this .colTo = colTo;
048:            }
049:
050:            /**
051:             * special constructor (I know this is bad but it is so wrong that its right
052:             * okay) that makes a region from a mergedcells's region subrecord.
053:             */
054:
055:            public Region(MergedRegion region) {
056:                this (region.row_from, region.col_from, region.row_to,
057:                        region.col_to);
058:            }
059:
060:            /**
061:             * get the upper left hand corner column number
062:             *
063:             * @return column number for the upper left hand corner
064:             */
065:
066:            public short getColumnFrom() {
067:                return colFrom;
068:            }
069:
070:            /**
071:             * get the upper left hand corner row number
072:             *
073:             * @return row number for the upper left hand corner
074:             */
075:
076:            public int getRowFrom() {
077:                return rowFrom;
078:            }
079:
080:            /**
081:             * get the lower right hand corner column number
082:             *
083:             * @return column number for the lower right hand corner
084:             */
085:
086:            public short getColumnTo() {
087:                return colTo;
088:            }
089:
090:            /**
091:             * get the lower right hand corner row number
092:             *
093:             * @return row number for the lower right hand corner
094:             */
095:
096:            public int getRowTo() {
097:                return rowTo;
098:            }
099:
100:            /**
101:             * set the upper left hand corner column number
102:             *
103:             * @param colFrom  column number for the upper left hand corner
104:             */
105:
106:            public void setColumnFrom(short colFrom) {
107:                this .colFrom = colFrom;
108:            }
109:
110:            /**
111:             * set the upper left hand corner row number
112:             *
113:             * @param rowFrom  row number for the upper left hand corner
114:             */
115:
116:            public void setRowFrom(int rowFrom) {
117:                this .rowFrom = rowFrom;
118:            }
119:
120:            /**
121:             * set the lower right hand corner column number
122:             *
123:             * @param colTo  column number for the lower right hand corner
124:             */
125:
126:            public void setColumnTo(short colTo) {
127:                this .colTo = colTo;
128:            }
129:
130:            /**
131:             * get the lower right hand corner row number
132:             *
133:             * @param rowTo  row number for the lower right hand corner
134:             */
135:
136:            public void setRowTo(int rowTo) {
137:                this .rowTo = rowTo;
138:            }
139:
140:            /**
141:             * Answers: "is the row/column inside this range?"
142:             *
143:             * @return <code>true</code> if the cell is in the range and
144:             * <code>false</code> if it is not
145:             */
146:
147:            public boolean contains(int row, short col) {
148:                if ((this .rowFrom <= row) && (this .rowTo >= row)
149:                        && (this .colFrom <= col) && (this .colTo >= col)) {
150:
151:                    //                System.out.println("Region ("+rowFrom+","+colFrom+","+rowTo+","+ 
152:                    //                                   colTo+") does contain "+row+","+col);
153:                    return true;
154:                }
155:                return false;
156:            }
157:
158:            public boolean equals(Region r) {
159:                return (compareTo(r) == 0);
160:            }
161:
162:            /**
163:             * Compares that the given region is the same less than or greater than this
164:             * region.  If any regional coordiant passed in is less than this regions
165:             * coordinants then a positive integer is returned.  Otherwise a negative
166:             * integer is returned.
167:             *
168:             * @param r  region
169:             * @see #compareTo(Object)
170:             */
171:
172:            public int compareTo(Region r) {
173:                if ((this .getRowFrom() == r.getRowFrom())
174:                        && (this .getColumnFrom() == r.getColumnFrom())
175:                        && (this .getRowTo() == r.getRowTo())
176:                        && (this .getColumnTo() == r.getColumnTo())) {
177:                    return 0;
178:                }
179:                if ((this .getRowFrom() < r.getRowFrom())
180:                        || (this .getColumnFrom() < r.getColumnFrom())
181:                        || (this .getRowTo() < r.getRowTo())
182:                        || (this .getColumnTo() < r.getColumnTo())) {
183:                    return 1;
184:                }
185:                return -1;
186:            }
187:
188:            public int compareTo(Object o) {
189:                return compareTo((Region) o);
190:            }
191:
192:            /**
193:             * @return the area contained by this region (number of cells)
194:             */
195:
196:            public int getArea() {
197:                return ((1 + (getRowTo() - getRowFrom())) * (1 + (getColumnTo() - getColumnFrom())));
198:            }
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.