Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2016-09-21 14:04:09 -0400
committerAlexander Kurtakov2016-09-21 14:05:40 -0400
commite6824b4ed64634fc024c73258eb67b26103026d9 (patch)
treed041cf85df809376b4120edb5b0da3bd3c592620 /examples
parent9d47fcbc02dc29ce772f0eec3ec450063617efac (diff)
downloadeclipse.platform.swt-e6824b4ed64634fc024c73258eb67b26103026d9.tar.gz
eclipse.platform.swt-e6824b4ed64634fc024c73258eb67b26103026d9.tar.xz
eclipse.platform.swt-e6824b4ed64634fc024c73258eb67b26103026d9.zip
Use lambdas in lwjgl snippets.Y20160922-1000
Change-Id: I9ac7b2921c654aa62349712cda9f3540a9db60fe Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet195.java51
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet341.java67
2 files changed, 45 insertions, 73 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet195.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet195.java
index da0f243fc2..6d4a68cf01 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet195.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet195.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,15 +19,14 @@ package org.eclipse.swt.snippets;
* @since 3.2
*/
import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
+import org.eclipse.swt.opengl.*;
import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.opengl.GLCanvas;
-import org.eclipse.swt.opengl.GLData;
-import org.lwjgl.opengl.GL11;
-import org.lwjgl.opengl.GLContext;
-import org.lwjgl.util.glu.GLU;
-import org.lwjgl.LWJGLException;
+import org.eclipse.swt.widgets.Display;
+import org.lwjgl.*;
+import org.lwjgl.opengl.*;
+import org.lwjgl.util.glu.*;
public class Snippet195 {
static void drawTorus(float r, float R, int nsides, int rings) {
@@ -72,22 +71,19 @@ public class Snippet195 {
GLContext.useContext(canvas);
} catch(LWJGLException e) { e.printStackTrace(); }
- canvas.addListener(SWT.Resize, new Listener() {
- @Override
- public void handleEvent(Event event) {
- Rectangle bounds = canvas.getBounds();
- float fAspect = (float) bounds.width / (float) bounds.height;
- canvas.setCurrent();
- try {
- GLContext.useContext(canvas);
- } catch(LWJGLException e) { e.printStackTrace(); }
- GL11.glViewport(0, 0, bounds.width, bounds.height);
- GL11.glMatrixMode(GL11.GL_PROJECTION);
- GL11.glLoadIdentity();
- GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f);
- GL11.glMatrixMode(GL11.GL_MODELVIEW);
- GL11.glLoadIdentity();
- }
+ canvas.addListener(SWT.Resize, event -> {
+ Rectangle bounds = canvas.getBounds();
+ float fAspect = (float) bounds.width / (float) bounds.height;
+ canvas.setCurrent();
+ try {
+ GLContext.useContext(canvas);
+ } catch(LWJGLException e) { e.printStackTrace(); }
+ GL11.glViewport(0, 0, bounds.width, bounds.height);
+ GL11.glMatrixMode(GL11.GL_PROJECTION);
+ GL11.glLoadIdentity();
+ GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f);
+ GL11.glMatrixMode(GL11.GL_MODELVIEW);
+ GL11.glLoadIdentity();
});
GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
@@ -126,12 +122,7 @@ public class Snippet195 {
}
}
};
- canvas.addListener(SWT.Paint, new Listener() {
- @Override
- public void handleEvent(Event event) {
- run.run();
- }
- });
+ canvas.addListener(SWT.Paint, event -> run.run());
display.asyncExec(run);
while (!shell.isDisposed()) {
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet341.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet341.java
index fc5467a211..465ae67529 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet341.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet341.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,18 +21,17 @@ package org.eclipse.swt.snippets;
*
* @since 3.2
*/
-import java.nio.ByteBuffer;
+import java.nio.*;
import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
+import org.eclipse.swt.opengl.*;
import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.opengl.GLCanvas;
-import org.eclipse.swt.opengl.GLData;
-import org.lwjgl.opengl.GL11;
-import org.lwjgl.opengl.GLContext;
-import org.lwjgl.util.glu.GLU;
-import org.lwjgl.LWJGLException;
+import org.eclipse.swt.widgets.Display;
+import org.lwjgl.*;
+import org.lwjgl.opengl.*;
+import org.lwjgl.util.glu.*;
public class Snippet341 {
static void drawTorus(float r, float R, int nsides, int rings) {
@@ -76,22 +75,19 @@ public class Snippet341 {
GLContext.useContext(canvas);
} catch(LWJGLException e) { e.printStackTrace(); }
- canvas.addListener(SWT.Resize, new Listener() {
- @Override
- public void handleEvent(Event event) {
- Rectangle bounds = canvas.getBounds();
- float fAspect = (float) bounds.width / (float) bounds.height;
- canvas.setCurrent();
- try {
- GLContext.useContext(canvas);
- } catch(LWJGLException e) { e.printStackTrace(); }
- GL11.glViewport(0, 0, bounds.width, bounds.height);
- GL11.glMatrixMode(GL11.GL_PROJECTION);
- GL11.glLoadIdentity();
- GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f);
- GL11.glMatrixMode(GL11.GL_MODELVIEW);
- GL11.glLoadIdentity();
- }
+ canvas.addListener(SWT.Resize, event -> {
+ Rectangle bounds = canvas.getBounds();
+ float fAspect = (float) bounds.width / (float) bounds.height;
+ canvas.setCurrent();
+ try {
+ GLContext.useContext(canvas);
+ } catch(LWJGLException e) { e.printStackTrace(); }
+ GL11.glViewport(0, 0, bounds.width, bounds.height);
+ GL11.glMatrixMode(GL11.GL_PROJECTION);
+ GL11.glLoadIdentity();
+ GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f);
+ GL11.glMatrixMode(GL11.GL_MODELVIEW);
+ GL11.glLoadIdentity();
});
GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
@@ -103,12 +99,7 @@ public class Snippet341 {
Button button = new Button(shell, SWT.PUSH);
button.setText("Capture");
- button.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- capture(canvas);
- }
- });
+ button.addListener(SWT.Selection, event -> capture(canvas));
shell.pack();
shell.open();
@@ -173,19 +164,9 @@ public class Snippet341 {
shell.setLayout(new GridLayout());
Canvas canvas = new Canvas(shell, SWT.NONE);
canvas.setLayoutData(new GridData(bounds.width, bounds.height));
- canvas.addListener(SWT.Paint, new Listener() {
- @Override
- public void handleEvent(Event event) {
- event.gc.drawImage(image, 0, 0);
- }
- });
+ canvas.addListener(SWT.Paint, event -> event.gc.drawImage(image, 0, 0));
shell.pack();
shell.open();
- shell.addListener(SWT.Dispose, new Listener() {
- @Override
- public void handleEvent(Event event) {
- image.dispose();
- }
- });
+ shell.addListener(SWT.Dispose, event -> image.dispose());
}
}

Back to the top