Class CanvasDrawerGUI


public class CanvasDrawerGUI extends ViewerDefaultGUI
CanvasDrawerGUI extends ViewerDefaultGUI so that a canvas is used for rendering the simulation.
  • Constructor Details

    • CanvasDrawerGUI

      public CanvasDrawerGUI(Viewer viewer)
      Creates a new CanvasDrawerGUI with the specified viewer.
      Parameters:
      viewer - the viewer associated with this GUI.
  • Method Details

    • createTopNode

      protected Node createTopNode()
      Creates the top node of the GUI. It adds a color picker to the menu bar to allow the user to select the background color of the canvas.
      Overrides:
      createTopNode in class ViewerDefaultGUI
      Returns:
      a VBox containing the menu bar
    • createCenterNode

      protected Node createCenterNode()
      Creates the central node of the GUI. It returns a canvas.
      Specified by:
      createCenterNode in class ViewerDefaultGUI
      Returns:
      the central node of the main pane
    • getGraphics

      public GraphicsContext getGraphics()
      Gets the graphics context of the canvas.
      Returns:
      the graphics context of the canvas.
    • getCanvas

      public Canvas getCanvas()
      Gets the canvas
      Returns:
      the canvas
    • clearCanvas

      public void clearCanvas()
      Clears the canvas by filling it with the background color.
    • setCanvasSize

      public void setCanvasSize(int width, int height)
      Sets the size of the canvas.
      Parameters:
      width - the width of the canvas.
      height - the height of the canvas.
    • getBackground

      public Color getBackground()
      Sets the background color of the canvas.
      Returns:
      the background color of the canvas.
    • setBackground

      public void setBackground(Color background)
      Sets the background color of the canvas.
      Parameters:
      background - the background to set