Skip to content

SimState.java

Raphael Lutz edited this page Aug 19, 2018 · 1 revision

Main state, manages about ticking and rendering all its elements.

Fields

  • UIManager uiManager : link to the uiManager.
  • KeyManager keyManager : link to the keyManager.
  • Network network : represents the network being simulated.
  • int step = 0 : the counter of the number of steps being already simulated.
  • double stepSize = 1 : size of a step in seconds.
  • String[] daysOfWeek = {"Mon","Tue","Wed","Thu","Fri","Sat","Sun"} : contains the abbreviated days of a week.
  • boolean paused = false : tells if the simulation is paused.
  • boolean askExit = false : tells if user has clicked on "Exit" button.
  • long lastTick : long containing time of the last tick.
  • double simSpeed = 20 : speed of the simulation display.
  • double offsetSpeed = 1 : speed at which user can offset the network.
  • double offsetSpeedDefault = offsetSpeed : default value of offsetSpeed.
  • long offsetTime = 0 : records the duration of the offset.
  • double rotationSpeed = 0.02 : speed at which user can rotate the network.
  • UITextButton stepByStep, exitY, exitN : represents the 3 text button (step-by-step, Yes/No buttons after asking to exit)
  • UIImageButton playPause : the only buttons changing its image.
  • UITextSwitch colorOn, wireOn, idOn, namesOn, centersOn : the buttons changing their text.
  • BufferedImage[] networkDisplays : the possible displays of the network (wire, colors, ...).
  • BufferedImage currentDisplay : the current display chosen by user.
  • BufferedImage hud : image containing the HUD.
  • BufferedImage background : image of the background.
  • int currentBackgroundID = 0 : current ID of the background.
  • int currentNetwork = -1 : current chosen network.

Method

  • SimState(Simulation simulation) : constructor of the class, initializes the managers and the buttons.
  • void init() : initializes the simulation, renders the backgrounds and network, and call computation of cells position.
  • void renderBG(Network network, BufferedImage[] backgrounds) : render all backgrounds possibilities on backgrounds.
  • void tick(int n) : calls evolution of the network n times every tick, and listen mouse and keyboard entries.
  • void increaseOffset() : increase the offset speed, giving a smooth movement.
  • void tick() : does nothing.
  • void render(Graphics g) : renders the background, network, HUD and buttons.
  • void restartNetwork() : restarts simulation of the network.
  • String getTime() : returns the time on human format "DDD HH:MM:SS".

Getters and setters

The getters and setters for some fields.

Clone this wiki locally