X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fevent%2FTMouseEvent.java;h=29e0c1b42c51ccd775a348146679145cdc9dd615;hb=d4a29741fb714f71fd47c9c6e8ae93b57f015821;hp=fd0eedef2537bedff59628ee26ce52ecee924f9e;hpb=b158962153f6f17e458a9846c4296ecd1644221b;p=fanfix.git diff --git a/src/jexer/event/TMouseEvent.java b/src/jexer/event/TMouseEvent.java index fd0eede..29e0c1b 100644 --- a/src/jexer/event/TMouseEvent.java +++ b/src/jexer/event/TMouseEvent.java @@ -1,16 +1,11 @@ /** * Jexer - Java Text User Interface * - * Version: $Id$ - * - * Author: Kevin Lamonte, kevin.lamonte@gmail.com - * * License: LGPLv3 or later * - * Copyright: This module is licensed under the GNU Lesser General - * Public License Version 3. Please see the file "COPYING" in this - * directory for more information about the GNU Lesser General Public - * License Version 3. + * This module is licensed under the GNU Lesser General Public License + * Version 3. Please see the file "COPYING" in this directory for more + * information about the GNU Lesser General Public License Version 3. * * Copyright (C) 2015 Kevin Lamonte * @@ -29,105 +24,225 @@ * http://www.gnu.org/licenses/, or write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA + * + * @author Kevin Lamonte [kevin.lamonte@gmail.com] + * @version 1 */ package jexer.event; /** * This class encapsulates several kinds of mouse input events. */ -public class TMouseEvent extends TInputEvent { +public final class TMouseEvent extends TInputEvent { + /** + * The type of event generated. + */ public enum Type { - /** - * Mouse motion. X and Y will have screen coordinates. - */ - MOUSE_MOTION, - - /** - * Mouse button down. X and Y will have screen coordinates. - */ - MOUSE_DOWN, - - /** - * Mouse button up. X and Y will have screen coordinates. - */ - MOUSE_UP + /** + * Mouse motion. X and Y will have screen coordinates. + */ + MOUSE_MOTION, + + /** + * Mouse button down. X and Y will have screen coordinates. + */ + MOUSE_DOWN, + + /** + * Mouse button up. X and Y will have screen coordinates. + */ + MOUSE_UP } /** * Type of event, one of MOUSE_MOTION, MOUSE_UP, or MOUSE_DOWN, or - * KEYPRESS + * KEYPRESS. + */ + private Type type; + + /** + * Get type. + * + * @return type + */ + public Type getType() { + return type; + } + + /** + * Mouse X - relative coordinates. + */ + private int x; + + /** + * Get x. + * + * @return x + */ + public int getX() { + return x; + } + + /** + * Mouse Y - relative coordinates. + */ + private int y; + + /** + * Get y. + * + * @return y + */ + public int getY() { + return y; + } + + /** + * Mouse X - absolute screen coordinates. + */ + private int absoluteX; + + /** + * Get absoluteX. + * + * @return absoluteX + */ + public int getAbsoluteX() { + return absoluteX; + } + + /** + * Mouse Y - absolute screen coordinate. + */ + private int absoluteY; + + /** + * Get absoluteY. + * + * @return absoluteY + */ + public int getAbsoluteY() { + return absoluteY; + } + + /** + * Mouse button 1 (left button). */ - public Type type; + private boolean mouse1; /** - * Mouse X - relative coordinates + * Get mouse1. + * + * @return mouse1 */ - public int x; + public boolean getMouse1() { + return mouse1; + } /** - * Mouse Y - relative coordinates + * Mouse button 2 (right button). */ - public int y; + private boolean mouse2; /** - * Mouse X - absolute screen coordinates + * Get mouse2. + * + * @return mouse2 */ - public int absoluteX; + public boolean getMouse2() { + return mouse2; + } /** - * Mouse Y - absolute screen coordinate + * Mouse button 3 (middle button). */ - public int absoluteY; + private boolean mouse3; /** - * Mouse button 1 (left button) + * Get mouse3. + * + * @return mouse3 */ - public boolean mouse1; + public boolean getMouse3() { + return mouse3; + } /** - * Mouse button 2 (right button) + * Mouse wheel UP (button 4). */ - public boolean mouse2; + private boolean mouseWheelUp; /** - * Mouse button 3 (middle button) + * Get mouseWheelUp. + * + * @return mouseWheelUp */ - public boolean mouse3; + public boolean getMouseWheelUp() { + return mouseWheelUp; + } /** - * Mouse wheel UP (button 4) + * Mouse wheel DOWN (button 5). */ - public boolean mouseWheelUp; + private boolean mouseWheelDown; /** - * Mouse wheel DOWN (button 5) + * Get mouseWheelDown. + * + * @return mouseWheelDown */ - public boolean mouseWheelDown; + public boolean getMouseWheelDown() { + return mouseWheelDown; + } /** - * Public contructor + * Public contructor. * * @param type the type of event, MOUSE_MOTION, MOUSE_DOWN, or MOUSE_UP + * @param x relative column + * @param y relative row + * @param absoluteX absolute column + * @param absoluteY absolute row + * @param mouse1 if true, left button is down + * @param mouse2 if true, right button is down + * @param mouse3 if true, middle button is down + * @param mouseWheelUp if true, mouse wheel (button 4) is down + * @param mouseWheelDown if true, mouse wheel (button 5) is down */ - public TMouseEvent(Type type) { - this.type = type; + public TMouseEvent(final Type type, final int x, final int y, + final int absoluteX, final int absoluteY, + final boolean mouse1, final boolean mouse2, final boolean mouse3, + final boolean mouseWheelUp, final boolean mouseWheelDown) { + + this.type = type; + this.x = x; + this.y = y; + this.absoluteX = absoluteX; + this.absoluteY = absoluteY; + this.mouse1 = mouse1; + this.mouse2 = mouse2; + this.mouse3 = mouse3; + this.mouseWheelUp = mouseWheelUp; + this.mouseWheelDown = mouseWheelDown; } /** - * Make human-readable description of this event + * Make human-readable description of this TMouseEvent. + * + * @return displayable String */ @Override public String toString() { - return String.format("Mouse: %s x %d y %d absoluteX %d absoluteY %d 1 %s 2 %s 3 %s DOWN %s UP %s", - type, - x, y, - absoluteX, absoluteY, - mouse1, - mouse2, - mouse3, - mouseWheelUp, - mouseWheelDown); + return String.format("Mouse: %s x %d y %d absoluteX %d absoluteY %d 1 %s 2 %s 3 %s DOWN %s UP %s", + type, + x, y, + absoluteX, absoluteY, + mouse1, + mouse2, + mouse3, + mouseWheelUp, + mouseWheelDown); } }