VANET Simulator
 All Classes Functions Variables
Public Member Functions | Static Public Member Functions | List of all members
vanetsim.gui.Renderer Class Reference

Public Member Functions

void drawMovingObjects (Graphics2D g2d)
 
void drawScale (BufferedImage image)
 
synchronized void drawStaticObjects (BufferedImage image)
 
synchronized void pan (char direction)
 
synchronized void pan (double x, double y)
 
synchronized void setMapZoom (double zoom)
 
synchronized void updateParams ()
 
void ReRender (boolean fullRender, boolean forceRenderNow)
 
double getMiddleX ()
 
double getMiddleY ()
 
double getMapZoom ()
 
int getTimePassed ()
 
AffineTransform getTransform ()
 
void notifySimulationRunning (boolean running)
 
synchronized void setMarkedStreet (Street markedStreet)
 
synchronized void setMarkedVehicle (Vehicle markedVehicle)
 
synchronized Vehicle getMarkedVehicle ()
 
synchronized void setAttackerVehicle (Vehicle attackerVehicle)
 
synchronized Vehicle getAttackerVehicle ()
 
synchronized void setMiddle (int x, int y)
 
void setDrawArea (DrawingArea drawArea)
 
void setDrawHeight (int drawHeight)
 
void setDrawWidth (int drawWidth)
 
void setTimePassed (int timePassed)
 
void setBarrierForSimulationMaster (CyclicBarrier barrier)
 
void setHighlightNodes (boolean highlightNodes)
 
void setHighlightCommunication (boolean highlightCommunication)
 
void setHideMixZones (boolean hideMixZones)
 
void setDisplayVehicleIDs (boolean displayVehicleIDs)
 
void setShowAllBlockings (boolean showAllBlockings)
 
void setShowBeaconMonitorZone (boolean showBeaconMonitorZone)
 
void setMonitoredBeaconZoneVariables (int beaconMonitorMinX, int beaconMonitorMaxX, int beaconMonitorMinY, int beaconMonitorMaxY)
 
void setShowVehicles (boolean showVehicles)
 
boolean isShowVehicles ()
 
void setShowMixZones (boolean showMixZones)
 
boolean isShowMixZones ()
 
void setAutoAddMixZones (boolean autoAddMixZones)
 
boolean isAutoAddMixZones ()
 
void setShowRSUs (boolean showRSUs)
 
boolean isShowRSUs ()
 
Vehicle getAttackedVehicle ()
 
void setAttackedVehicle (Vehicle attackedVehicle_)
 
boolean isShowAttackers ()
 
void setShowAttackers (boolean showAttackers_)
 
boolean isConsoleStart ()
 
void setConsoleStart (boolean consoleStart)
 
void setMarkedJunction_ (Junction markedJunction_)
 
Junction getMarkedJunction_ ()
 
ArrayList< String > getLocationInformationMix ()
 
void setLocationInformationMix (ArrayList< String > locationInformation)
 
ArrayList< String > getLocationInformationSilentPeriod_ ()
 
void setLocationInformationSilentPeriod_ (ArrayList< String > locationInformationSilentPeriod_)
 
int getMixZoneAmount ()
 
void setMixZoneAmount (int mixZoneAmount)
 

Static Public Member Functions

static Renderer getInstance ()
 

Detailed Description

This class performs all rendering tasks.

Member Function Documentation

void vanetsim.gui.Renderer.drawMovingObjects ( Graphics2D  g2d)
inline

This function renders all non-static objects on the supplied Graphics2D object.

Parameters
g2dthe Graphics2D object on which rendering takes place
void vanetsim.gui.Renderer.drawScale ( BufferedImage  image)
inline

Creates an image to see the current scale.

Parameters
imagethe BufferedImage on which rendering should be done
synchronized void vanetsim.gui.Renderer.drawStaticObjects ( BufferedImage  image)
inline

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

  • size changes of the drawing area
  • zooming or panning
  • map loading
  • new map objects appearing



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
imagethe BufferedImage on which rendering should be done
synchronized Vehicle vanetsim.gui.Renderer.getAttackerVehicle ( )
inline

Gets the attacker vehicle.

static Renderer vanetsim.gui.Renderer.getInstance ( )
inlinestatic

Gets the single instance of this renderer.

Returns
single instance of this renderer
double vanetsim.gui.Renderer.getMapZoom ( )
inline

Gets the current zooming factor.

Returns
the current zooming factor
Junction vanetsim.gui.Renderer.getMarkedJunction_ ( )
inline
Returns
the markedJunction_
synchronized Vehicle vanetsim.gui.Renderer.getMarkedVehicle ( )
inline

Gets a marked vehicle.

double vanetsim.gui.Renderer.getMiddleX ( )
inline

Gets the x coordinate of the middle of the current view.

Returns
the x coordinate in map scale
double vanetsim.gui.Renderer.getMiddleY ( )
inline

Gets the y coordinate of the middle of the current view.

Returns
the y coordinate in map scale
int vanetsim.gui.Renderer.getTimePassed ( )
inline

Gets the time passed since simulation start.

Returns
the time passed in milliseconds
AffineTransform vanetsim.gui.Renderer.getTransform ( )
inline

Gets the currently active coordinate transformation.

Returns
the transform
boolean vanetsim.gui.Renderer.isAutoAddMixZones ( )
inline

Gets if mix zones are added automatically on each street corner

Returns
true if mix zones are added automatically
boolean vanetsim.gui.Renderer.isShowMixZones ( )
inline

Gets if mix zones are displayed

Returns
true if mix zones are displayed
boolean vanetsim.gui.Renderer.isShowRSUs ( )
inline

Gets if RSUs are displayed

Returns
true if RSUs are displayed
boolean vanetsim.gui.Renderer.isShowVehicles ( )
inline

Gets if vehicles are displayed.

Returns
true if vehicles are displayed
void vanetsim.gui.Renderer.notifySimulationRunning ( boolean  running)
inline

Notify if the simulation is running or not.

Parameters
runningtrue if a simulation is currently running, false if it's suspended
synchronized void vanetsim.gui.Renderer.pan ( char  direction)
inline

Pans the viewable area.

Parameters
directionu to pan up, d to pan down, l to pan left, r to pan right
synchronized void vanetsim.gui.Renderer.pan ( double  x,
double  y 
)
inline

Pans the viewable area.

Parameters
xthe value for how far to pan in x direction (in map scale!)
ythe value for how far to pan in y direction (in map scale!)
void vanetsim.gui.Renderer.ReRender ( boolean  fullRender,
boolean  forceRenderNow 
)
inline

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
fullRendertrue if a full update including all static objects should be done, else false
forceRenderNowtrue to force an immediate update regardless of consistency considerations (should only be used by the vanetsim.simulation.SimulationMaster)
synchronized void vanetsim.gui.Renderer.setAttackerVehicle ( Vehicle  attackerVehicle)
inline

Sets a new attacker vehicle.

Parameters
attackerVehiclethe attacker vehicle
void vanetsim.gui.Renderer.setAutoAddMixZones ( boolean  autoAddMixZones)
inline

If you want to add mix zones to all street corners automatically.

Parameters
autoAddMixZonestrue if you want to add mix zones to all street corners automatically else false
void vanetsim.gui.Renderer.setBarrierForSimulationMaster ( CyclicBarrier  barrier)
inline

Sets the barrier for synchronization with the SimulationMaster.

Parameters
barrierthe barrier to use
void vanetsim.gui.Renderer.setDisplayVehicleIDs ( boolean  displayVehicleIDs)
inline

If the IDs of the vehicle shall be drawn on the map.

Parameters
displayVehicleIDstrue if you want to show the IDs, else false
void vanetsim.gui.Renderer.setDrawArea ( DrawingArea  drawArea)
inline

Sets the DrawingArea this Renderer is associated with.

Parameters
drawAreathe area on which this Renderer draws
void vanetsim.gui.Renderer.setDrawHeight ( int  drawHeight)
inline

Set the height of the DrawingArea.

Parameters
drawHeightthe new height
void vanetsim.gui.Renderer.setDrawWidth ( int  drawWidth)
inline

Set the width of the DrawingArea.

Parameters
drawWidththe new width
void vanetsim.gui.Renderer.setHideMixZones ( boolean  hideMixZones)
inline

If filled circles shall be displayed to hide the mix zones.

Parameters
hideMixZonestrue if you want to show the circles, else false
void vanetsim.gui.Renderer.setHighlightCommunication ( boolean  highlightCommunication)
inline

If circles shall be displayed to show communication distance.

Parameters
highlightCommunicationtrue if you want to show the circles, else false
void vanetsim.gui.Renderer.setHighlightNodes ( boolean  highlightNodes)
inline

If all nodes shall be highlighted.

Parameters
highlightNodestrue if you want to highlight nodes, else false
synchronized void vanetsim.gui.Renderer.setMapZoom ( double  zoom)
inline

Sets a new zooming factor.

Parameters
zoomthe new zooming factor
void vanetsim.gui.Renderer.setMarkedJunction_ ( Junction  markedJunction_)
inline
Parameters
markedJunction_the markedJunction_ to set
synchronized void vanetsim.gui.Renderer.setMarkedStreet ( Street  markedStreet)
inline

Sets a new marked street.

Parameters
markedStreetthe street to mark
synchronized void vanetsim.gui.Renderer.setMarkedVehicle ( Vehicle  markedVehicle)
inline

Sets a new marked vehicle.

Parameters
markedVehiclethe vehicle to mark
synchronized void vanetsim.gui.Renderer.setMiddle ( int  x,
int  y 
)
inline

Sets the coordinates of the center of the viewable area.

Parameters
xthe new x coordinate for the center of the viewable area
ythe new y coordinate for the center of the viewable area
void vanetsim.gui.Renderer.setMonitoredBeaconZoneVariables ( int  beaconMonitorMinX,
int  beaconMonitorMaxX,
int  beaconMonitorMinY,
int  beaconMonitorMaxY 
)
inline

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
beaconMonitorMinXthe minimum x coordinate
beaconMonitorMaxXthe maximum x coordinate
beaconMonitorMinYthe minimum y coordinate
beaconMonitorMaxYthe maximum y coordinate
void vanetsim.gui.Renderer.setShowAllBlockings ( boolean  showAllBlockings)
inline

If you want to show all blockings.

Parameters
showAllBlockingstrue if you want to show all blockings, else false
void vanetsim.gui.Renderer.setShowBeaconMonitorZone ( boolean  showBeaconMonitorZone)
inline

If you want to display the monitored beacon zone.

Parameters
showBeaconMonitorZonetrue if you want to display the monitored beacon zones, else false
void vanetsim.gui.Renderer.setShowMixZones ( boolean  showMixZones)
inline

If you want to show all mix zones.

Parameters
showMixZonestrue if you want to show all mix zones, else false
void vanetsim.gui.Renderer.setShowRSUs ( boolean  showRSUs)
inline

If you want to show all RSUs.

Parameters
showRSUstrue if you want to show all RSUs, else false
void vanetsim.gui.Renderer.setShowVehicles ( boolean  showVehicles)
inline

If you want to show all vehicles.

Parameters
showVehiclestrue if you want to show all vehicles, else false
void vanetsim.gui.Renderer.setTimePassed ( int  timePassed)
inline

Sets the time passed since simulation start.

Parameters
timePassedthe new time in milliseconds
synchronized void vanetsim.gui.Renderer.updateParams ( )
inline

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.


The documentation for this class was generated from the following file: