Package com.treemap.swing.voronoi
Class MarchingSquares
java.lang.Object
com.treemap.swing.voronoi.MarchingSquares
A simple implementation of the marching squares algorithm that can identify
perimeters in an supplied raster.
-
Constructor Summary
ConstructorsConstructorDescriptionMarchingSquares
(int width, int height, VoronoiCell cell, VoronoiOutputRaster outputRaster) Creates a new object that can locate perimeter paths in the supplied raster. -
Method Summary
Modifier and TypeMethodDescriptionA convenience method that locates at least one perimeter in the raster with which this object was constructed.identifyPerimeter
(int initialX, int initialY) Finds the perimeter between a set of cells which begins at the specified data element.
-
Constructor Details
-
MarchingSquares
Creates a new object that can locate perimeter paths in the supplied raster.- Parameters:
width
- the width of the outputRaster matrixheight
- the width of the outputRaster matrixcell
- the type of cell we are interested inoutputRaster
- the raster
-
-
Method Details
-
identifyPerimeter
Finds the perimeter between a set of cells which begins at the specified data element. If no initial point is known, consider using the convenience method supplied. The paths returned by this method are always closed.- Parameters:
initialX
- the column of the data matrix at which to start tracing the perimeterinitialY
- the row of the data matrix at which to start tracing the perimeter- Returns:
- a closed, anti-clockwise path that is a perimeter of between a set of zero and non-zero values in the data.
- Throws:
IllegalArgumentException
- if there is no perimeter at the specified initial point.
-
identifyPerimeter
A convenience method that locates at least one perimeter in the raster with which this object was constructed. If there is no perimeter (ie. if all elements of the supplied array are identically zero) then null is returned.- Returns:
- a perimeter path obtained from the raster, or null
-