Class MapElement

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

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

MapElement contains the graphical image of a map along with lists of its points and lines. It has methods for adjusting the position of overlapping lines and for placing text on the map. Further it can assign statistic values to lines and points.


Field Summary
private  java.awt.Image backgroundImage
           
private  float bitmapFactor
           
private  int bitmapHeight
           
private  int bitmapWidth
           
static int BORDER_SIZE
           
private  java.lang.String coordType
           
private  int coordX1
           
private  int coordX2
           
private  int coordY1
           
private  int coordY2
           
private  java.util.Vector filteredLineList
           
private  java.util.Vector filteredPointList
           
private static int FREE
           
static int GRID_SIZE
           
private  java.net.URL imageURL
           
private  boolean isSuperRegion
           
private  java.util.Vector lineList
           
private  java.lang.String mapName
           
private static int OCCUPIED
           
private  java.util.Vector pointList
           
private  java.awt.Rectangle rectangleOutline
           
private  int[][] textMap
           
private  int UTMZone
           
private  int zoomLevel
           
 
Constructor Summary
MapElement(java.lang.String name, java.lang.String coord, int width, int height, int x1, int y1, int x2, int y2, int zoom, java.net.URL imageURL, float factor)
          Creates a new instance of MapElement
 
Method Summary
 void adjustOverlappingLines()
          Checks all the lines and moves those that are on top of each other.
 void adjustOverlappingPoints()
          Checks points along the border of the map and moves those that overlap.
 void assignLineStatistics(java.util.Vector lineStatList)
          Assigns all the available line statistics to line elements.
 void assignPointStatistics(java.util.Vector pointStatList)
          Assigns all the available point statistics to point elements.
 void clearTextMap()
          Resets the text map.
 int compareTo(java.lang.Object o)
          Returns the string comparison of the map names.
 boolean contains(MapElement otherElement)
          Returns true if the given map element is contained inside this map element.
 boolean contains(java.awt.Point point)
          Returns true if the given point is located within this map element.
 void createLineRegions()
          Creates regions for all the lines.
 void createPointRegions()
          Creates regions for all the points.
 void createRectangleOutline(int x, int y, int width, int height)
          Creates a rectangle outline with the given dimensions.
 void createSubRegion(MapElement subElement)
          Marks the given map element as a sub region for this map element.
 void createSuperRegion(MapElement superElement)
          Marks the given map element as a super region for this map element.
 void displaceLine(LineElement line1, LineElement line2)
          Displaces two lines with respect to each other.
 void drawSelected(java.awt.Graphics _g)
          Draws the map region when selected with the mouse pointer.
 double factorX()
          Returns the ratio of coords/pixels along the x-axis.
 double factorY()
          Returns the ratio of coords/pixels along the y-axis.
 void filterLines(java.lang.String lineType)
          Filters all the lines, keeping only those with a spesific linetype.
 void filterPoints(java.lang.String pointType)
          Filters all the points, keeping only those with a spesific pointtype.
 java.awt.Image getBackgroundImage()
          Returns the clean map image.
 java.awt.Rectangle getContourRectangle()
          Returns the contour rectangle, which is the same as the outline of the map.
 java.net.URL getImageURL()
           
 java.awt.Rectangle getIntersectionRectangle()
          Returns the intersection rectangle, which is in the middle between the map and the border.
 int getIntersectLength(LineElement line1, LineElement line2)
          Returns the length of the overlap of two lines.
 LineElement getLineAtPoint(java.awt.Point point)
          Returns the line element at a given point.
 LineElement getLineElement(java.lang.String lineName)
          Returns a line element given a linename.
 java.util.Vector getLineTypes()
          Returns all the linetypes.
 java.awt.Image getMapImage(java.util.Date date)
          Returns the map image for a given date with lines, points and text drawn on it.
 java.lang.String getMapName()
           
 PointElement getNodeAtPoint(java.awt.Point point)
          Returns the point element at a given point.
 PointElement getPointElement(java.lang.String pointName)
          Returns a point element given a pointname.
 java.util.Vector getPointTypes()
          Returns all the pointtypes.
 int getRegionSize()
           
 int[] getTextCoords(int pointX, int pointY, int length)
          Returns the coordinates of where the text should be placed given a pair of coordinates and text length.
 int getUTMZone()
           
 int getX1()
           
 int getX2()
           
 int getY1()
           
 int getY2()
           
 int getZoomLevel()
           
 boolean isLoaded()
          Returns true if the image has been loaded, false otherwise.
 boolean isSuperRegion()
          Returns true if this map element is a super region.
 boolean overlaps(MapElement otherElement)
           
 void performMouseClickAction(MapFrame mapFrame, java.awt.event.MouseEvent e)
          Selects this map when it is clicked on with the mouse.
 void removeRegion()
          Clears the rectangle outline.
 void resetLineStatistics()
          Clears all the line statistics.
 void resetPointStatistics()
          Clears all the point statistics.
 void setBackgroundImage(java.awt.Image image)
          Sets the clean map image, draws a border around it and initializes the text map.
 void setLineList(java.util.Vector lineList)
           
 void setOccupiedText(int x, int y, int length)
          Marks the given slot in the text map as occupied.
 void setPointList(java.util.Vector pointList)
           
 void setSuperRegion(boolean isSuper)
          Sets this map element as a super region.
 java.lang.String toString()
          Returns the name of the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lineList

private java.util.Vector lineList

filteredLineList

private java.util.Vector filteredLineList

pointList

private java.util.Vector pointList

filteredPointList

private java.util.Vector filteredPointList

mapName

private java.lang.String mapName

coordType

private java.lang.String coordType

bitmapWidth

private int bitmapWidth

bitmapHeight

private int bitmapHeight

coordX1

private int coordX1

coordY1

private int coordY1

coordX2

private int coordX2

coordY2

private int coordY2

zoomLevel

private int zoomLevel

UTMZone

private int UTMZone

backgroundImage

private java.awt.Image backgroundImage

imageURL

private java.net.URL imageURL

bitmapFactor

private float bitmapFactor

rectangleOutline

private java.awt.Rectangle rectangleOutline

textMap

private int[][] textMap

isSuperRegion

private boolean isSuperRegion

BORDER_SIZE

public static final int BORDER_SIZE
See Also:
Constant Field Values

GRID_SIZE

public static final int GRID_SIZE
See Also:
Constant Field Values

OCCUPIED

private static final int OCCUPIED
See Also:
Constant Field Values

FREE

private static final int FREE
See Also:
Constant Field Values
Constructor Detail

MapElement

public MapElement(java.lang.String name,
                  java.lang.String coord,
                  int width,
                  int height,
                  int x1,
                  int y1,
                  int x2,
                  int y2,
                  int zoom,
                  java.net.URL imageURL,
                  float factor)
Creates a new instance of MapElement

Method Detail

setPointList

public void setPointList(java.util.Vector pointList)

setLineList

public void setLineList(java.util.Vector lineList)

isLoaded

public boolean isLoaded()
Returns true if the image has been loaded, false otherwise.


adjustOverlappingPoints

public void adjustOverlappingPoints()
Checks points along the border of the map and moves those that overlap.


adjustOverlappingLines

public void adjustOverlappingLines()
Checks all the lines and moves those that are on top of each other.


getIntersectLength

public int getIntersectLength(LineElement line1,
                              LineElement line2)
Returns the length of the overlap of two lines.


displaceLine

public void displaceLine(LineElement line1,
                         LineElement line2)
Displaces two lines with respect to each other.


setBackgroundImage

public void setBackgroundImage(java.awt.Image image)
Sets the clean map image, draws a border around it and initializes the text map.


getBackgroundImage

public java.awt.Image getBackgroundImage()
Returns the clean map image.


getTextCoords

public int[] getTextCoords(int pointX,
                           int pointY,
                           int length)
Returns the coordinates of where the text should be placed given a pair of coordinates and text length.


setOccupiedText

public void setOccupiedText(int x,
                            int y,
                            int length)
Marks the given slot in the text map as occupied.


clearTextMap

public void clearTextMap()
Resets the text map.


getIntersectionRectangle

public java.awt.Rectangle getIntersectionRectangle()
Returns the intersection rectangle, which is in the middle between the map and the border.


getContourRectangle

public java.awt.Rectangle getContourRectangle()
Returns the contour rectangle, which is the same as the outline of the map.


getMapImage

public java.awt.Image getMapImage(java.util.Date date)
Returns the map image for a given date with lines, points and text drawn on it.


getPointElement

public PointElement getPointElement(java.lang.String pointName)
Returns a point element given a pointname.


getLineElement

public LineElement getLineElement(java.lang.String lineName)
Returns a line element given a linename.


contains

public boolean contains(MapElement otherElement)
Returns true if the given map element is contained inside this map element.


overlaps

public boolean overlaps(MapElement otherElement)

contains

public boolean contains(java.awt.Point point)
Returns true if the given point is located within this map element.


factorX

public double factorX()
Returns the ratio of coords/pixels along the x-axis.


factorY

public double factorY()
Returns the ratio of coords/pixels along the y-axis.


getX1

public int getX1()

getY1

public int getY1()

getX2

public int getX2()

getY2

public int getY2()

getUTMZone

public int getUTMZone()

getZoomLevel

public int getZoomLevel()

getMapName

public java.lang.String getMapName()

getImageURL

public java.net.URL getImageURL()

getRegionSize

public int getRegionSize()

createSuperRegion

public void createSuperRegion(MapElement superElement)
Marks the given map element as a super region for this map element.


createSubRegion

public void createSubRegion(MapElement subElement)
Marks the given map element as a sub region for this map element.


createRectangleOutline

public void createRectangleOutline(int x,
                                   int y,
                                   int width,
                                   int height)
Creates a rectangle outline with the given dimensions.


removeRegion

public void removeRegion()
Clears the rectangle outline.


isSuperRegion

public boolean isSuperRegion()
Returns true if this map element is a super region.


setSuperRegion

public void setSuperRegion(boolean isSuper)
Sets this map element as a super region.


createLineRegions

public void createLineRegions()
Creates regions for all the lines.


createPointRegions

public void createPointRegions()
Creates regions for all the points.


getNodeAtPoint

public PointElement getNodeAtPoint(java.awt.Point point)
Returns the point element at a given point.


getLineAtPoint

public LineElement getLineAtPoint(java.awt.Point point)
Returns the line element at a given point.


filterLines

public void filterLines(java.lang.String lineType)
Filters all the lines, keeping only those with a spesific linetype.


filterPoints

public void filterPoints(java.lang.String pointType)
Filters all the points, keeping only those with a spesific pointtype.


getLineTypes

public java.util.Vector getLineTypes()
Returns all the linetypes.


getPointTypes

public java.util.Vector getPointTypes()
Returns all the pointtypes.


assignLineStatistics

public void assignLineStatistics(java.util.Vector lineStatList)
Assigns all the available line statistics to line elements.


assignPointStatistics

public void assignPointStatistics(java.util.Vector pointStatList)
Assigns all the available point statistics to point elements.


resetPointStatistics

public void resetPointStatistics()
Clears all the point statistics.


resetLineStatistics

public void resetLineStatistics()
Clears all the line statistics.


drawSelected

public void drawSelected(java.awt.Graphics _g)
Draws the map region when selected with the mouse pointer.

Specified by:
drawSelected in interface Selectable

performMouseClickAction

public void performMouseClickAction(MapFrame mapFrame,
                                    java.awt.event.MouseEvent e)
Selects this map when it is clicked on with the mouse.

Specified by:
performMouseClickAction in interface Selectable

toString

public java.lang.String toString()
Returns the name of the map.


compareTo

public int compareTo(java.lang.Object o)
Returns the string comparison of the map names.

Specified by:
compareTo in interface java.lang.Comparable