Class TransitBusSymbol

java.lang.Object
  |
  +--TransitBusSymbol
All Implemented Interfaces:
hw7.ClickableProp, uwcse.animation.Prop

public class TransitBusSymbol
extends java.lang.Object
implements hw7.ClickableProp

This class holds all the parts of a symbol that represents a bus on a map.


Constructor Summary
TransitBusSymbol(hw7.TransitBusEvent evt)
          Create a new TransitBusSymbol.
 
Method Summary
 void addTo(uwcse.graphics.GWindow gw)
          Add this symbol to the given GWindow.
 void doClickAction()
          This method is called whenever this Prop is clicked on.
 boolean intersects(uwcse.graphics.Shape other)
          Decide if the other Shape intersects this symbol.
 void removeFromWindow()
          Remove this symbol from the GWindow it was added to earlier.
 void setVehicleLocation(TransitMap m, double lat, double lon)
          Set the Location of the LocatedVehicle we are tracking, based on new latitude and longitude values.
 java.lang.String toString()
          Provide a String representing this symbol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransitBusSymbol

public TransitBusSymbol(hw7.TransitBusEvent evt)
Create a new TransitBusSymbol. Initialize an instance variable for our display window to null, since we haven't been added to a window yet. Remember the vin, lat, lon, and route information from the TransitBusEvent object by storing them in instance variables, either individually or as part of a TransitBus object. Create and remember the various shapes (Rectangle, TextShape) that we will use to display this bus on the map. Initialize any other instance variables that you need in the other methods.

Method Detail

setVehicleLocation

public void setVehicleLocation(TransitMap m,
                               double lat,
                               double lon)
Set the Location of the LocatedVehicle we are tracking, based on new latitude and longitude values. Move the symbol to that location on the map by moving all of the Shapes to their proper locations. The supplied TransitMap object has methods pixelX(lon) and pixelY(lat) that can convert longitude and latitude into the proper x,y pixel coordinates for display.

Parameters:
m - the TransitMap that we are being displayed on. Supplies the pixelX and pixelY methods that convert coordinates.
lat - the new latitude to use
lon - the new longitude to use.

addTo

public void addTo(uwcse.graphics.GWindow gw)
Add this symbol to the given GWindow. If we are already added to a window, return without doing anything. Otherwise, add all the Shapes we are using to the window.

Specified by:
addTo in interface uwcse.animation.Prop
Parameters:
gw - the GWindow to add ourselves to

removeFromWindow

public void removeFromWindow()
Remove this symbol from the GWindow it was added to earlier. If we are not in a window, return without doing anything. Otherwise, remove all of our Shapes from the window.

Specified by:
removeFromWindow in interface uwcse.animation.Prop

intersects

public boolean intersects(uwcse.graphics.Shape other)
Decide if the other Shape intersects this symbol. This method uses the intersects(other) method to decide if there is an intersection between the other Shape and our background shape, assuming that the background Shape covers all the area that the other parts of this symbol might fall onto.

Specified by:
intersects in interface hw7.ClickableProp
Parameters:
other - the other Shape that we might intersect with
Returns:
true if the given Shape intersects us, else false

doClickAction

public void doClickAction()
This method is called whenever this Prop is clicked on. The method prints out some information about the bus this symbol represents.

Specified by:
doClickAction in interface hw7.ClickableProp

toString

public java.lang.String toString()
Provide a String representing this symbol.

Overrides:
toString in class java.lang.Object
Returns:
our String representation