Class View

  • All Implemented Interfaces:
    EventListener, javafx.event.EventHandler<javafx.scene.input.KeyEvent>

    public class View
    extends Object
    implements javafx.event.EventHandler<javafx.scene.input.KeyEvent>
    • Constructor Summary

      Constructors 
      Constructor Description
      View​(int w, int h)
      constructor method - we get told the width and height of the window
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void displayGameObj​(javafx.scene.canvas.GraphicsContext gc, GameObj go)
      Display a game object - it is just a rectangle on the canvas
      void drawPicture()
      drawing the game image
      void handle​(javafx.scene.input.KeyEvent event)
      Event handler for key presses - it just passes the event to the controller
      void start​(javafx.stage.Stage window)
      start is called from the Main class, to start the GUI up
      void update()
      This is how the Model talks to the View This method gets called BY THE MODEL, whenever the model changes It has to do whatever is required to update the GUI to show the new game position
    • Field Detail

      • width

        public int width
        variables for components of the user interface
      • height

        public int height
        width of window
      • pane

        public javafx.scene.layout.Pane pane
        user interface objects
      • canvas

        public javafx.scene.canvas.Canvas canvas
        basic layout pane
      • infoText

        public javafx.scene.control.Label infoText
        canvas to draw game on
      • controller

        public Controller controller
        The other parts of the model-view-controller setup
      • model

        public Model model
      • ball

        public GameObj ball
        The bat
      • bricks

        public GameObj[] bricks
        The ball
      • score

        public int score
        The bricks
    • Constructor Detail

      • View

        public View​(int w,
                    int h)
        constructor method - we get told the width and height of the window
    • Method Detail

      • start

        public void start​(javafx.stage.Stage window)
        start is called from the Main class, to start the GUI up
      • handle

        public void handle​(javafx.scene.input.KeyEvent event)
        Event handler for key presses - it just passes the event to the controller
        Specified by:
        handle in interface javafx.event.EventHandler<javafx.scene.input.KeyEvent>
      • drawPicture

        public void drawPicture()
        drawing the game image
      • displayGameObj

        public void displayGameObj​(javafx.scene.canvas.GraphicsContext gc,
                                   GameObj go)
        Display a game object - it is just a rectangle on the canvas
      • update

        public void update()
        This is how the Model talks to the View This method gets called BY THE MODEL, whenever the model changes It has to do whatever is required to update the GUI to show the new game position