aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-awt/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'ardor3d-awt/src/main/java')
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageLoader.java7
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageUtil.java6
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTTextureUtil.java10
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AwtColorUtil.java2
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/ScreenShotImageExporter.java4
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtFocusWrapper.java8
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKey.java2
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java11
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseManager.java9
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java43
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/ui/text/awt/AwtCopyPasteImpl.java44
11 files changed, 119 insertions, 27 deletions
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageLoader.java b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageLoader.java
index 839d03a..5ecbeb3 100644
--- a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageLoader.java
+++ b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageLoader.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ * Copyright (c) 2008-2014 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
@@ -19,6 +19,7 @@ import java.awt.image.renderable.RenderableImage;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
+import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
@@ -31,7 +32,6 @@ import com.ardor3d.image.util.ImageLoader;
import com.ardor3d.image.util.ImageLoaderUtil;
import com.ardor3d.renderer.state.TextureState;
import com.ardor3d.util.geom.BufferUtils;
-import com.google.common.collect.Lists;
/**
* Image loader that makes use of AWT's ImageIO to load image file data.
@@ -49,7 +49,7 @@ public class AWTImageLoader implements ImageLoader {
public static void registerLoader() {
if (supportedFormats == null) {
- final List<String> formats = Lists.newArrayList();
+ final List<String> formats = new ArrayList<>();
for (String format : ImageIO.getReaderFormatNames()) {
format = "." + format.toUpperCase();
if (!formats.contains(format)) {
@@ -61,6 +61,7 @@ public class AWTImageLoader implements ImageLoader {
ImageLoaderUtil.registerHandler(new AWTImageLoader(), supportedFormats);
}
+ @Override
public Image load(final InputStream is, final boolean flipImage) throws IOException {
final BufferedImage image = ImageIO.read(is);
if (image == null) {
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageUtil.java b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageUtil.java
index ef417be..d158478 100644
--- a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageUtil.java
+++ b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTImageUtil.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ * Copyright (c) 2008-2014 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
@@ -13,11 +13,11 @@ package com.ardor3d.image.util.awt;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.nio.ByteBuffer;
+import java.util.ArrayList;
import java.util.List;
import com.ardor3d.image.Image;
import com.ardor3d.image.PixelDataType;
-import com.google.common.collect.Lists;
/**
* Utility methods for converting Ardor3D Images to AWT BufferedImages.
@@ -63,7 +63,7 @@ public abstract class AWTImageUtil {
final int width = input.getWidth(), height = input.getHeight();
// create our return list
- final List<BufferedImage> rVal = Lists.newArrayList();
+ final List<BufferedImage> rVal = new ArrayList<>();
// Calculate our modulation or "tint" values per channel
final double tRed = tint != null ? tint.getRed() / 255. : 1.0;
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTTextureUtil.java b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTTextureUtil.java
index 76f1447..3d7525d 100644
--- a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTTextureUtil.java
+++ b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AWTTextureUtil.java
@@ -1,9 +1,9 @@
/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ * Copyright (c) 2008-2014 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -22,7 +22,7 @@ public abstract class AWTTextureUtil {
/**
* Convenience Utility for loading a BufferedImage as an Ardor3D Texture.
- *
+ *
* @param image
* our buffered image
* @param minFilter
@@ -36,8 +36,8 @@ public abstract class AWTTextureUtil {
public static final Texture loadTexture(final BufferedImage image, final Texture.MinificationFilter minFilter,
final TextureStoreFormat storeFormat, final boolean flipVertically) {
final Image imageData = AWTImageLoader.makeArdor3dImage(image, flipVertically);
- final String fileType = (image != null) ? "" + image.hashCode() : null;
- final TextureKey tkey = TextureKey.getKey(null, flipVertically, storeFormat, fileType, minFilter);
+ final String imageId = (image != null) ? "" + image.hashCode() : null;
+ final TextureKey tkey = TextureKey.getKey(null, flipVertically, storeFormat, imageId, minFilter);
return TextureManager.loadFromKey(tkey, imageData, null);
}
}
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AwtColorUtil.java b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AwtColorUtil.java
index 9f9a4fd..376834b 100644
--- a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AwtColorUtil.java
+++ b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/AwtColorUtil.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ * Copyright (c) 2008-2014 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/ScreenShotImageExporter.java b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/ScreenShotImageExporter.java
index e3a8e8f..a5c98c0 100644
--- a/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/ScreenShotImageExporter.java
+++ b/ardor3d-awt/src/main/java/com/ardor3d/image/util/awt/ScreenShotImageExporter.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ * Copyright (c) 2008-2014 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
@@ -67,6 +67,7 @@ public class ScreenShotImageExporter implements ScreenExportable {
_useAlpha = useAlpha;
}
+ @Override
public void export(final ByteBuffer data, final int width, final int height) {
final BufferedImage img = new BufferedImage(width, height, _useAlpha ? BufferedImage.TYPE_INT_ARGB
: BufferedImage.TYPE_INT_RGB);
@@ -105,6 +106,7 @@ public class ScreenShotImageExporter implements ScreenExportable {
}
}
+ @Override
public ImageDataFormat getFormat() {
if (_useAlpha) {
return ImageDataFormat.RGBA;
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtFocusWrapper.java b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtFocusWrapper.java
index 5514856..b26793c 100644
--- a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtFocusWrapper.java
+++ b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtFocusWrapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ * Copyright (c) 2008-2014 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
@@ -28,14 +28,17 @@ public class AwtFocusWrapper implements FocusWrapper, FocusListener {
_component = component;
}
+ @Override
public void focusGained(final FocusEvent e) {
- // do nothing
+ // do nothing
}
+ @Override
public void focusLost(final FocusEvent e) {
_focusLost = true;
}
+ @Override
public boolean getAndClearFocusLost() {
final boolean result = _focusLost;
@@ -44,6 +47,7 @@ public class AwtFocusWrapper implements FocusWrapper, FocusListener {
return result;
}
+ @Override
public void init() {
_component.addFocusListener(this);
}
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKey.java b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKey.java
index f464154..05fcdc6 100644
--- a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKey.java
+++ b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKey.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ * Copyright (c) 2008-2014 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java
index 5aa9a4d..4db16eb 100644
--- a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java
+++ b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ * Copyright (c) 2008-2014 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
@@ -31,7 +31,7 @@ import com.google.common.collect.PeekingIterator;
*/
public class AwtKeyboardWrapper implements KeyboardWrapper, KeyListener {
@GuardedBy("this")
- protected final LinkedList<KeyEvent> _upcomingEvents = new LinkedList<KeyEvent>();
+ protected final LinkedList<KeyEvent> _upcomingEvents = new LinkedList<>();
@GuardedBy("this")
protected AwtKeyboardIterator _currentIterator = null;
@@ -46,17 +46,21 @@ public class AwtKeyboardWrapper implements KeyboardWrapper, KeyListener {
_component = Preconditions.checkNotNull(component, "component");
}
+ @Override
public void init() {
_component.addKeyListener(this);
_component.addFocusListener(new FocusListener() {
+ @Override
public void focusLost(final FocusEvent e) {}
+ @Override
public void focusGained(final FocusEvent e) {
_pressedList.clear();
}
});
}
+ @Override
public synchronized PeekingIterator<KeyEvent> getEvents() {
if (_currentIterator == null || !_currentIterator.hasNext()) {
_currentIterator = new AwtKeyboardIterator();
@@ -65,6 +69,7 @@ public class AwtKeyboardWrapper implements KeyboardWrapper, KeyListener {
return _currentIterator;
}
+ @Override
public synchronized void keyTyped(final java.awt.event.KeyEvent e) {
if (_consumeEvents) {
e.consume();
@@ -72,6 +77,7 @@ public class AwtKeyboardWrapper implements KeyboardWrapper, KeyListener {
}
}
+ @Override
public synchronized void keyPressed(final java.awt.event.KeyEvent e) {
final Key pressed = fromKeyEventToKey(e);
if (!_pressedList.contains(pressed)) {
@@ -83,6 +89,7 @@ public class AwtKeyboardWrapper implements KeyboardWrapper, KeyListener {
}
}
+ @Override
public synchronized void keyReleased(final java.awt.event.KeyEvent e) {
final Key released = fromKeyEventToKey(e);
_upcomingEvents.add(new KeyEvent(released, KeyState.UP, e.getKeyChar()));
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseManager.java b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseManager.java
index 9f5a816..f820b9c 100644
--- a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseManager.java
+++ b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseManager.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ * Copyright (c) 2008-2014 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
@@ -61,6 +61,7 @@ public class AwtMouseManager implements MouseManager {
}
}
+ @Override
public void setCursor(final MouseCursor cursor) {
if (cursor == MouseCursor.SYSTEM_DEFAULT || cursor == null) {
if (_grabbedState == GrabbedState.GRABBED) {
@@ -87,6 +88,7 @@ public class AwtMouseManager implements MouseManager {
}
}
+ @Override
public void setPosition(final int x, final int y) {
if (!isSetPositionSupported()) {
throw new UnsupportedOperationException();
@@ -98,6 +100,7 @@ public class AwtMouseManager implements MouseManager {
setMousePosition(x, y);
} else {
SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
public void run() {
setMousePosition(x, y);
}
@@ -118,6 +121,7 @@ public class AwtMouseManager implements MouseManager {
_robot.mouseMove(p.x, p.y);
}
+ @Override
public void setGrabbed(final GrabbedState grabbedState) {
if (!isSetGrabbedSupported()) {
throw new UnsupportedOperationException();
@@ -153,14 +157,17 @@ public class AwtMouseManager implements MouseManager {
return _transparentCursor;
}
+ @Override
public boolean isSetPositionSupported() {
return _robot != null;
}
+ @Override
public boolean isSetGrabbedSupported() {
return _robot != null;
}
+ @Override
public GrabbedState getGrabbed() {
return _grabbedState;
}
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java
index c64b70b..aa36fd9 100644
--- a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java
+++ b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java
@@ -1,9 +1,9 @@
/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ * Copyright (c) 2008-2014 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -32,8 +32,6 @@ import com.ardor3d.input.MouseState;
import com.ardor3d.input.MouseWrapper;
import com.google.common.collect.AbstractIterator;
import com.google.common.collect.EnumMultiset;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import com.google.common.collect.Multiset;
import com.google.common.collect.PeekingIterator;
@@ -42,7 +40,7 @@ import com.google.common.collect.PeekingIterator;
*/
public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelListener, MouseMotionListener {
@GuardedBy("this")
- protected final LinkedList<MouseState> _upcomingEvents = Lists.newLinkedList();
+ protected final LinkedList<MouseState> _upcomingEvents = new LinkedList<>();
@GuardedBy("this")
protected AwtMouseIterator _currentIterator = null;
@@ -57,7 +55,7 @@ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelL
protected final MouseManager _manager;
protected final Multiset<MouseButton> _clicks = EnumMultiset.create(MouseButton.class);
- protected final EnumMap<MouseButton, Long> _lastClickTime = Maps.newEnumMap(MouseButton.class);
+ protected final EnumMap<MouseButton, Long> _lastClickTime = new EnumMap<>(MouseButton.class);
protected final EnumSet<MouseButton> _clickArmed = EnumSet.noneOf(MouseButton.class);
protected int _ignoreX = Integer.MAX_VALUE;
@@ -76,12 +74,14 @@ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelL
}
}
+ @Override
public void init() {
_component.addMouseListener(this);
_component.addMouseMotionListener(this);
_component.addMouseWheelListener(this);
}
+ @Override
public synchronized PeekingIterator<MouseState> getEvents() {
expireClickEvents();
@@ -102,6 +102,7 @@ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelL
}
}
+ @Override
public synchronized void mousePressed(final MouseEvent e) {
final MouseButton b = getButtonForEvent(e);
if (_clickArmed.contains(b)) {
@@ -122,6 +123,7 @@ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelL
addNewState(e, buttons, null);
}
+ @Override
public synchronized void mouseReleased(final MouseEvent e) {
initState(e);
if (_consumeEvents) {
@@ -145,11 +147,13 @@ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelL
addNewState(e, buttons, null);
}
+ @Override
public synchronized void mouseDragged(final MouseEvent e) {
// forward to mouseMoved.
mouseMoved(e);
}
+ @Override
public synchronized void mouseMoved(final MouseEvent e) {
_clickArmed.clear();
_clicks.clear();
@@ -206,6 +210,7 @@ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelL
}
}
+ @Override
public void mouseWheelMoved(final MouseWheelEvent e) {
initState(e);
@@ -224,8 +229,9 @@ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelL
private void addNewState(final MouseEvent mouseEvent, final EnumMap<MouseButton, ButtonState> enumMap,
final Multiset<MouseButton> clicks) {
final MouseState newState = new MouseState(mouseEvent.getX(), getArdor3DY(mouseEvent), getDX(mouseEvent),
- getDY(mouseEvent), (mouseEvent instanceof MouseWheelEvent ? ((MouseWheelEvent) mouseEvent)
- .getWheelRotation() : 0), enumMap, clicks);
+ getDY(mouseEvent),
+ (mouseEvent instanceof MouseWheelEvent ? ((MouseWheelEvent) mouseEvent).getWheelRotation() : 0),
+ enumMap, clicks);
synchronized (AwtMouseWrapper.this) {
_upcomingEvents.add(newState);
@@ -271,6 +277,24 @@ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelL
case MouseEvent.BUTTON3:
button = MouseButton.RIGHT;
break;
+ case 4:
+ button = MouseButton.FOUR;
+ break;
+ case 5:
+ button = MouseButton.FIVE;
+ break;
+ case 6:
+ button = MouseButton.SIX;
+ break;
+ case 7:
+ button = MouseButton.SEVEN;
+ break;
+ case 8:
+ button = MouseButton.EIGHT;
+ break;
+ case 9:
+ button = MouseButton.NINE;
+ break;
default:
throw new RuntimeException("unknown button: " + e.getButton());
}
@@ -293,6 +317,7 @@ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelL
// -- The following interface methods are not used. --
+ @Override
public synchronized void mouseClicked(final MouseEvent e) {
// Yes, we could use the click count here, but in the interests of this working the same way as SWT and Native,
// we
@@ -302,6 +327,7 @@ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelL
}
}
+ @Override
public synchronized void mouseEntered(final MouseEvent e) {
// ignore this
if (_consumeEvents) {
@@ -309,6 +335,7 @@ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelL
}
}
+ @Override
public synchronized void mouseExited(final MouseEvent e) {
// ignore this
if (_consumeEvents) {
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/ui/text/awt/AwtCopyPasteImpl.java b/ardor3d-awt/src/main/java/com/ardor3d/ui/text/awt/AwtCopyPasteImpl.java
new file mode 100644
index 0000000..43058c5
--- /dev/null
+++ b/ardor3d-awt/src/main/java/com/ardor3d/ui/text/awt/AwtCopyPasteImpl.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2008-2014 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.ui.text.awt;
+
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.StringSelection;
+import java.awt.datatransfer.Transferable;
+
+import com.ardor3d.ui.text.CopyPasteImpl;
+
+public class AwtCopyPasteImpl implements CopyPasteImpl {
+
+ @Override
+ public String getClipBoardContents() {
+ final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+ final Transferable clipboardContent = clipboard.getContents(null);
+
+ if (clipboardContent != null && clipboardContent.isDataFlavorSupported(DataFlavor.stringFlavor)) {
+ try {
+ return (String) clipboardContent.getTransferData(DataFlavor.stringFlavor);
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void setClipBoardContents(final String contents) {
+ final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+ final StringSelection string = new StringSelection(contents);
+ clipboard.setContents(string, null);
+ }
+}