us.zuercher.gpx2map.plotter
Class Line

java.lang.Object
  extended by us.zuercher.gpx2map.plotter.AbstractShape
      extended by us.zuercher.gpx2map.plotter.Line

public class Line
extends AbstractShape

Line extends AbstractShape to draw a line with a given color and thickness.

Author:
Stephan Zuercher

Field Summary
private  Color color
          Line color.
private  Point end
          Ending point.
private  Point start
          Starting point.
private  int thickness
          Line thickness, in pixels.
 
Fields inherited from class us.zuercher.gpx2map.plotter.AbstractShape
pixelsByRow, zOrdering
 
Constructor Summary
Line(Point start, Point end, Color color, int thickness)
          Constructs a new Line with the given end-points, color and thicnkess.
 
Method Summary
 void computePixels(Dimension bounds)
          Compute the Pixels necessary to draw this line.
 Color getColor()
          Returns the Line's Color.
 Point getEnd()
          Returns the ending point of the line.
 Point getStart()
          Returns the starting point of the line.
 int getThickenedEndY()
          Returns the Y coordinate for the ending point of the line, with line thickness taken in to account.
 int getThickenedStartY()
          Returns the Y coordinate for the starting point of the line, with line thickness taken in to account.
 int startDrawingRow()
          Computes the start Y coordinate for this line.
 
Methods inherited from class us.zuercher.gpx2map.plotter.AbstractShape
getPixelRowIterator, getZOrdering, setZOrdering
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

start

private final Point start
Starting point. Must be above end.


end

private final Point end
Ending point. Must be below start.


color

private final Color color
Line color.


thickness

private final int thickness
Line thickness, in pixels.

Constructor Detail

Line

public Line(Point start,
            Point end,
            Color color,
            int thickness)
Constructs a new Line with the given end-points, color and thicnkess.

Parameters:
start - starting point
end - ending point
color - line color
thickness - line thickness, in pixels
Method Detail

getStart

public Point getStart()
Returns the starting point of the line. Note that the locations of the starting and ending points of the line may be reveresed by the constructor to facilitate line rendering.

Returns:
the starting point of the line.

getEnd

public Point getEnd()
Returns the ending point of the line. Note that the locations of the starting and ending points of the line may be reveresed by the constructor to facilitate line rendering.

Returns:
the ending point of the line.

getThickenedStartY

public int getThickenedStartY()
Returns the Y coordinate for the starting point of the line, with line thickness taken in to account.

Returns:
the Y coordinate for the starting point of the line, may be negative

getThickenedEndY

public int getThickenedEndY()
Returns the Y coordinate for the ending point of the line, with line thickness taken in to account.

Returns:
the Y coordinate for the ending point of the line, may exceed the image's size.

getColor

public Color getColor()
Returns the Line's Color.

Returns:
the Line's Color.

startDrawingRow

public int startDrawingRow()
Computes the start Y coordinate for this line. If the thickness-adjusted starting point for this line is negative the value is clipped to 0.

Specified by:
startDrawingRow in class AbstractShape
Returns:
the start Y coordinate for this line.

computePixels

public void computePixels(Dimension bounds)
Compute the Pixels necessary to draw this line.

Specified by:
computePixels in class AbstractShape
Parameters:
bounds - the image dimensions