Class LineElement

java.lang.Object
  extended byLineElement
All Implemented Interfaces:
java.lang.Comparable, Selectable

public class LineElement
extends java.lang.Object
implements Selectable, java.lang.Comparable

This class contains the coordinates, current statistic values and various other information about a line. It contains methods for clipping the line if it extends the border of the map and methods for drawing it on the map.


Field Summary
private  int bitmapX1
           
private  int bitmapX2
           
private  int bitmapY1
           
private  int bitmapY2
           
private  java.util.Vector dateStrings
           
private static java.awt.Color defaultColour
           
private static int defaultSize
           
private  PointElement destination
           
private  java.awt.Color destinationColour
           
private  int destinationSize
           
private  StatisticDialog dialog
           
private  boolean enabled
           
private  java.util.Date fromDate
           
private  java.lang.String lineName
           
private  java.lang.String lineType
           
private  java.util.Vector measureStrings
           
private  PointElement origin
           
private  java.awt.Color originColour
           
private  int originSize
           
private  MapElement parentMap
           
private  java.awt.Polygon polygonOutline
           
private  java.util.Date toDate
           
 
Constructor Summary
LineElement(MapElement parent, PointElement origin, PointElement destination, java.lang.String name, java.lang.String type, java.util.Date from, java.util.Date to)
          Creates a new instance of LineElement
 
Method Summary
 void addStatisticColumn(java.util.Hashtable hash, java.lang.String title)
          Adds a column of statistics to the dialog showing stats for this line.
 void addStatisticURL(java.lang.String lineName, java.lang.String URLtemplate, int timestamp, java.lang.String statName)
           
 void addTimestamp(java.util.Date statisticDate, java.lang.String statName)
          Creates strings that displays the name of the statistic and the time at which it was measured and adds them the list of strings.
 void addURL(java.lang.String url, java.lang.String urlInfo, java.util.Date date)
          Adds an url button the the dialog showing stats for this line.
private  void checkCoordBounds()
          Check if the line crosses any border of the map, and update the origin or destination pointelements to lie on the map border instead.
 void checkEnabled(java.util.Date date)
          Enables this line if it exists at the given date, otherwise it is disabled.
 int compareTo(java.lang.Object o)
          Compares the length of lines.
 boolean contains(java.awt.Point point)
          Checks if the polygon outline of this line contains the given point.
 void createPolygonOutline()
          Creates a polygon outline for this line to be used for hit testing.
 void drawMe(java.awt.Graphics _g)
          Draw the unselected version of the line.
 void drawSelected(java.awt.Graphics _g)
          Draw the selected version of the line.
 PointElement getDestination()
           
 PointElement getOrigin()
           
 java.awt.Polygon getPolygonOutline()
           
 int getSize()
          Returns the length of the line.
 java.lang.String getType()
           
 int getX1()
           
 int getX2()
           
 int getY1()
           
 int getY2()
           
 boolean isEnabled()
           
 void performMouseClickAction(MapFrame mapFrame, java.awt.event.MouseEvent e)
          Opens a statistic dialog showing stats and urls when the mouse is clicked on the line.
 void resetBitmapCoordinates()
           
 void resetStatistics()
          Sets all the statistics to the default values.
 void setDestinationColour(java.awt.Color colour)
           
 void setDestinationSize(int size)
           
 void setOriginColour(java.awt.Color colour)
           
 void setOriginSize(int size)
           
 void setX1(int x1)
           
 void setX2(int x2)
           
 void setY1(int y1)
           
 void setY2(int y2)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parentMap

private MapElement parentMap

origin

private PointElement origin

destination

private PointElement destination

lineName

private java.lang.String lineName

lineType

private java.lang.String lineType

originSize

private int originSize

destinationSize

private int destinationSize

destinationColour

private java.awt.Color destinationColour

originColour

private java.awt.Color originColour

polygonOutline

private java.awt.Polygon polygonOutline

fromDate

private java.util.Date fromDate

toDate

private java.util.Date toDate

bitmapX1

private int bitmapX1

bitmapY1

private int bitmapY1

bitmapX2

private int bitmapX2

bitmapY2

private int bitmapY2

dateStrings

private java.util.Vector dateStrings

measureStrings

private java.util.Vector measureStrings

dialog

private StatisticDialog dialog

defaultColour

private static java.awt.Color defaultColour

defaultSize

private static int defaultSize

enabled

private boolean enabled
Constructor Detail

LineElement

public LineElement(MapElement parent,
                   PointElement origin,
                   PointElement destination,
                   java.lang.String name,
                   java.lang.String type,
                   java.util.Date from,
                   java.util.Date to)
Creates a new instance of LineElement

Method Detail

checkCoordBounds

private void checkCoordBounds()
Check if the line crosses any border of the map, and update the origin or destination pointelements to lie on the map border instead.


getType

public java.lang.String getType()

getOrigin

public PointElement getOrigin()

getDestination

public PointElement getDestination()

setOriginSize

public void setOriginSize(int size)

setDestinationSize

public void setDestinationSize(int size)

setOriginColour

public void setOriginColour(java.awt.Color colour)

setDestinationColour

public void setDestinationColour(java.awt.Color colour)

getX1

public int getX1()

getY1

public int getY1()

getX2

public int getX2()

getY2

public int getY2()

setX1

public void setX1(int x1)

setX2

public void setX2(int x2)

setY1

public void setY1(int y1)

setY2

public void setY2(int y2)

getPolygonOutline

public java.awt.Polygon getPolygonOutline()

addTimestamp

public void addTimestamp(java.util.Date statisticDate,
                         java.lang.String statName)
Creates strings that displays the name of the statistic and the time at which it was measured and adds them the list of strings.


getSize

public int getSize()
Returns the length of the line.


resetStatistics

public void resetStatistics()
Sets all the statistics to the default values.


resetBitmapCoordinates

public void resetBitmapCoordinates()

contains

public boolean contains(java.awt.Point point)
Checks if the polygon outline of this line contains the given point. Used for hit testing.


checkEnabled

public void checkEnabled(java.util.Date date)
Enables this line if it exists at the given date, otherwise it is disabled.


isEnabled

public boolean isEnabled()

createPolygonOutline

public void createPolygonOutline()
Creates a polygon outline for this line to be used for hit testing.


drawSelected

public void drawSelected(java.awt.Graphics _g)
Draw the selected version of the line.

Specified by:
drawSelected in interface Selectable

drawMe

public void drawMe(java.awt.Graphics _g)
Draw the unselected version of the line.


performMouseClickAction

public void performMouseClickAction(MapFrame mapFrame,
                                    java.awt.event.MouseEvent e)
Opens a statistic dialog showing stats and urls when the mouse is clicked on the line.

Specified by:
performMouseClickAction in interface Selectable

addStatisticColumn

public void addStatisticColumn(java.util.Hashtable hash,
                               java.lang.String title)
Adds a column of statistics to the dialog showing stats for this line.


addStatisticURL

public void addStatisticURL(java.lang.String lineName,
                            java.lang.String URLtemplate,
                            int timestamp,
                            java.lang.String statName)

addURL

public void addURL(java.lang.String url,
                   java.lang.String urlInfo,
                   java.util.Date date)
Adds an url button the the dialog showing stats for this line.


toString

public java.lang.String toString()

compareTo

public int compareTo(java.lang.Object o)
Compares the length of lines.

Specified by:
compareTo in interface java.lang.Comparable