vanetsim.gui
Class Renderer

java.lang.Object
  extended by vanetsim.gui.Renderer

public final class Renderer
extends java.lang.Object

This class performs all rendering tasks.


Method Summary
 void drawMovingObjects(java.awt.Graphics2D g2d)
          This function renders all non-static objects on the supplied Graphics2D object.
 void drawScale(java.awt.image.BufferedImage image)
          Creates an image to see the current scale.
 void drawStaticObjects(java.awt.image.BufferedImage image)
          This function renders all non-moving objects on a supplied image.
 Vehicle getAttackedVehicle()
           
 Vehicle getAttackerVehicle()
          Gets the attacker vehicle.
static Renderer getInstance()
          Gets the single instance of this renderer.
 java.util.ArrayList<java.lang.String> getLocationInformationMix()
           
 java.util.ArrayList<java.lang.String> getLocationInformationSilentPeriod_()
           
 double getMapZoom()
          Gets the current zooming factor.
 Junction getMarkedJunction_()
           
 Vehicle getMarkedVehicle()
          Gets a marked vehicle.
 double getMiddleX()
          Gets the x coordinate of the middle of the current view.
 double getMiddleY()
          Gets the y coordinate of the middle of the current view.
 int getMixZoneAmount()
           
 int getTimePassed()
          Gets the time passed since simulation start.
 java.awt.geom.AffineTransform getTransform()
          Gets the currently active coordinate transformation.
 boolean isAutoAddMixZones()
          Gets if mix zones are added automatically on each street corner
 boolean isConsoleStart()
           
 boolean isShowAttackers()
           
 boolean isShowMixZones()
          Gets if mix zones are displayed
 boolean isShowRSUs()
          Gets if RSUs are displayed
 boolean isShowVehicles()
          Gets if vehicles are displayed.
 void notifySimulationRunning(boolean running)
          Notify if the simulation is running or not.
 void pan(char direction)
          Pans the viewable area.
 void pan(double x, double y)
          Pans the viewable area.
 void ReRender(boolean fullRender, boolean forceRenderNow)
          Schedules an update of the DrawingArea.
 void setAttackedVehicle(Vehicle attackedVehicle_)
           
 void setAttackerVehicle(Vehicle attackerVehicle)
          Sets a new attacker vehicle.
 void setAutoAddMixZones(boolean autoAddMixZones)
          If you want to add mix zones to all street corners automatically.
 void setBarrierForSimulationMaster(java.util.concurrent.CyclicBarrier barrier)
          Sets the barrier for synchronization with the SimulationMaster.
 void setConsoleStart(boolean consoleStart)
           
 void setDisplayVehicleIDs(boolean displayVehicleIDs)
          If the IDs of the vehicle shall be drawn on the map.
 void setDrawArea(DrawingArea drawArea)
          Sets the DrawingArea this Renderer is associated with.
 void setDrawHeight(int drawHeight)
          Set the height of the DrawingArea.
 void setDrawWidth(int drawWidth)
          Set the width of the DrawingArea.
 void setHideMixZones(boolean hideMixZones)
          If filled circles shall be displayed to hide the mix zones.
 void setHighlightCommunication(boolean highlightCommunication)
          If circles shall be displayed to show communication distance.
 void setHighlightNodes(boolean highlightNodes)
          If all nodes shall be highlighted.
 void setLocationInformationMix(java.util.ArrayList<java.lang.String> locationInformation)
           
 void setLocationInformationSilentPeriod_(java.util.ArrayList<java.lang.String> locationInformationSilentPeriod_)
           
 void setMapZoom(double zoom)
          Sets a new zooming factor.
 void setMarkedJunction_(Junction markedJunction_)
           
 void setMarkedStreet(Street markedStreet)
          Sets a new marked street.
 void setMarkedVehicle(Vehicle markedVehicle)
          Sets a new marked vehicle.
 void setMiddle(int x, int y)
          Sets the coordinates of the center of the viewable area.
 void setMixZoneAmount(int mixZoneAmount)
           
 void setMonitoredBeaconZoneVariables(int beaconMonitorMinX, int beaconMonitorMaxX, int beaconMonitorMinY, int beaconMonitorMaxY)
          Sets the values for the monitored beacon zone.
 void setShowAllBlockings(boolean showAllBlockings)
          If you want to show all blockings.
 void setShowAttackers(boolean showAttackers_)
           
 void setShowBeaconMonitorZone(boolean showBeaconMonitorZone)
          If you want to display the monitored beacon zone.
 void setShowMixZones(boolean showMixZones)
          If you want to show all mix zones.
 void setShowRSUs(boolean showRSUs)
          If you want to show all RSUs.
 void setShowVehicles(boolean showVehicles)
          If you want to show all vehicles.
 void setTimePassed(int timePassed)
          Sets the time passed since simulation start.
 void updateParams()
          Updates various internal parameters after changes through panning or zooming.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Renderer getInstance()
Gets the single instance of this renderer.

Returns:
single instance of this renderer

drawMovingObjects

public void drawMovingObjects(java.awt.Graphics2D g2d)
This function renders all non-static objects on the supplied Graphics2D object.

Parameters:
g2d - the Graphics2D object on which rendering takes place

drawScale

public void drawScale(java.awt.image.BufferedImage image)
Creates an image to see the current scale.

Parameters:
image - the BufferedImage on which rendering should be done

drawStaticObjects

public void drawStaticObjects(java.awt.image.BufferedImage image)
This function renders all non-moving objects on a supplied image. All streets and other static objects are rendered into the cached Image in this function. This function should only be called on

Note: The main performance factor here are the calls to draw() or drawLine(). This is a factor determined by the underlying graphics subsytem and there's not much space for lot of improvement. Multithreading approaches are not possible here: The graphics subsystem is just singlethreaded (blocks concurrent draw-Calls even if they are done on different BufferedImages) and so there's no performance benefit.
Optimizing anything concerned with iterating through the regions is not worth it because the cpu time for this is barely measurable after using ArrayLists instead of Iterators (iterators create lots of object creations and calls)

Parameters:
image - the BufferedImage on which rendering should be done

pan

public void pan(char direction)
Pans the viewable area.

Parameters:
direction - u to pan up, d to pan down, l to pan left, r to pan right

pan

public void pan(double x,
                double y)
Pans the viewable area.

Parameters:
x - the value for how far to pan in x direction (in map scale!)
y - the value for how far to pan in y direction (in map scale!)

setMapZoom

public void setMapZoom(double zoom)
Sets a new zooming factor.

Parameters:
zoom - the new zooming factor

updateParams

public void updateParams()
Updates various internal parameters after changes through panning or zooming.
The regions which shall be drawn are calculated here. They are a little bit larger than normally necessary in order to correctly display communication distance and mix zones. Otherwise, the distance of a vehicle, which is a little bit outside the currently viewable area wouldn't be drawn. This all induces a little bit of an unnecessary overdraw to the static objects but this should not matter a lot.


ReRender

public void ReRender(boolean fullRender,
                     boolean forceRenderNow)
Schedules an update of the DrawingArea. Note that depending on if a simulation is running or not, the update might be performed at a later time!

Parameters:
fullRender - true if a full update including all static objects should be done, else false
forceRenderNow - true to force an immediate update regardless of consistency considerations (should only be used by the SimulationMaster)

getMiddleX

public double getMiddleX()
Gets the x coordinate of the middle of the current view.

Returns:
the x coordinate in map scale

getMiddleY

public double getMiddleY()
Gets the y coordinate of the middle of the current view.

Returns:
the y coordinate in map scale

getMapZoom

public double getMapZoom()
Gets the current zooming factor.

Returns:
the current zooming factor

getTimePassed

public int getTimePassed()
Gets the time passed since simulation start.

Returns:
the time passed in milliseconds

getTransform

public java.awt.geom.AffineTransform getTransform()
Gets the currently active coordinate transformation.

Returns:
the transform

notifySimulationRunning

public void notifySimulationRunning(boolean running)
Notify if the simulation is running or not.

Parameters:
running - true if a simulation is currently running, false if it's suspended

setMarkedStreet

public void setMarkedStreet(Street markedStreet)
Sets a new marked street.

Parameters:
markedStreet - the street to mark

setMarkedVehicle

public void setMarkedVehicle(Vehicle markedVehicle)
Sets a new marked vehicle.

Parameters:
markedVehicle - the vehicle to mark

getMarkedVehicle

public Vehicle getMarkedVehicle()
Gets a marked vehicle.


setAttackerVehicle

public void setAttackerVehicle(Vehicle attackerVehicle)
Sets a new attacker vehicle.

Parameters:
attackerVehicle - the attacker vehicle

getAttackerVehicle

public Vehicle getAttackerVehicle()
Gets the attacker vehicle.


setMiddle

public void setMiddle(int x,
                      int y)
Sets the coordinates of the center of the viewable area.

Parameters:
x - the new x coordinate for the center of the viewable area
y - the new y coordinate for the center of the viewable area

setDrawArea

public void setDrawArea(DrawingArea drawArea)
Sets the DrawingArea this Renderer is associated with.

Parameters:
drawArea - the area on which this Renderer draws

setDrawHeight

public void setDrawHeight(int drawHeight)
Set the height of the DrawingArea.

Parameters:
drawHeight - the new height

setDrawWidth

public void setDrawWidth(int drawWidth)
Set the width of the DrawingArea.

Parameters:
drawWidth - the new width

setTimePassed

public void setTimePassed(int timePassed)
Sets the time passed since simulation start.

Parameters:
timePassed - the new time in milliseconds

setBarrierForSimulationMaster

public void setBarrierForSimulationMaster(java.util.concurrent.CyclicBarrier barrier)
Sets the barrier for synchronization with the SimulationMaster.

Parameters:
barrier - the barrier to use

setHighlightNodes

public void setHighlightNodes(boolean highlightNodes)
If all nodes shall be highlighted.

Parameters:
highlightNodes - true if you want to highlight nodes, else false

setHighlightCommunication

public void setHighlightCommunication(boolean highlightCommunication)
If circles shall be displayed to show communication distance.

Parameters:
highlightCommunication - true if you want to show the circles, else false

setHideMixZones

public void setHideMixZones(boolean hideMixZones)
If filled circles shall be displayed to hide the mix zones.

Parameters:
hideMixZones - true if you want to show the circles, else false

setDisplayVehicleIDs

public void setDisplayVehicleIDs(boolean displayVehicleIDs)
If the IDs of the vehicle shall be drawn on the map.

Parameters:
displayVehicleIDs - true if you want to show the IDs, else false

setShowAllBlockings

public void setShowAllBlockings(boolean showAllBlockings)
If you want to show all blockings.

Parameters:
showAllBlockings - true if you want to show all blockings, else false

setShowBeaconMonitorZone

public void setShowBeaconMonitorZone(boolean showBeaconMonitorZone)
If you want to display the monitored beacon zone.

Parameters:
showBeaconMonitorZone - true if you want to display the monitored beacon zones, else false

setMonitoredBeaconZoneVariables

public void setMonitoredBeaconZoneVariables(int beaconMonitorMinX,
                                            int beaconMonitorMaxX,
                                            int beaconMonitorMinY,
                                            int beaconMonitorMaxY)
Sets the values for the monitored beacon zone. A rectangular bounding box within the specified coordinates is monitored if setShowBeaconMonitorZone(boolean) is set to true.

Parameters:
beaconMonitorMinX - the minimum x coordinate
beaconMonitorMaxX - the maximum x coordinate
beaconMonitorMinY - the minimum y coordinate
beaconMonitorMaxY - the maximum y coordinate

setShowVehicles

public void setShowVehicles(boolean showVehicles)
If you want to show all vehicles.

Parameters:
showVehicles - true if you want to show all vehicles, else false

isShowVehicles

public boolean isShowVehicles()
Gets if vehicles are displayed.

Returns:
true if vehicles are displayed

setShowMixZones

public void setShowMixZones(boolean showMixZones)
If you want to show all mix zones.

Parameters:
showMixZones - true if you want to show all mix zones, else false

isShowMixZones

public boolean isShowMixZones()
Gets if mix zones are displayed

Returns:
true if mix zones are displayed

setAutoAddMixZones

public void setAutoAddMixZones(boolean autoAddMixZones)
If you want to add mix zones to all street corners automatically.

Parameters:
autoAddMixZones - true if you want to add mix zones to all street corners automatically else false

isAutoAddMixZones

public boolean isAutoAddMixZones()
Gets if mix zones are added automatically on each street corner

Returns:
true if mix zones are added automatically

setShowRSUs

public void setShowRSUs(boolean showRSUs)
If you want to show all RSUs.

Parameters:
showRSUs - true if you want to show all RSUs, else false

isShowRSUs

public boolean isShowRSUs()
Gets if RSUs are displayed

Returns:
true if RSUs are displayed

getAttackedVehicle

public Vehicle getAttackedVehicle()

setAttackedVehicle

public void setAttackedVehicle(Vehicle attackedVehicle_)

isShowAttackers

public boolean isShowAttackers()

setShowAttackers

public void setShowAttackers(boolean showAttackers_)

isConsoleStart

public boolean isConsoleStart()

setConsoleStart

public void setConsoleStart(boolean consoleStart)

setMarkedJunction_

public void setMarkedJunction_(Junction markedJunction_)
Parameters:
markedJunction_ - the markedJunction_ to set

getMarkedJunction_

public Junction getMarkedJunction_()
Returns:
the markedJunction_

getLocationInformationMix

public java.util.ArrayList<java.lang.String> getLocationInformationMix()

setLocationInformationMix

public void setLocationInformationMix(java.util.ArrayList<java.lang.String> locationInformation)

getLocationInformationSilentPeriod_

public java.util.ArrayList<java.lang.String> getLocationInformationSilentPeriod_()

setLocationInformationSilentPeriod_

public void setLocationInformationSilentPeriod_(java.util.ArrayList<java.lang.String> locationInformationSilentPeriod_)

getMixZoneAmount

public int getMixZoneAmount()

setMixZoneAmount

public void setMixZoneAmount(int mixZoneAmount)