summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-10-17 17:25:38 +0200
committerSven Gothel <[email protected]>2013-10-17 17:25:38 +0200
commit202834f148e0eb8c435af02850085d582b3006a4 (patch)
tree88a79d0c93f7a3d6d49c0da208de1e72a85f0722 /src/newt/classes/com/jogamp
parentc9837ef133ff3465d9b06f1907a7a320181ec97c (diff)
Refine Int -> Enum conversion (commit 40863632d1428de015099b5967e5136425e99f25), throw IllegalArgumentException if ordinal is out-of-range. Add API doc.
- FFMPEGNatives - MouseEvent.PointerType
Diffstat (limited to 'src/newt/classes/com/jogamp')
-rw-r--r--src/newt/classes/com/jogamp/newt/event/MouseEvent.java35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
index cb9e7a290..85c65b39c 100644
--- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
@@ -79,13 +79,38 @@ public class MouseEvent extends InputEvent
public PointerClass getPointerClass() { return pc; }
- public static PointerType valueOf(int i) {
- // ordinal = enumValue.ordinal(), reverse: enumValue = EnumClass.values()[ordinal]
+ /**
+ * Returns the matching PointerType value corresponding to the given PointerType's integer ordinal.
+ * <pre>
+ * given:
+ * ordinal = enumValue.ordinal()
+ * reverse:
+ * enumValue = EnumClass.values()[ordinal]
+ * </pre>
+ * @throws IllegalArgumentException if the given ordinal is out of range, i.e. not within [ 0 .. PointerType.values().length-1 ]
+ */
+ public static PointerType valueOf(int ordinal) throws IllegalArgumentException {
final PointerType[] all = PointerType.values();
- if( 0 <= i && i < all.length ) {
- return all[i];
+ if( 0 <= ordinal && ordinal < all.length ) {
+ return all[ordinal];
}
- return null;
+ throw new IllegalArgumentException("Ordinal "+ordinal+" out of range of PointerType.values()[0.."+(all.length-1)+"]");
+ }
+
+ /**
+ * Returns the PointerType array of matching PointerType values corresponding to the given PointerType's integer ordinal values.
+ * <p>
+ * See {@link #valueOf(int)}.
+ * </p>
+ * @throws IllegalArgumentException if one of the given ordinal values is out of range, i.e. not within [ 0 .. PointerType.values().length-1 ]
+ */
+ public static PointerType[] valuesOf(int[] ordinals) throws IllegalArgumentException {
+ final int count = ordinals.length;
+ final PointerType[] types = new PointerType[count];
+ for(int i=count-1; i>=0; i--) {
+ types[i] = PointerType.valueOf(ordinals[i]);
+ }
+ return types;
}
private PointerType(PointerClass pc) {