summaryrefslogtreecommitdiffstats
path: root/src/demos/j2d
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-06-21 20:58:04 +0200
committerSven Gothel <[email protected]>2012-06-21 20:58:04 +0200
commitbe0ebf39ac48e904803ad35ad280dc6ecde03119 (patch)
tree877e5b6cb721d182cf6f5b6c7bb2d6d34dcef0fd /src/demos/j2d
parent9c2d74736fdd723267aaf6f7a5018dd1bc882775 (diff)
Remove GLProfile.initSingleton(..) calls and JNLP argument 'NotFirstUIActionOnProcess'; Adapt to CapabilitiesChooser API/generics change; Misc
- Remove GLProfile.initSingleton(..) calls and JNLP argument 'NotFirstUIActionOnProcess' - Adapt to CapabilitiesChooser API/generics change - Cleanup some generics use .. etc
Diffstat (limited to 'src/demos/j2d')
-rwxr-xr-xsrc/demos/j2d/CustomText.java21
-rwxr-xr-xsrc/demos/j2d/FlyingText.java24
-rwxr-xr-xsrc/demos/j2d/TestOverlay.java8
-rwxr-xr-xsrc/demos/j2d/TestTextRenderer.java12
-rwxr-xr-xsrc/demos/j2d/TestTextureRenderer.java11
-rwxr-xr-xsrc/demos/j2d/TextCube.java11
-rwxr-xr-xsrc/demos/j2d/TextFlow.java12
7 files changed, 17 insertions, 82 deletions
diff --git a/src/demos/j2d/CustomText.java b/src/demos/j2d/CustomText.java
index 3a68761..8405b6e 100755
--- a/src/demos/j2d/CustomText.java
+++ b/src/demos/j2d/CustomText.java
@@ -42,7 +42,6 @@ package demos.j2d;
import com.jogamp.opengl.util.awt.TextRenderer;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureCoords;
-import com.jogamp.opengl.util.texture.TextureIO;
import com.jogamp.opengl.util.texture.awt.AWTTextureIO;
import demos.common.Demo;
import demos.util.FPSCounter;
@@ -69,7 +68,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
-import javax.media.opengl.GLProfile;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES1;
import javax.media.opengl.GL2;
@@ -87,13 +85,6 @@ import javax.swing.JPanel;
public class CustomText extends Demo {
public static void main(String[] args) {
- // set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example
- // <application-desc main-class="demos.j2d.TextCube"/>
- // <argument>NotFirstUIActionOnProcess</argument>
- // </application-desc>
- boolean firstUIActionOnProcess = 0==args.length || !args[0].equals("NotFirstUIActionOnProcess") ;
- GLProfile.initSingleton(firstUIActionOnProcess);
-
JFrame frame = new JFrame("Custom Text");
frame.getContentPane().setLayout(new BorderLayout());
@@ -131,7 +122,7 @@ public class CustomText extends Demo {
// Put a little physics on the text to make it look nicer
private static final float INIT_ANG_VEL_MAG = 0.3f;
private static final float INIT_VEL_MAG = 400.0f;
- private static final int DEFAULT_DROP_SHADOW_DIST = 20;
+ // private static final int DEFAULT_DROP_SHADOW_DIST = 20;
// Information about each piece of text
private static class TextInfo {
@@ -144,7 +135,7 @@ public class CustomText extends Demo {
String text;
}
- private List/*<TextInfo>*/ textInfo = new ArrayList/*<TextInfo>*/();
+ private List<TextInfo> textInfo = new ArrayList<TextInfo>();
private Time time;
private Texture backgroundTexture;
private TextRenderer renderer;
@@ -255,8 +246,8 @@ public class CustomText extends Demo {
// Update velocities and positions of all text
float deltaT = (float) time.deltaT();
Vec2f tmp = new Vec2f();
- for (Iterator iter = textInfo.iterator(); iter.hasNext(); ) {
- TextInfo info = (TextInfo) iter.next();
+ for (Iterator<TextInfo> iter = textInfo.iterator(); iter.hasNext(); ) {
+ TextInfo info = iter.next();
// Randomize things a little bit at run time
if (random.nextInt(1000) == 0) {
@@ -328,8 +319,8 @@ public class CustomText extends Demo {
gl.glMatrixMode(GL2ES1.GL_MODELVIEW);
- for (Iterator iter = textInfo.iterator(); iter.hasNext(); ) {
- TextInfo info = (TextInfo) iter.next();
+ for (Iterator<TextInfo> iter = textInfo.iterator(); iter.hasNext(); ) {
+ TextInfo info = iter.next();
gl.glLoadIdentity();
gl.glTranslatef(info.position.x(),
info.position.y(),
diff --git a/src/demos/j2d/FlyingText.java b/src/demos/j2d/FlyingText.java
index debb9c7..949a231 100755
--- a/src/demos/j2d/FlyingText.java
+++ b/src/demos/j2d/FlyingText.java
@@ -42,7 +42,6 @@ package demos.j2d;
import com.jogamp.opengl.util.awt.TextRenderer;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureCoords;
-import com.jogamp.opengl.util.texture.TextureIO;
import com.jogamp.opengl.util.texture.awt.AWTTextureIO;
import demos.common.Demo;
import demos.util.FPSCounter;
@@ -65,9 +64,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
-import javax.media.opengl.GLProfile;
import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES1;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.awt.GLCanvas;
@@ -88,13 +85,6 @@ import javax.swing.event.ChangeListener;
public class FlyingText extends Demo {
public static void main(String[] args) {
- // set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example
- // <application-desc main-class="demos.j2d.TextCube"/>
- // <argument>NotFirstUIActionOnProcess</argument>
- // </application-desc>
- boolean firstUIActionOnProcess = 0==args.length || !args[0].equals("NotFirstUIActionOnProcess") ;
- GLProfile.initSingleton(firstUIActionOnProcess);
-
JFrame frame = new JFrame("Flying Text");
frame.getContentPane().setLayout(new BorderLayout());
@@ -157,7 +147,7 @@ public class FlyingText extends Demo {
String text;
}
- private List/*<TextInfo>*/ textInfo = new ArrayList/*<TextInfo>*/();
+ private List<TextInfo> textInfo = new ArrayList<TextInfo>();
private int dropShadowDistance = DEFAULT_DROP_SHADOW_DIST;
private Time time;
private Texture backgroundTexture;
@@ -297,8 +287,8 @@ public class FlyingText extends Demo {
// Update velocities and positions of all text
float deltaT = (float) time.deltaT();
Vec2f tmp = new Vec2f();
- for (Iterator iter = textInfo.iterator(); iter.hasNext(); ) {
- TextInfo info = (TextInfo) iter.next();
+ for (Iterator<TextInfo> iter = textInfo.iterator(); iter.hasNext(); ) {
+ TextInfo info = iter.next();
// Randomize things a little bit at run time
if (random.nextInt(1000) == 0) {
@@ -384,8 +374,8 @@ public class FlyingText extends Demo {
// First render drop shadows
renderer.setColor(0, 0, 0, 0.5f);
- for (Iterator iter = textInfo.iterator(); iter.hasNext(); ) {
- TextInfo info = (TextInfo) iter.next();
+ for (Iterator<TextInfo> iter = textInfo.iterator(); iter.hasNext(); ) {
+ TextInfo info = iter.next();
gl.glLoadIdentity();
gl.glTranslatef(info.position.x() + dropShadowDistance,
info.position.y() - dropShadowDistance,
@@ -397,8 +387,8 @@ public class FlyingText extends Demo {
}
// Now render the actual text
- for (Iterator iter = textInfo.iterator(); iter.hasNext(); ) {
- TextInfo info = (TextInfo) iter.next();
+ for (Iterator<TextInfo> iter = textInfo.iterator(); iter.hasNext(); ) {
+ TextInfo info = iter.next();
gl.glLoadIdentity();
gl.glTranslatef(info.position.x(),
info.position.y(),
diff --git a/src/demos/j2d/TestOverlay.java b/src/demos/j2d/TestOverlay.java
index eda3e0a..13cb39e 100755
--- a/src/demos/j2d/TestOverlay.java
+++ b/src/demos/j2d/TestOverlay.java
@@ -54,7 +54,6 @@ import java.awt.event.WindowEvent;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.text.DecimalFormat;
-import javax.media.opengl.GLProfile;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
@@ -67,13 +66,6 @@ import com.jogamp.opengl.util.Animator;
public class TestOverlay implements GLEventListener {
public static void main(String[] args) {
- // set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example
- // <application-desc main-class="demos.j2d.TextCube"/>
- // <argument>NotFirstUIActionOnProcess</argument>
- // </application-desc>
- boolean firstUIActionOnProcess = 0==args.length || !args[0].equals("NotFirstUIActionOnProcess") ;
- GLProfile.initSingleton(firstUIActionOnProcess);
-
Frame frame = new Frame("Java 2D Overlay Test");
GLCapabilities caps = new GLCapabilities(null);
caps.setAlphaBits(8);
diff --git a/src/demos/j2d/TestTextRenderer.java b/src/demos/j2d/TestTextRenderer.java
index 53042dd..4779522 100755
--- a/src/demos/j2d/TestTextRenderer.java
+++ b/src/demos/j2d/TestTextRenderer.java
@@ -50,7 +50,6 @@ import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.Rectangle2D;
-import javax.media.opengl.GLProfile;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
@@ -65,13 +64,6 @@ import com.jogamp.opengl.util.Animator;
public class TestTextRenderer implements GLEventListener {
public static void main(String[] args) {
- // set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example
- // <application-desc main-class="demos.j2d.TextCube"/>
- // <argument>NotFirstUIActionOnProcess</argument>
- // </application-desc>
- boolean firstUIActionOnProcess = 0==args.length || !args[0].equals("NotFirstUIActionOnProcess") ;
- GLProfile.initSingleton(firstUIActionOnProcess);
-
Frame frame = new Frame("Text Renderer Test");
GLCapabilities caps = new GLCapabilities(null);
caps.setAlphaBits(8);
@@ -101,7 +93,7 @@ public class TestTextRenderer implements GLEventListener {
private TextRenderer renderer;
private Time time;
- private Font font;
+ // private Font font;
private Vec2f velocity = new Vec2f(100.0f, 150.0f);
private Vec2f position;
private String TEST_STRING = "Java 2D Text";
@@ -154,8 +146,6 @@ public class TestTextRenderer implements GLEventListener {
velocity.setY(-1.0f * Math.abs(velocity.y()));
}
- GL gl = drawable.getGL();
-
// Prepare to draw text
renderer.beginRendering(drawable.getWidth(), drawable.getHeight());
diff --git a/src/demos/j2d/TestTextureRenderer.java b/src/demos/j2d/TestTextureRenderer.java
index cedee83..a217c7b 100755
--- a/src/demos/j2d/TestTextureRenderer.java
+++ b/src/demos/j2d/TestTextureRenderer.java
@@ -61,7 +61,6 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
-import javax.media.opengl.glu.GLU;
import com.jogamp.opengl.util.Animator;
@@ -71,13 +70,6 @@ import com.jogamp.opengl.util.Animator;
public class TestTextureRenderer implements GLEventListener {
public static void main(String[] args) {
- // set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example
- // <application-desc main-class="demos.j2d.TextCube"/>
- // <argument>NotFirstUIActionOnProcess</argument>
- // </application-desc>
- boolean firstUIActionOnProcess = 0==args.length || !args[0].equals("NotFirstUIActionOnProcess") ;
- GLProfile.initSingleton(firstUIActionOnProcess);
-
Frame frame = new Frame("Java 2D Renderer Test");
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
caps.setAlphaBits(8);
@@ -114,7 +106,6 @@ public class TestTextureRenderer implements GLEventListener {
private Rectangle textBounds;
private Rectangle fpsBounds;
private String TEST_STRING = "Java 2D Text";
- private GLU glu = new GLU();
private long startTime;
private int frameCount;
private DecimalFormat format = new DecimalFormat("####.00");
@@ -195,8 +186,6 @@ public class TestTextureRenderer implements GLEventListener {
velocity.setY(-1.0f * Math.abs(velocity.y()));
}
- GL gl = drawable.getGL();
-
// Prepare to draw from the renderer's texture
renderer.beginOrthoRendering(drawable.getWidth(), drawable.getHeight());
diff --git a/src/demos/j2d/TextCube.java b/src/demos/j2d/TextCube.java
index 4587e10..6b72259 100755
--- a/src/demos/j2d/TextCube.java
+++ b/src/demos/j2d/TextCube.java
@@ -50,9 +50,7 @@ import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.Rectangle2D;
-import javax.media.opengl.GL;
import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GL2ES1;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLProfile;
@@ -74,13 +72,6 @@ public class TextCube extends Demo {
private float textScaleFactor;
public static void main(String[] args) {
- // set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example
- // <application-desc main-class="demos.j2d.TextCube"/>
- // <argument>NotFirstUIActionOnProcess</argument>
- // </application-desc>
- boolean firstUIActionOnProcess = 0==args.length || !args[0].equals("NotFirstUIActionOnProcess") ;
- GLProfile.initSingleton(firstUIActionOnProcess);
-
Frame frame = new Frame("Text Cube");
frame.setLayout(new BorderLayout());
@@ -119,7 +110,7 @@ public class TextCube extends Demo {
// them all fit on the faces of the cube
Rectangle2D bounds = renderer.getBounds("Bottom");
float w = (float) bounds.getWidth();
- float h = (float) bounds.getHeight();
+ // float h = (float) bounds.getHeight();
textScaleFactor = 1.0f / (w * 1.1f);
fps = new FPSCounter(drawable, 36);
diff --git a/src/demos/j2d/TextFlow.java b/src/demos/j2d/TextFlow.java
index f0f29f8..395554b 100755
--- a/src/demos/j2d/TextFlow.java
+++ b/src/demos/j2d/TextFlow.java
@@ -61,7 +61,6 @@ import javax.media.opengl.GL;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.Animator;
@@ -75,13 +74,6 @@ import com.jogamp.opengl.util.Animator;
public class TextFlow extends Demo {
public static void main(String[] args) {
- // set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example
- // <application-desc main-class="demos.j2d.TextCube"/>
- // <argument>NotFirstUIActionOnProcess</argument>
- // </application-desc>
- boolean firstUIActionOnProcess = 0==args.length || !args[0].equals("NotFirstUIActionOnProcess") ;
- GLProfile.initSingleton(firstUIActionOnProcess);
-
Frame frame = new Frame("Text Flow");
frame.setLayout(new BorderLayout());
@@ -111,7 +103,7 @@ public class TextFlow extends Demo {
animator.start();
}
- private List/*<String>*/ lines = new ArrayList();
+ private List<String> lines = new ArrayList<String>();
private Time time;
private TextRenderer renderer;
private int curParagraph;
@@ -128,7 +120,7 @@ public class TextFlow extends Demo {
FontRenderContext frc = renderer.getFontRenderContext();
for (int i = 0; i < text.length; i++) {
String paragraph = text[i];
- Map attrs = new HashMap();
+ Map<TextAttribute, Font> attrs = new HashMap<TextAttribute, Font>();
attrs.put(TextAttribute.FONT, renderer.getFont());
AttributedString str = new AttributedString(paragraph, attrs);
LineBreakMeasurer measurer = new LineBreakMeasurer(str.getIterator(), frc);