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 / complex / PrimitiveListPathIterator.java @ 45910
History | View | Annotate | Download (2.3 KB)
1 |
/*
|
---|---|
2 |
* To change this license header, choose License Headers in Project Properties.
|
3 |
* To change this template file, choose Tools | Templates
|
4 |
* and open the template in the editor.
|
5 |
*/
|
6 |
package org.gvsig.fmap.geom.jts.complex; |
7 |
|
8 |
import java.awt.geom.AffineTransform; |
9 |
import java.awt.geom.PathIterator; |
10 |
import java.util.ArrayList; |
11 |
import java.util.Iterator; |
12 |
import java.util.List; |
13 |
import org.gvsig.fmap.geom.Geometry; |
14 |
import org.gvsig.fmap.geom.jts.gputils.GeneralPathXIterator; |
15 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
16 |
import org.gvsig.fmap.geom.primitive.Primitive; |
17 |
|
18 |
/**
|
19 |
*
|
20 |
* @author fdiaz
|
21 |
*/
|
22 |
class PrimitiveListPathIterator extends GeneralPathXIterator { |
23 |
|
24 |
/** Transform applied on the coordinates during iteration */
|
25 |
private final AffineTransform at; |
26 |
/** True when the point has been read once */
|
27 |
private boolean done; |
28 |
private int index = 0; |
29 |
private final List<PathIterator> iterators; |
30 |
private final List<Geometry> geometries; |
31 |
|
32 |
/**
|
33 |
* Creates a new PointIterator object.
|
34 |
*
|
35 |
* @param at
|
36 |
* The affine transform applied to coordinates during
|
37 |
* iteration
|
38 |
*/
|
39 |
public PrimitiveListPathIterator(List<Geometry> geometries, AffineTransform at) { |
40 |
super(new GeneralPathX()); |
41 |
this.geometries = geometries;
|
42 |
this.iterators = new ArrayList<>(geometries.size()); |
43 |
if (at == null) { |
44 |
at = new AffineTransform(); |
45 |
} |
46 |
this.at = at;
|
47 |
for (Iterator iterator = geometries.iterator(); iterator.hasNext();) { |
48 |
Primitive primitive = (Primitive) iterator.next(); |
49 |
iterators.add(primitive.getPathIterator(at)); |
50 |
} |
51 |
done = false;
|
52 |
} |
53 |
|
54 |
public int getWindingRule() { |
55 |
return PathIterator.WIND_EVEN_ODD; |
56 |
} |
57 |
|
58 |
public void next() { |
59 |
PathIterator pathIteratorPrimitive = iterators.get(index);
|
60 |
pathIteratorPrimitive.next(); |
61 |
if (pathIteratorPrimitive.isDone()) {
|
62 |
index++; |
63 |
done = (index == geometries.size()); |
64 |
} |
65 |
} |
66 |
|
67 |
public boolean isDone() { |
68 |
return done;
|
69 |
} |
70 |
|
71 |
public int currentSegment(double[] coords) { |
72 |
return iterators.get(index).currentSegment(coords);
|
73 |
} |
74 |
|
75 |
public int currentSegment(float[] coords) { |
76 |
return iterators.get(index).currentSegment(coords);
|
77 |
} |
78 |
|
79 |
} |