All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----gerken.vehicles.VehicleScenario
The VehicleScenario class implements the behavior that manages a vehicle simulation. It contains all simulation participants and maintains the general simulation parameters.
This software is provided on an as-is basis and is copyright Chris Gerken. The only rights granted to you are to enjoy and learn from this software.
Return a vehicle scenario that covers an area w pixels wide and h pixels high.
Register a participant in the scenario.
Return the Color used to paint the SimulationWindow's background.
Return the x coordinate of the center of the scenario's simulation area
Return the y coordinate of the center of the scenario's simulation area
Return the participant closest to the given Location.
Perform transformations on a DisplayCoordinates to get the corresponding Location.
Perform transformations on a Location to get the DisplayCoordinates that correctly represent that point in a SimulatorWindow.
Return the height in pixels of the simulation area
Return the width in pixels of the space between the simulaiton border and the edge of the screen.
Return a vector containing all of the registered participants for the scenario.
Return a random direction
Return a random x coordinate between 0.0 and the scenario's width inclusive
Return a random y coordinate between 0.0 and the scenario's height inclusive
Return a Vector containing all of the registered simulation participants with color c.
Return the width of the scenario simulation area.
Return whether or not vehicles can "see" and "travel" over borders to the other side of the scenario simulation area.
Begin continuous simulation.
Stop continuous simulation.
Remove (unregister) a participant from the simulation.
Begin simulation of this scenario on a new thread.
Set the current foreground color on the SimulationWIndows's Canvas.
Convenience method to set the current forground color for the SimulationWindow's Canvas to that Canvas' background color.
Put up a SimulationWindow for the scenario and display the initial positions of the scenario's registered participants.
Perform a single step in the scenario's simulation.
Check to see if the participant sits outside of the ScenarioBoundary.
public VehicleScenario(int w,
int h,
boolean a)
Return a vehicle scenario that covers an area w pixels wide and h pixels high. Boolean value a indicates whether participants can see and move across borders (by wraping around to the opposite border).
public void addParticipant(SimulationParticipant participant)
Register a participant in the scenario.
public Color getBackground()
Return the Color used to paint the SimulationWindow's background. This is useful for "erasing" a vehicle at its old positin before it is drawn in its new position.
public double getCenterX()
Return the x coordinate of the center of the scenario's simulation area
public double getCenterY()
Return the y coordinate of the center of the scenario's simulation area
public SimulationParticipant getClosestTo(Location l)
Return the participant closest to the given Location.
public Location getDisplayCoordinates(DisplayCoordinates dc)
Perform transformations on a DisplayCoordinates to get the corresponding Location.
public DisplayCoordinates getDisplayCoordinates(Location l)
Perform transformations on a Location to get the DisplayCoordinates that correctly represent that point in a SimulatorWindow.
public double getHeight()
Return the height in pixels of the simulation area
public int getMargin()
Return the width in pixels of the space between the simulaiton border and the edge of the screen.
public Vector getParticipants()
Return a vector containing all of the registered participants for the scenario.
public double getRandomDirection()
Return a random direction
public double getRandomX()
Return a random x coordinate between 0.0 and the scenario's width inclusive
public double getRandomY()
Return a random y coordinate between 0.0 and the scenario's height inclusive
public Vector getSimulationParticipantsColored(Color c)
Return a Vector containing all of the registered simulation participants with color c.
public double getWidth()
Return the width of the scenario simulation area.
public boolean getWrapsAround()
Return whether or not vehicles can "see" and "travel" over borders to the other side of the scenario simulation area.
public void go()
Begin continuous simulation.
public void halt()
Stop continuous simulation.
public void removeParticipant(SimulationParticipant participant)
Remove (unregister) a participant from the simulation. This is usually done when a participant has been rendered inactive.
public void run()
Begin simulation of this scenario on a new thread.
public void setColor(Color value)
Set the current foreground color on the SimulationWIndows's Canvas.
public void setColorToBackground()
Convenience method to set the current forground color for the SimulationWindow's Canvas to that Canvas' background color. This is usually used to "erase" a vehicle before drawing it in its new position.
public void start()
Put up a SimulationWindow for the scenario and display the initial positions of the scenario's registered participants. It is expected that the scenario is ready to begin imulation when this method is called.
public void step()
Perform a single step in the scenario's simulation.
public void verifyLocation(SimulationParticipant participant)
Check to see if the participant sits outside of the ScenarioBoundary. If so, take appropriate action for the setting of the wrapsAround property.
All Packages Class Hierarchy This Package Previous Next Index