|
69 | 69 | public interface Tool extends RichPlugin, SingletonPlugin { |
70 | 70 |
|
71 | 71 | /** When true, tool has no button but rather is active all the time. */ |
72 | | - boolean isAlwaysActive(); |
| 72 | + default boolean isAlwaysActive() { |
| 73 | + return false; |
| 74 | + } |
73 | 75 |
|
74 | 76 | /** |
75 | 77 | * When true, tool receives events when the main application frame is active. |
76 | 78 | * When false, tool only receives events when a display window is active. |
77 | 79 | */ |
78 | | - boolean isActiveInAppFrame(); |
| 80 | + default boolean isActiveInAppFrame() { |
| 81 | + return false; |
| 82 | + } |
79 | 83 |
|
80 | 84 | /** The tool's mouse pointer. */ |
81 | | - MouseCursor getCursor(); |
| 85 | + default MouseCursor getCursor() { |
| 86 | + return MouseCursor.DEFAULT; |
| 87 | + } |
82 | 88 |
|
83 | 89 | /** Informs the tool that it is now active. */ |
84 | | - void activate(); |
| 90 | + default void activate() { |
| 91 | + // do nothing by default |
| 92 | + } |
85 | 93 |
|
86 | 94 | /** Informs the tool that it is no longer active. */ |
87 | | - void deactivate(); |
| 95 | + default void deactivate() { |
| 96 | + // do nothing by default |
| 97 | + } |
88 | 98 |
|
89 | 99 | /** Occurs when a key on the keyboard is pressed while the tool is active. */ |
90 | | - void onKeyDown(KyPressedEvent event); |
| 100 | + @SuppressWarnings("unused") |
| 101 | + default void onKeyDown(final KyPressedEvent evt) { |
| 102 | + // do nothing by default |
| 103 | + } |
91 | 104 |
|
92 | 105 | /** Occurs when a key on the keyboard is released while the tool is active. */ |
93 | | - void onKeyUp(KyReleasedEvent event); |
| 106 | + @SuppressWarnings("unused") |
| 107 | + default void onKeyUp(final KyReleasedEvent evt) { |
| 108 | + // do nothing by default |
| 109 | + } |
94 | 110 |
|
95 | 111 | /** Occurs when a mouse button is pressed while the tool is active. */ |
96 | | - void onMouseDown(MsPressedEvent event); |
| 112 | + @SuppressWarnings("unused") |
| 113 | + default void onMouseDown(final MsPressedEvent evt) { |
| 114 | + // do nothing by default |
| 115 | + } |
97 | 116 |
|
98 | 117 | /** Occurs when a mouse button is released while the tool is active. */ |
99 | | - void onMouseUp(MsReleasedEvent event); |
| 118 | + @SuppressWarnings("unused") |
| 119 | + default void onMouseUp(final MsReleasedEvent evt) { |
| 120 | + // do nothing by default |
| 121 | + } |
100 | 122 |
|
101 | 123 | /** Occurs when a mouse button is double clicked while the tool is active. */ |
102 | | - void onMouseClick(MsClickedEvent event); |
| 124 | + @SuppressWarnings("unused") |
| 125 | + default void onMouseClick(final MsClickedEvent evt) { |
| 126 | + // do nothing by default |
| 127 | + } |
103 | 128 |
|
104 | 129 | /** Occurs when the mouse is moved while the tool is active. */ |
105 | | - void onMouseMove(MsMovedEvent event); |
| 130 | + @SuppressWarnings("unused") |
| 131 | + default void onMouseMove(final MsMovedEvent evt) { |
| 132 | + // do nothing by default |
| 133 | + } |
106 | 134 |
|
107 | 135 | /** Occurs when the mouse is dragged while the tool is active. */ |
108 | | - void onMouseDrag(MsDraggedEvent event); |
| 136 | + @SuppressWarnings("unused") |
| 137 | + default void onMouseDrag(final MsDraggedEvent evt) { |
| 138 | + // do nothing by default |
| 139 | + } |
109 | 140 |
|
110 | 141 | /** Occurs when the mouse wheel is moved while the tool is active. */ |
111 | | - void onMouseWheel(MsWheelEvent event); |
| 142 | + @SuppressWarnings("unused") |
| 143 | + default void onMouseWheel(final MsWheelEvent evt) { |
| 144 | + // do nothing by default |
| 145 | + } |
112 | 146 |
|
113 | 147 | /** Occurs when the user right clicks this tool's icon. */ |
114 | | - void configure(); |
| 148 | + default void configure() { |
| 149 | + // do nothing by default |
| 150 | + } |
115 | 151 |
|
116 | 152 | /** Returns the text the tool provides when mouse hovers over tool */ |
117 | | - String getDescription(); |
118 | | - |
| 153 | + default String getDescription() { |
| 154 | + return getInfo().getDescription(); |
| 155 | + } |
119 | 156 | } |
0 commit comments