root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / FPolygon2DM.java @ 32872
History | View | Annotate | Download (2.81 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2010 Software Colaborativo (www.scolab.es) development
|
26 |
*/
|
27 |
|
28 |
package com.iver.cit.gvsig.fmap.core; |
29 |
|
30 |
import java.awt.geom.PathIterator; |
31 |
import java.awt.geom.Rectangle2D; |
32 |
|
33 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
34 |
|
35 |
public class FPolygon2DM extends FPolyline2DM implements FShapeM { |
36 |
|
37 |
/**
|
38 |
*
|
39 |
*/
|
40 |
private static final long serialVersionUID = -3376505816513737862L; |
41 |
|
42 |
public FPolygon2DM(GeneralPathX gpx, double[] pm) { |
43 |
super(gpx, pm);
|
44 |
// TODO Auto-generated constructor stub
|
45 |
} |
46 |
|
47 |
@Override
|
48 |
public FShape cloneFShape() {
|
49 |
return new FPolygon2DM((GeneralPathX) gp.clone(), (double[]) pM); |
50 |
} |
51 |
|
52 |
@Override
|
53 |
public int getShapeType() { |
54 |
return FShape.POLYGON | FShape.M;
|
55 |
} |
56 |
|
57 |
@Override
|
58 |
public String toText() { |
59 |
StringBuffer str = new StringBuffer(); |
60 |
str.append("MULTIPOLYGONM");
|
61 |
str.append(" ((");
|
62 |
int theType;
|
63 |
double[] theData = new double[6]; |
64 |
|
65 |
PathIterator theIterator = getPathIterator(null, FConverter.FLATNESS); |
66 |
int i = 0; |
67 |
|
68 |
while (!theIterator.isDone()) {
|
69 |
//while not done
|
70 |
theType = theIterator.currentSegment(theData); |
71 |
|
72 |
double m = 0.0; |
73 |
if (i < pM.length){
|
74 |
m = pM[i]; |
75 |
} |
76 |
|
77 |
switch (theType) {
|
78 |
case PathIterator.SEG_MOVETO: |
79 |
str.append(theData[0] + " " + theData[1] + " " + m + ","); |
80 |
break;
|
81 |
|
82 |
case PathIterator.SEG_LINETO: |
83 |
str.append(theData[0] + " " + theData[1] + " " + m + ","); |
84 |
|
85 |
break;
|
86 |
|
87 |
case PathIterator.SEG_QUADTO: |
88 |
System.out.println("Not supported here"); |
89 |
|
90 |
break;
|
91 |
|
92 |
case PathIterator.SEG_CUBICTO: |
93 |
System.out.println("Not supported here"); |
94 |
|
95 |
break;
|
96 |
|
97 |
case PathIterator.SEG_CLOSE: |
98 |
break;
|
99 |
} //end switch
|
100 |
|
101 |
theIterator.next(); |
102 |
i++; |
103 |
} //end while loop
|
104 |
return str.delete(str.length()-1, str.length()) + "))"; |
105 |
|
106 |
} |
107 |
|
108 |
@Override
|
109 |
public boolean intersects(Rectangle2D r) { |
110 |
return gp.intersects(r);
|
111 |
} |
112 |
|
113 |
} |
114 |
|