|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectus.zuercher.gpx2map.plotter.AbstractPlotter
abstract class AbstractPlotter
AbstractPlotter renders arbitrary shapes defined by the caller onto an
existing Netpbm file without reading the entire file into memory. Each
AbstractShape
is capable of indicating which image row it starts
on. By sorting Shapes by their starting row, AbstractPlotter can read one
row of the input NetpbmImage
at a time, modify it according to the
Shapes that appear on that line and write the row out to a WritablePpmImage.
Furthermore, the pixel-row
iterators
used to obtain rows of pixels from each shape are sorting
by Z-ordering.
Field Summary | |
---|---|
private Rectangle |
cropTo
Rectangle used for cropping the final image. |
private static int |
LINE_THICKNESS
Thickness, in pixels, of a plotter line. |
private MapSource |
mapSource
MapSource used for mapping coordinates to the image. |
private File |
netpbmFile
Netpbm input file. |
private List<AbstractShape> |
shapes
List of AbstractShapes to plot. |
private static Comparator<AbstractShapePixelRowIterator> |
Z_COMPARATOR
Comparator for ordering rows of Pixels by their
Z-ordering. |
Constructor Summary | |
---|---|
protected |
AbstractPlotter(File netpbmFile,
MapSource mapSource)
Constructs a new AbstractPlotter based on the given Netpbm file and map source. |
Method Summary | |
---|---|
protected void |
addLine(WayPoint start,
WayPoint end,
Color color,
double minLength,
int initialZOrdering)
Add a Line to the list of shapes to be plotted. |
protected void |
addShape(AbstractShape shape)
Add an AbstractShape to the list of shapes to be plotted. |
private void |
applyZOrdering()
Apply Z-ordering for all shapes based on their initial Z-ordering. |
void |
execute(ProgressMeter meter)
Plot the configured AbstractShapes on the
image. |
protected Rectangle |
getCroppingRectangle()
Returns the cropping rectangle for the output image. |
protected Point |
mapLocationToPixel(LatLon location)
Maps a LatLon coordinate onto the image. |
void |
setCropping(Rectangle cropTo)
Sets the rectangle within the image boundaries that will be stored in the final output file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int LINE_THICKNESS
private static final Comparator<AbstractShapePixelRowIterator> Z_COMPARATOR
Pixels
by their
Z-ordering. Smaller Z values are closer to the viewer and are
sorted later in the list so that the pixel rows may be drawn
in sort order to achieve the correct Z-ordering.
private final File netpbmFile
private final MapSource mapSource
MapSource
used for mapping coordinates to the image.
private List<AbstractShape> shapes
AbstractShapes
to plot.
private Rectangle cropTo
Rectangle(1, 1, 10, 10)
is 9 pixels by 9 pixels.
Constructor Detail |
---|
protected AbstractPlotter(File netpbmFile, MapSource mapSource)
netpbmFile
- the Netpbm file to plot onmapSource
- the MapSource
that generated the fileMethod Detail |
---|
public void setCropping(Rectangle cropTo)
cropTo
- rectangle to crop to.
IllegalArgumentException
- if the rectangle's left or top
boundaries are less than 0, or if the
rectangle's right or bottom boundaries
are greater than the image size.public void execute(ProgressMeter meter) throws IOException
AbstractShapes
on the
image.
meter
- progress indicator
IOException
- if there's an error reading the source image
or writing the target image.protected Rectangle getCroppingRectangle()
protected Point mapLocationToPixel(LatLon location)
LatLon
coordinate onto the image.
location
- the coordinate to locate on the image
Point
representing the coordinate on the image.protected void addShape(AbstractShape shape)
AbstractShape
to the list of shapes to be plotted.
shape
- the shape to addprotected void addLine(WayPoint start, WayPoint end, Color color, double minLength, int initialZOrdering)
Line
to the list of shapes to be plotted. Lines are
assumed to be drawn from one marker to the next. Markers have a size,
and therefore may be close enough together to overlap. Pass a value
of minLength
where minLength
is the maximum
distance between two markers such that they still obscure the line
drawn between them. If the line is shorter than this length, it will
not be drawn.
start
- starting coordinates of the lineend
- ending coordinates of the linecolor
- the line's colorminLength
- the minimum line length to plot.initialZOrdering
- initial Z-orderingprivate void applyZOrdering()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |