formatting and better javadoc

This commit is contained in:
Brian Matzon 2003-02-10 23:09:54 +00:00
parent 3a28d769a7
commit 7bff025626
4 changed files with 108 additions and 59 deletions

View File

@ -54,13 +54,13 @@ public final class Display {
/** The current display mode, if created */ /** The current display mode, if created */
private static DisplayMode mode; private static DisplayMode mode;
/** A pointer to the native display window. On Windows this will be an hWnd. */ /** A pointer to the native display window. On Windows this will be an hWnd. */
private static int handle; private static int handle;
/** Whether or not the display has been requested to shutdown by the user */ /** Whether or not the display has been requested to shutdown by the user */
private static boolean closeRequested = false; private static boolean closeRequested = false;
/** /**
* No construction allowed. * No construction allowed.
*/ */
@ -95,8 +95,9 @@ public final class Display {
String title) String title)
throws Exception { throws Exception {
if (created) if (created) {
return; return;
}
if (!nCreate(displayMode.width, if (!nCreate(displayMode.width,
displayMode.height, displayMode.height,
@ -106,8 +107,9 @@ public final class Display {
displayMode.depth, displayMode.depth,
displayMode.stencil, displayMode.stencil,
fullscreen, fullscreen,
title)) title)) {
throw new Exception("Failed to set display mode to " + displayMode); throw new Exception("Failed to set display mode to " + displayMode);
}
created = true; created = true;
mode = displayMode; mode = displayMode;
@ -135,19 +137,23 @@ public final class Display {
* been created no action is taken. * been created no action is taken.
*/ */
public static void destroy() { public static void destroy() {
if (!created) if (!created) {
return; return;
}
nDestroy(); nDestroy();
created = false; created = false;
mode = null; mode = null;
} }
/** /**
* Native method to destroy the display. This will reset the handle. * Native method to destroy the display. This will reset the handle.
*/ */
private static native void nDestroy(); private static native void nDestroy();
/** /**
* Retrieves the width of the created display
*
* @return the current display width. * @return the current display width.
* @throws AssertionError if the display has not been created yet. * @throws AssertionError if the display has not been created yet.
*/ */
@ -157,6 +163,8 @@ public final class Display {
} }
/** /**
* Retrieves the height of the created display
*
* @return the current display height. * @return the current display height.
* @throws AssertionError if the display has not been created yet. * @throws AssertionError if the display has not been created yet.
*/ */
@ -166,6 +174,8 @@ public final class Display {
} }
/** /**
* Retrieves the current display depth of the created display
*
* @return the current display depth. * @return the current display depth.
* @throws AssertionError if the display has not been created yet. * @throws AssertionError if the display has not been created yet.
*/ */
@ -175,6 +185,8 @@ public final class Display {
} }
/** /**
* Retrieves the current display frequency of the created display
*
* @return the current display frequency. * @return the current display frequency.
* @throws AssertionError if the display has not been created yet. * @throws AssertionError if the display has not been created yet.
*/ */
@ -182,8 +194,11 @@ public final class Display {
assert created : "The display has not been created yet."; assert created : "The display has not been created yet.";
return mode.freq; return mode.freq;
} }
/** /**
* Retrieves the <code>DisplayMode</code> that the display has currently been
* set to.
*
* @return the current display mode, or null if the display is not yet created * @return the current display mode, or null if the display is not yet created
* @throws AssertionError if the display has not been created yet. * @throws AssertionError if the display has not been created yet.
*/ */
@ -191,8 +206,10 @@ public final class Display {
assert created : "The display has not been created yet."; assert created : "The display has not been created yet.";
return mode; return mode;
} }
/** /**
* Retrieves the native handle to the created window
*
* @return the native handle * @return the native handle
* @throws AssertionError if the display has not been created yet. * @throws AssertionError if the display has not been created yet.
*/ */
@ -200,8 +217,10 @@ public final class Display {
assert created : "The display has not been created yet."; assert created : "The display has not been created yet.";
return handle; return handle;
} }
/** /**
* Tests whether or not the display has been created
*
* @return true if the display has been created * @return true if the display has been created
*/ */
public static boolean isCreated() { public static boolean isCreated() {
@ -217,13 +236,16 @@ public final class Display {
* @return true if the display is minimized * @return true if the display is minimized
*/ */
public static native boolean isMinimized(); public static native boolean isMinimized();
/** /**
* Determines if the user has requested that the application should close. * Determines if the user has requested that the application should close.
* * When a user has requested that the application should shutdown, it is up to
* @return true if the user has requested that the application should close * the application to perform the actual shutdown and cleanup of any allocated
*/ * resources.
public static boolean isCloseRequested() { *
return closeRequested; * @return true if the user has requested that the application should close
} */
public static boolean isCloseRequested() {
return closeRequested;
}
} }

View File

@ -35,7 +35,9 @@ package org.lwjgl;
/** /**
* $Id$ * $Id$
* *
* Describes a display mode. * This class encapsulates the properties for a given display mode.
* This class is not instantiable, and is aquired from the <code>Display.
* getAvailableDisplayModes()</code> method.
* *
* @author cix_foo <cix_foo@users.sourceforge.net> * @author cix_foo <cix_foo@users.sourceforge.net>
* @version $Revision$ * @version $Revision$
@ -43,6 +45,7 @@ package org.lwjgl;
public final class DisplayMode { public final class DisplayMode {
/** properties of the display mode */
public final int width, height, bpp, freq, alpha, depth, stencil; public final int width, height, bpp, freq, alpha, depth, stencil;
/** /**
@ -61,12 +64,15 @@ public final class DisplayMode {
} }
/* (non-Javadoc) /**
* Tests for <code>DisplayMode</code> equality
*
* @see java.lang.Object#equals(Object) * @see java.lang.Object#equals(Object)
*/ */
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null || !(obj instanceof DisplayMode)) if (obj == null || !(obj instanceof DisplayMode)) {
return false; return false;
}
DisplayMode dm = (DisplayMode) obj; DisplayMode dm = (DisplayMode) obj;
return dm.width == width return dm.width == width
@ -78,14 +84,18 @@ public final class DisplayMode {
&& dm.stencil == stencil; && dm.stencil == stencil;
} }
/* (non-Javadoc) /**
* Retrieves the hashcode for this object
*
* @see java.lang.Object#hashCode() * @see java.lang.Object#hashCode()
*/ */
public int hashCode() { public int hashCode() {
return width ^ height ^ freq ^ bpp ^ alpha ^ (depth << 8) ^ (stencil << 24); return width ^ height ^ freq ^ bpp ^ alpha ^ (depth << 8) ^ (stencil << 24);
} }
/* (non-Javadoc) /**
* Retrieves a String representation of this <code>DisplayMode</code>
*
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
public String toString() { public String toString() {
@ -106,5 +116,4 @@ public final class DisplayMode {
sb.append("bit stencil"); sb.append("bit stencil");
return sb.toString(); return sb.toString();
} }
}
}

View File

@ -43,10 +43,8 @@ import org.lwjgl.Sys;
* *
* No buffering is available. * No buffering is available.
* *
* Currently n (native limits, currently 128 - might change) buttons, the x, y, * Currently n (native limits) buttons, the x, y, z axis (also rotational x,y ,
* z axis is supported along with a POV (or HAT) and a slider, where the z axis * z axis) is supported along with a POV (or HAT) and a slider
* represents a throttle. In the future the controller may support more buttons
* and axises and other features. but this is a platform issue.
* *
* The Controller implementation currently only supports the first attached device. * The Controller implementation currently only supports the first attached device.
* *
@ -67,27 +65,27 @@ public class Controller {
/** X position, range -1000 to 1000 */ /** X position, range -1000 to 1000 */
public static int x = 0; public static int x = 0;
/** X rotational position, range -1000 to 1000 */ /** X rotational position, range -1000 to 1000 */
public static int rx = 0; public static int rx = 0;
/** Y position, range -1000 to 1000 */ /** Y position, range -1000 to 1000 */
public static int y = 0; public static int y = 0;
/** Y rotational position, range -1000 to 1000 */ /** Y rotational position, range -1000 to 1000 */
public static int ry = 0; public static int ry = 0;
/** Z position, range -1000 to 1000 */ /** Z position, range -1000 to 1000 */
public static int z = 0; public static int z = 0;
/** Z rotational position, range -1000 to 1000 */ /** Z rotational position, range -1000 to 1000 */
public static int rz = 0; public static int rz = 0;
/** Position of Point of View from -1 to 27000 (360 degrees) */ /** Position of Point of View from -1 to 27000 (360 degrees) */
public static int pov; public static int pov;
/** Slider position, range -1000 to 1000 */ /** Slider position, range -1000 to 1000 */
public static int slider = 0; public static int slider = 0;
/** Constant specifying centered POV */ /** Constant specifying centered POV */
public static final int POV_CENTER = -1; public static final int POV_CENTER = -1;
@ -104,16 +102,32 @@ public class Controller {
/** Constant specifying westward POV */ /** Constant specifying westward POV */
public static final int POV_WEST = 9000; public static final int POV_WEST = 9000;
/* Controller capabilities */ /** Number of buttons on the controller */
public static int buttonCount = -1; public static int buttonCount = -1;
public static boolean hasXAxis = false;
public static boolean hasRXAxis = false; /** Does this controller support a x axis */
public static boolean hasYAxis = false; public static boolean hasXAxis = false;
public static boolean hasRYAxis = false;
public static boolean hasZAxis = false; /** Does this controller support a rotational x axis */
public static boolean hasRZAxis = false; public static boolean hasRXAxis = false;
/** Does this controller support an y axis */
public static boolean hasYAxis = false;
/** Does this controller support a rotational y axis */
public static boolean hasRYAxis = false;
/** Does this controller support a z axis */
public static boolean hasZAxis = false;
/** Does this controller support a rotational z axis */
public static boolean hasRZAxis = false;
/** Does this controller support a Point-Of-View (hat) */
public static boolean hasPOV = false; public static boolean hasPOV = false;
public static boolean hasSlider = false;
/** Does this controller support a slider */
public static boolean hasSlider = false;
/** /**
* Controller cannot be constructed. * Controller cannot be constructed.
@ -165,9 +179,9 @@ public class Controller {
} }
/** /**
* See if a particular button is down. * Tests if a particular button is down.
* *
* @param button The index of the button you wish to test (0..buttonCount) * @param button The index of the button you wish to test (0..buttonCount-1)
* @return true if the specified button is down * @return true if the specified button is down
* @see #buttonCount * @see #buttonCount
*/ */

View File

@ -41,8 +41,9 @@ import org.lwjgl.Sys;
* A raw Mouse interface. This can be used to poll the current state of the * A raw Mouse interface. This can be used to poll the current state of the
* mouse buttons, and determine the mouse movement delta since the last poll. * mouse buttons, and determine the mouse movement delta since the last poll.
* *
* Up to 8 buttons are available. A scrolly wheel, if present, is the z * n buttons supported, n being a native limit. A scrolly wheel is also
* value. This will be in the range of -10000 to +10000. * supported, if one such is available. All movement is reported as delta from
* last position.
* *
* @author cix_foo <cix_foo@users.sourceforge.net> * @author cix_foo <cix_foo@users.sourceforge.net>
* @version $Revision$ * @version $Revision$
@ -68,8 +69,10 @@ public class Mouse {
/** Delta Z */ /** Delta Z */
public static int dwheel; public static int dwheel;
/* Mouse capabilities */ /** Number of buttons supported by the mouse */
public static int buttonCount = -1; public static int buttonCount = -1;
/** Does this mouse support a scroll wheel */
public static boolean hasWheel = false; public static boolean hasWheel = false;
/** /**
@ -93,6 +96,7 @@ public class Mouse {
/** /**
* "Create" the mouse. The display must first have been created. * "Create" the mouse. The display must first have been created.
*
* @throws Exception if the mouse could not be created for any reason * @throws Exception if the mouse could not be created for any reason
*/ */
public static void create() throws Exception { public static void create() throws Exception {
@ -143,7 +147,7 @@ public class Mouse {
/** /**
* See if a particular mouse button is down. * See if a particular mouse button is down.
* *
* @param button The index of the button you wish to test (0..buttonCount) * @param button The index of the button you wish to test (0..buttonCount-1)
* @return true if the specified button is down * @return true if the specified button is down
*/ */
public static boolean isButtonDown(int button) { public static boolean isButtonDown(int button) {