Package edu.princeton.cs.algs4
Interface DrawListener
-
public interface DrawListenerTheDrawListenerinterface provides a basic capability for responding to keyboard in mouse events fromDrawvia callbacks. You can see some examples in Section 3.6.For additional documentation, see Section 3.1 of Computer Science: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.
- Author:
- Robert Sedgewick, Kevin Wayne
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default voidkeyPressed(int keycode)Invoked when a key has been pressed.default voidkeyReleased(int keycode)Invoked when a key has been released.default voidkeyTyped(char c)Invoked when a key has been typed.default voidmouseClicked(double x, double y)Invoked when the mouse has been clicked (pressed and released).default voidmouseDragged(double x, double y)Invoked when the mouse has been dragged.default voidmousePressed(double x, double y)Invoked when the mouse has been pressed.default voidmouseReleased(double x, double y)Invoked when the mouse has been released.default voidupdate()Gets called at regular time intervals.
-
-
-
Method Detail
-
mousePressed
default void mousePressed(double x, double y)Invoked when the mouse has been pressed.- Parameters:
x- the x-coordinate of the mousey- the y-coordinate of the mouse
-
mouseDragged
default void mouseDragged(double x, double y)Invoked when the mouse has been dragged.- Parameters:
x- the x-coordinate of the mousey- the y-coordinate of the mouse
-
mouseReleased
default void mouseReleased(double x, double y)Invoked when the mouse has been released.- Parameters:
x- the x-coordinate of the mousey- the y-coordinate of the mouse
-
mouseClicked
default void mouseClicked(double x, double y)Invoked when the mouse has been clicked (pressed and released). A mouse click is triggered only if the user presses a mouse button and then releases it quickly, without moving the mouse. It does not work with touch events. ThemousePressed(double,double)method is generally preferred for detecting mouse clicks.- Parameters:
x- the x-coordinate of the mousey- the y-coordinate of the mouse
-
keyTyped
default void keyTyped(char c)
Invoked when a key has been typed.- Parameters:
c- the character typed
-
keyPressed
default void keyPressed(int keycode)
Invoked when a key has been pressed.- Parameters:
keycode- the key combination pressed
-
keyReleased
default void keyReleased(int keycode)
Invoked when a key has been released.- Parameters:
keycode- the key combination released
-
update
default void update()
Gets called at regular time intervals.
-
-