us.zuercher.gpx2map.plotter
Class AbstractShape

java.lang.Object
  extended by us.zuercher.gpx2map.plotter.AbstractShape
Direct Known Subclasses:
ImageShape, Line, Shape

public abstract class AbstractShape
extends Object

AbstractShape represents a figure to be drawn on the output map.

Author:
Stephan Zuercher

Field Summary
protected  List<List<Pixel>> pixelsByRow
          Each element of pixelsByRow contains the a List of Pixels for a horizontal row of the shape.
protected  int zOrdering
          The Z-ordering for this shape.
 
Constructor Summary
protected AbstractShape()
          Constructs an AbstractShape.
 
Method Summary
abstract  void computePixels(Dimension bounds)
          The AbstractPlotter calls this method to allow the shape to compute its Pixels.
 AbstractShapePixelRowIterator getPixelRowIterator()
          Returns an AbstractShapePixelRowIterator on pixelsByRow.
 int getZOrdering()
          Returns the Z-ordering for this AbstractShape.
 void setZOrdering(int zOrdering)
          Sets the Z-ordering for this AbstractShape.
abstract  int startDrawingRow()
          Returns the vertical position of the first row in this shape.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pixelsByRow

protected List<List<Pixel>> pixelsByRow
Each element of pixelsByRow contains the a List of Pixels for a horizontal row of the shape.


zOrdering

protected int zOrdering
The Z-ordering for this shape.

Constructor Detail

AbstractShape

protected AbstractShape()
Constructs an AbstractShape. Initializes pixelsByRow.

Method Detail

computePixels

public abstract void computePixels(Dimension bounds)
The AbstractPlotter calls this method to allow the shape to compute its Pixels. This allows simple shapes, such as marker styles to delay populating pixelsByRow until its necessary for plotting.

When computing pixels, the AbstractShape implementation should not include pixels outside the given image bounds.

Parameters:
bounds - maximum image dimensions

startDrawingRow

public abstract int startDrawingRow()
Returns the vertical position of the first row in this shape. For example a 5 x 5 square centered on (25, 40) would return 38.

Returns:
the vertical position of the first row in this shape.

getPixelRowIterator

public final AbstractShapePixelRowIterator getPixelRowIterator()
Returns an AbstractShapePixelRowIterator on pixelsByRow. The AbstractPlotter guarantees this method will not be called until after computePixels(Dimension).

Returns:
an AbstractShapePixelRowIterator on pixelsByRow.

setZOrdering

public void setZOrdering(int zOrdering)
Sets the Z-ordering for this AbstractShape.

Parameters:
zOrdering - the new Z-ordering for this shape.
See Also:
getZOrdering()

getZOrdering

public int getZOrdering()
Returns the Z-ordering for this AbstractShape. Shapes with lower values are "closer" to the viewer and drawn on top of shapes with higher values.

Returns:
Z-ordering for this shape