Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.jts / src / main / java / org / gvsig / fmap / geom / jts / aggregate / AbstractMultiLine.java @ 42283

History | View | Annotate | Download (6.57 KB)

1 42267 fdiaz
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2015 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.geom.jts.aggregate;
24
25 42278 fdiaz
import java.awt.Shape;
26 42274 fdiaz
import java.awt.geom.AffineTransform;
27
import java.awt.geom.PathIterator;
28
import java.util.ArrayList;
29
import java.util.Iterator;
30
import java.util.List;
31
32
import com.vividsolutions.jts.geom.LineString;
33
34 42283 fdiaz
import org.gvsig.fmap.geom.Geometry;
35
import org.gvsig.fmap.geom.GeometryException;
36 42267 fdiaz
import org.gvsig.fmap.geom.aggregate.MultiLine;
37 42274 fdiaz
import org.gvsig.fmap.geom.jts.GeometryJTS;
38 42277 fdiaz
import org.gvsig.fmap.geom.jts.gputils.DefaultGeneralPathX;
39 42274 fdiaz
import org.gvsig.fmap.geom.jts.gputils.GeneralPathXIterator;
40
import org.gvsig.fmap.geom.jts.util.JTSUtils;
41 42281 fdiaz
import org.gvsig.fmap.geom.operation.GeometryOperationException;
42
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
43 42274 fdiaz
import org.gvsig.fmap.geom.primitive.GeneralPathX;
44
import org.gvsig.fmap.geom.primitive.Primitive;
45 42267 fdiaz
46
47
/**
48
 * @author fdiaz
49
 *
50
 */
51
public abstract class AbstractMultiLine extends AbstractMultiCurve implements MultiLine {
52
53
    /**
54
     *
55
     */
56
    private static final long serialVersionUID = 3585059833766514177L;
57
58
    /**
59
     * @param type
60
     */
61
    public AbstractMultiLine(int subtype) {
62 42283 fdiaz
        super(Geometry.TYPES.MULTILINE, subtype);
63 42267 fdiaz
    }
64
65 42274 fdiaz
66
    /* (non-Javadoc)
67
     * @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS()
68
     */
69
    public com.vividsolutions.jts.geom.Geometry getJTS() {
70 42283 fdiaz
        LineString[] lineStrings = new LineString[primitives.size()];
71
        for(int i=0; i<primitives.size(); i++){
72
            lineStrings[i]=(LineString) ((GeometryJTS)primitives.get(i)).getJTS();
73 42274 fdiaz
        }
74 42283 fdiaz
        return JTSUtils.createJTSMultiLineString(lineStrings);
75 42274 fdiaz
    }
76
77 42283 fdiaz
//    /* (non-Javadoc)
78
//     * @see org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform)
79
//     */
80
//    public PathIterator getPathIterator(AffineTransform at) {
81
//        MultiLineIterator pi = new MultiLineIterator(at);
82
//        return pi;
83
//    }
84
//
85
//    /* (non-Javadoc)
86
//     * @see org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform, double)
87
//     */
88
//    public PathIterator getPathIterator(AffineTransform at, double flatness) {
89
//        return getPathIterator(at);
90
//    }
91
//
92
//    /* (non-Javadoc)
93
//     * @see org.gvsig.fmap.geom.Geometry#getGeneralPath()
94
//     */
95
//    public GeneralPathX getGeneralPath() {
96
//        return new DefaultGeneralPathX(getPathIterator(null), false, 0);
97
//    }
98
//
99
//    protected class MultiLineIterator extends GeneralPathXIterator {
100
//
101
//        /** Transform applied on the coordinates during iteration */
102
//        private AffineTransform at;
103
//
104
//        /** True when the point has been read once */
105
//        private boolean done;
106
//        private int index = 0;
107
//        private List<PathIterator>iterators = new ArrayList<PathIterator>(primitives.size());
108
//
109
//        /**
110
//         * Creates a new PointIterator object.
111
//         *
112
//         * @param p
113
//         *            The polygon
114
//         * @param at
115
//         *            The affine transform applied to coordinates during
116
//         *            iteration
117
//         */
118
//        public MultiLineIterator(AffineTransform at) {
119
//            super(new GeneralPathX());
120
//            if (at == null) {
121
//                at = new AffineTransform();
122
//            }
123
//
124
//            this.at = at;
125
//            for (Iterator iterator = primitives.iterator(); iterator.hasNext();) {
126
//                Primitive primitive = (Primitive) iterator.next();
127
//                iterators.add(primitive.getPathIterator(at));
128
//            }
129
//            done = false;
130
//        }
131
//
132
//        /**
133
//         * Return the winding rule for determining the interior of the path.
134
//         *
135
//         * @return <code>WIND_EVEN_ODD</code> by default.
136
//         */
137
//        public int getWindingRule() {
138
//            return PathIterator.WIND_EVEN_ODD;
139
//        }
140
//
141
//        /**
142
//         * @see java.awt.geom.PathIterator#next()
143
//         */
144
//        public void next() {
145
//            PathIterator pathIteratorPrimitive = iterators.get(index);
146
//            pathIteratorPrimitive.next();
147
//            if(pathIteratorPrimitive.isDone()){
148
//                index++;
149
//                done = (index==primitives.size());
150
//            }
151
//        }
152
//
153
//        /**
154
//         * @see java.awt.geom.PathIterator#isDone()
155
//         */
156
//        public boolean isDone() {
157
//            return done;
158
//        }
159
//
160
//        /**
161
//         * @see java.awt.geom.PathIterator#currentSegment(double[])
162
//         */
163
//        public int currentSegment(double[] coords) {
164
//            return iterators.get(index).currentSegment(coords);
165
//        }
166
//
167
//        /*
168
//         * (non-Javadoc)
169
//         *
170
//         * @see java.awt.geom.PathIterator#currentSegment(float[])
171
//         */
172
//        public int currentSegment(float[] coords) {
173
//            return iterators.get(index).currentSegment(coords);
174
//        }
175
//    }
176
//
177
//
178
//    /*
179
//     * (non-Javadoc)
180
//     *
181
//     * @see org.gvsig.fmap.geom.Geometry#getShape(java.awt.geom.AffineTransform)
182
//     */
183
//    public Shape getShape(AffineTransform affineTransform) {
184
//        return new DefaultGeneralPathX(getPathIterator(affineTransform),false,0);
185
//    }
186
//
187
//    /*
188
//     * (non-Javadoc)
189
//     *
190
//     * @see org.gvsig.fmap.geom.Geometry#getShape()
191
//     */
192
//    public Shape getShape() {
193
//        return new DefaultGeneralPathX(getPathIterator(null),false,0);
194
//    }
195 42274 fdiaz
196
    /* (non-Javadoc)
197 42281 fdiaz
     * @see org.gvsig.fmap.geom.jts.GeometryJTS#flip()
198
     */
199
    public void flip() throws GeometryOperationNotSupportedException, GeometryOperationException {
200
        for (Iterator iterator = primitives.iterator(); iterator.hasNext();) {
201
            ((GeometryJTS)iterator.next()).flip();
202
        }
203
    }
204 42267 fdiaz
}