courselog.maputils
Class MapTrack

java.lang.Object
  extended by courselog.maputils.MapTrack

public class MapTrack
extends java.lang.Object

A track which is able to display on a map.


Field Summary
protected  int DISTANCESYMBOLSSQUARE
           
protected  GeoDirection gdTmp
           
protected  int myIndexNext
           
protected  int myIndexSelected
           
protected  double myTotalLength
           
protected  TrackRecord myTrack
           
protected  ewe.fx.Pen PENHANDLE
           
protected  ewe.fx.Point ptTmp
           
protected  ewe.fx.Pen thePenNonVisited
           
protected  ewe.fx.Pen thePenVisited
           
protected  int[] tPX
           
protected  int[] tPY
           
 
Constructor Summary
MapTrack(ewe.fx.Pen pVisited, ewe.fx.Pen pNotVisited)
          Creates a new instance of MapTrack
MapTrack(ewe.fx.Pen pVisited, ewe.fx.Pen pNotVisited, TrackRecord tr)
          Creates a new instance of MapTrack with a track
 
Method Summary
 void addLast(ewe.fx.Point p, GeoGraphable gG)
          Add a point to the track
 void drawHandle(ewe.fx.Graphics g, int x, int y)
          Draw the handle for a waypoint.
 void drawIn(ewe.fx.Graphics g, ewe.fx.Rect r, GeoGraphable gG)
          Display track on a GeoGraphable.
 ewe.fx.Point getMapPointFromPosition(int idxP, GeoDirection tmp, ewe.fx.Point pt, GeoGraphable gG)
          Compute X and Y on map from point index in track.
 TrackPoint getNext()
          Getter for next point to visit.
 TrackPoint getPointAt(int idx)
          Element from the track.
 TrackPoint getSelected()
          Getter for selected point.
 int getSize()
          Number of elements in the track.
 double getTotalLength()
          Total length of the track.
 int indexOfClosestPoint(ewe.fx.Point p, int dMinInt, GeoGraphable gG)
          Find index of closest point from track.
 void loadFromFile(ewe.io.File f)
          Load the track from a file.
 void movePointAt(int idx, ewe.fx.Point p, GeoGraphable gG)
          Move a point to a new position.
 void removeAll()
          Empty the track.
 void removeAt(int idx)
          Remove a point at an index from the track.
 void reverse()
          Invert the direction of the track.
 void selectNext(int direction)
          Circular selection of points.
 void setNextTo(int idx)
          Set the next track point to visit.
 void setSelectedIndex(int sel)
          Setter for selected point.
 void updateDistancesFromIndex(int idxStart)
          Update track points distances starting at a given point.
 void visitNext()
          Visit next point on the track.
 boolean writeToFile(ewe.io.File f)
          Write the track to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PENHANDLE

protected final ewe.fx.Pen PENHANDLE

DISTANCESYMBOLSSQUARE

protected final int DISTANCESYMBOLSSQUARE
See Also:
Constant Field Values

thePenVisited

protected ewe.fx.Pen thePenVisited

thePenNonVisited

protected ewe.fx.Pen thePenNonVisited

tPX

protected int[] tPX

tPY

protected int[] tPY

myTrack

protected TrackRecord myTrack

myIndexSelected

protected int myIndexSelected

myIndexNext

protected int myIndexNext

myTotalLength

protected double myTotalLength

ptTmp

protected ewe.fx.Point ptTmp

gdTmp

protected GeoDirection gdTmp
Constructor Detail

MapTrack

public MapTrack(ewe.fx.Pen pVisited,
                ewe.fx.Pen pNotVisited)
Creates a new instance of MapTrack


MapTrack

public MapTrack(ewe.fx.Pen pVisited,
                ewe.fx.Pen pNotVisited,
                TrackRecord tr)
Creates a new instance of MapTrack with a track

Method Detail

getSize

public int getSize()
Number of elements in the track.


getPointAt

public TrackPoint getPointAt(int idx)
Element from the track.

Parameters:
idx - index of the point from the track.
Returns:
Element casted to a TrackPoint or null if index is invalid.

getTotalLength

public double getTotalLength()
Total length of the track.


getNext

public TrackPoint getNext()
Getter for next point to visit.


getSelected

public TrackPoint getSelected()
Getter for selected point.


setSelectedIndex

public void setSelectedIndex(int sel)
Setter for selected point.


selectNext

public void selectNext(int direction)
Circular selection of points.

Parameters:
direction - if positive, go to next, if negative previous.

addLast

public void addLast(ewe.fx.Point p,
                    GeoGraphable gG)
Add a point to the track


updateDistancesFromIndex

public void updateDistancesFromIndex(int idxStart)
Update track points distances starting at a given point.

Parameters:
idxStart - Index of first point to update. If 0, all track is updated.

removeAt

public void removeAt(int idx)
Remove a point at an index from the track.


removeAll

public void removeAll()
Empty the track.


indexOfClosestPoint

public int indexOfClosestPoint(ewe.fx.Point p,
                               int dMinInt,
                               GeoGraphable gG)
Find index of closest point from track.


movePointAt

public void movePointAt(int idx,
                        ewe.fx.Point p,
                        GeoGraphable gG)
Move a point to a new position.


reverse

public void reverse()
Invert the direction of the track.


visitNext

public void visitNext()
Visit next point on the track.


setNextTo

public void setNextTo(int idx)
Set the next track point to visit. All points before are visited too.


loadFromFile

public void loadFromFile(ewe.io.File f)
Load the track from a file.


writeToFile

public boolean writeToFile(ewe.io.File f)
Write the track to a file.


drawIn

public void drawIn(ewe.fx.Graphics g,
                   ewe.fx.Rect r,
                   GeoGraphable gG)
Display track on a GeoGraphable.


drawHandle

public void drawHandle(ewe.fx.Graphics g,
                       int x,
                       int y)
Draw the handle for a waypoint.


getMapPointFromPosition

public ewe.fx.Point getMapPointFromPosition(int idxP,
                                            GeoDirection tmp,
                                            ewe.fx.Point pt,
                                            GeoGraphable gG)
Compute X and Y on map from point index in track.

Parameters:
idxP - Point index to localise.
tmp - GeoDirection reference to compute intermediate direction. If null a new object is allocated.
pt - point on bitmap image to compute. If null a new Point object is allocated.
Returns:
Computed point. Should be pt or a new Point object.