Package gui

Class DiverSprite

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class DiverSprite extends JPanel
Responsible for managing the sewer diver and drawing it on the screen. Handles functions to update the sewer diver and update its drawing as well.
See Also:
  • Constructor Details

    • DiverSprite

      public DiverSprite(int startRow, int startCol, GUI gui)
      Constructor: an instance starting at (startRow, startCol), created for gui.
  • Method Details

    • sprite

      public BufferedImage sprite()
      Return the image representing the current state of the diver.
    • row

      public int row()
      Return the diver's row on the grid. Will remain the diver's old position until the diver has completely arrived at the new one.
    • col

      public int col()
      Return the diver's column on the grid. Will remain the diver's old position until the diver has completely arrived at the new one.
    • moveTo

      public void moveTo(Node dst)
      Tell the diver to move from its current location to node dst. After making move, calling thread will block until the move completes on GUI. Requires: dst must be adjacent to the current location and not currently moving.
    • paintComponent

      public void paintComponent(Graphics page)
      Draw the diver on its own panel.
      Overrides:
      paintComponent in class JComponent