summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-10-17 05:25:59 +0200
committerSven Gothel <[email protected]>2013-10-17 05:25:59 +0200
commit40863632d1428de015099b5967e5136425e99f25 (patch)
tree33dc7b82204280294d9faa266d75c6c01702cab9
parent56322e1cf41bbb5bcc097164fb3ddcc0061c1c73 (diff)
Int -> Enum using EnumClass.values()[ordinal] instead of for-loop - FFMPEGNatives's Enums and new MouseEvent.PointerType.valueOf(int)
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java16
-rw-r--r--src/newt/classes/com/jogamp/newt/event/MouseEvent.java18
2 files changed, 22 insertions, 12 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java
index 77cf4ff77..89c15b905 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java
@@ -93,10 +93,10 @@ interface FFMPEGNatives {
COUNT; ///< Number of sample formats.
public static SampleFormat valueOf(int i) {
- for (SampleFormat fmt : SampleFormat.values()) {
- if(fmt.ordinal() == i) {
- return fmt;
- }
+ // ordinal = enumValue.ordinal(), reverse: enumValue = EnumClass.values()[ordinal]
+ final SampleFormat[] all = SampleFormat.values();
+ if( 0 <= i && i < all.length ) {
+ return all[i];
}
return null;
}
@@ -247,10 +247,10 @@ interface FFMPEGNatives {
COUNT ///< number of pixel formats in this list
;
public static PixelFormat valueOf(int i) {
- for (PixelFormat fmt : PixelFormat.values()) {
- if(fmt.ordinal() == i) {
- return fmt;
- }
+ // ordinal = enumValue.ordinal(), reverse: enumValue = EnumClass.values()[ordinal]
+ final PixelFormat[] all = PixelFormat.values();
+ if( 0 <= i && i < all.length ) {
+ return all[i];
}
return null;
}
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;
}