Source Code Cross Referenced for MultiCurveImpl.java in  » GIS » deegree » org » deegree » model » spatialschema » 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 » GIS » deegree » org.deegree.model.spatialschema 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/model/spatialschema/MultiCurveImpl.java $
002:        /*----------------    FILE HEADER  ------------------------------------------
003:
004:         This file is part of deegree.
005:         Copyright (C) 2001-2008 by:
006:         EXSE, Department of Geography, University of Bonn
007:         http://www.giub.uni-bonn.de/deegree/
008:         lat/lon GmbH
009:         http://www.lat-lon.de
010:
011:         This library is free software; you can redistribute it and/or
012:         modify it under the terms of the GNU Lesser General Public
013:         License as published by the Free Software Foundation; either
014:         version 2.1 of the License, or (at your option) any later version.
015:
016:         This library is distributed in the hope that it will be useful,
017:         but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019:         Lesser General Public License for more details.
020:
021:         You should have received a copy of the GNU Lesser General Public
022:         License along with this library; if not, write to the Free Software
023:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024:
025:         Contact:
026:
027:         Andreas Poth
028:         lat/lon GmbH
029:         Aennchenstr. 19
030:         53115 Bonn
031:         Germany
032:         E-Mail: poth@lat-lon.de
033:
034:         Prof. Dr. Klaus Greve
035:         Department of Geography
036:         University of Bonn
037:         Meckenheimer Allee 166
038:         53115 Bonn
039:         Germany
040:         E-Mail: greve@giub.uni-bonn.de
041:
042:        
043:         ---------------------------------------------------------------------------*/
044:        package org.deegree.model.spatialschema;
045:
046:        import java.io.Serializable;
047:
048:        import org.deegree.framework.log.ILogger;
049:        import org.deegree.framework.log.LoggerFactory;
050:        import org.deegree.model.crs.CoordinateSystem;
051:
052:        /**
053:         * default implementation of the MultiCurve interface from package jago.model.
054:         * 
055:         * ------------------------------------------------------------
056:         * 
057:         * @version 12.6.2001
058:         * @author Andreas Poth
059:         */
060:        final class MultiCurveImpl extends MultiPrimitiveImpl implements 
061:                MultiCurve, Serializable {
062:            /** Use serialVersionUID for interoperability. */
063:            private final static long serialVersionUID = 2730942874409216686L;
064:
065:            private static final ILogger LOG = LoggerFactory
066:                    .getLogger(MultiCurveImpl.class);
067:
068:            /**
069:             * Creates a new MultiCurveImpl object.
070:             * 
071:             * @param crs
072:             */
073:            public MultiCurveImpl(CoordinateSystem crs) {
074:                super (crs);
075:            }
076:
077:            /**
078:             * Creates a new MultiCurveImpl object.
079:             * 
080:             * @param gmc
081:             */
082:            public MultiCurveImpl(Curve[] gmc) {
083:                super (gmc[0].getCoordinateSystem());
084:
085:                for (int i = 0; i < gmc.length; i++) {
086:                    aggregate.add(gmc[i]);
087:                }
088:
089:            }
090:
091:            /**
092:             * Creates a new MultiCurveImpl object.
093:             * 
094:             * @param gmc
095:             * @param crs
096:             */
097:            public MultiCurveImpl(Curve[] gmc, CoordinateSystem crs) {
098:                super (crs);
099:
100:                for (int i = 0; i < gmc.length; i++) {
101:                    aggregate.add(gmc[i]);
102:                }
103:
104:            }
105:
106:            /**
107:             * adds a Curve to the aggregation
108:             */
109:            public void addCurve(Curve gmc) {
110:                super .add(gmc);
111:            }
112:
113:            /**
114:             * inserts a Curve in the aggregation. all elements with an index equal or larger index will be
115:             * moved. if index is larger then getSize() - 1 or smaller then 0 or gmc equals null an
116:             * exception will be thrown.
117:             * 
118:             * @param gmc
119:             *            Curve to insert.
120:             * @param index
121:             *            position where to insert the new Curve
122:             */
123:            public void insertCurveAt(Curve gmc, int index)
124:                    throws GeometryException {
125:                super .insertObjectAt(gmc, index);
126:            }
127:
128:            /**
129:             * sets the submitted Curve at the submitted index. the element at the position
130:             * <code>index</code> will be removed. if index is larger then getSize() - 1 or smaller then 0
131:             * or gmc equals null an exception will be thrown.
132:             * 
133:             * @param gmc
134:             *            Curve to set.
135:             * @param index
136:             *            position where to set the new Curve
137:             */
138:            public void setCurveAt(Curve gmc, int index)
139:                    throws GeometryException {
140:                setObjectAt(gmc, index);
141:            }
142:
143:            /**
144:             * removes the submitted Curve from the aggregation
145:             * 
146:             * @return the removed Curve
147:             */
148:            public Curve removeCurve(Curve gmc) {
149:                return (Curve) super .removeObject(gmc);
150:            }
151:
152:            /**
153:             * removes the Curve at the submitted index from the aggregation. if index is larger then
154:             * getSize() - 1 or smaller then 0 an exception will be thrown.
155:             * 
156:             * @return the removed Curve
157:             */
158:            public Curve removeCurveAt(int index) throws GeometryException {
159:                return (Curve) super .removeObjectAt(index);
160:            }
161:
162:            /**
163:             * removes all Curve from the aggregation.
164:             */
165:            public void removeAll() {
166:                super .removeAll();
167:            }
168:
169:            /**
170:             * returns the Curve at the submitted index.
171:             */
172:            public Curve getCurveAt(int index) {
173:                return (Curve) super .getPrimitiveAt(index);
174:            }
175:
176:            /**
177:             * returns all Curves as array
178:             */
179:            public Curve[] getAllCurves() {
180:                return aggregate.toArray(new Curve[getSize()]);
181:            }
182:
183:            /**
184:             * returns true if the submitted Curve is within the aggregation
185:             */
186:            public boolean isMember(Curve gmc) {
187:                return super .isMember(gmc);
188:            }
189:
190:            /**
191:             * returns the boundary of the MultiCurve
192:             * <p>
193:             * not implemented yet
194:             */
195:            public Boundary getBoundary() {
196:                return null;
197:            }
198:
199:            /**
200:             * calculates the bounding box / envelope of the aggregation
201:             */
202:            protected void calculateEnvelope() {
203:                Envelope bb = getCurveAt(0).getEnvelope();
204:
205:                double[] min = bb.getMin().getAsArray().clone();
206:                double[] max = bb.getMax().getAsArray().clone();
207:
208:                for (int i = 1; i < getSize(); i++) {
209:                    double[] pos1 = getCurveAt(i).getEnvelope().getMin()
210:                            .getAsArray();
211:                    double[] pos2 = getCurveAt(i).getEnvelope().getMax()
212:                            .getAsArray();
213:
214:                    for (int j = 0; j < pos1.length; j++) {
215:                        if (pos1[j] < min[j]) {
216:                            min[j] = pos1[j];
217:                        } else if (pos1[j] > max[j]) {
218:                            max[j] = pos1[j];
219:                        }
220:
221:                        if (pos2[j] < min[j]) {
222:                            min[j] = pos2[j];
223:                        } else if (pos2[j] > max[j]) {
224:                            max[j] = pos2[j];
225:                        }
226:                    }
227:                }
228:
229:                envelope = new EnvelopeImpl(new PositionImpl(min),
230:                        new PositionImpl(max), this .crs);
231:            }
232:
233:            /**
234:             * calculates the centroid of the aggregation
235:             */
236:            protected void calculateCentroid() {
237:                try {
238:                    double cnt = 0;
239:                    Point gmp = getCurveAt(0).getCentroid();
240:
241:                    double[] cen = new double[gmp.getAsArray().length];
242:
243:                    for (int i = 0; i < getSize(); i++) {
244:                        cnt += getCurveAt(i).getNumberOfCurveSegments();
245:
246:                        double[] pos = getCurveAt(i).getCentroid().getAsArray();
247:
248:                        for (int j = 0; j < getCoordinateDimension(); j++) {
249:                            cen[j] += pos[j];
250:                        }
251:                    }
252:
253:                    for (int j = 0; j < getCoordinateDimension(); j++) {
254:                        cen[j] = cen[j] / cnt / getSize();
255:                    }
256:
257:                    centroid = new PointImpl(new PositionImpl(cen), null);
258:                } catch (Exception ex) {
259:                    LOG.logError("", ex);
260:                }
261:            }
262:
263:            /**
264:             * calculates the centroid and envelope of the aggregation
265:             */
266:            protected void calculateParam() {
267:                calculateCentroid();
268:                calculateEnvelope();
269:                setValid(true);
270:            }
271:
272:            /**
273:             * The operation "dimension" shall return the inherent dimension of this Geometry, which shall
274:             * be less than or equal to the coordinate dimension. The dimension of a collection of geometric
275:             * objects shall be the largest dimension of any of its pieces. Points are 0-dimensional, curves
276:             * are 1-dimensional, surfaces are 2-dimensional, and solids are 3-dimensional.
277:             */
278:            public int getDimension() {
279:                return 1;
280:            }
281:
282:            /**
283:             * The operation "coordinateDimension" shall return the dimension of the coordinates that define
284:             * this Geometry, which must be the same as the coordinate dimension of the coordinate reference
285:             * system for this Geometry.
286:             */
287:            public int getCoordinateDimension() {
288:                return getCurveAt(0).getCoordinateDimension();
289:            }
290:
291:            /**
292:             * returns a shallow copy of the geometry
293:             */
294:            public Object clone() {
295:                MultiCurve mc = null;
296:
297:                try {
298:                    mc = new MultiCurveImpl(getCoordinateSystem());
299:
300:                    for (int i = 0; i < this .getSize(); i++) {
301:                        CurveImpl ci = (CurveImpl) getCurveAt(i);
302:                        mc.addCurve((Curve) ci.clone());
303:                    }
304:                } catch (Exception ex) {
305:                    LOG.logError("MultiCurve_Impl.clone: ", ex);
306:                }
307:
308:                return mc;
309:            }
310:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.