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.shapehandler.jts;
18:
19: import java.awt.Rectangle;
20:
21: import org.geotools.data.shapefile.shp.ShapeType;
22: import org.geotools.geometry.jts.LiteCoordinateSequence;
23: import org.geotools.geometry.jts.LiteCoordinateSequenceFactory;
24: import org.opengis.referencing.operation.MathTransform;
25: import org.opengis.referencing.operation.TransformException;
26:
27: import com.vividsolutions.jts.geom.Envelope;
28: import com.vividsolutions.jts.geom.GeometryFactory;
29: import com.vividsolutions.jts.geom.LineString;
30:
31: /**
32: * Creates Geometry line objects for use by the ShapeRenderer.
33: *
34: * @author jeichar
35: *
36: * @since 2.1.x
37: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/shapefile-renderer/src/main/java/org/geotools/renderer/shape/shapehandler/jts/MultiLineHandler.java $
38: */
39: public class MultiLineHandler
40: extends
41: org.geotools.renderer.shape.shapehandler.simple.MultiLineHandler {
42: private static final GeometryFactory factory = new GeometryFactory(
43: new LiteCoordinateSequenceFactory());
44:
45: public MultiLineHandler(ShapeType type, Envelope env,
46: MathTransform mt, boolean hasOpacity, Rectangle screenSize)
47: throws TransformException {
48: super (type, env, mt, hasOpacity, screenSize);
49: }
50:
51: protected Object createGeometry(ShapeType type, Envelope geomBBox,
52: double[][] transformed) {
53:
54: LineString[] ls = new LineString[transformed.length];
55: for (int i = 0; i < transformed.length; i++) {
56: ls[i] = factory
57: .createLineString(new LiteCoordinateSequence(
58: transformed[i]));
59: }
60:
61: return factory.createMultiLineString(ls);
62: }
63: }
|