OSDN Git Service

[added] Javadocs.
authornathan.sweet <nathan.sweet@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Wed, 3 Nov 2010 07:28:07 +0000 (07:28 +0000)
committernathan.sweet <nathan.sweet@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Wed, 3 Nov 2010 07:28:07 +0000 (07:28 +0000)
backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/LwjglApplet.java
backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/LwjglApplication.java
backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/LwjglCanvas.java
extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/Layout.java
extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/TWL.java
gdx/src/com/badlogic/gdx/Game.java
gdx/src/com/badlogic/gdx/InputMultiplexer.java
gdx/src/com/badlogic/gdx/Screen.java

index 79b24db..5dc4704 100644 (file)
@@ -7,6 +7,10 @@ import java.awt.Canvas;
 \r
 import com.badlogic.gdx.ApplicationListener;\r
 \r
+/**\r
+ * An OpenGL surface in an applet.\r
+ * @author Nathan Sweet <misc@n4te.com>\r
+ */\r
 public class LwjglApplet extends Applet {\r
        final Canvas canvas;\r
        LwjglApplication app;\r
index 1d2c313..067f236 100644 (file)
@@ -16,6 +16,9 @@ import com.badlogic.gdx.Graphics;
 import com.badlogic.gdx.Input;\r
 import com.badlogic.gdx.utils.GdxRuntimeException;\r
 \r
+/**\r
+ * An OpenGL surface fullscreen or in a lightweight window.\r
+ */\r
 public class LwjglApplication implements Application {\r
        LwjglGraphics graphics;\r
        LwjglAudio audio;\r
index 238cbaa..7dbdc8a 100644 (file)
@@ -18,6 +18,11 @@ import com.badlogic.gdx.Graphics;
 import com.badlogic.gdx.Input;\r
 import com.badlogic.gdx.utils.GdxRuntimeException;\r
 \r
+/**\r
+ * An OpenGL surface on an AWT Canvas, allowing OpenGL to be embedded in a Swing application. All OpenGL calls are done on the\r
+ * EDT. This is slightly less efficient then a dedicated thread, but greatly simplifies synchronization.\r
+ * @author Nathan Sweet <misc@n4te.com>\r
+ */\r
 public class LwjglCanvas implements Application {\r
        final LwjglGraphics graphics;\r
        final LwjglAudio audio;\r
index f77acee..e2e4ba7 100644 (file)
@@ -4,6 +4,10 @@ package com.badlogic.gdx.twl;
 import de.matthiasmann.twl.DialogLayout;\r
 import de.matthiasmann.twl.Widget;\r
 \r
+/**\r
+ * Adds convenience methods to {@link DialogLayout}.\r
+ * @author Nathan Sweet <misc@n4te.com>\r
+ */\r
 public class Layout extends DialogLayout {\r
        public Layout () {\r
                setTheme("");\r
@@ -24,6 +28,9 @@ public class Layout extends DialogLayout {
                        this.horizontal = horizontal;\r
                }\r
 \r
+               /**\r
+                * @param widgets Either {@link Widget} or {@link Integer} objects. Integers are used to specify the gap size.\r
+                */\r
                public Group sequence (Object... widgets) {\r
                        DialogLayout.Group dialogGroup = createSequentialGroup();\r
                        if (horizontal)\r
@@ -33,6 +40,9 @@ public class Layout extends DialogLayout {
                        return new Group(null, dialogGroup).add(widgets);\r
                }\r
 \r
+               /**\r
+                * @param widgets Either {@link Widget} or {@link Integer} objects. Integers are used to specify the gap size.\r
+                */\r
                public Group parallel (Object... widgets) {\r
                        DialogLayout.Group dialogGroup = createParallelGroup();\r
                        if (horizontal)\r
@@ -51,18 +61,27 @@ public class Layout extends DialogLayout {
                                this.dialogGroup = dialogGroup;\r
                        }\r
 \r
+                       /**\r
+                        * @param widgets Either {@link Widget} or {@link Integer} objects. Integers are used to specify the gap size.\r
+                        */\r
                        public Group sequence (Object... widgets) {\r
                                DialogLayout.Group dialogGroup = createSequentialGroup();\r
                                this.dialogGroup.addGroup(dialogGroup);\r
                                return new Group(this, dialogGroup).add(widgets);\r
                        }\r
 \r
+                       /**\r
+                        * @param widgets Either {@link Widget} or {@link Integer} objects. Integers are used to specify the gap size.\r
+                        */\r
                        public Group parallel (Object... widgets) {\r
                                DialogLayout.Group dialogGroup = createParallelGroup();\r
                                this.dialogGroup.addGroup(dialogGroup);\r
                                return new Group(this, dialogGroup).add(widgets);\r
                        }\r
 \r
+                       /**\r
+                        * @param widgets Either {@link Widget} or {@link Integer} objects. Integers are used to specify the gap size.\r
+                        */\r
                        public Group add (Object... widgets) {\r
                                for (int i = 0, n = widgets.length; i < n; i++) {\r
                                        Object object = widgets[i];\r
index 4cfc0b8..525d35b 100644 (file)
@@ -12,6 +12,7 @@ import java.net.URLStreamHandler;
 import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.Gdx;\r
 import com.badlogic.gdx.Input;\r
+import com.badlogic.gdx.InputMultiplexer;\r
 import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.files.FileHandle;\r
 import com.badlogic.gdx.twl.renderer.GdxRenderer;\r
@@ -22,15 +23,38 @@ import de.matthiasmann.twl.GUI;
 import de.matthiasmann.twl.Widget;\r
 import de.matthiasmann.twl.theme.ThemeManager;\r
 \r
+/**\r
+ * Convenience class for using TWL. This provides all the basics sufficient for most UIs. TWL can be used without this class if\r
+ * more complex configurations are required (eg, multiple GUI instances).<br>\r
+ * <br>\r
+ * This class provides a single {@link GUI} instance with a root pane set to a widget that takes up the whole screen.\r
+ * {@link #setWidget(Widget)} puts a widget into the root pane, making it easy to layout your widgets using the whole screen.<br>\r
+ * <br>\r
+ * This class is relatively heavyweight because it loads a TWL theme. Generally only one instance should be created for an entire\r
+ * application. Use {@link #setWidget(Widget)} and {@link #clear()} to change the widgets displayed on various application\r
+ * screens.<br>\r
+ * <br>\r
+ * This class implements {@link InputProcessor} and the input methods return true if TWL handled an event. Generally you will want\r
+ * to use {@link InputMultiplexer} to avoid dispatching events that TWL handled to your application.<br>\r
+ * <br>\r
+ * If an instance of this call will no longer be used, {@link #dispose()} must be called to release resources.\r
+ * @author Nathan Sweet <misc@n4te.com>\r
+ */\r
 public class TWL implements InputProcessor {\r
        private final GdxRenderer renderer = new GdxRenderer();\r
        private final GUI gui;\r
 \r
+       /**\r
+        * Creates a new TWL instance with the specified theme file. The specified widget is added to the root pane.\r
+        */\r
        public TWL (String themeFile, FileType fileType, Widget widget) {\r
                this(themeFile, fileType);\r
                setWidget(widget);\r
        }\r
 \r
+       /**\r
+        * Creates a new TWL instance with the specified theme file.\r
+        */\r
        public TWL (String themeFile, FileType fileType) {\r
                Widget root = new Widget() {\r
                        protected void layout () {\r
@@ -47,24 +71,32 @@ public class TWL implements InputProcessor {
                }\r
        }\r
 \r
-       public GdxRenderer getRenderer () {\r
-               return renderer;\r
-       }\r
-\r
+       /**\r
+        * Returns the GUI instance, which is the root of the TWL UI hierachy and manages timing, inputs, etc.\r
+        */\r
        public GUI getGUI () {\r
                return gui;\r
        }\r
 \r
+       /**\r
+        * Sets the widget in the GUI's root pane. By default the root pane takes up the whole screen.\r
+        */\r
        public void setWidget (Widget widget) {\r
                Widget root = gui.getRootPane();\r
                root.removeAllChildren();\r
                root.add(widget);\r
        }\r
 \r
+       /**\r
+        * Removes all widgets from the GUI's root pane. This effectively means that no TWL UI will be drawn.\r
+        */\r
        public void clear () {\r
                gui.getRootPane().removeAllChildren();\r
        }\r
 \r
+       /**\r
+        * Draws the TWL UI.\r
+        */\r
        public void render () {\r
                GUI gui = this.gui;\r
                int viewWidth = Gdx.graphics.getWidth();\r
@@ -174,6 +206,11 @@ public class TWL implements InputProcessor {
                return Event.KEY_NONE;\r
        }\r
 \r
+       /**\r
+        * Returns a URL to a theme file, which can be used with\r
+        * {@link ThemeManager#createThemeManager(URL, de.matthiasmann.twl.renderer.Renderer) ThemeManager} to create a theme for\r
+        * {@link GUI#applyTheme(ThemeManager)}. This is only needed if not using the TWL class make use of TWL.\r
+        */\r
        static public URL getThemeURL (String themeFile, final FileType fileType) throws MalformedURLException {\r
                File file = new File(themeFile);\r
                final File themeRoot = file.getParentFile();\r
index e96e19a..b3d0f0c 100644 (file)
@@ -1,6 +1,12 @@
 \r
 package com.badlogic.gdx;\r
 \r
+/**\r
+ * An {@link ApplicationListener} that delegates to a {@link Screen}. This allows an application to easily have multiple screens.<br>\r
+ * <br>\r
+ * Screens are not disposed automatically. You must handle whether you want to keep screens around or dispose of them when another\r
+ * screen is set.\r
+ */\r
 public abstract class Game implements ApplicationListener {\r
        Screen screen;\r
 \r
@@ -24,9 +30,17 @@ public abstract class Game implements ApplicationListener {
                if (screen != null) screen.resize(width, height);\r
        }\r
 \r
+       /**\r
+        * Sets the current screen. {@link Screen#hide()} is called on any old screen, and {@link Screen#show()} is called on the new\r
+        * screen.\r
+        */\r
        public void setScreen (Screen screen) {\r
                if (this.screen != null) this.screen.hide();\r
                this.screen = screen;\r
                screen.show();\r
        }\r
+\r
+       public Screen getScreen () {\r
+               return screen;\r
+       }\r
 }\r
index 2c4c71b..3d57cac 100644 (file)
@@ -3,6 +3,11 @@ package com.badlogic.gdx;
 \r
 import java.util.ArrayList;\r
 \r
+/**\r
+ * An {@link InputProcessor} that delegates to an ordered list of other InputProcessors. Delegation for an event stops if a\r
+ * processor returns true, which indicates that the event was handled.\r
+ * @author Nathan Sweet <misc@n4te.com>\r
+ */\r
 public class InputMultiplexer implements InputProcessor {\r
        private ArrayList<InputProcessor> processors = new ArrayList(4);\r
 \r
@@ -10,6 +15,10 @@ public class InputMultiplexer implements InputProcessor {
                processors.add(processor);\r
        }\r
 \r
+       public void removeProcessor (InputProcessor processor) {\r
+               processors.remove(processor);\r
+       }\r
+\r
        public boolean keyDown (int keycode) {\r
                for (int i = 0, n = processors.size(); i < n; i++)\r
                        if (processors.get(i).keyDown(keycode)) return true;\r
index 01284d2..baeeff2 100644 (file)
@@ -1,30 +1,52 @@
 \r
 package com.badlogic.gdx;\r
 \r
+/**\r
+ * Represents one of many application screens.<br>\r
+ * <br>\r
+ * Note that {@link #dispose()} is not called automatically.\r
+ * @see Game\r
+ */\r
 public abstract class Screen {\r
-       public final Game game;\r
-\r
-       public Screen (Game game) {\r
-               this.game = game;\r
-       }\r
-\r
+       /**\r
+        * Called when the screen should render itself.\r
+        * @param delta The time in seconds since the last render.\r
+        */\r
        public abstract void render (float delta);\r
 \r
+       /**\r
+        * @see ApplicationListener#resize(int, int)\r
+        */\r
        public void resize (int width, int height) {\r
        }\r
 \r
+       /**\r
+        * Called when this screen becomes the current screen for a {@link Game}.\r
+        */\r
        public void show () {\r
        }\r
 \r
+       /**\r
+        * Called when this screen is no longer the current screen for a {@link Game}.\r
+        */\r
        public void hide () {\r
        }\r
 \r
+       /**\r
+        * @see ApplicationListener#pause()\r
+        */\r
        public void pause () {\r
        }\r
 \r
+       /**\r
+        * @see ApplicationListener#resume()\r
+        */\r
        public void resume () {\r
        }\r
 \r
+       /**\r
+        * Called when this screen should release all resources.\r
+        */\r
        public void dispose () {\r
        }\r
 }\r