# HG changeset patch # User Sascha L. Teichmann # Date 1270626552 0 # Node ID 4abe172be9701bceba6017a0cb6e35d2f0e61552 # Parent d766fe2d917a733d0368360dbc41a596c69f962c Finished Javadoc of the raster package. gnv-artifacts/trunk@884 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r d766fe2d917a -r 4abe172be970 gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Tue Apr 06 16:53:43 2010 +0000 +++ b/gnv-artifacts/ChangeLog Wed Apr 07 07:49:12 2010 +0000 @@ -1,3 +1,14 @@ +2010-04-07 Sascha L. Teichmann + + * src/main/java/de/intevation/gnv/raster/ExternalIndexConverter.java, + src/main/java/de/intevation/gnv/raster/JTSMultiLineStringProducer.java, + src/main/java/de/intevation/gnv/raster/IsoPolygonSeriesProducer.java, + src/main/java/de/intevation/gnv/raster/DemuxRingsHandler.java, + src/main/java/de/intevation/gnv/raster/IsoAttributeGenerator.java, + src/main/java/de/intevation/gnv/raster/JTSMultiPolygonProducer.java, + src/main/java/de/intevation/gnv/raster/IsoProducer.java: + Finished Javadoc of the raster package. + 2010-04-06 Sascha L. Teichmann * src/main/java/de/intevation/gnv/**/*.java: More javadoc. diff -r d766fe2d917a -r 4abe172be970 gnv-artifacts/src/main/java/de/intevation/gnv/raster/DemuxRingsHandler.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/raster/DemuxRingsHandler.java Tue Apr 06 16:53:43 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/raster/DemuxRingsHandler.java Wed Apr 07 07:49:12 2010 +0000 @@ -7,17 +7,31 @@ import java.util.List; /** + * Ring Handler that demultiplexes to a list of other ring handlers. + * Handy if you want to pipe the polygons and line strings produced + * by the Vectorize to more than one handler at once. + * * @author Sascha L. Teichmann */ public class DemuxRingsHandler implements RingsHandler { + /** + * The list of internal ring handlers. + */ protected ArrayList handlers; + /** + * Default constructor. + */ public DemuxRingsHandler() { handlers = new ArrayList(); } + /** + * Add a ring handler to the list of handlers. + * @param handler The handler to add to the internal list. + */ public void addHandler(RingsHandler handler) { handlers.add(handler); } @@ -33,6 +47,9 @@ } } + /** + * Empties the internal list of ring handlers. + */ public void clear() { handlers.clear(); } diff -r d766fe2d917a -r 4abe172be970 gnv-artifacts/src/main/java/de/intevation/gnv/raster/ExternalIndexConverter.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/raster/ExternalIndexConverter.java Tue Apr 06 16:53:43 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/raster/ExternalIndexConverter.java Wed Apr 07 07:49:12 2010 +0000 @@ -3,6 +3,9 @@ import org.apache.log4j.Logger; /** + * Converts the interal color index of a polygon to the external index + * defined by the corresponding palette entry. + * * @author Sascha L. Teichmann */ public class ExternalIndexConverter @@ -11,15 +14,33 @@ private static Logger log = Logger.getLogger( ExternalIndexConverter.class); + /** + * The palette where to find the color indices. + */ protected Palette palette; + /** + * Default constructor. + */ public ExternalIndexConverter() { } + /** + * Constrcutor to create an ExternalIndexConverter with + * a given palette. + * @param palette The palette where to find the color indices. + */ public ExternalIndexConverter(Palette palette) { this.palette = palette; } + /** + * Maps the color index of a polygon to the external index + * defined by the corresponing palette entry. + * @param value The value to convert + * @return The mapped value or the original value if + * no corresponing palette entry was found. + */ public Integer convert(Integer value) { if (value == null) { return value; diff -r d766fe2d917a -r 4abe172be970 gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoAttributeGenerator.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoAttributeGenerator.java Tue Apr 06 16:53:43 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoAttributeGenerator.java Wed Apr 07 07:49:12 2010 +0000 @@ -1,16 +1,30 @@ package de.intevation.gnv.raster; /** + * Generates label attributes for iso lines. It takes the + * neighboring palette ranges and calculates the mid point + * between these two ranges. * @author Sascha L. Teichmann */ public class IsoAttributeGenerator implements IsoProducer.AttributeGenerator { + /** + * The palette where to look for the ranges. + */ protected Palette palette; + /** + * Default constructor. + */ public IsoAttributeGenerator() { } + /** + * Constructor to create an IsoAttributeGenerator with + * a given lookup palette. + * @param palette The palette. + */ public IsoAttributeGenerator(Palette palette) { this.palette = palette; } diff -r d766fe2d917a -r 4abe172be970 gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoPolygonSeriesProducer.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoPolygonSeriesProducer.java Tue Apr 06 16:53:43 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoPolygonSeriesProducer.java Wed Apr 07 07:49:12 2010 +0000 @@ -16,6 +16,10 @@ import org.apache.log4j.Logger; /** + * Vectorizer backend to generate iso lines which are able to be visualized + * via {@link de.intevation.gnv.jfreechart.PolygonPlot} as line strings + * and custom labels on the chart. + * * @author Sascha L. Teichmann */ public class IsoPolygonSeriesProducer @@ -24,8 +28,19 @@ private static Logger log = Logger.getLogger( IsoPolygonSeriesProducer.class); - public static final Float LINE_WIDTH = Float.valueOf(0.1f); + /** + * The line width of the line string used in the chart. + */ + public static final Float LINE_WIDTH = Float.valueOf(0.1f); + /** + * Constructor to create an IsoPolygonSeriesProducer with a + * given world bounding box. + * @param minX Min x coord of the world. + * @param minY Min y coord of the world. + * @param maxX Max x coord of the world. + * @param maxY Max y coord of the world. + */ public IsoPolygonSeriesProducer( double minX, double minY, double maxX, double maxY @@ -33,10 +48,22 @@ super(minX, minY, maxX, maxY); } + /** + * Returns a collection of series with line strings + * with no AttributeGenerator. + * @return The collection with line strings. + */ public Collection getSeries() { return getSeries(null); } + /** + * Returns a collection of series with line strings. + * The label attributes are generated with a given generator. + * @param attributeGenerator The attribute generator. Maybe null + * if no attributes should be generated. + * @return The collection with the line strings. + */ public Collection getSeries( AttributeGenerator attributeGenerator ) { diff -r d766fe2d917a -r 4abe172be970 gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoProducer.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoProducer.java Tue Apr 06 16:53:43 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoProducer.java Wed Apr 07 07:49:12 2010 +0000 @@ -14,8 +14,7 @@ import java.util.List; /** - * Vectorizer backend to generate iso lines which are able to be visualized - * via {@link de.intevation.gnv.jfreechart.PolygonPlot} as line strings + * Vectorizer backend to generate iso lines as line strings * and custom labels on the chart. * * @author Sascha L. Teichmann diff -r d766fe2d917a -r 4abe172be970 gnv-artifacts/src/main/java/de/intevation/gnv/raster/JTSMultiLineStringProducer.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/raster/JTSMultiLineStringProducer.java Tue Apr 06 16:53:43 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/raster/JTSMultiLineStringProducer.java Wed Apr 07 07:49:12 2010 +0000 @@ -22,6 +22,9 @@ import org.apache.log4j.Logger; /** + * Vectorizer backend to generated iso lines in form of + * JTS multi linestrings. + * * @author Sascha L. Teichmann */ public class JTSMultiLineStringProducer @@ -30,10 +33,25 @@ private static Logger log = Logger.getLogger( JTSMultiLineStringProducer.class); + /** + * The JTS geometry factory of this producer. + */ protected GeometryFactory geometryFactory; + /** + * The polygon used to clip the produced multe line strings. + */ protected Polygon clip; + /** + * Constructor to create a JTSMultiLineStringProducer with + * a given clipping polygon and a world bounding box. + * @param clip The clipping polygon. + * @param minX Min x coord of the world. + * @param minY Min y coord of the world. + * @param maxX Max x coord of the world. + * @param maxY Max y coord of the world. + */ public JTSMultiLineStringProducer( Polygon clip, double minX, double minY, @@ -47,6 +65,17 @@ maxX, maxY); } + /** + * Constructor to create a JTSMultiLineStringProducer with + * a given clipping polygon, a geometry factory + * and a world bounding box. + * @param clip The clipping polygon. + * @param geometryFactory The geometry factory. + * @param minX Min x coord of the world. + * @param minY Min y coord of the world. + * @param maxX Max x coord of the world. + * @param maxY Max y coord of the world. + */ public JTSMultiLineStringProducer( Polygon clip, GeometryFactory geometryFactory, @@ -58,6 +87,12 @@ this.geometryFactory = geometryFactory; } + /** + * Clips a given line string against the clippin polygon. The + * result is stored in the given list of line strings. + * @param lineString The line string to be clipped. + * @param lineStrings The result line string list. + */ protected void clipLineString( LineString lineString, ArrayList lineStrings @@ -99,6 +134,13 @@ } } + /** + * Returns a list of pairs attribute -> multi line string. + * All line strings produced are grouped by there attribute + * which is generated with the given attribute generator. + * @param attributeGenerator The attribute generator. + * @return The list of attribute/multi line strings. + */ public List> getMultiLineStrings( AttributeGenerator attributeGenerator ) { diff -r d766fe2d917a -r 4abe172be970 gnv-artifacts/src/main/java/de/intevation/gnv/raster/JTSMultiPolygonProducer.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/raster/JTSMultiPolygonProducer.java Tue Apr 06 16:53:43 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/raster/JTSMultiPolygonProducer.java Wed Apr 07 07:49:12 2010 +0000 @@ -24,6 +24,9 @@ import org.apache.log4j.Logger; /** + * Vectorizer backend to generated polygons in form of + * JTS multi multi polygons. + * * @author Sascha L. Teichmann */ public class JTSMultiPolygonProducer @@ -32,23 +35,57 @@ private static Logger log = Logger.getLogger( JTSMultiPolygonProducer.class); + /** + * The reference system of used coordinates: {@value} + */ public static final int SRID_WGS84 = 4326; + /** + * Interface to decouple the conversion of the internal + * index scheme of the polygons to an external one. + */ public interface ValueConverter { + /** + * Maps integer index schemes. + * @param value The input value. + * @return The resulting index. + */ Integer convert(Integer value); } // interface ValueConverter + /** + * The JTS geometry factory. + */ protected GeometryFactory geometryFactory; + /** + * The clipping polygon. + */ protected Polygon clip; + /** + * Internal map to map the internal polygons indices to a + * list of generated polygons. + */ protected HashMap> valueToPolygons; + /** + * Default constructor. + */ public JTSMultiPolygonProducer() { } + /** + * Constructor to create a JTSMultiPolygonProducer with a + * given clipping polygon and a world bounding box. + * @param clip The clipping polygon. + * @param minX Min x coord of the world. + * @param minY Min y coord of the world. + * @param maxX Max x coord of the world. + * @param maxY Max y coord of the world. + */ public JTSMultiPolygonProducer( Polygon clip, double minX, double minY, @@ -61,6 +98,16 @@ maxX, maxY); } + /** + * Constructor to create a JTSMultiPolygonProducer with a + * given clipping polygon, a geometry factory and a world bounding box. + * @param clip The clipping polygon. + * @param geometryFactory The geometry factory. + * @param minX Min x coord of the world. + * @param minY Min y coord of the world. + * @param maxX Max x coord of the world. + * @param maxY Max y coord of the world. + */ public JTSMultiPolygonProducer( Polygon clip, GeometryFactory geometryFactory, @@ -73,10 +120,20 @@ valueToPolygons = new HashMap>(); } + /** + * Creates a 3D geometry factory via + * {@link #createDefaultGeometryFactory(int)}. + * @return The new geometry factory. + */ public static GeometryFactory createDefaultGeometryFactory() { return createDefaultGeometryFactory(3); } + /** + * Creates a geometry factory with a given dimension. + * @param dim The dimension. + * @return The new geometry factory. + */ public static GeometryFactory createDefaultGeometryFactory(int dim) { return new GeometryFactory( new PrecisionModel( @@ -162,10 +219,21 @@ } } + /** + * Returns a index -> multi polyon map. The internal index scheme + * is retained. + * {@link #getMultiPolygons(de.intevation.gnv.raster.JTSMultiPolygonProducer.ValueConverter)} + * @return The new map. + */ public Map getMultiPolygons() { return getMultiPolygons(null); } + /** + * Flattend a JTS geometry to a multi polygon if possible + * @param result The geometry to be flattend + * @return The resulting multi polygon. + */ protected MultiPolygon flattenCollection(Geometry result) { if (result instanceof MultiPolygon) { @@ -182,6 +250,13 @@ return null; } + /** + * Returns a index -> multi polyon map. The internal index scheme + * is remapped with the given value converter. + * @param valueConverter Converter to remap the index scheme. Maybe null + * if no remapping is required. + * @return The new map. + */ public Map getMultiPolygons( ValueConverter valueConverter ) { @@ -218,6 +293,9 @@ return multiPolygons; } + /** + * Empties internal temporary data structures to save some memory. + */ public void clear() { valueToPolygons.clear(); }