aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-core
diff options
context:
space:
mode:
authorJulien Gouesse <[email protected]>2018-02-12 22:40:34 +0100
committerJulien Gouesse <[email protected]>2018-02-12 22:40:34 +0100
commite4289ed7966d2ffe289633b00485026db6e72fb3 (patch)
tree84d66e64582861f3e62caeadf220b9bd110e9bfb /ardor3d-core
parent484a7bc1b7354f80027e45d0fd0d97473cc454dd (diff)
Drops Guava's immutable lists, sets and maps
Diffstat (limited to 'ardor3d-core')
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/bounding/CollisionTreeManager.java3
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/MouseState.java35
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/PhysicalLayer.java10
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueueManager.java14
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/TextureManager.java47
5 files changed, 55 insertions, 54 deletions
diff --git a/ardor3d-core/src/main/java/com/ardor3d/bounding/CollisionTreeManager.java b/ardor3d-core/src/main/java/com/ardor3d/bounding/CollisionTreeManager.java
index c655b78..8ab1688 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/bounding/CollisionTreeManager.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/CollisionTreeManager.java
@@ -19,7 +19,6 @@ import java.util.WeakHashMap;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.Node;
import com.ardor3d.scenegraph.Spatial;
-import com.google.common.collect.ImmutableList;
/**
* CollisionTreeManager is an automated system for handling the creation and deletion of CollisionTrees. The manager
@@ -405,6 +404,6 @@ public enum CollisionTreeManager {
* @return an immutable copy of the list of protected meshes.
*/
public List<Mesh> getProtectedMeshes() {
- return ImmutableList.copyOf(_protectedList);
+ return Collections.unmodifiableList(new ArrayList<>(_protectedList));
}
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/MouseState.java b/ardor3d-core/src/main/java/com/ardor3d/input/MouseState.java
index e05ea87..398810e 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/MouseState.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/MouseState.java
@@ -3,19 +3,20 @@
*
* 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>.
*/
package com.ardor3d.input;
+import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
+import java.util.Map;
import com.ardor3d.annotation.Immutable;
import com.google.common.collect.EnumMultiset;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultiset;
import com.google.common.collect.ImmutableMultiset.Builder;
import com.google.common.collect.Multiset;
@@ -33,12 +34,12 @@ public class MouseState {
private final int _dx;
private final int _dy;
private final int _dwheel;
- private final ImmutableMap<MouseButton, ButtonState> _buttonStates;
+ private final Map<MouseButton, ButtonState> _buttonStates;
private final ImmutableMultiset<MouseButton> _clickCounts;
/**
* Constructs a new MouseState instance.
- *
+ *
* @param x
* the mouse's x position
* @param y
@@ -62,11 +63,9 @@ public class MouseState {
_dy = dy;
_dwheel = dwheel;
if (buttonStates != null) {
- final com.google.common.collect.ImmutableMap.Builder<MouseButton, ButtonState> builder = ImmutableMap
- .builder();
- _buttonStates = builder.putAll(buttonStates).build();
+ _buttonStates = Collections.unmodifiableMap(new EnumMap<>(buttonStates));
} else {
- _buttonStates = ImmutableMap.of();
+ _buttonStates = Collections.emptyMap();
}
if (clicks != null) {
final Builder<MouseButton> builder = ImmutableMultiset.builder();
@@ -97,7 +96,7 @@ public class MouseState {
}
/**
- *
+ *
* @param state
* the button state to look for
* @return true if at least one mouse button is in the given button state.
@@ -107,7 +106,7 @@ public class MouseState {
}
/**
- *
+ *
* @param state
* the button to look for
* @return true if the given mouse button is currently mapped to a state.
@@ -119,7 +118,7 @@ public class MouseState {
/**
* Returns all the buttons' states. It could be easier for most classes to use the
* {@link #getButtonState(MouseButton)} methods, and that also results in less object creation.
- *
+ *
* @return a defensive copy of the states of all the buttons at this point in time.
*/
public EnumMap<MouseButton, ButtonState> getButtonStates() {
@@ -129,7 +128,7 @@ public class MouseState {
/**
* Returns all the buttons' states. It could be easier for most classes to use the
* {@link #getButtonState(MouseButton)} methods, and that also results in less object creation.
- *
+ *
* @param store
* a map to store the states in... any values in store are cleared first. If store is null, a new map is
* created.
@@ -147,7 +146,7 @@ public class MouseState {
/**
* Returns the current state for the supplied button, or UP if no state for that button is registered.
- *
+ *
* @param button
* the mouse button to check
* @return the button's state, or {@link ButtonState#UP} if no button state registered.
@@ -189,7 +188,7 @@ public class MouseState {
/**
* Returns all the buttons' states. It could be easier for most classes to use the
* {@link #getClickCount(MouseButton)} method, and that also results in less object creation.
- *
+ *
* @return a defensive copy of the click counts of all the buttons at this point in time.
*/
public Multiset<MouseButton> getClickCounts() {
@@ -226,11 +225,11 @@ public class MouseState {
* <li>Frame 6, mouse button down - click count == 0</li>
* <li>Frame 7, mouse button released - click count == 2</li>
* </nl>
- *
+ *
* Whether or not a mouse press/release sequence counts as a click (or double-click) depends on the time passed
* between them. See {@link #CLICK_TIME_MS}.
- *
- *
+ *
+ *
* @param button
* the button to check for clicks
* @return the click count in this frame
@@ -241,7 +240,7 @@ public class MouseState {
/**
* Returns a new EnumSet of all buttons that were clicked this frame.
- *
+ *
* @return every mouse button whose click count this frame is > 0
*/
public EnumSet<MouseButton> getButtonsClicked() {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/PhysicalLayer.java b/ardor3d-core/src/main/java/com/ardor3d/input/PhysicalLayer.java
index ba5b18d..7c746a3 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/PhysicalLayer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/PhysicalLayer.java
@@ -3,13 +3,14 @@
*
* 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>.
*/
package com.ardor3d.input;
+import java.util.Collections;
import java.util.EnumSet;
import java.util.LinkedList;
import java.util.List;
@@ -20,7 +21,6 @@ import java.util.logging.Logger;
import com.ardor3d.input.logical.DummyControllerWrapper;
import com.ardor3d.input.logical.DummyFocusWrapper;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.PeekingIterator;
/**
@@ -45,7 +45,7 @@ public class PhysicalLayer {
private boolean _inited = false;
private static final long MAX_INPUT_POLL_TIME = TimeUnit.SECONDS.toNanos(2);
- private static final List<InputState> EMPTY_LIST = ImmutableList.of();
+ private static final List<InputState> EMPTY_LIST = Collections.emptyList();
public PhysicalLayer(final KeyboardWrapper keyboardWrapper, final MouseWrapper mouseWrapper) {
this(keyboardWrapper, mouseWrapper, DummyControllerWrapper.INSTANCE, DummyFocusWrapper.INSTANCE);
@@ -77,7 +77,7 @@ public class PhysicalLayer {
/**
* Causes a poll of the input devices to happen, making any updates to input states available via the
* {@link #drainAvailableStates()} method.
- *
+ *
* @throws IllegalStateException
* if too many state changes have happened since the last call to this method
*/
@@ -178,7 +178,7 @@ public class PhysicalLayer {
/**
* Fetches any new <code>InputState</code>s since the last call to this method. If no input system changes have been
* made since the last call (no mouse movements, no keys pressed or released), an empty list is returned.
- *
+ *
* @return the list of new <code>InputState</code>, or an empty list if there have been no changes in input
*/
public List<InputState> drainAvailableStates() {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueueManager.java b/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueueManager.java
index 3000bd1..f442186 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueueManager.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueueManager.java
@@ -3,27 +3,29 @@
*
* 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>.
*/
package com.ardor3d.util;
+import java.util.Collections;
+import java.util.Map;
+import java.util.WeakHashMap;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Future;
-import com.google.common.collect.MapMaker;
-
/**
* <code>GameTaskQueueManager</code> is just a simple Singleton class allowing easy access to task queues.
*/
public final class GameTaskQueueManager {
private static final Object MAP_LOCK = new Object();
- private static final ConcurrentMap<Object, GameTaskQueueManager> _managers = new MapMaker().weakKeys().makeMap();
+ private static final Map<Object, GameTaskQueueManager> _managers = Collections
+ .synchronizedMap(new WeakHashMap<Object, GameTaskQueueManager>());
private final ConcurrentMap<String, GameTaskQueue> _managedQueues = new ConcurrentHashMap<>(2);
@@ -77,7 +79,7 @@ public final class GameTaskQueueManager {
/**
* This method adds <code>callable</code> to the queue to be invoked in the update() method in the OpenGL thread.
* The Future returned may be utilized to cancel the task or wait for the return object.
- *
+ *
* @param callable
* @return Future<V>
*/
@@ -89,7 +91,7 @@ public final class GameTaskQueueManager {
/**
* This method adds <code>callable</code> to the queue to be invoked in the render() method in the OpenGL thread.
* The Future returned may be utilized to cancel the task or wait for the return object.
- *
+ *
* @param callable
* @return Future<V>
*/
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/TextureManager.java b/ardor3d-core/src/main/java/com/ardor3d/util/TextureManager.java
index d8c5315..d90d2c0 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/TextureManager.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/TextureManager.java
@@ -3,7 +3,7 @@
*
* 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>.
*/
@@ -11,8 +11,10 @@
package com.ardor3d.util;
import java.lang.ref.ReferenceQueue;
+import java.util.Collections;
import java.util.Map;
import java.util.Set;
+import java.util.WeakHashMap;
import java.util.concurrent.Future;
import java.util.logging.Logger;
@@ -34,7 +36,6 @@ import com.ardor3d.renderer.state.TextureState;
import com.ardor3d.util.resource.ResourceLocatorTool;
import com.ardor3d.util.resource.ResourceSource;
import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.MapMaker;
import com.google.common.collect.Multimap;
/**
@@ -44,7 +45,8 @@ import com.google.common.collect.Multimap;
final public class TextureManager {
private static final Logger logger = Logger.getLogger(TextureManager.class.getName());
- private static Map<TextureKey, Texture> _tCache = new MapMaker().weakKeys().weakValues().makeMap();
+ private static Map<TextureKey, Texture> _tCache = Collections
+ .synchronizedMap(new WeakHashMap<TextureKey, Texture>());
private static ReferenceQueue<TextureKey> _textureRefQueue = new ReferenceQueue<>();
@@ -61,7 +63,7 @@ final public class TextureManager {
/**
* Loads a texture by attempting to locate the given name using ResourceLocatorTool.
- *
+ *
* @param name
* the name of the texture image.
* @param minFilter
@@ -78,7 +80,7 @@ final public class TextureManager {
/**
* Loads a texture by attempting to locate the given name using ResourceLocatorTool.
- *
+ *
* @param name
* the name of the texture image.
* @param minFilter
@@ -97,7 +99,7 @@ final public class TextureManager {
/**
* Loads a texture from the given source.
- *
+ *
* @param source
* the source of the texture image.
* @param minFilter
@@ -113,7 +115,7 @@ final public class TextureManager {
/**
* Loads a texture from the given source.
- *
+ *
* @param source
* the source of the texture image.
* @param minFilter
@@ -139,7 +141,7 @@ final public class TextureManager {
/**
* Creates a texture from a given Ardor3D Image object.
- *
+ *
* @param image
* the Ardor3D image.
* @param minFilter
@@ -152,7 +154,7 @@ final public class TextureManager {
/**
* Creates a texture from a given Ardor3D Image object.
- *
+ *
* @param image
* the Ardor3D image.
* @param minFilter
@@ -170,7 +172,7 @@ final public class TextureManager {
/**
* Load a texture from the given TextureKey. If imageData is given, use that, otherwise load it using the key's
* source information. If store is given, populate and return that Texture object.
- *
+ *
* @param tkey
* our texture key. Must not be null.
* @param imageData
@@ -236,21 +238,20 @@ final public class TextureManager {
/**
* Add a given texture to the cache
- *
+ *
* @param texture
* our texture
*/
public static void addToCache(final Texture texture) {
- if (TextureState.getDefaultTexture() == null
- || (texture != TextureState.getDefaultTexture() && texture.getImage() != TextureState
- .getDefaultTextureImage())) {
+ if (TextureState.getDefaultTexture() == null || (texture != TextureState.getDefaultTexture()
+ && texture.getImage() != TextureState.getDefaultTextureImage())) {
_tCache.put(texture.getTextureKey(), texture);
}
}
/**
* Locate a texture in the cache by key
- *
+ *
* @param textureKey
* our key
* @return the texture, or null if not found.
@@ -269,7 +270,7 @@ final public class TextureManager {
* be deleted immediately. If a deleter is not passed in, we do not have an active context, or we encounter textures
* that are not part of the current context, then we will queue those textures to be deleted later using the
* GameTaskQueueManager.
- *
+ *
* @param deleter
* if not null, this renderer will be used to immediately delete any textures in the currently active
* context. All other textures will be queued to delete in their own contexts.
@@ -284,10 +285,10 @@ final public class TextureManager {
* be deleted immediately. If a deleter is not passed in, we do not have an active context, or we encounter textures
* that are not part of the current context, then we will queue those textures to be deleted later using the
* GameTaskQueueManager.
- *
+ *
* If a non null map is passed into futureStore, it will be populated with Future objects for each queued context.
* These objects may be used to discover when the deletion tasks have all completed.
- *
+ *
* @param deleter
* if not null, this renderer will be used to immediately delete any textures in the currently active
* context. All other textures will be queued to delete in their own contexts.
@@ -329,10 +330,10 @@ final public class TextureManager {
* currently active context (if one is active) will be deleted immediately. If a deleter is not passed in, we do not
* have an active context, or we encounter textures that are not part of the current context, then we will queue
* those textures to be deleted later using the GameTaskQueueManager.
- *
+ *
* If a non null map is passed into futureStore, it will be populated with Future objects for each queued context.
* These objects may be used to discover when the deletion tasks have all completed.
- *
+ *
* @param deleter
* if not null, this renderer will be used to immediately delete any textures in the currently active
* context. All other textures will be queued to delete in their own contexts.
@@ -372,7 +373,7 @@ final public class TextureManager {
* gc'd textures that are part of the currently active context (if one is active) will be deleted immediately. If a
* deleter is not passed in, we do not have an active context, or we encounter gc'd textures that are not part of
* the current context, then we will queue those textures to be deleted later using the GameTaskQueueManager.
- *
+ *
* @param deleter
* if not null, this renderer will be used to immediately delete any gc'd textures in the currently
* active context. All other gc'd textures will be queued to delete in their own contexts.
@@ -386,10 +387,10 @@ final public class TextureManager {
* gc'd textures that are part of the currently active context (if one is active) will be deleted immediately. If a
* deleter is not passed in, we do not have an active context, or we encounter gc'd textures that are not part of
* the current context, then we will queue those textures to be deleted later using the GameTaskQueueManager.
- *
+ *
* If a non null map is passed into futureStore, it will be populated with Future objects for each queued context.
* These objects may be used to discover when the deletion tasks have all completed.
- *
+ *
* @param deleter
* if not null, this renderer will be used to immediately delete any gc'd textures in the currently
* active context. All other gc'd textures will be queued to delete in their own contexts.