diff options
author | Sven Gothel <[email protected]> | 2014-07-10 01:51:47 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-10 01:51:47 +0200 |
commit | 5a00a46bd2c494116b0cd73f98f9fe08bec8528f (patch) | |
tree | 5f776c3ac784ddf067d239652490877507e9fcf3 /src/demos/jgears/JGears.java | |
parent | 548fee0b3d65605ff5cbcbe750564eda1bc611d7 (diff) |
Adapt to JOGL commit ec2d94ca26ddab8ec67135ebc5f2d0a43f6a4c25 (Bug 1031: Remove Deprecated Classes and Methods)
Diffstat (limited to 'src/demos/jgears/JGears.java')
-rw-r--r-- | src/demos/jgears/JGears.java | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/demos/jgears/JGears.java b/src/demos/jgears/JGears.java index 7e7d2e2..db466e3 100644 --- a/src/demos/jgears/JGears.java +++ b/src/demos/jgears/JGears.java @@ -1,7 +1,6 @@ package demos.jgears; -import demos.gears.Gears; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; @@ -17,15 +16,19 @@ import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.io.InputStream; import java.text.DecimalFormat; + import javax.imageio.ImageIO; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLJPanel; -import com.jogamp.opengl.util.Animator; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JPanel; +import com.jogamp.opengl.util.Animator; + +import demos.gears.Gears; + /** * JGears.java <BR> * author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel) <P> @@ -39,7 +42,7 @@ public class JGears extends GLJPanel { private int frameCount; private float fps; private static Font fpsFont = new Font("SansSerif", Font.BOLD, 24); - private DecimalFormat format = new DecimalFormat("####.00"); + private final DecimalFormat format = new DecimalFormat("####.00"); private BufferedImage javaImage; private BufferedImage openglImage; @@ -47,9 +50,9 @@ public class JGears extends GLJPanel { caps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); caps.setAlphaBits(8); } - + public JGears() { - super(caps, null, null); + super(caps, null); addGLEventListener(new Gears()); try { InputStream in = JGears.class.getClassLoader().getResourceAsStream("demos/data/images/java_logo.png"); @@ -65,7 +68,8 @@ public class JGears extends GLJPanel { } - public void paintComponent(Graphics g) { + @Override +public void paintComponent(Graphics g) { super.paintComponent(g); if (startTime == 0) { startTime = System.currentTimeMillis(); @@ -73,7 +77,7 @@ public class JGears extends GLJPanel { if (++frameCount == 30) { long endTime = System.currentTimeMillis(); - fps = 30.0f / (float) (endTime - startTime) * 1000; + fps = 30.0f / (endTime - startTime) * 1000; frameCount = 0; startTime = System.currentTimeMillis(); } @@ -96,7 +100,8 @@ public class JGears extends GLJPanel { // Helper routine for various demos public static JPanel createGradientPanel() { JPanel gradientPanel = new JPanel() { - public void paintComponent(Graphics g) { + @Override + public void paintComponent(Graphics g) { ((Graphics2D) g).setPaint(new GradientPaint(0, 0, Color.WHITE, getWidth(), getHeight(), Color.DARK_GRAY)); g.fillRect(0, 0, getWidth(), getHeight()); @@ -129,7 +134,8 @@ public class JGears extends GLJPanel { final JCheckBox checkBox = new JCheckBox("Transparent", true); checkBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + @Override + public void actionPerformed(ActionEvent e) { drawable.setOpaque(!checkBox.isSelected()); } }); @@ -138,12 +144,14 @@ public class JGears extends GLJPanel { frame.setSize(300, 300); final Animator animator = new Animator(drawable); frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { + @Override + public void windowClosing(WindowEvent e) { // Run this on another thread than the AWT event queue to // make sure the call to Animator.stop() completes before // exiting new Thread(new Runnable() { - public void run() { + @Override + public void run() { animator.stop(); System.exit(0); } |