org.esa.beam.util
Class ShapeRasterizer

java.lang.Object
  extended by org.esa.beam.util.ShapeRasterizer

public class ShapeRasterizer
extends Object

Instances of this class are used to rasterize the outline of a java.awt.Shape.

Version:
$Revision$ $Date$
Author:
Norman Fomferra

Nested Class Summary
static class ShapeRasterizer.BresenhamLineRasterizer
          The Bresenham Algorithm is the default algorithm used to rasterize lines.
static interface ShapeRasterizer.LinePixelVisitor
          Visits each pixel of a rasterized line.
static interface ShapeRasterizer.LineRasterizer
          An abstract representation of an algorithm used to rasterize lines.
 
Constructor Summary
ShapeRasterizer()
          Constructs a new rasterizer with a no affine transformation, a flatness of 1.0 and a bresenham line rasterizer.
ShapeRasterizer(AffineTransform transform, double flatness, ShapeRasterizer.LineRasterizer lineRasterizer)
          Constructs a new rasterizer with the specified affine transformation, flatness and line rasterizer.
 
Method Summary
 double getFlatness()
          Gets the flatness of the of the rasterized outlines to be created.
 ShapeRasterizer.LineRasterizer getLineRasterizer()
          Sets the rasterizing algorithm.
 AffineTransform getTransform()
          Gets the affine transformation to be applied before a shape is rasterized.
 Point2D[] getVertices(Shape shape)
          Converts the given shape into an array of vertices.
 Point2D[] rasterize(Point2D[] vertices)
          Rasterizes the given shape given as a vertices array.
 Point2D[] rasterize(Point2D[] vertices, int[] vertexIndexes)
          Rasterizes the given shape given as a vertices array.
 Point2D[] rasterize(Shape shape)
          Rasterizes the given shape.
 void setFlatness(double flatness)
          Sets the flatness of the of the rasterized outlines to be created.
 void setLineRasterizer(ShapeRasterizer.LineRasterizer lineRasterizer)
          Sets the rasterizing algorithm.
 void setTransform(AffineTransform transform)
          Sets the affine transformation to be applied before a shape is rasterized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShapeRasterizer

public ShapeRasterizer()
Constructs a new rasterizer with a no affine transformation, a flatness of 1.0 and a bresenham line rasterizer.

See Also:
ShapeRasterizer.BresenhamLineRasterizer

ShapeRasterizer

public ShapeRasterizer(AffineTransform transform,
                       double flatness,
                       ShapeRasterizer.LineRasterizer lineRasterizer)
Constructs a new rasterizer with the specified affine transformation, flatness and line rasterizer.

Parameters:
transform - the affine transformation to be applied before a shape is rasterized. Can be null.
flatness - the flatness of the rasterized outlines to be created.
lineRasterizer - the rasterizing algorithm
Method Detail

getTransform

public AffineTransform getTransform()
Gets the affine transformation to be applied before a shape is rasterized.

Returns:
the affine transformation, can be null.

setTransform

public void setTransform(AffineTransform transform)
Sets the affine transformation to be applied before a shape is rasterized.

Parameters:
transform - the affine transformation to be applied before a shape is rasterized. Can be null.

getFlatness

public double getFlatness()
Gets the flatness of the of the rasterized outlines to be created.

Returns:
the flatness.

setFlatness

public void setFlatness(double flatness)
Sets the flatness of the of the rasterized outlines to be created.

Parameters:
flatness - the flatness.

getLineRasterizer

public ShapeRasterizer.LineRasterizer getLineRasterizer()
Sets the rasterizing algorithm.

Returns:
the rasterizing algorithm

setLineRasterizer

public void setLineRasterizer(ShapeRasterizer.LineRasterizer lineRasterizer)
Sets the rasterizing algorithm.

Parameters:
lineRasterizer - the rasterizing algorithm

rasterize

public Point2D[] rasterize(Shape shape)
Rasterizes the given shape.

Parameters:
shape - the shape to be rasterized
Returns:
an array of points representing the rasterized shape outline

rasterize

public Point2D[] rasterize(Point2D[] vertices)
Rasterizes the given shape given as a vertices array.

Parameters:
vertices - the shape to be rasterized given as vertices
Returns:
an array of points representing the rasterized shape outline

rasterize

public Point2D[] rasterize(Point2D[] vertices,
                           int[] vertexIndexes)
Rasterizes the given shape given as a vertices array. The method also stores the indeices of the original vertices in the given index array.

Parameters:
vertices - the shape to be rasterized given as vertices
vertexIndexes - if not null, the method stores the original vertex indices in this array
Returns:
an array of points representing the rasterized shape outline

getVertices

public Point2D[] getVertices(Shape shape)
Converts the given shape into an array of vertices.

Parameters:
shape - the shape
Returns:
the shape given as a vertices array


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.