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 TypeMethodDescriptionvoidThis method is called in regular intervals to draw onto the canvas.default voidonKeyDown(KeyDownEvent event) This method is called exactly once every time a key is pressed down.default voidonKeyPress(KeyPressEvent event) This method is called continuously while a key is being held down.default voidonKeyUp(KeyUpEvent event) This method is called exactly once every time a key is released.default voidonMouseClick(MouseClickEvent event) This method is called once every time a mouse button is pressed down and quickly released again.default voidonMouseDown(MouseDownEvent event) This method is called exactly once every time a mouse button is pressed down.default voidonMouseEnter(MouseEnterEvent event) This method is called every time the mouse enters the canvas.default voidonMouseLeave(MouseLeaveEvent event) This method is called every time the mouse leaves the canvas.default voidonMouseMove(MouseMoveEvent event) This method is called continuously while the mouse is being moved.default voidonMouseUp(MouseUpEvent event) This method is called exactly once every time a mouse button is released.default voidonMouseWheel(MouseWheelEvent event) This method is called every time the mouse wheel is turned.default voidonWindowClose(WindowCloseEvent event) This method is called exactly once after the user closes the window orCodeDraw.close()is called.default voidonWindowMove(WindowMoveEvent event) This method is called every time the CodeDraw window is moved.default voidsimulate()This method is executed independently of thedraw(Image)method.
-
Method Details
-
draw
This method is called in regular intervals to draw onto the canvas. The frequency is defined, by setting the frames per second on theCodeDraw.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 thedraw(Image)method. While thedraw(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
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
This method is called continuously while the mouse is being moved.- Parameters:
event- the data of the event.
-
onMouseDown
This method is called exactly once every time a mouse button is pressed down.- Parameters:
event- the data of the event.
-
onMouseUp
This method is called exactly once every time a mouse button is released.- Parameters:
event- the data of the event.
-
onMouseEnter
This method is called every time the mouse enters the canvas.- Parameters:
event- the data of the event.
-
onMouseLeave
This method is called every time the mouse leaves the canvas.- Parameters:
event- the data of the event.
-
onMouseWheel
This method is called every time the mouse wheel is turned.- Parameters:
event- the data of the event.
-
onKeyDown
This method is called exactly once every time a key is pressed down.- Parameters:
event- the data of the event.
-
onKeyUp
This method is called exactly once every time a key is released.- Parameters:
event- the data of the event.
-
onKeyPress
This method is called continuously while a key is being held down.- Parameters:
event- the data of the event.
-
onWindowMove
This method is called every time the CodeDraw window is moved.- Parameters:
event- the data of the event.
-
onWindowClose
This method is called exactly once after the user closes the window orCodeDraw.close()is called.- Parameters:
event- the data of the event.
-