us.zuercher.gpx2map.plotter
Class AbstractTextPlotter

java.lang.Object
  extended by us.zuercher.gpx2map.plotter.AbstractPlotter
      extended by us.zuercher.gpx2map.plotter.AbstractTextPlotter
Direct Known Subclasses:
WayPointPlotter

abstract class AbstractTextPlotter
extends AbstractPlotter

AbstractTextPlotter extends AbstractPlotter to provide marker labelling capabilities.

Author:
Stephan Zuercher

Field Summary
static String DEFAULT_FONT_NAME
          Default font name.
static float DEFAULT_FONT_SIZE
          Default font size.
private  Font font
          Java AWT Font instance.
private  String fontname
          Configured font name.
private  float fontsize
          Configured font size.
private static int INITIAL_TEXT_Z_ORDERING
          Initial Z-ordering for text.
private  List<Label> labels
          List of Labels to be applied to the image.
private static String SAFE_FONT_NAME
          Fallback font name if the default cannot be loaded.
 
Constructor Summary
protected AbstractTextPlotter(File netpbmFile, MapSource mapSource)
          Constructs an AbstractTextPlotter for the given Netpbm file and map source.
 
Method Summary
private  void addTextShapes()
          Generates Shape instance for each label.
protected  void drawLabel(String labelString, Point adjacentTo, int distance, Color color)
          Add a new label to the plotter.
 void execute(ProgressMeter meter)
          Convert the configured Labels and plot them along with all other configured AbstractShapes on the image.
 void setFontName(String fontname)
          Changes the configured font name.
 void setFontSize(float fontsize)
          Changes the configured font size.
 
Methods inherited from class us.zuercher.gpx2map.plotter.AbstractPlotter
addLine, addShape, getCroppingRectangle, mapLocationToPixel, setCropping
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_TEXT_Z_ORDERING

private static final int INITIAL_TEXT_Z_ORDERING
Initial Z-ordering for text. Text shapes are drawn above all other plotter shapes. Earlier text is drawn above later text.

See Also:
Constant Field Values

DEFAULT_FONT_NAME

public static final String DEFAULT_FONT_NAME
Default font name.

See Also:
Constant Field Values

SAFE_FONT_NAME

private static final String SAFE_FONT_NAME
Fallback font name if the default cannot be loaded. This font is guaranteed to be available in any JVM, whereas the default is not.

See Also:
Constant Field Values

DEFAULT_FONT_SIZE

public static final float DEFAULT_FONT_SIZE
Default font size.

See Also:
Constant Field Values

fontname

private String fontname
Configured font name.


fontsize

private float fontsize
Configured font size.


font

private Font font
Java AWT Font instance.


labels

private List<Label> labels
List of Labels to be applied to the image.

Constructor Detail

AbstractTextPlotter

protected AbstractTextPlotter(File netpbmFile,
                              MapSource mapSource)
Constructs an AbstractTextPlotter for the given Netpbm file and map source.

Parameters:
netpbmFile - the Netpbm file to plot on
mapSource - the map source that generated the image file.
Method Detail

setFontSize

public void setFontSize(float fontsize)
Changes the configured font size. This font size applies to all subsequent calls to drawLabel(String, Point, int, Color).

Parameters:
fontsize - new font size.

setFontName

public void setFontName(String fontname)
Changes the configured font name. This font name applies to all subsequent calls to drawLabel(String, Point, int, Color).

Parameters:
fontname - the new font name

drawLabel

protected void drawLabel(String labelString,
                         Point adjacentTo,
                         int distance,
                         Color color)
Add a new label to the plotter.

Parameters:
labelString - label's text
adjacentTo - location of the marker
distance - distance the text should be from the marker
color - text color

execute

public void execute(ProgressMeter meter)
             throws IOException
Convert the configured Labels and plot them along with all other configured AbstractShapes on the image.

Overrides:
execute in class AbstractPlotter
Parameters:
meter - progress indicator
Throws:
IOException - if there's an error reading the source image or writing the target image.

addTextShapes

private void addTextShapes()
Generates Shape instance for each label.