01: /*
02: * Geotools2 - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002, Geotools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library 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 GNU
14: * Lesser General Public License for more details.
15: *
16: */
17: package org.geotools.renderer.shape;
18:
19: import java.awt.Shape;
20: import java.awt.geom.AffineTransform;
21: import java.awt.geom.PathIterator;
22:
23: /**
24: * A shape for drawing on a graphics2d
25: *
26: * @author jeichar
27: *
28: * @since 2.1.x
29: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/shapefile-renderer/src/main/java/org/geotools/renderer/shape/MultiPointShape.java $
30: */
31: public class MultiPointShape extends AbstractShape implements Shape {
32: public MultiPointShape(SimpleGeometry geom) {
33: super (geom);
34: }
35:
36: /**
37: * @see java.awt.Shape#getPathIterator(java.awt.geom.AffineTransform)
38: */
39: public PathIterator getPathIterator(final AffineTransform at) {
40: return new PathIterator() {
41: int currentPart = 0;
42:
43: public int getWindingRule() {
44: return WIND_NON_ZERO;
45: }
46:
47: public boolean isDone() {
48: return currentPart == geom.coords.length;
49: }
50:
51: public void next() {
52: if (isDone()) {
53: return;
54: }
55:
56: currentPart++;
57: }
58:
59: public int currentSegment(float[] coords) {
60: coords[0] = (float) geom.coords[currentPart][0];
61: coords[1] = (float) geom.coords[currentPart][1];
62:
63: if (at != null) {
64: at.transform(coords, 0, coords, 0, 1);
65: }
66:
67: return SEG_MOVETO;
68: }
69:
70: public int currentSegment(double[] coords) {
71: coords[0] = (float) geom.coords[currentPart][0];
72: coords[1] = (float) geom.coords[currentPart][1];
73:
74: if (at != null) {
75: at.transform(coords, 0, coords, 0, 1);
76: }
77:
78: return SEG_MOVETO;
79: }
80: };
81: }
82:
83: /*
84: * (non-Javadoc)
85: *
86: * @see java.awt.Shape#getPathIterator(java.awt.geom.AffineTransform,
87: * double)
88: */
89: public PathIterator getPathIterator(AffineTransform at,
90: double flatness) {
91: return getPathIterator(at);
92: }
93: }
|