From 40863632d1428de015099b5967e5136425e99f25 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Oct 2013 05:25:59 +0200 Subject: Int -> Enum using EnumClass.values()[ordinal] instead of for-loop - FFMPEGNatives's Enums and new MouseEvent.PointerType.valueOf(int) --- src/newt/classes/com/jogamp/newt/event/MouseEvent.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/newt/classes/com/jogamp') diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 4e13d63fe..fd5e27bdd 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -66,18 +66,28 @@ public class MouseEvent extends InputEvent /** Type of pointer devices */ public static enum PointerType implements InputEvent.InputType { - /** {@link PointerClass#Offscreen} mouse. */ + /** {@link PointerClass#Offscreen} mouse. Ordinal 0. */ Mouse(PointerClass.Offscreen), - /** {@link PointerClass#Offscreen} touch pad, usually using fingers. */ + /** {@link PointerClass#Offscreen} touch pad, usually using fingers. Ordinal 1. */ TouchPad(PointerClass.Offscreen), - /** {@link PointerClass#Onscreen} touch screen, usually using fingers. */ + /** {@link PointerClass#Onscreen} touch screen, usually using fingers. Ordinal 2. */ TouchScreen(PointerClass.Onscreen), - /** {@link PointerClass#Onscreen} pen on screen ?. */ + /** {@link PointerClass#Onscreen} pen usually on screen? Ordinal 3. FIXME*/ Pen(PointerClass.Onscreen), + /** {@link PointerClass#Undefined} ?. Ordinal 4. */ Undefined(PointerClass.Undefined); public PointerClass getPointerClass() { return pc; } + public static PointerType valueOf(int i) { + // ordinal = enumValue.ordinal(), reverse: enumValue = EnumClass.values()[ordinal] + final PointerType[] all = PointerType.values(); + if( 0 <= i && i < all.length ) { + return all[i]; + } + return null; + } + private PointerType(PointerClass pc) { this.pc = pc; } -- cgit v1.2.3