Package codedraw

Interface Animation


public interface Animation
The animation interface can be implemented to create animations and interactive applications. Pass an instance of the Animation interface to CodeDraw.run(Animation), BorderlessWindow.run(Animation) or FullScreen.run(Animation). The functions in this interface are executed in order: First, the event methods like onMouseMove(MouseMoveEvent) are called. Second, the simulate() method is called. Third, the draw(Image) method is called.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    draw(Image canvas)
    This method is called in regular intervals to draw onto the canvas.
    default void
    This method is called exactly once every time a key is pressed down.
    default void
    This method is called continuously while a key is being held down.
    default void
    This method is called exactly once every time a key is released.
    default void
    This method is called once every time a mouse button is pressed down and quickly released again.
    default void
    This method is called exactly once every time a mouse button is pressed down.
    default void
    This method is called every time the mouse enters the canvas.
    default void
    This method is called every time the mouse leaves the canvas.
    default void
    This method is called continuously while the mouse is being moved.
    default void
    This method is called exactly once every time a mouse button is released.
    default void
    This method is called every time the mouse wheel is turned.
    default void
    This method is called exactly once after the user closes the window or CodeDraw.close() is called.
    default void
    This method is called every time the CodeDraw window is moved.
    default void
    This method is executed independently of the draw(Image) method.
  • Method Details

    • draw

      void draw(Image canvas)
      This method is called in regular intervals to draw onto the canvas. The frequency is defined, by setting the frames per second on the CodeDraw.run(Animation) method. Per default the frequency is set to 60 frames per second. If the computer is under heavy load it might not achieve the desired frequency and draw is not called.
      Parameters:
      canvas - the canvas to draw on.
    • simulate

      default void simulate()
      This method is executed independently of the draw(Image) method. While the draw(Image) might not get executed when the user's computer is under load, this method will always get executed. Per default the frequency is set to 60 times per second.
    • onMouseClick

      default void onMouseClick(MouseClickEvent event)
      This method is called once every time a mouse button is pressed down and quickly released again.
      Parameters:
      event - the data of the event.
    • onMouseMove

      default void onMouseMove(MouseMoveEvent event)
      This method is called continuously while the mouse is being moved.
      Parameters:
      event - the data of the event.
    • onMouseDown

      default void onMouseDown(MouseDownEvent event)
      This method is called exactly once every time a mouse button is pressed down.
      Parameters:
      event - the data of the event.
    • onMouseUp

      default void onMouseUp(MouseUpEvent event)
      This method is called exactly once every time a mouse button is released.
      Parameters:
      event - the data of the event.
    • onMouseEnter

      default void onMouseEnter(MouseEnterEvent event)
      This method is called every time the mouse enters the canvas.
      Parameters:
      event - the data of the event.
    • onMouseLeave

      default void onMouseLeave(MouseLeaveEvent event)
      This method is called every time the mouse leaves the canvas.
      Parameters:
      event - the data of the event.
    • onMouseWheel

      default void onMouseWheel(MouseWheelEvent event)
      This method is called every time the mouse wheel is turned.
      Parameters:
      event - the data of the event.
    • onKeyDown

      default void onKeyDown(KeyDownEvent event)
      This method is called exactly once every time a key is pressed down.
      Parameters:
      event - the data of the event.
    • onKeyUp

      default void onKeyUp(KeyUpEvent event)
      This method is called exactly once every time a key is released.
      Parameters:
      event - the data of the event.
    • onKeyPress

      default void onKeyPress(KeyPressEvent event)
      This method is called continuously while a key is being held down.
      Parameters:
      event - the data of the event.
    • onWindowMove

      default void onWindowMove(WindowMoveEvent event)
      This method is called every time the CodeDraw window is moved.
      Parameters:
      event - the data of the event.
    • onWindowClose

      default void onWindowClose(WindowCloseEvent event)
      This method is called exactly once after the user closes the window or CodeDraw.close() is called.
      Parameters:
      event - the data of the event.