aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-core/src/main/java
diff options
context:
space:
mode:
authorJulien Gouesse <[email protected]>2016-06-30 22:36:24 +0200
committerJulien Gouesse <[email protected]>2016-06-30 22:36:24 +0200
commitced8e5e5a3439630b51a5aef53ef5dfbde69eb95 (patch)
treed09e41e49f4ad4a172a2cb4760d373aead49d4eb /ardor3d-core/src/main/java
parent1257dbbf93986d1c2f21c0b1758efd8ffd110cf5 (diff)
Switches from Java 1.6 to Java 1.7 and fixes numerous warnings
Diffstat (limited to 'ardor3d-core/src/main/java')
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingBox.java29
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingSphere.java30
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java15
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/bounding/CollisionTree.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/bounding/CollisionTreeManager.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/bounding/OrientedBoundingBox.java84
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/framework/FrameHandler.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/image/Image.java8
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/image/util/GeneratedImageFactory.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/image/util/ImageLoaderUtil.java11
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/image/util/dds/DdsLoader.java53
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/ControllerInfo.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.java20
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/MouseButton.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/MouseCursor.java30
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/MouseState.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/PhysicalLayer.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/LogicalLayer.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonCondition.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/TriggerConditions.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/TwoInputStates.java14
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/intersection/CollisionResults.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/intersection/PickResults.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/intersection/PrimitiveCollisionResults.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/intersection/PrimitiveKey.java11
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractFBOTextureRenderer.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractPbufferTextureRenderer.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/ContextManager.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/RenderContext.java20
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectStep_RenderScreenOverlay.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectStep_RenderSpatials.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/effect/RenderEffect.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/effect/TextureRendererPool.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/pass/BasicPassManager.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/pass/Pass.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/queue/AbstractRenderBucket.java6
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/queue/RenderBucketType.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/queue/RenderQueue.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/state/FragmentProgramState.java32
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/state/GLSLShaderObjectsState.java42
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/state/LightState.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/state/RenderState.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/state/TextureState.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/state/VertexProgramState.java32
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/LightStateRecord.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/RendererRecord.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/ShaderObjectsStateRecord.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/TextureStateRecord.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/AbstractBufferData.java10
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/InstancingManager.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/Node.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java12
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/controller/interpolation/InterpolationController.java28
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/event/SceneGraphManager.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNode.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNodeState.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Extrusion.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/spline/ArcLengthTable.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/ui/text/BMFont.java16
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/ContextIdReference.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java6
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueueManager.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianDataInput.java23
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/SimpleContextIdReference.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/TextureKey.java28
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/TextureManager.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryExporter.java25
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.java53
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryInputCapsule.java12
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryOutputCapsule.java7
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java12
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMSerializer.java6
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/geom/GeometryTool.java6
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/geom/MeshCombiner.java12
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/geom/NormalGenerator.java47
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/geom/VertGroupData.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/resource/RelativeResourceLocator.java9
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/resource/ResourceLocatorTool.java6
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.java11
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.java13
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/DisplayListDelegate.java6
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/shader/ShaderVariable.java9
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/stat/MultiStatSample.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/stat/StatCollector.java8
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/stat/StatType.java7
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/AbstractStatGrapher.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/LineGrapher.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java4
95 files changed, 448 insertions, 513 deletions
diff --git a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingBox.java b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingBox.java
index 35d4245..14c2d80 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingBox.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingBox.java
@@ -12,6 +12,7 @@ package com.ardor3d.bounding;
import java.io.IOException;
import java.nio.FloatBuffer;
+import java.util.Objects;
import com.ardor3d.intersection.IntersectionRecord;
import com.ardor3d.math.MathUtils;
@@ -66,16 +67,8 @@ public class BoundingBox extends BoundingVolume {
@Override
public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- long temp;
- temp = Double.doubleToLongBits(_xExtent);
- result = prime * result + (int) (temp ^ (temp >>> 32));
- temp = Double.doubleToLongBits(_yExtent);
- result = prime * result + (int) (temp ^ (temp >>> 32));
- temp = Double.doubleToLongBits(_zExtent);
- result = prime * result + (int) (temp ^ (temp >>> 32));
- return result;
+ return Objects.hash(Integer.valueOf(super.hashCode()), Double.valueOf(getXExtent()),
+ Double.valueOf(getYExtent()), Double.valueOf(getZExtent()));
}
@Override
@@ -259,10 +252,10 @@ public class BoundingBox extends BoundingVolume {
return;
}
- final Vector3 min = _compVect1
- .set(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
- final Vector3 max = _compVect2
- .set(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
+ final Vector3 min = _compVect1.set(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY,
+ Double.POSITIVE_INFINITY);
+ final Vector3 max = _compVect2.set(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY,
+ Double.NEGATIVE_INFINITY);
final int vertsPerPrimitive = data.getIndexMode(section).getVertexCount();
Vector3[] store = new Vector3[vertsPerPrimitive];
@@ -397,8 +390,8 @@ public class BoundingBox extends BoundingVolume {
switch (volume.getType()) {
case AABB: {
final BoundingBox vBox = (BoundingBox) volume;
- return merge(vBox._center, vBox.getXExtent(), vBox.getYExtent(), vBox.getZExtent(), new BoundingBox(
- new Vector3(0, 0, 0), 0, 0, 0));
+ return merge(vBox._center, vBox.getXExtent(), vBox.getYExtent(), vBox.getZExtent(),
+ new BoundingBox(new Vector3(0, 0, 0), 0, 0, 0));
}
case Sphere: {
@@ -768,8 +761,8 @@ public class BoundingBox extends BoundingVolume {
}
final double[] distances = new double[] { t[0] };
- final Vector3[] points = new Vector3[] { new Vector3(ray.getDirection()).multiplyLocal(distances[0])
- .addLocal(ray.getOrigin()), };
+ final Vector3[] points = new Vector3[] {
+ new Vector3(ray.getDirection()).multiplyLocal(distances[0]).addLocal(ray.getOrigin()), };
return new IntersectionRecord(distances, points);
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingSphere.java b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingSphere.java
index ca6c0f9..b6ffb5d 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingSphere.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingSphere.java
@@ -12,6 +12,7 @@ package com.ardor3d.bounding;
import java.io.IOException;
import java.nio.FloatBuffer;
+import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -68,12 +69,7 @@ public class BoundingSphere extends BoundingVolume {
@Override
public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- long temp;
- temp = Double.doubleToLongBits(_radius);
- result = prime * result + (int) (temp ^ (temp >>> 32));
- return result;
+ return Objects.hash(Integer.valueOf(super.hashCode()), Double.valueOf(getRadius()));
}
@Override
@@ -294,8 +290,9 @@ public class BoundingSphere extends BoundingVolume {
final Vector3 b = B.subtract(O, null);
final Vector3 c = C.subtract(O, null);
- final double Denominator = 2.0 * (a.getX() * (b.getY() * c.getZ() - c.getY() * b.getZ()) - b.getX()
- * (a.getY() * c.getZ() - c.getY() * a.getZ()) + c.getX() * (a.getY() * b.getZ() - b.getY() * a.getZ()));
+ final double Denominator = 2.0 * (a.getX() * (b.getY() * c.getZ() - c.getY() * b.getZ())
+ - b.getX() * (a.getY() * c.getZ() - c.getY() * a.getZ())
+ + c.getX() * (a.getY() * b.getZ() - b.getY() * a.getZ()));
if (Denominator == 0) {
_center.set(0, 0, 0);
setRadius(0);
@@ -349,9 +346,9 @@ public class BoundingSphere extends BoundingVolume {
* @see #calcWelzl(java.nio.FloatBuffer)
*/
private void setSphere(final Vector3 O, final Vector3 A) {
- setRadius(Math.sqrt(((A.getX() - O.getX()) * (A.getX() - O.getX()) + (A.getY() - O.getY())
- * (A.getY() - O.getY()) + (A.getZ() - O.getZ()) * (A.getZ() - O.getZ())) / 4f)
- + radiusEpsilon - 1);
+ setRadius(
+ Math.sqrt(((A.getX() - O.getX()) * (A.getX() - O.getX()) + (A.getY() - O.getY()) * (A.getY() - O.getY())
+ + (A.getZ() - O.getZ()) * (A.getZ() - O.getZ())) / 4f) + radiusEpsilon - 1);
Vector3.lerp(O, A, .5, _center);
}
@@ -542,7 +539,8 @@ public class BoundingSphere extends BoundingVolume {
return this;
}
- private BoundingVolume merge(final double otherRadius, final ReadOnlyVector3 otherCenter, final BoundingSphere store) {
+ private BoundingVolume merge(final double otherRadius, final ReadOnlyVector3 otherCenter,
+ final BoundingSphere store) {
// check for infinite bounds... is so, return infinite bounds with center at origin
if (Double.isInfinite(otherRadius) || Double.isInfinite(getRadius())) {
store.setCenter(Vector3.ZERO);
@@ -720,8 +718,8 @@ public class BoundingSphere extends BoundingVolume {
discr = (a1 * a1) - a;
root = Math.sqrt(discr);
final double[] distances = new double[] { root - a1 };
- final Vector3[] points = new Vector3[] { ray.getDirection().multiply(distances[0], new Vector3())
- .addLocal(ray.getOrigin()) };
+ final Vector3[] points = new Vector3[] {
+ ray.getDirection().multiply(distances[0], new Vector3()).addLocal(ray.getOrigin()) };
return new IntersectionRecord(distances, points);
}
@@ -745,8 +743,8 @@ public class BoundingSphere extends BoundingVolume {
}
final double[] distances = new double[] { -a1 };
- final Vector3[] points = new Vector3[] { ray.getDirection().multiply(distances[0], new Vector3())
- .addLocal(ray.getOrigin()) };
+ final Vector3[] points = new Vector3[] {
+ ray.getDirection().multiply(distances[0], new Vector3()).addLocal(ray.getOrigin()) };
return new IntersectionRecord(distances, points);
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java
index d2f4d81..37609c1 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java
@@ -13,6 +13,7 @@ package com.ardor3d.bounding;
import java.io.IOException;
import java.io.Serializable;
import java.nio.FloatBuffer;
+import java.util.Objects;
import com.ardor3d.intersection.IntersectionRecord;
import com.ardor3d.math.Vector3;
@@ -47,10 +48,7 @@ public abstract class BoundingVolume implements Serializable, Savable {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((_center == null) ? 0 : _center.hashCode());
- return result;
+ return Objects.hashCode(getCenter());
}
@Override
@@ -65,14 +63,7 @@ public abstract class BoundingVolume implements Serializable, Savable {
return false;
}
final BoundingVolume other = (BoundingVolume) obj;
- if (_center == null) {
- if (other._center != null) {
- return false;
- }
- } else if (!_center.equals(other._center)) {
- return false;
- }
- return true;
+ return Objects.equals(_center, other._center);
}
/**
diff --git a/ardor3d-core/src/main/java/com/ardor3d/bounding/CollisionTree.java b/ardor3d-core/src/main/java/com/ardor3d/bounding/CollisionTree.java
index df3f7ef..23396b9 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/bounding/CollisionTree.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/CollisionTree.java
@@ -449,7 +449,7 @@ public class CollisionTree implements Serializable {
public List<PrimitiveKey> intersect(final Ray3 ray, final List<PrimitiveKey> store) {
List<PrimitiveKey> result = store;
if (result == null) {
- result = new ArrayList<PrimitiveKey>();
+ result = new ArrayList<>();
}
// if our ray doesn't hit the bounds, then it must not hit a primitive.
@@ -594,6 +594,6 @@ public class CollisionTree implements Serializable {
* @return a new reference to the given mesh.
*/
private WeakReference<Mesh> makeRef(final Mesh mesh) {
- return new WeakReference<Mesh>(mesh);
+ return new WeakReference<>(mesh);
}
}
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 cbdfcca..ff7d64c 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/bounding/CollisionTreeManager.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/CollisionTreeManager.java
@@ -80,7 +80,7 @@ public enum CollisionTreeManager {
* private constructor for the Singleton. Initializes the cache.
*/
private CollisionTreeManager() {
- _cache = new WeakHashMap<Mesh, CollisionTree>();
+ _cache = new WeakHashMap<>();
_protectedList = Collections.synchronizedList(new ArrayList<Mesh>(1));
setCollisionTreeController(new UsageTreeController());
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/bounding/OrientedBoundingBox.java b/ardor3d-core/src/main/java/com/ardor3d/bounding/OrientedBoundingBox.java
index c053ab6..24d14c1 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/bounding/OrientedBoundingBox.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/OrientedBoundingBox.java
@@ -13,6 +13,7 @@ package com.ardor3d.bounding;
import java.io.IOException;
import java.nio.FloatBuffer;
import java.util.Arrays;
+import java.util.Objects;
import com.ardor3d.intersection.IntersectionRecord;
import com.ardor3d.math.Matrix3;
@@ -63,15 +64,8 @@ public class OrientedBoundingBox extends BoundingVolume {
@Override
public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((_extent == null) ? 0 : _extent.hashCode());
- result = prime * result + Arrays.hashCode(_vectorStore);
- result = prime * result + ((_xAxis == null) ? 0 : _xAxis.hashCode());
- result = prime * result + ((_yAxis == null) ? 0 : _yAxis.hashCode());
- result = prime * result + ((_zAxis == null) ? 0 : _zAxis.hashCode());
- result = prime * result + (correctCorners ? 1231 : 1237);
- return result;
+ return Objects.hash(Integer.valueOf(super.hashCode()), getExtent(),
+ Integer.valueOf(Arrays.hashCode(_vectorStore)), getXAxis(), getYAxis(), getZAxis());
}
@Override
@@ -302,29 +296,29 @@ public class OrientedBoundingBox extends BoundingVolume {
mergeBuf.put((float) _vectorStore[i].getZ());
}
mergeBuf.put((float) (mergeSphere._center.getX() + mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getY() + mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getZ() + mergeSphere.getRadius()));
+ .put((float) (mergeSphere._center.getY() + mergeSphere.getRadius()))
+ .put((float) (mergeSphere._center.getZ() + mergeSphere.getRadius()));
mergeBuf.put((float) (mergeSphere._center.getX() - mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getY() + mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getZ() + mergeSphere.getRadius()));
+ .put((float) (mergeSphere._center.getY() + mergeSphere.getRadius()))
+ .put((float) (mergeSphere._center.getZ() + mergeSphere.getRadius()));
mergeBuf.put((float) (mergeSphere._center.getX() + mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getY() - mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getZ() + mergeSphere.getRadius()));
+ .put((float) (mergeSphere._center.getY() - mergeSphere.getRadius()))
+ .put((float) (mergeSphere._center.getZ() + mergeSphere.getRadius()));
mergeBuf.put((float) (mergeSphere._center.getX() + mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getY() + mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getZ() - mergeSphere.getRadius()));
+ .put((float) (mergeSphere._center.getY() + mergeSphere.getRadius()))
+ .put((float) (mergeSphere._center.getZ() - mergeSphere.getRadius()));
mergeBuf.put((float) (mergeSphere._center.getX() - mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getY() - mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getZ() + mergeSphere.getRadius()));
+ .put((float) (mergeSphere._center.getY() - mergeSphere.getRadius()))
+ .put((float) (mergeSphere._center.getZ() + mergeSphere.getRadius()));
mergeBuf.put((float) (mergeSphere._center.getX() - mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getY() + mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getZ() - mergeSphere.getRadius()));
+ .put((float) (mergeSphere._center.getY() + mergeSphere.getRadius()))
+ .put((float) (mergeSphere._center.getZ() - mergeSphere.getRadius()));
mergeBuf.put((float) (mergeSphere._center.getX() + mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getY() - mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getZ() - mergeSphere.getRadius()));
+ .put((float) (mergeSphere._center.getY() - mergeSphere.getRadius()))
+ .put((float) (mergeSphere._center.getZ() - mergeSphere.getRadius()));
mergeBuf.put((float) (mergeSphere._center.getX() - mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getY() - mergeSphere.getRadius()))
- .put((float) (mergeSphere._center.getZ() - mergeSphere.getRadius()));
+ .put((float) (mergeSphere._center.getY() - mergeSphere.getRadius()))
+ .put((float) (mergeSphere._center.getZ() - mergeSphere.getRadius()));
containAABB(mergeBuf);
correctCorners = false;
return this;
@@ -353,29 +347,29 @@ public class OrientedBoundingBox extends BoundingVolume {
mergeBuf.put((float) _vectorStore[i].getZ());
}
mergeBuf.put((float) (mergeBox._center.getX() + mergeBox.getXExtent()))
- .put((float) (mergeBox._center.getY() + mergeBox.getYExtent()))
- .put((float) (mergeBox._center.getZ() + mergeBox.getZExtent()));
+ .put((float) (mergeBox._center.getY() + mergeBox.getYExtent()))
+ .put((float) (mergeBox._center.getZ() + mergeBox.getZExtent()));
mergeBuf.put((float) (mergeBox._center.getX() - mergeBox.getXExtent()))
- .put((float) (mergeBox._center.getY() + mergeBox.getYExtent()))
- .put((float) (mergeBox._center.getZ() + mergeBox.getZExtent()));
+ .put((float) (mergeBox._center.getY() + mergeBox.getYExtent()))
+ .put((float) (mergeBox._center.getZ() + mergeBox.getZExtent()));
mergeBuf.put((float) (mergeBox._center.getX() + mergeBox.getXExtent()))
- .put((float) (mergeBox._center.getY() - mergeBox.getYExtent()))
- .put((float) (mergeBox._center.getZ() + mergeBox.getZExtent()));
+ .put((float) (mergeBox._center.getY() - mergeBox.getYExtent()))
+ .put((float) (mergeBox._center.getZ() + mergeBox.getZExtent()));
mergeBuf.put((float) (mergeBox._center.getX() + mergeBox.getXExtent()))
- .put((float) (mergeBox._center.getY() + mergeBox.getYExtent()))
- .put((float) (mergeBox._center.getZ() - mergeBox.getZExtent()));
+ .put((float) (mergeBox._center.getY() + mergeBox.getYExtent()))
+ .put((float) (mergeBox._center.getZ() - mergeBox.getZExtent()));
mergeBuf.put((float) (mergeBox._center.getX() - mergeBox.getXExtent()))
- .put((float) (mergeBox._center.getY() - mergeBox.getYExtent()))
- .put((float) (mergeBox._center.getZ() + mergeBox.getZExtent()));
+ .put((float) (mergeBox._center.getY() - mergeBox.getYExtent()))
+ .put((float) (mergeBox._center.getZ() + mergeBox.getZExtent()));
mergeBuf.put((float) (mergeBox._center.getX() - mergeBox.getXExtent()))
- .put((float) (mergeBox._center.getY() + mergeBox.getYExtent()))
- .put((float) (mergeBox._center.getZ() - mergeBox.getZExtent()));
+ .put((float) (mergeBox._center.getY() + mergeBox.getYExtent()))
+ .put((float) (mergeBox._center.getZ() - mergeBox.getZExtent()));
mergeBuf.put((float) (mergeBox._center.getX() + mergeBox.getXExtent()))
- .put((float) (mergeBox._center.getY() - mergeBox.getYExtent()))
- .put((float) (mergeBox._center.getZ() - mergeBox.getZExtent()));
+ .put((float) (mergeBox._center.getY() - mergeBox.getYExtent()))
+ .put((float) (mergeBox._center.getZ() - mergeBox.getZExtent()));
mergeBuf.put((float) (mergeBox._center.getX() - mergeBox.getXExtent()))
- .put((float) (mergeBox._center.getY() - mergeBox.getYExtent()))
- .put((float) (mergeBox._center.getZ() - mergeBox.getZExtent()));
+ .put((float) (mergeBox._center.getY() - mergeBox.getYExtent()))
+ .put((float) (mergeBox._center.getZ() - mergeBox.getZExtent()));
containAABB(mergeBuf);
correctCorners = false;
return this;
@@ -600,10 +594,10 @@ public class OrientedBoundingBox extends BoundingVolume {
final int vertsPerPrimitive = data.getIndexMode(section).getVertexCount();
Vector3[] store = new Vector3[vertsPerPrimitive];
- final Vector3 min = _compVect1
- .set(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
- final Vector3 max = _compVect2
- .set(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
+ final Vector3 min = _compVect1.set(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY,
+ Double.POSITIVE_INFINITY);
+ final Vector3 max = _compVect2.set(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY,
+ Double.NEGATIVE_INFINITY);
Vector3 point;
for (int i = start; i < end; i++) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/framework/FrameHandler.java b/ardor3d-core/src/main/java/com/ardor3d/framework/FrameHandler.java
index c5465cf..869b332 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/framework/FrameHandler.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/framework/FrameHandler.java
@@ -48,8 +48,8 @@ public final class FrameHandler {
public FrameHandler(final Timer timer) {
_timer = timer;
- _updaters = new CopyOnWriteArrayList<Updater>();
- _canvases = new CopyOnWriteArrayList<Canvas>();
+ _updaters = new CopyOnWriteArrayList<>();
+ _canvases = new CopyOnWriteArrayList<>();
}
@MainThread
diff --git a/ardor3d-core/src/main/java/com/ardor3d/image/Image.java b/ardor3d-core/src/main/java/com/ardor3d/image/Image.java
index b6b07ca..c81334d 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/image/Image.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/image/Image.java
@@ -42,7 +42,7 @@ public class Image implements Serializable, Savable {
* Constructor instantiates a new <code>Image</code> object. All values are undefined.
*/
public Image() {
- _data = new ArrayList<ByteBuffer>(1);
+ _data = new ArrayList<>(1);
}
/**
@@ -97,7 +97,7 @@ public class Image implements Serializable, Savable {
*/
public Image(final ImageDataFormat format, final PixelDataType type, final int width, final int height,
final ByteBuffer data, final int[] mipMapSizes) {
- this(format, type, width, height, new ArrayList<ByteBuffer>(Arrays.asList(data)), mipMapSizes);
+ this(format, type, width, height, new ArrayList<>(Arrays.asList(data)), mipMapSizes);
}
/**
@@ -122,7 +122,7 @@ public class Image implements Serializable, Savable {
* the data that contains the image information.
*/
public void setData(final ByteBuffer data) {
- _data = new ArrayList<ByteBuffer>(Arrays.asList(data));
+ _data = new ArrayList<>(Arrays.asList(data));
}
/**
@@ -133,7 +133,7 @@ public class Image implements Serializable, Savable {
*/
public void addData(final ByteBuffer data) {
if (_data == null) {
- _data = new ArrayList<ByteBuffer>(1);
+ _data = new ArrayList<>(1);
}
_data.add(data);
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/image/util/GeneratedImageFactory.java b/ardor3d-core/src/main/java/com/ardor3d/image/util/GeneratedImageFactory.java
index 6316b57..6fa46a0 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/image/util/GeneratedImageFactory.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/image/util/GeneratedImageFactory.java
@@ -144,7 +144,7 @@ public abstract class GeneratedImageFactory {
double val;
final double rangeDiv = 1.0 / (rangeEnd - rangeStart);
// prepare list of image slices.
- final List<ByteBuffer> dataList = new ArrayList<ByteBuffer>(depth);
+ final List<ByteBuffer> dataList = new ArrayList<>(depth);
final byte[] data = new byte[width * height];
for (double z = 0; z < depth; z++) {
@@ -199,7 +199,7 @@ public abstract class GeneratedImageFactory {
final ReadOnlyColorRGBA... colorTable) {
assert (colorTable.length == 256) : "color table must be size 256.";
- final List<ByteBuffer> dataList = new ArrayList<ByteBuffer>(lumImage.getDepth());
+ final List<ByteBuffer> dataList = new ArrayList<>(lumImage.getDepth());
ReadOnlyColorRGBA c;
for (int i = 0; i < lumImage.getDepth(); i++) {
final ByteBuffer src = lumImage.getData(i);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/image/util/ImageLoaderUtil.java b/ardor3d-core/src/main/java/com/ardor3d/image/util/ImageLoaderUtil.java
index bd404fa..4e80df7 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/image/util/ImageLoaderUtil.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/image/util/ImageLoaderUtil.java
@@ -47,21 +47,12 @@ public abstract class ImageLoaderUtil {
return TextureState.getDefaultTextureImage();
}
- InputStream is = null;
- try {
- is = src.openStream();
+ try (final InputStream is = src.openStream()) {
logger.log(Level.FINER, "loadImage(ResourceSource, boolean) opened stream: {0}", src);
return loadImage(type, is, flipped);
} catch (final IOException e) {
logger.log(Level.WARNING, "loadImage(ResourceSource, boolean): defaultTexture used", e);
return TextureState.getDefaultTextureImage();
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (final IOException ioe) {
- } // ignore
- }
}
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/image/util/dds/DdsLoader.java b/ardor3d-core/src/main/java/com/ardor3d/image/util/dds/DdsLoader.java
index 3c28364..d44f44b 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/image/util/dds/DdsLoader.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/image/util/dds/DdsLoader.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>.
*/
@@ -58,39 +58,40 @@ public class DdsLoader implements ImageLoader {
@Override
public Image load(final InputStream is, final boolean flipVertically) throws IOException {
- final LittleEndianDataInput in = new LittleEndianDataInput(is);
+ try (final LittleEndianDataInput in = new LittleEndianDataInput(is)) {
- // Read and check magic word...
- final int dwMagic = in.readInt();
- if (dwMagic != getInt("DDS ")) {
- throw new Error("Not a dds file.");
- }
- logger.finest("Reading DDS file.");
+ // Read and check magic word...
+ final int dwMagic = in.readInt();
+ if (dwMagic != getInt("DDS ")) {
+ throw new Error("Not a dds file.");
+ }
+ logger.finest("Reading DDS file.");
- // Create our data store;
- final DdsImageInfo info = new DdsImageInfo();
+ // Create our data store;
+ final DdsImageInfo info = new DdsImageInfo();
- info.flipVertically = flipVertically;
+ info.flipVertically = flipVertically;
- // Read standard dds header
- info.header = DdsHeader.read(in);
+ // Read standard dds header
+ info.header = DdsHeader.read(in);
- // if applicable, read DX10 header
- info.headerDX10 = info.header.ddpf.dwFourCC == getInt("DX10") ? DdsHeaderDX10.read(in) : null;
+ // if applicable, read DX10 header
+ info.headerDX10 = info.header.ddpf.dwFourCC == getInt("DX10") ? DdsHeaderDX10.read(in) : null;
- // Create our new image
- final Image image = new Image();
- image.setWidth(info.header.dwWidth);
- image.setHeight(info.header.dwHeight);
+ // Create our new image
+ final Image image = new Image();
+ image.setWidth(info.header.dwWidth);
+ image.setHeight(info.header.dwHeight);
- // update depth based on flags / header
- updateDepth(image, info);
+ // update depth based on flags / header
+ updateDepth(image, info);
- // add our format and image data.
- populateImage(image, info, in);
+ // add our format and image data.
+ populateImage(image, info, in);
- // return the loaded image
- return image;
+ // return the loaded image
+ return image;
+ }
}
private static final void updateDepth(final Image image, final DdsImageInfo info) {
@@ -254,7 +255,7 @@ public class DdsLoader implements ImageLoader {
}
// Go through and load in image data
- final List<ByteBuffer> imageData = new ArrayList<ByteBuffer>();
+ final List<ByteBuffer> imageData = new ArrayList<>();
for (int i = 0; i < image.getDepth(); i++) {
// read in compressed data
if (compressedFormat) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/ControllerInfo.java b/ardor3d-core/src/main/java/com/ardor3d/input/ControllerInfo.java
index e9175bf..649c356 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/ControllerInfo.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/ControllerInfo.java
@@ -21,8 +21,8 @@ public class ControllerInfo {
public ControllerInfo(final String controllerName, final List<String> axisNames, final List<String> buttonNames) {
_controllerName = controllerName;
- _axisNames = new ArrayList<String>(axisNames);
- _buttonNames = new ArrayList<String>(buttonNames);
+ _axisNames = new ArrayList<>(axisNames);
+ _buttonNames = new ArrayList<>(buttonNames);
}
public String getControllerName() {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.java b/ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.java
index bd3ed45..c0570bd 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.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>.
*/
@@ -17,6 +17,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import com.ardor3d.annotation.Immutable;
@@ -25,8 +26,8 @@ public class ControllerState {
public static final ControllerState NOTHING = new ControllerState(0);
- protected final Map<String, Map<String, Float>> _controllerStates = new LinkedHashMap<String, Map<String, Float>>();
- protected final List<ControllerEvent> _eventsSinceLastState = new ArrayList<ControllerEvent>();
+ protected final Map<String, Map<String, Float>> _controllerStates = new LinkedHashMap<>();
+ protected final List<ControllerEvent> _eventsSinceLastState = new ArrayList<>();
protected ControllerState(final int ignore) {}
@@ -50,7 +51,7 @@ public class ControllerState {
if (_controllerStates.containsKey(controllerName)) {
controllerState = _controllerStates.get(controllerName);
} else {
- controllerState = new LinkedHashMap<String, Float>();
+ controllerState = new LinkedHashMap<>();
_controllerStates.put(controllerName, controllerState);
}
@@ -68,6 +69,11 @@ public class ControllerState {
}
@Override
+ public int hashCode() {
+ return Objects.hashCode(_controllerStates);
+ }
+
+ @Override
public String toString() {
final StringBuilder stateString = new StringBuilder("ControllerState: ");
@@ -94,7 +100,7 @@ public class ControllerState {
private void duplicateStates(final Map<String, Map<String, Float>> store) {
store.clear();
for (final Entry<String, Map<String, Float>> entry : _controllerStates.entrySet()) {
- store.put(entry.getKey(), new LinkedHashMap<String, Float>(entry.getValue()));
+ store.put(entry.getKey(), new LinkedHashMap<>(entry.getValue()));
}
}
@@ -119,11 +125,11 @@ public class ControllerState {
}
public List<String> getControllerNames() {
- return new ArrayList<String>(_controllerStates.keySet());
+ return new ArrayList<>(_controllerStates.keySet());
}
public List<String> getControllerComponentNames(final String controller) {
- return new ArrayList<String>(_controllerStates.get(controller).keySet());
+ return new ArrayList<>(_controllerStates.get(controller).keySet());
}
public Map<String, Float> getControllerComponentValues(final String controller) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/MouseButton.java b/ardor3d-core/src/main/java/com/ardor3d/input/MouseButton.java
index 49e4d69..f356853 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/MouseButton.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/MouseButton.java
@@ -51,7 +51,7 @@ public enum MouseButton {
if (nine == null) {
throw new NullPointerException("nine");
}
- final EnumMap<MouseButton, ButtonState> map = new EnumMap<MouseButton, ButtonState>(MouseButton.class);
+ final EnumMap<MouseButton, ButtonState> map = new EnumMap<>(MouseButton.class);
map.put(LEFT, left);
map.put(RIGHT, right);
map.put(MIDDLE, middle);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/MouseCursor.java b/ardor3d-core/src/main/java/com/ardor3d/input/MouseCursor.java
index e24e4ce..62ec847 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/MouseCursor.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/MouseCursor.java
@@ -12,6 +12,8 @@ package com.ardor3d.input;
import static com.google.common.base.Preconditions.checkArgument;
+import java.util.Objects;
+
import com.ardor3d.annotation.Immutable;
import com.ardor3d.image.Image;
import com.ardor3d.image.ImageDataFormat;
@@ -21,7 +23,7 @@ import com.ardor3d.util.geom.BufferUtils;
/**
* An immutable representation of a mouse cursor. A mouse cursor consists of an image and a hotspot where clicking is
* done.
- *
+ *
*/
@Immutable
public class MouseCursor {
@@ -29,8 +31,9 @@ public class MouseCursor {
* This constant is used to identify that the native operating system's default cursor should be used. It is not a
* valid mouse cursor in itself.
*/
- public static final MouseCursor SYSTEM_DEFAULT = new MouseCursor("system default", new Image(ImageDataFormat.RGBA,
- PixelDataType.UnsignedByte, 1, 1, BufferUtils.createByteBuffer(4), null), 0, 0);
+ public static final MouseCursor SYSTEM_DEFAULT = new MouseCursor("system default",
+ new Image(ImageDataFormat.RGBA, PixelDataType.UnsignedByte, 1, 1, BufferUtils.createByteBuffer(4), null), 0,
+ 0);
private final String _name;
private final Image _image;
@@ -39,7 +42,7 @@ public class MouseCursor {
/**
* Instantiates a MouseCursor.
- *
+ *
* @param name
* the name of this cursor, for debugging purposes.
* @param image
@@ -55,10 +58,10 @@ public class MouseCursor {
_hotspotX = hotspotX;
_hotspotY = hotspotY;
- checkArgument(hotspotX >= 0 && hotspotX < image.getWidth(), "hotspot X is out of bounds: 0 <= %s < "
- + image.getWidth(), hotspotX);
- checkArgument(hotspotY >= 0 && hotspotY < image.getHeight(), "hotspot Y is out of bounds: 0 <= %s < "
- + image.getHeight(), hotspotY);
+ checkArgument(hotspotX >= 0 && hotspotX < image.getWidth(),
+ "hotspot X is out of bounds: 0 <= %s < " + image.getWidth(), hotspotX);
+ checkArgument(hotspotY >= 0 && hotspotY < image.getHeight(),
+ "hotspot Y is out of bounds: 0 <= %s < " + image.getHeight(), hotspotY);
}
public String getName() {
@@ -102,11 +105,10 @@ public class MouseCursor {
if (_hotspotY != that._hotspotY) {
return false;
}
- if (_image != null ? !_image.equals(that._image) : that._image != null) {
+ if (!Objects.equals(_image, that._image)) {
return false;
}
- // noinspection RedundantIfStatement
- if (_name != null ? !_name.equals(that._name) : that._name != null) {
+ if (!Objects.equals(_name, that._name)) {
return false;
}
@@ -115,10 +117,6 @@ public class MouseCursor {
@Override
public int hashCode() {
- int result = _name != null ? _name.hashCode() : 0;
- result = 31 * result + (_image != null ? _image.hashCode() : 0);
- result = 31 * result + _hotspotX;
- result = 31 * result + _hotspotY;
- return result;
+ return Objects.hash(getName(), getImage(), Integer.valueOf(getHotspotX()), Integer.valueOf(getHotspotY()));
}
}
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 b1f4faa..d86a4a3 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/MouseState.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/MouseState.java
@@ -138,7 +138,7 @@ public class MouseState {
public EnumMap<MouseButton, ButtonState> getButtonStates(final EnumMap<MouseButton, ButtonState> store) {
EnumMap<MouseButton, ButtonState> rVal = store;
if (store == null) {
- rVal = new EnumMap<MouseButton, ButtonState>(MouseButton.class);
+ rVal = new EnumMap<>(MouseButton.class);
}
rVal.clear();
rVal.putAll(_buttonStates);
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 5948094..0a5a438 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/PhysicalLayer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/PhysicalLayer.java
@@ -67,7 +67,7 @@ public class PhysicalLayer {
_mouseWrapper = mouseWrapper;
_focusWrapper = focusWrapper;
_controllerWrapper = controllerWrapper;
- _stateQueue = new LinkedBlockingQueue<InputState>();
+ _stateQueue = new LinkedBlockingQueue<>();
_currentKeyboardState = KeyboardState.NOTHING;
_currentMouseState = MouseState.NOTHING;
@@ -189,7 +189,7 @@ public class PhysicalLayer {
return EMPTY_LIST;
}
- final LinkedList<InputState> result = new LinkedList<InputState>();
+ final LinkedList<InputState> result = new LinkedList<>();
_stateQueue.drainTo(result);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/LogicalLayer.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/LogicalLayer.java
index ed57f8c..1e15458 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/LogicalLayer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/LogicalLayer.java
@@ -27,8 +27,8 @@ import com.ardor3d.input.PhysicalLayer;
*/
@ThreadSafe
public final class LogicalLayer {
- private final Set<InputSource> _inputs = new CopyOnWriteArraySet<InputSource>();
- private final Set<InputTrigger> _triggers = new CopyOnWriteArraySet<InputTrigger>();
+ private final Set<InputSource> _inputs = new CopyOnWriteArraySet<>();
+ private final Set<InputTrigger> _triggers = new CopyOnWriteArraySet<>();
private LogicalTriggersApplier _applier = new BasicTriggersApplier();
public LogicalLayer() {}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonCondition.java
index 58c283f..e4c3639 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonCondition.java
@@ -23,7 +23,7 @@ import com.google.common.base.Predicate;
*/
@Immutable
public final class MouseButtonCondition implements Predicate<TwoInputStates> {
- private final EnumMap<MouseButton, ButtonState> _states = new EnumMap<MouseButton, ButtonState>(MouseButton.class);
+ private final EnumMap<MouseButton, ButtonState> _states = new EnumMap<>(MouseButton.class);
public MouseButtonCondition(final EnumMap<MouseButton, ButtonState> states) {
_states.putAll(states);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/TriggerConditions.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/TriggerConditions.java
index 2ce1a58..f98d005 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/TriggerConditions.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/TriggerConditions.java
@@ -49,7 +49,7 @@ public final class TriggerConditions {
};
private static MouseButtonCondition makeCondition(final MouseButton button, final ButtonState state) {
- final EnumMap<MouseButton, ButtonState> map = new EnumMap<MouseButton, ButtonState>(MouseButton.class);
+ final EnumMap<MouseButton, ButtonState> map = new EnumMap<>(MouseButton.class);
for (final MouseButton b : MouseButton.values()) {
map.put(b, button != b ? ButtonState.UNDEFINED : state);
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/TwoInputStates.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/TwoInputStates.java
index 2e058e1..e770389 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/TwoInputStates.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/TwoInputStates.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>.
*/
@@ -12,6 +12,8 @@ package com.ardor3d.input.logical;
import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.Objects;
+
import com.ardor3d.annotation.Immutable;
import com.ardor3d.input.InputState;
@@ -27,12 +29,12 @@ public final class TwoInputStates {
/**
* Instantiates a new TwoInputStates. It is safe for both parameters to point to the same instance, but they cannot
* be null.
- *
+ *
* @param previous
* the previous input state
* @param current
* the current input state
- *
+ *
* @throws NullPointerException
* if either parameter is null
*/
@@ -51,9 +53,7 @@ public final class TwoInputStates {
@Override
public int hashCode() {
- // we don't expect this to be used in a map.
- assert false : "hashCode not designed";
- return 42;
+ return Objects.hash(getPrevious(), getCurrent());
}
@Override
@@ -65,6 +65,6 @@ public final class TwoInputStates {
return false;
}
final TwoInputStates comp = (TwoInputStates) o;
- return _previous == comp._previous && _current == comp._current;
+ return Objects.equals(_previous, comp._previous) && Objects.equals(_current, comp._current);
}
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/intersection/CollisionResults.java b/ardor3d-core/src/main/java/com/ardor3d/intersection/CollisionResults.java
index 0d4d693..a7a5981 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/intersection/CollisionResults.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/intersection/CollisionResults.java
@@ -26,7 +26,7 @@ public abstract class CollisionResults {
* Constructor instantiates a new <code>PickResults</code> object.
*/
public CollisionResults() {
- _nodeList = new ArrayList<CollisionData>();
+ _nodeList = new ArrayList<>();
}
/**
diff --git a/ardor3d-core/src/main/java/com/ardor3d/intersection/PickResults.java b/ardor3d-core/src/main/java/com/ardor3d/intersection/PickResults.java
index 283dc27..11f8e8e 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/intersection/PickResults.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/intersection/PickResults.java
@@ -32,7 +32,7 @@ public abstract class PickResults {
* Constructor instantiates a new <code>PickResults</code> object.
*/
public PickResults() {
- _nodeList = new ArrayList<PickData>();
+ _nodeList = new ArrayList<>();
}
/**
diff --git a/ardor3d-core/src/main/java/com/ardor3d/intersection/PrimitiveCollisionResults.java b/ardor3d-core/src/main/java/com/ardor3d/intersection/PrimitiveCollisionResults.java
index 133312d..3328e91 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/intersection/PrimitiveCollisionResults.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/intersection/PrimitiveCollisionResults.java
@@ -34,8 +34,8 @@ public class PrimitiveCollisionResults extends CollisionResults {
public void addCollision(final Mesh s, final Mesh t) {
// find the triangle that is being hit.
// add this node and the triangle to the CollisionResults list.
- final List<PrimitiveKey> a = new ArrayList<PrimitiveKey>();
- final List<PrimitiveKey> b = new ArrayList<PrimitiveKey>();
+ final List<PrimitiveKey> a = new ArrayList<>();
+ final List<PrimitiveKey> b = new ArrayList<>();
PickingUtil.findPrimitiveCollision(s, t, a, b);
final CollisionData data = new CollisionData(s, t, a, b);
addCollisionData(data);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/intersection/PrimitiveKey.java b/ardor3d-core/src/main/java/com/ardor3d/intersection/PrimitiveKey.java
index c23d085..9f03d36 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/intersection/PrimitiveKey.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/intersection/PrimitiveKey.java
@@ -3,13 +3,15 @@
*
* 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.intersection;
+import java.util.Objects;
+
public class PrimitiveKey {
private final int _primitiveIndex;
private final int _section;
@@ -35,12 +37,7 @@ public class PrimitiveKey {
@Override
public int hashCode() {
- int result = 17;
-
- result += 31 * result + _primitiveIndex;
- result += 31 * result + _section;
-
- return result;
+ return Objects.hash(Integer.valueOf(getPrimitiveIndex()), Integer.valueOf(getSection()));
}
@Override
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractFBOTextureRenderer.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractFBOTextureRenderer.java
index 0bf54fb..5e7f6d9 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractFBOTextureRenderer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractFBOTextureRenderer.java
@@ -30,7 +30,7 @@ public abstract class AbstractFBOTextureRenderer implements TextureRenderer {
private static final Logger logger = Logger.getLogger(AbstractFBOTextureRenderer.class.getName());
/** List of states that override any set states on a spatial if not null. */
- protected final EnumMap<RenderState.StateType, RenderState> _enforcedStates = new EnumMap<RenderState.StateType, RenderState>(
+ protected final EnumMap<RenderState.StateType, RenderState> _enforcedStates = new EnumMap<>(
RenderState.StateType.class);
protected final Camera _camera = new Camera(1, 1);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractPbufferTextureRenderer.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractPbufferTextureRenderer.java
index 565f531..16afb05 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractPbufferTextureRenderer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractPbufferTextureRenderer.java
@@ -28,7 +28,7 @@ public abstract class AbstractPbufferTextureRenderer implements TextureRenderer
private static final Logger logger = Logger.getLogger(AbstractPbufferTextureRenderer.class.getName());
/** List of states that override any set states on a spatial if not null. */
- protected final EnumMap<RenderState.StateType, RenderState> _enforcedStates = new EnumMap<RenderState.StateType, RenderState>(
+ protected final EnumMap<RenderState.StateType, RenderState> _enforcedStates = new EnumMap<>(
RenderState.StateType.class);
protected final Camera _camera = new Camera(1, 1);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java
index c3b04fd..8a6dcdf 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java
@@ -47,7 +47,7 @@ public abstract class AbstractRenderer implements Renderer {
protected RenderLogic renderLogic;
/** List of default rendering states for this specific renderer type */
- protected final EnumMap<RenderState.StateType, RenderState> defaultStateList = new EnumMap<RenderState.StateType, RenderState>(
+ protected final EnumMap<RenderState.StateType, RenderState> defaultStateList = new EnumMap<>(
RenderState.StateType.class);
public AbstractRenderer() {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/ContextManager.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/ContextManager.java
index ed46ec9..1a87c80 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/ContextManager.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/ContextManager.java
@@ -19,9 +19,9 @@ public class ContextManager {
protected static RenderContext currentContext = null;
- private static List<ContextCleanListener> _cleanListeners = new ArrayList<ContextCleanListener>();
+ private static List<ContextCleanListener> _cleanListeners = new ArrayList<>();
- protected static final Map<Object, RenderContext> contextStore = new WeakHashMap<Object, RenderContext>();
+ protected static final Map<Object, RenderContext> contextStore = new WeakHashMap<>();
/**
* @return a RenderContext object representing the current OpenGL context.
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/RenderContext.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/RenderContext.java
index eaaeb57..d8feb7e 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/RenderContext.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/RenderContext.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>.
*/
@@ -26,18 +26,18 @@ import com.ardor3d.renderer.state.record.StateRecord;
public class RenderContext {
/** List of states that override any set states on a spatial if not null. */
- protected final EnumMap<RenderState.StateType, RenderState> _enforcedStates = new EnumMap<RenderState.StateType, RenderState>(
+ protected final EnumMap<RenderState.StateType, RenderState> _enforcedStates = new EnumMap<>(
RenderState.StateType.class);
- protected final Stack<EnumMap<StateType, RenderState>> _enforcedBackStack = new Stack<EnumMap<StateType, RenderState>>();
+ protected final Stack<EnumMap<StateType, RenderState>> _enforcedBackStack = new Stack<>();
- protected final Stack<AbstractFBOTextureRenderer> _textureRenderers = new Stack<AbstractFBOTextureRenderer>();
+ protected final Stack<AbstractFBOTextureRenderer> _textureRenderers = new Stack<>();
/** RenderStates a Spatial contains during rendering. */
- protected final EnumMap<RenderState.StateType, RenderState> _currentStates = new EnumMap<RenderState.StateType, RenderState>(
+ protected final EnumMap<RenderState.StateType, RenderState> _currentStates = new EnumMap<>(
RenderState.StateType.class);
- protected final EnumMap<RenderState.StateType, StateRecord> _stateRecords = new EnumMap<RenderState.StateType, StateRecord>(
+ protected final EnumMap<RenderState.StateType, StateRecord> _stateRecords = new EnumMap<>(
RenderState.StateType.class);
protected final LineRecord _lineRecord = new LineRecord();
@@ -105,7 +105,7 @@ public class RenderContext {
* Enforce a particular state. In other words, the given state will override any state of the same type set on a
* scene object. Remember to clear the state when done enforcing. Very useful for multipass techniques where
* multiple sets of states need to be applied to a scenegraph drawn multiple times.
- *
+ *
* @param state
* state to enforce
*/
@@ -122,7 +122,7 @@ public class RenderContext {
/**
* Clears an enforced render state index by setting it to null. This allows object specific states to be used.
- *
+ *
* @param type
* The type of RenderState to clear enforcement on.
*/
@@ -188,12 +188,12 @@ public class RenderContext {
* Saves the currently set states to a stack. Does not changes the currently enforced states.
*/
public void pushEnforcedStates() {
- _enforcedBackStack.push(new EnumMap<StateType, RenderState>(_enforcedStates));
+ _enforcedBackStack.push(new EnumMap<>(_enforcedStates));
}
/**
* Restores the enforced states from the stack. Any states enforced or cleared since the last push are reverted.
- *
+ *
* @throws EmptyStackException
* if this method is called without first calling {@link #pushEnforcedStates()}
*/
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java
index bc40f1d..a0cbb69 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java
@@ -33,8 +33,8 @@ import com.ardor3d.util.geom.BufferUtils;
public class EffectManager {
protected final DisplaySettings _canvasSettings;
- protected final List<RenderEffect> _effects = new ArrayList<RenderEffect>();
- protected final Map<String, RenderTarget> _renderTargetMap = new HashMap<String, RenderTarget>();
+ protected final List<RenderEffect> _effects = new ArrayList<>();
+ protected final Map<String, RenderTarget> _renderTargetMap = new HashMap<>();
protected Renderer _currentRenderer = null;
protected RenderTarget _currentRenderTarget = null;
protected Camera _fsqCamera, _sceneCamera;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectStep_RenderScreenOverlay.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectStep_RenderScreenOverlay.java
index 588b95a..76a0219 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectStep_RenderScreenOverlay.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectStep_RenderScreenOverlay.java
@@ -20,9 +20,9 @@ import com.ardor3d.renderer.state.TextureState;
public class EffectStep_RenderScreenOverlay implements EffectStep {
- private final EnumMap<StateType, RenderState> _states = new EnumMap<StateType, RenderState>(StateType.class);
+ private final EnumMap<StateType, RenderState> _states = new EnumMap<>(StateType.class);
private final TextureState _texState = new TextureState();
- private final Map<String, Integer> _targetMap = new HashMap<String, Integer>();
+ private final Map<String, Integer> _targetMap = new HashMap<>();
public EffectStep_RenderScreenOverlay() {
_states.put(StateType.Texture, _texState);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectStep_RenderSpatials.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectStep_RenderSpatials.java
index a07df8b..c1af85c 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectStep_RenderSpatials.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectStep_RenderSpatials.java
@@ -20,8 +20,8 @@ import com.ardor3d.renderer.state.RenderState.StateType;
import com.ardor3d.scenegraph.Spatial;
public class EffectStep_RenderSpatials implements EffectStep {
- private final EnumMap<StateType, RenderState> _states = new EnumMap<StateType, RenderState>(StateType.class);
- private final List<Spatial> _spatials = new ArrayList<Spatial>();
+ private final EnumMap<StateType, RenderState> _states = new EnumMap<>(StateType.class);
+ private final List<Spatial> _spatials = new ArrayList<>();
private final Camera _trackedCamera;
public EffectStep_RenderSpatials(final Camera trackedCamera) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/RenderEffect.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/RenderEffect.java
index 409e443..b3b4162 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/RenderEffect.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/RenderEffect.java
@@ -20,7 +20,7 @@ import java.util.List;
public abstract class RenderEffect {
/** A list of logical steps that comprise our effect. */
- protected final List<EffectStep> _steps = new ArrayList<EffectStep>();
+ protected final List<EffectStep> _steps = new ArrayList<>();
/** Is this render effect active? */
protected boolean _enabled = true;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/TextureRendererPool.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/TextureRendererPool.java
index 82af301..bab4d39 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/TextureRendererPool.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/TextureRendererPool.java
@@ -22,7 +22,7 @@ import com.ardor3d.renderer.TextureRendererFactory;
public enum TextureRendererPool {
INSTANCE;
- private final List<TextureRenderer> renderers = new LinkedList<TextureRenderer>();
+ private final List<TextureRenderer> renderers = new LinkedList<>();
public static TextureRenderer fetch(final int width, final int height, final Renderer renderer) {
for (final Iterator<TextureRenderer> it = INSTANCE.renderers.iterator(); it.hasNext();) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/pass/BasicPassManager.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/pass/BasicPassManager.java
index 6597e59..f60b54f 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/pass/BasicPassManager.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/pass/BasicPassManager.java
@@ -22,7 +22,7 @@ import com.ardor3d.renderer.TextureRenderer;
*/
public class BasicPassManager {
- protected List<Pass> _passes = new ArrayList<Pass>();
+ protected List<Pass> _passes = new ArrayList<>();
public void add(final Pass toAdd) {
if (toAdd != null) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/pass/Pass.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/pass/Pass.java
index 12fadf3..ab0bdd6 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/pass/Pass.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/pass/Pass.java
@@ -38,7 +38,7 @@ public abstract class Pass implements Serializable {
private static final long serialVersionUID = 1L;
/** list of Spatial objects registered with this pass. */
- protected List<Spatial> _spatials = new ArrayList<Spatial>();
+ protected List<Spatial> _spatials = new ArrayList<>();
/** if false, pass will not be updated or rendered. */
protected boolean _enabled = true;
@@ -47,7 +47,7 @@ public abstract class Pass implements Serializable {
* RenderStates registered with this pass - if a given state is not null it overrides the corresponding state set
* during rendering.
*/
- protected final EnumMap<RenderState.StateType, RenderState> _passStates = new EnumMap<RenderState.StateType, RenderState>(
+ protected final EnumMap<RenderState.StateType, RenderState> _passStates = new EnumMap<>(
RenderState.StateType.class);
protected RenderContext _context = null;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/AbstractRenderBucket.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/AbstractRenderBucket.java
index 89f21c8..10dbf54 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/AbstractRenderBucket.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/AbstractRenderBucket.java
@@ -28,9 +28,9 @@ public class AbstractRenderBucket implements RenderBucket {
protected Spatial[] _currentList, _tempList;
protected int _currentListSize;
- protected Stack<Spatial[]> _listStack = new Stack<Spatial[]>();
- protected Stack<Spatial[]> _listStackPool = new Stack<Spatial[]>();
- protected Stack<Integer> _listSizeStack = new Stack<Integer>();
+ protected Stack<Spatial[]> _listStack = new Stack<>();
+ protected Stack<Spatial[]> _listStackPool = new Stack<>();
+ protected Stack<Integer> _listSizeStack = new Stack<>();
public AbstractRenderBucket() {
_currentList = new Spatial[32];
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/RenderBucketType.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/RenderBucketType.java
index d5f881d..103f9e7 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/RenderBucketType.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/RenderBucketType.java
@@ -28,7 +28,7 @@ public final class RenderBucketType {
return bucketType;
}
- private static final Map<String, RenderBucketType> bucketTypeMap = new HashMap<String, RenderBucketType>();
+ private static final Map<String, RenderBucketType> bucketTypeMap = new HashMap<>();
private final String name;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/RenderQueue.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/RenderQueue.java
index 34a28ba..65bdf35 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/RenderQueue.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/RenderQueue.java
@@ -22,7 +22,7 @@ import com.ardor3d.util.Constants;
public class RenderQueue {
- private final Map<RenderBucketType, RenderBucket> renderBuckets = new LinkedHashMap<RenderBucketType, RenderBucket>();
+ private final Map<RenderBucketType, RenderBucket> renderBuckets = new LinkedHashMap<>();
public RenderQueue() {
setupDefaultBuckets();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/FragmentProgramState.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/FragmentProgramState.java
index 13b6f6d..8ae5b6e 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/FragmentProgramState.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/FragmentProgramState.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>.
*/
@@ -39,7 +39,7 @@ public class FragmentProgramState extends RenderState {
/**
* <code>setEnvParameter</code> sets an environmental fragment program parameter that is accessable by all fragment
* programs in memory.
- *
+ *
* @param param
* four-element array of floating point numbers
* @param paramID
@@ -50,7 +50,7 @@ public class FragmentProgramState extends RenderState {
* public static void setEnvParameter(float[] param, int paramID){ if (paramID < 0 || paramID > 95) throw new
* IllegalArgumentException("Invalid parameter ID"); if (param != null && param.length != 4) throw new
* IllegalArgumentException("Vertex program parameters must be of type float[4]");
- *
+ *
* envparameters[paramID] = param; }
*/
@@ -60,7 +60,7 @@ public class FragmentProgramState extends RenderState {
/**
* <code>setParameter</code> sets a parameter for this fragment program.
- *
+ *
* @param paramID
* identity number of the parameter, ranging from 0 to 23
* @param param
@@ -86,14 +86,12 @@ public class FragmentProgramState extends RenderState {
/**
* Loads the fragment program into a byte array.
- *
+ *
* @see com.ardor3d.renderer.state.FragmentProgramState#load(java.net.URL)
*/
public void load(final java.net.URL file) {
- InputStream inputStream = null;
- try {
- final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(16 * 1024);
- inputStream = new BufferedInputStream(file.openStream());
+ try (final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(16 * 1024);
+ final InputStream inputStream = new BufferedInputStream(file.openStream())) {
final byte[] buffer = new byte[1024];
int byteCount = -1;
@@ -107,7 +105,6 @@ public class FragmentProgramState extends RenderState {
// Release resources
inputStream.close();
- outputStream.close();
program = BufferUtils.createByteBuffer(data.length);
program.put(data);
@@ -117,21 +114,12 @@ public class FragmentProgramState extends RenderState {
} catch (final Exception e) {
logger.severe("Could not load fragment program: " + e);
logger.logp(Level.SEVERE, getClass().getName(), "load(URL)", "Exception", e);
- } finally {
- // Ensure that the stream is closed, even if there is an exception.
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (final IOException closeFailure) {
- logger.log(Level.WARNING, "Failed to close the fragment program", closeFailure);
- }
- }
}
}
/**
* Loads the fragment program into a byte array.
- *
+ *
* @see com.ardor3d.renderer.state.FragmentProgramState#load(java.net.URL)
*/
public void load(final String programContents) {
@@ -170,7 +158,7 @@ public class FragmentProgramState extends RenderState {
/**
* Used with Serialization. Do not call this directly.
- *
+ *
* @param s
* @throws IOException
* @see java.io.Serializable
@@ -190,7 +178,7 @@ public class FragmentProgramState extends RenderState {
/**
* Used with Serialization. Do not call this directly.
- *
+ *
* @param s
* @throws IOException
* @throws ClassNotFoundException
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/GLSLShaderObjectsState.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/GLSLShaderObjectsState.java
index ccedbce..47c4504 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/GLSLShaderObjectsState.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/GLSLShaderObjectsState.java
@@ -70,9 +70,9 @@ public class GLSLShaderObjectsState extends RenderState {
private static final Logger logger = Logger.getLogger(GLSLShaderObjectsState.class.getName());
/** Storage for shader uniform values */
- protected List<ShaderVariable> _shaderUniforms = new ArrayList<ShaderVariable>();
+ protected List<ShaderVariable> _shaderUniforms = new ArrayList<>();
/** Storage for shader attribute values */
- protected List<ShaderVariable> _shaderAttributes = new ArrayList<ShaderVariable>();
+ protected List<ShaderVariable> _shaderAttributes = new ArrayList<>();
protected ByteBuffer _vertShader, _fragShader, _geomShader, _tessControlShader, _tessEvalShader, _compShader;
@@ -240,28 +240,14 @@ public class GLSLShaderObjectsState extends RenderState {
}
protected ByteBuffer load(final InputStream in) throws IOException {
- DataInputStream dataStream = null;
- try {
- final BufferedInputStream bufferedInputStream = new BufferedInputStream(in);
- dataStream = new DataInputStream(bufferedInputStream);
+ try (final BufferedInputStream bufferedInputStream = new BufferedInputStream(in);
+ final DataInputStream dataStream = new DataInputStream(bufferedInputStream)) {
final byte shaderCode[] = new byte[bufferedInputStream.available()];
dataStream.readFully(shaderCode);
- bufferedInputStream.close();
- dataStream.close();
final ByteBuffer shaderByteBuffer = BufferUtils.createByteBuffer(shaderCode.length);
shaderByteBuffer.put(shaderCode);
shaderByteBuffer.rewind();
-
return shaderByteBuffer;
- } finally {
- // Ensure that the stream is closed, even if there is an exception.
- if (dataStream != null) {
- try {
- dataStream.close();
- } catch (final IOException closeFailure) {
- logger.log(Level.WARNING, "Failed to close the shader object", closeFailure);
- }
- }
}
}
@@ -1190,8 +1176,8 @@ public class GLSLShaderObjectsState extends RenderState {
* @param data
* The actual data to use as attribute pointer
*/
- public void setAttributePointer(final String name, final int size, final boolean normalized,
- final boolean unsigned, final int stride, final ByteBufferData data) {
+ public void setAttributePointer(final String name, final int size, final boolean normalized, final boolean unsigned,
+ final int stride, final ByteBufferData data) {
final ShaderVariablePointerByte shaderUniform = getShaderAttribute(name, ShaderVariablePointerByte.class);
shaderUniform.size = size;
shaderUniform.normalized = normalized;
@@ -1221,8 +1207,8 @@ public class GLSLShaderObjectsState extends RenderState {
* @param data
* The actual data to use as attribute pointer
*/
- public void setAttributePointer(final String name, final int size, final boolean normalized,
- final boolean unsigned, final int stride, final IntBufferData data) {
+ public void setAttributePointer(final String name, final int size, final boolean normalized, final boolean unsigned,
+ final int stride, final IntBufferData data) {
final ShaderVariablePointerInt shaderUniform = getShaderAttribute(name, ShaderVariablePointerInt.class);
shaderUniform.size = size;
shaderUniform.normalized = normalized;
@@ -1252,8 +1238,8 @@ public class GLSLShaderObjectsState extends RenderState {
* @param data
* The actual data to use as attribute pointer
*/
- public void setAttributePointer(final String name, final int size, final boolean normalized,
- final boolean unsigned, final int stride, final ShortBufferData data) {
+ public void setAttributePointer(final String name, final int size, final boolean normalized, final boolean unsigned,
+ final int stride, final ShortBufferData data) {
final ShaderVariablePointerShort shaderUniform = getShaderAttribute(name, ShaderVariablePointerShort.class);
shaderUniform.size = size;
shaderUniform.normalized = normalized;
@@ -1332,11 +1318,11 @@ public class GLSLShaderObjectsState extends RenderState {
return shaderUniform;
} catch (final InstantiationException e) {
- logger.logp(Level.SEVERE, this.getClass().toString(),
- "getShaderVariable(name, classz, shaderVariableList)", "Exception", e);
+ logger.logp(Level.SEVERE, this.getClass().toString(), "getShaderVariable(name, classz, shaderVariableList)",
+ "Exception", e);
} catch (final IllegalAccessException e) {
- logger.logp(Level.SEVERE, this.getClass().toString(),
- "getShaderVariable(name, classz, shaderVariableList)", "Exception", e);
+ logger.logp(Level.SEVERE, this.getClass().toString(), "getShaderVariable(name, classz, shaderVariableList)",
+ "Exception", e);
}
return null;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/LightState.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/LightState.java
index a5ce713..e8b86eb 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/LightState.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/LightState.java
@@ -95,7 +95,7 @@ public class LightState extends RenderState {
* Constructor instantiates a new <code>LightState</code> object. Initially there are no lights set.
*/
public LightState() {
- lightList = new ArrayList<Light>();
+ lightList = new ArrayList<>();
}
@Override
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/RenderState.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/RenderState.java
index bbe1b64..ad80e9e 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/RenderState.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/RenderState.java
@@ -95,7 +95,7 @@ public abstract class RenderState implements Savable {
static public class StateStack implements Poolable {
- private final EnumMap<RenderState.StateType, Stack<RenderState>> stacks = new EnumMap<StateType, Stack<RenderState>>(
+ private final EnumMap<RenderState.StateType, Stack<RenderState>> stacks = new EnumMap<>(
RenderState.StateType.class);
public StateStack() {}
@@ -122,7 +122,7 @@ public abstract class RenderState implements Savable {
public void push(final RenderState state) {
Stack<RenderState> stack = stacks.get(state.getType());
if (stack == null) {
- stack = new Stack<RenderState>();
+ stack = new Stack<>();
stacks.put(state.getType(), stack);
}
stack.push(state);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/TextureState.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/TextureState.java
index 9b8d4ea..b9f5e71 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/TextureState.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/TextureState.java
@@ -62,7 +62,7 @@ public class TextureState extends RenderState {
}
/** The texture(s). */
- protected List<Texture> _texture = new ArrayList<Texture>(1);
+ protected List<Texture> _texture = new ArrayList<>(1);
/**
* Perspective correction to use for the object rendered with this texture state. Default is
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/VertexProgramState.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/VertexProgramState.java
index 44e49b4..6c107f4 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/VertexProgramState.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/VertexProgramState.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>.
*/
@@ -46,7 +46,7 @@ public class VertexProgramState extends RenderState {
/**
* <code>setEnvParameter</code> sets an environmental vertex program parameter that is accessible by all vertex
* programs in memory.
- *
+ *
* @param param
* four-element array of floating point numbers
* @param paramID
@@ -72,7 +72,7 @@ public class VertexProgramState extends RenderState {
/**
* <code>setParameter</code> sets a parameter for this vertex program.
- *
+ *
* @param paramID
* identity number of the parameter, ranging from 0 to 95
* @param param
@@ -97,10 +97,8 @@ public class VertexProgramState extends RenderState {
}
public void load(final java.net.URL file) {
- InputStream inputStream = null;
- try {
- final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(16 * 1024);
- inputStream = new BufferedInputStream(file.openStream());
+ try (final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(16 * 1024);
+ final InputStream inputStream = new BufferedInputStream(file.openStream())) {
final byte[] buffer = new byte[1024];
int byteCount = -1;
@@ -112,10 +110,6 @@ public class VertexProgramState extends RenderState {
// Set data with byte content from stream
final byte[] data = outputStream.toByteArray();
- // Release resources
- inputStream.close();
- outputStream.close();
-
_program = BufferUtils.createByteBuffer(data.length);
_program.put(data);
_program.rewind();
@@ -125,22 +119,12 @@ public class VertexProgramState extends RenderState {
} catch (final Exception e) {
logger.severe("Could not load vertex program: " + e);
logger.logp(Level.SEVERE, getClass().getName(), "load(URL)", "Exception", e);
- } finally {
- // Ensure that the stream is closed, even if there is an exception.
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (final IOException closeFailure) {
- logger.log(Level.WARNING, "Failed to close the vertex program", closeFailure);
- }
- }
-
}
}
/**
* Loads the vertex program into a byte array.
- *
+ *
* @see com.ardor3d.renderer.state.VertexProgramState#load(java.net.URL)
*/
public void load(final String programContents) {
@@ -184,7 +168,7 @@ public class VertexProgramState extends RenderState {
/**
* Used with Serialization. Do not call this directly.
- *
+ *
* @param s
* @throws IOException
* @see java.io.Serializable
@@ -204,7 +188,7 @@ public class VertexProgramState extends RenderState {
/**
* Used with Serialization. Do not call this directly.
- *
+ *
* @param s
* @throws IOException
* @throws ClassNotFoundException
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/LightStateRecord.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/LightStateRecord.java
index 3a04e45..2a8be1c 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/LightStateRecord.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/LightStateRecord.java
@@ -18,7 +18,7 @@ import com.ardor3d.math.ColorRGBA;
import com.ardor3d.util.geom.BufferUtils;
public class LightStateRecord extends StateRecord {
- private final List<LightRecord> lightList = new ArrayList<LightRecord>();
+ private final List<LightRecord> lightList = new ArrayList<>();
private int lightMask;
private int backLightMask;
private boolean twoSidedOn;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/RendererRecord.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/RendererRecord.java
index 9f51cbc..d5edbaf 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/RendererRecord.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/RendererRecord.java
@@ -26,7 +26,7 @@ public class RendererRecord extends StateRecord {
private boolean _clippingTestEnabled;
private transient final ColorRGBA _tempColor = new ColorRGBA();
private DrawBufferTarget _drawBufferTarget = null;
- private final Stack<ReadOnlyRectangle2> _clips = new Stack<ReadOnlyRectangle2>();
+ private final Stack<ReadOnlyRectangle2> _clips = new Stack<>();
private int _normalMode = -1; // signifies disabled
private int _enabledTextures = 0;
private boolean _texturesValid = false;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/ShaderObjectsStateRecord.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/ShaderObjectsStateRecord.java
index 2fa77e4..a3e77ae 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/ShaderObjectsStateRecord.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/ShaderObjectsStateRecord.java
@@ -22,7 +22,7 @@ public class ShaderObjectsStateRecord extends StateRecord {
// XXX checking system.
GLSLShaderObjectsState reference = null;
- public List<ShaderVariable> enabledAttributes = new ArrayList<ShaderVariable>();
+ public List<ShaderVariable> enabledAttributes = new ArrayList<>();
public int shaderId = -1;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/TextureStateRecord.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/TextureStateRecord.java
index 3e63a6b..286ccb7 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/TextureStateRecord.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/record/TextureStateRecord.java
@@ -46,7 +46,7 @@ public class TextureStateRecord extends StateRecord {
public final DoubleBuffer tmp_matrixBuffer = BufferUtils.createDoubleBuffer(16);
public TextureStateRecord() {
- textures = new HashMap<Integer, TextureRecord>();
+ textures = new HashMap<>();
units = new TextureUnitRecord[TextureState.MAX_TEXTURES];
for (int i = 0; i < units.length; i++) {
units[i] = new TextureUnitRecord();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/AbstractBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/AbstractBufferData.java
index 2581a89..b49e1c1 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/AbstractBufferData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/AbstractBufferData.java
@@ -32,10 +32,10 @@ import com.google.common.collect.Multimap;
public abstract class AbstractBufferData<T extends Buffer> {
- private static Map<AbstractBufferData<?>, Object> _identityCache = new WeakHashMap<AbstractBufferData<?>, Object>();
+ private static Map<AbstractBufferData<?>, Object> _identityCache = new WeakHashMap<>();
private static final Object STATIC_REF = new Object();
- private static ReferenceQueue<AbstractBufferData<?>> _vboRefQueue = new ReferenceQueue<AbstractBufferData<?>>();
+ private static ReferenceQueue<AbstractBufferData<?>> _vboRefQueue = new ReferenceQueue<>();
static {
ContextManager.addContextCleanListener(new ContextCleanListener() {
@@ -165,7 +165,7 @@ public abstract class AbstractBufferData<T extends Buffer> {
}
if (_vboIdCache == null) {
- _vboIdCache = new ContextIdReference<AbstractBufferData<T>>(this, _vboRefQueue);
+ _vboIdCache = new ContextIdReference<>(this, _vboRefQueue);
}
_vboIdCache.put(glContextRep, vboId);
}
@@ -300,8 +300,8 @@ public abstract class AbstractBufferData<T extends Buffer> {
}
// Otherwise, add a delete request to that context's render task queue.
else {
- GameTaskQueueManager.getManager(ContextManager.getContextForRef(glref)).render(
- new RendererCallable<Void>() {
+ GameTaskQueueManager.getManager(ContextManager.getContextForRef(glref))
+ .render(new RendererCallable<Void>() {
@Override
public Void call() throws Exception {
getRenderer().deleteVBOs(idMap.get(glref));
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/InstancingManager.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/InstancingManager.java
index 320e4e4..f7e4c88 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/InstancingManager.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/InstancingManager.java
@@ -26,7 +26,7 @@ import com.ardor3d.util.geom.BufferUtils;
public class InstancingManager {
private int _maxBatchSize = 30;
- private final List<Mesh> _visibleMeshes = new ArrayList<Mesh>(_maxBatchSize);
+ private final List<Mesh> _visibleMeshes = new ArrayList<>(_maxBatchSize);
private FloatBuffer _transformBuffer;
private int _primCount;
private int _meshesToDraw = 0;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java
index bc3882d..f483e83 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java
@@ -66,7 +66,7 @@ public class Mesh extends Spatial implements Renderable, Pickable {
* The compiled list of renderstates for this mesh, taking into account ancestors states - updated with
* updateRenderStates()
*/
- protected final EnumMap<RenderState.StateType, RenderState> _states = new EnumMap<RenderState.StateType, RenderState>(
+ protected final EnumMap<RenderState.StateType, RenderState> _states = new EnumMap<>(
RenderState.StateType.class);
/** The compiled lightState for this mesh */
@@ -559,7 +559,7 @@ public class Mesh extends Spatial implements Renderable, Pickable {
@Override
public IntersectionRecord intersectsPrimitivesWhere(final Ray3 ray) {
- final List<PrimitiveKey> primitives = new ArrayList<PrimitiveKey>();
+ final List<PrimitiveKey> primitives = new ArrayList<>();
// What about Lines and Points?
final CollisionTree ct = CollisionTreeManager.getInstance().getCollisionTree(this);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java
index 911e69d..590c582 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java
@@ -57,7 +57,7 @@ public class MeshData implements Savable {
protected FloatBufferData _colorCoords;
protected FloatBufferData _fogCoords;
protected FloatBufferData _tangentCoords;
- protected List<FloatBufferData> _textureCoords = new ArrayList<FloatBufferData>(1);
+ protected List<FloatBufferData> _textureCoords = new ArrayList<>(1);
/** Interleaved data (for VBO id use). */
protected FloatBufferData _interleaved;
@@ -1204,7 +1204,7 @@ public class MeshData implements Savable {
}
if (_vboIdCache == null) {
- _vboIdCache = new WeakHashMap<Object, Integer>(1);
+ _vboIdCache = new WeakHashMap<>(1);
}
_vboIdCache.put(glContext, vboId);
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Node.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Node.java
index f03c447..079e63a 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Node.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Node.java
@@ -494,7 +494,7 @@ public class Node extends Spatial {
@Override
public void write(final OutputCapsule capsule) throws IOException {
super.write(capsule);
- capsule.writeSavableList(new ArrayList<Spatial>(_children), "children", null);
+ capsule.writeSavableList(new ArrayList<>(_children), "children", null);
}
@Override
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java
index c657032..b7fe057 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java
@@ -79,7 +79,7 @@ public abstract class Spatial implements Savable, Hintable {
protected List<SpatialController<?>> _controllers;
/** The render states of this spatial. */
- protected EnumMap<RenderState.StateType, RenderState> _renderStateList = new EnumMap<RenderState.StateType, RenderState>(
+ protected EnumMap<RenderState.StateType, RenderState> _renderStateList = new EnumMap<>(
RenderState.StateType.class);
/** Listener for dirty events. */
@@ -165,7 +165,7 @@ public abstract class Spatial implements Savable, Hintable {
if (delegate == null) {
return;
} else {
- _delegateMap = new WeakHashMap<Object, RenderDelegate>();
+ _delegateMap = new WeakHashMap<>();
}
}
if (delegate != null) {
@@ -1102,7 +1102,7 @@ public abstract class Spatial implements Savable, Hintable {
*/
public void addController(final SpatialController<?> controller) {
if (_controllers == null) {
- _controllers = new ArrayList<SpatialController<?>>(1);
+ _controllers = new ArrayList<>(1);
}
_controllers.add(controller);
}
@@ -1158,7 +1158,7 @@ public abstract class Spatial implements Savable, Hintable {
*/
public SpatialController<?> getController(final int i) {
if (_controllers == null) {
- _controllers = new ArrayList<SpatialController<?>>(1);
+ _controllers = new ArrayList<>(1);
}
return _controllers.get(i);
}
@@ -1170,7 +1170,7 @@ public abstract class Spatial implements Savable, Hintable {
*/
public List<SpatialController<?>> getControllers() {
if (_controllers == null) {
- _controllers = new ArrayList<SpatialController<?>>(1);
+ _controllers = new ArrayList<>(1);
}
return _controllers;
}
@@ -1416,7 +1416,7 @@ public abstract class Spatial implements Savable, Hintable {
}
if (_controllers != null) {
- final List<Savable> list = new ArrayList<Savable>();
+ final List<Savable> list = new ArrayList<>();
for (final SpatialController<?> sc : _controllers) {
if (sc instanceof Savable) {
list.add((Savable) sc);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/controller/interpolation/InterpolationController.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/controller/interpolation/InterpolationController.java
index 0baf1d5..9762e77 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/controller/interpolation/InterpolationController.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/controller/interpolation/InterpolationController.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>.
*/
@@ -23,7 +23,7 @@ import com.ardor3d.scenegraph.controller.ComplexSpatialController;
* Implementation note: This class is comprised of quite a few protected methods, this is mainly to allow maximum
* flexibility for overriding classes.
* </p>
- *
+ *
* @param <C>
* The control 'points' being interpolated, for example Vectors or Quaternions.
* @param <T>
@@ -54,7 +54,7 @@ public abstract class InterpolationController<C, T extends Spatial> extends Comp
/**
* This method is automatically called by {@link #update(double, Spatial)} from this controller.
- *
+ *
* @param from
* The control to interpolate from.
* @param to
@@ -73,7 +73,7 @@ public abstract class InterpolationController<C, T extends Spatial> extends Comp
* It will only update the given object if this controller is {@link #isActive() active}, caller isn't
* <code>null</code> and it's {@link #getSpeed() speed} is greater than zero.
* </p>
- *
+ *
* @param time
* The passed since this controller was last called.
* @param caller
@@ -92,7 +92,8 @@ public abstract class InterpolationController<C, T extends Spatial> extends Comp
clampIndex();
- assert (getIndex() < getControls().size()) : "_index was greater than the number of controls, clampIndex() has probably been overriden incorrectly";
+ assert (getIndex() < getControls()
+ .size()) : "_index was greater than the number of controls, clampIndex() has probably been overriden incorrectly";
assert (getIndex() >= 0) : "_index was negative, clampIndex() has probably been overriden incorrectly";
interpolate(getControlFrom(), getControlTo(), getDelta(), caller);
@@ -139,7 +140,7 @@ public abstract class InterpolationController<C, T extends Spatial> extends Comp
* The new values to set, can not be <code>null</code> or size 0.
* @see #getControls()
*/
- public void setControls(final C... controlArray) {
+ public void setControls(@SuppressWarnings("unchecked") final C... controlArray) {
if (null == controlArray) {
throw new IllegalArgumentException("controlArray can not be null!");
}
@@ -153,14 +154,15 @@ public abstract class InterpolationController<C, T extends Spatial> extends Comp
*/
public List<C> getControls() {
assert (null != _controls) : "_controls was null, it must be set before use!";
- assert (!_controls.isEmpty()) : "_controls was empty, it must contain at least 1 element for this class to work!";
+ assert (!_controls
+ .isEmpty()) : "_controls was empty, it must contain at least 1 element for this class to work!";
return _controls;
}
/**
* Updates the {@link #getDelta() delta} and {@link #getIndex() index}.
- *
+ *
* @param time
* The raw time since this was last called.
*/
@@ -224,7 +226,7 @@ public abstract class InterpolationController<C, T extends Spatial> extends Comp
/**
* This method assumes the {@link #getIndex() index} has already been {@link #clampIndex() clamped} correctly.
- *
+ *
* @return The control to interpolate from, will not be <code>null</code>.
* @see #getControlTo()
*/
@@ -254,7 +256,7 @@ public abstract class InterpolationController<C, T extends Spatial> extends Comp
/**
* This method assumes the {@link #getIndex() index} has already been {@link #clampIndex() clamped} correctly.
- *
+ *
* @return The control to interpolate to, will not be <code>null</code>.
* @see #getControlFrom()
*/
@@ -288,7 +290,7 @@ public abstract class InterpolationController<C, T extends Spatial> extends Comp
/**
* Increments the index by 1.
- *
+ *
* @return The new index value as a convenience.
*/
protected int incrementIndex() {
@@ -297,7 +299,7 @@ public abstract class InterpolationController<C, T extends Spatial> extends Comp
/**
* Decrements the index by 1.
- *
+ *
* @return The new index value as a convenience.
*/
protected int decrementIndex() {
@@ -386,7 +388,7 @@ public abstract class InterpolationController<C, T extends Spatial> extends Comp
/**
* Also {@link #reset() resets} this controller for safety, because changing the repeat type part way through an
* interpolation can cause problems.
- *
+ *
* @param repeatType
* The new repeat type to use.
*/
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/event/SceneGraphManager.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/event/SceneGraphManager.java
index ba65860..4d8c900 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/event/SceneGraphManager.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/event/SceneGraphManager.java
@@ -24,7 +24,7 @@ public class SceneGraphManager implements DirtyEventListener {
private final List<DirtyEventListener> _listeners;
private SceneGraphManager() {
- _listeners = new ArrayList<DirtyEventListener>();
+ _listeners = new ArrayList<>();
}
public static SceneGraphManager getSceneGraphManager() {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNode.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNode.java
index 8d2377d..1b4c45d 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNode.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNode.java
@@ -24,7 +24,7 @@ import com.ardor3d.util.export.OutputCapsule;
public class PassNode extends Node {
- private List<PassNodeState> _passNodeStates = new ArrayList<PassNodeState>();
+ private List<PassNodeState> _passNodeStates = new ArrayList<>();
public PassNode(final String name) {
super(name);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNodeState.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNodeState.java
index abbc917..661a263 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNodeState.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNodeState.java
@@ -33,7 +33,7 @@ public class PassNodeState implements Savable, Serializable {
* RenderStates registered with this pass - if a given state is not null it overrides the corresponding state set
* during rendering.
*/
- protected final EnumMap<RenderState.StateType, RenderState> _passStates = new EnumMap<RenderState.StateType, RenderState>(
+ protected final EnumMap<RenderState.StateType, RenderState> _passStates = new EnumMap<>(
RenderState.StateType.class);
/**
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Extrusion.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Extrusion.java
index 6fb83ae..f8ce590 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Extrusion.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Extrusion.java
@@ -266,7 +266,7 @@ public class Extrusion extends Mesh {
final double d[][] = new double[3][np]; // Newton form coefficients
final double x[] = new double[np]; // x-coordinates of nodes
- final List<ReadOnlyVector3> path = new ArrayList<ReadOnlyVector3>();
+ final List<ReadOnlyVector3> path = new ArrayList<>();
for (int i = 0; i < np; i++) {
ReadOnlyVector3 p;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/spline/ArcLengthTable.java b/ardor3d-core/src/main/java/com/ardor3d/spline/ArcLengthTable.java
index df2fc6c..7ab7562 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/spline/ArcLengthTable.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/spline/ArcLengthTable.java
@@ -172,7 +172,7 @@ public class ArcLengthTable {
throw new IllegalArgumentException("step must be > 0! step=" + step);
}
- _lookupTable = new HashMap<Integer, List<ArcLengthEntry>>();
+ _lookupTable = new HashMap<>();
final Vector3 target = Vector3.fetchTempInstance();
final Vector3 previous = Vector3.fetchTempInstance();
@@ -187,7 +187,7 @@ public class ArcLengthTable {
previous.set(_curve.getControlPoints().get(i));
- final ArrayList<ArcLengthEntry> entries = new ArrayList<ArcLengthEntry>();
+ final ArrayList<ArcLengthEntry> entries = new ArrayList<>();
entries.add(new ArcLengthEntry(0f, 0));
final int endIndex = reverse ? startIndex - 1 : startIndex + 1;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/ui/text/BMFont.java b/ardor3d-core/src/main/java/com/ardor3d/ui/text/BMFont.java
index 657f56d..a51b171 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/ui/text/BMFont.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/ui/text/BMFont.java
@@ -55,11 +55,11 @@ import com.ardor3d.util.resource.ResourceSource;
public class BMFont implements Savable {
private static Logger logger = Logger.getLogger(BMFont.class.getName());
- private final Map<Integer, Char> _charMap = new HashMap<Integer, Char>();
- private final Map<Integer, Map<Integer, Integer>> _kernMap = new HashMap<Integer, Map<Integer, Integer>>();
+ private final Map<Integer, Char> _charMap = new HashMap<>();
+ private final Map<Integer, Map<Integer, Integer>> _kernMap = new HashMap<>();
private String _styleName; // e.g. "Courier-12-bold"
- private final ArrayList<Page> _pages = new ArrayList<Page>();
+ private final ArrayList<Page> _pages = new ArrayList<>();
private Texture _pageTexture;
private RenderStateSetter _blendStateSetter = null;
private RenderStateSetter _alphaStateSetter = null;
@@ -424,7 +424,7 @@ public class BMFont implements Savable {
}
public List<Integer> getMappedChars() {
- return new ArrayList<Integer>(_charMap.keySet());
+ return new ArrayList<>(_charMap.keySet());
}
public Map<Integer, Integer> getKerningsForCharacter(final int val) {
@@ -556,7 +556,7 @@ public class BMFont implements Savable {
Map<Integer, Integer> amtHash;
amtHash = _kernMap.get(first);
if (amtHash == null) {
- amtHash = new HashMap<Integer, Integer>();
+ amtHash = new HashMap<>();
_kernMap.put(first, amtHash);
}
amtHash.put(second, amount);
@@ -884,10 +884,10 @@ public class BMFont implements Savable {
// Pages
capsule.writeSavableList(_pages, "pages", _pages);
// Chars
- capsule.writeSavableList(new ArrayList<Char>(_charMap.values()), "charMap", null);
+ capsule.writeSavableList(new ArrayList<>(_charMap.values()), "charMap", null);
// Kernings
- final List<Kerning> kernings = new ArrayList<Kerning>();
+ final List<Kerning> kernings = new ArrayList<>();
for (final Iterator<Integer> iterator = _kernMap.keySet().iterator(); iterator.hasNext();) {
final Integer first = iterator.next();
final Map<Integer, Integer> amtHash = _kernMap.get(first);
@@ -938,7 +938,7 @@ public class BMFont implements Savable {
Map<Integer, Integer> amtHash;
amtHash = _kernMap.get(k.first);
if (amtHash == null) {
- amtHash = new HashMap<Integer, Integer>();
+ amtHash = new HashMap<>();
_kernMap.put(k.first, amtHash);
}
amtHash.put(k.second, k.amount);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/ContextIdReference.java b/ardor3d-core/src/main/java/com/ardor3d/util/ContextIdReference.java
index 7ae05a6..069c0fd 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/ContextIdReference.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/ContextIdReference.java
@@ -23,7 +23,7 @@ public class ContextIdReference<T> extends PhantomReference<T> {
/**
* Keep a strong reference to these objects until their reference is cleared.
*/
- private static final List<ContextIdReference<?>> REFS = new LinkedList<ContextIdReference<?>>();
+ private static final List<ContextIdReference<?>> REFS = new LinkedList<>();
private final Map<Object, Integer> _idCache;
private Integer _singleContextId;
@@ -31,7 +31,7 @@ public class ContextIdReference<T> extends PhantomReference<T> {
public ContextIdReference(final T reference, final ReferenceQueue<? super T> queue) {
super(reference, queue);
if (Constants.useMultipleContexts) {
- _idCache = new WeakHashMap<Object, Integer>(2);
+ _idCache = new WeakHashMap<>(2);
} else {
_idCache = null;
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java b/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java
index 2a0e17c..357a96b 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java
@@ -38,13 +38,13 @@ public class GameTaskQueue {
public static final String RENDER = "render";
public static final String UPDATE = "update";
- private final ConcurrentLinkedQueue<GameTask<?>> _queue = new ConcurrentLinkedQueue<GameTask<?>>();
+ private final ConcurrentLinkedQueue<GameTask<?>> _queue = new ConcurrentLinkedQueue<>();
private final AtomicBoolean _executeMultiple = new AtomicBoolean();
// Default execution time is 0, which means only 1 task will be executed at a time.
private long _executionTime = 0;
- private final List<ExecutionExceptionListener> _executionExceptionListeners = new LinkedList<ExecutionExceptionListener>();
+ private final List<ExecutionExceptionListener> _executionExceptionListeners = new LinkedList<>();
public void addExecutionExceptionListener(final ExecutionExceptionListener l) {
_executionExceptionListeners.add(l);
@@ -111,7 +111,7 @@ public class GameTaskQueue {
* @return
*/
public <V> Future<V> enqueue(final Callable<V> callable) {
- final GameTask<V> task = new GameTask<V>(callable);
+ final GameTask<V> task = new GameTask<>(callable);
_queue.add(task);
return task;
}
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 4f57874..26f9d16 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueueManager.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueueManager.java
@@ -25,7 +25,7 @@ public final class GameTaskQueueManager {
private static final Object MAP_LOCK = new Object();
private static final ConcurrentMap<Object, GameTaskQueueManager> _managers = new MapMaker().weakKeys().makeMap();
- private final ConcurrentMap<String, GameTaskQueue> _managedQueues = new ConcurrentHashMap<String, GameTaskQueue>(2);
+ private final ConcurrentMap<String, GameTaskQueue> _managedQueues = new ConcurrentHashMap<>(2);
public static GameTaskQueueManager getManager(final Object key) {
synchronized (MAP_LOCK) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianDataInput.java b/ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianDataInput.java
index 914364e..2241206 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianDataInput.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianDataInput.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>.
*/
@@ -20,7 +20,7 @@ import java.io.InputStream;
* LittleEndianDataInput is a class to read little-endian stored data via a InputStream. All functions work as defined
* in DataInput, but assume they come from a LittleEndian input stream.
*/
-public class LittleEndianDataInput implements DataInput {
+public class LittleEndianDataInput implements DataInput, AutoCloseable {
private final BufferedInputStream _stream;
@@ -33,7 +33,7 @@ public class LittleEndianDataInput implements DataInput {
/**
* Creates a new LittleEndian reader from the given input stream. The stream is wrapped in a BufferedInputStream
* automatically.
- *
+ *
* @param in
* The input stream to read from.
*/
@@ -50,8 +50,8 @@ public class LittleEndianDataInput implements DataInput {
* read an unsigned int as a long
*/
public final long readUnsignedInt() throws IOException {
- return ((_stream.read() & 0xff) | ((_stream.read() & 0xff) << 8) | ((_stream.read() & 0xff) << 16) | (((long) (_stream
- .read() & 0xff)) << 24));
+ return ((_stream.read() & 0xff) | ((_stream.read() & 0xff) << 8) | ((_stream.read() & 0xff) << 16)
+ | (((long) (_stream.read() & 0xff)) << 24));
}
@Override
@@ -81,16 +81,16 @@ public class LittleEndianDataInput implements DataInput {
@Override
public final int readInt() throws IOException {
- return ((_stream.read() & 0xff) | ((_stream.read() & 0xff) << 8) | ((_stream.read() & 0xff) << 16) | ((_stream
- .read() & 0xff) << 24));
+ return ((_stream.read() & 0xff) | ((_stream.read() & 0xff) << 8) | ((_stream.read() & 0xff) << 16)
+ | ((_stream.read() & 0xff) << 24));
}
@Override
public final long readLong() throws IOException {
- return ((_stream.read() & 0xff) | ((long) (_stream.read() & 0xff) << 8)
- | ((long) (_stream.read() & 0xff) << 16) | ((long) (_stream.read() & 0xff) << 24)
- | ((long) (_stream.read() & 0xff) << 32) | ((long) (_stream.read() & 0xff) << 40)
- | ((long) (_stream.read() & 0xff) << 48) | ((long) (_stream.read() & 0xff) << 56));
+ return ((_stream.read() & 0xff) | ((long) (_stream.read() & 0xff) << 8) | ((long) (_stream.read() & 0xff) << 16)
+ | ((long) (_stream.read() & 0xff) << 24) | ((long) (_stream.read() & 0xff) << 32)
+ | ((long) (_stream.read() & 0xff) << 40) | ((long) (_stream.read() & 0xff) << 48)
+ | ((long) (_stream.read() & 0xff) << 56));
}
@Override
@@ -141,6 +141,7 @@ public class LittleEndianDataInput implements DataInput {
throw new IOException("Unsupported operation");
}
+ @Override
public final void close() throws IOException {
_stream.close();
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/SimpleContextIdReference.java b/ardor3d-core/src/main/java/com/ardor3d/util/SimpleContextIdReference.java
index 21ff6e3..91ac624 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/SimpleContextIdReference.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/SimpleContextIdReference.java
@@ -20,7 +20,7 @@ public class SimpleContextIdReference<T> extends PhantomReference<T> {
/**
* Keep a string reference to these objects until their reference is cleared.
*/
- private static final List<SimpleContextIdReference<?>> REFS = new LinkedList<SimpleContextIdReference<?>>();
+ private static final List<SimpleContextIdReference<?>> REFS = new LinkedList<>();
private final int _id;
private final Object _glContext;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/TextureKey.java b/ardor3d-core/src/main/java/com/ardor3d/util/TextureKey.java
index b0d83ce..4202fcb 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/TextureKey.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/TextureKey.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>.
*/
@@ -16,6 +16,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@@ -67,14 +68,14 @@ final public class TextureKey implements Savable {
private boolean _dirty;
/** cache of OpenGL context specific texture ids for the associated texture. */
- protected final transient ContextIdReference<TextureKey> _idCache = new ContextIdReference<TextureKey>(this,
+ protected final transient ContextIdReference<TextureKey> _idCache = new ContextIdReference<>(this,
TextureManager.getRefQueue());
/** cached hashcode value. */
protected transient int _code = Integer.MAX_VALUE;
/** cache of texturekey objects allowing us to find an existing texture key. */
- protected static final List<WeakReference<TextureKey>> _keyCache = new LinkedList<WeakReference<TextureKey>>();
+ protected static final List<WeakReference<TextureKey>> _keyCache = new LinkedList<>();
private static final Integer ZERO = new Integer(0);
@@ -84,7 +85,7 @@ final public class TextureKey implements Savable {
/** DO NOT USE. FOR INTERNAL USE ONLY */
protected TextureKey() {
if (Constants.useMultipleContexts) {
- _dirtyContexts = new ArrayList<WeakReference<Object>>();
+ _dirtyContexts = new ArrayList<>();
} else {
_dirtyContexts = null;
}
@@ -101,7 +102,7 @@ final public class TextureKey implements Savable {
_dirtyContexts.clear();
// grab all contexts we currently have ids for and add them all as dirty
for (final Object context : _idCache.getContextObjects()) {
- final WeakReference<Object> ref = new WeakReference<Object>(context);
+ final WeakReference<Object> ref = new WeakReference<>(context);
_dirtyContexts.add(ref);
}
}
@@ -166,7 +167,7 @@ final public class TextureKey implements Savable {
/**
* Get a new unique TextureKey. This is meant for use by RTT and other situations where we know we are making a
* unique texture.
- *
+ *
* @param minFilter
* our minification filter value.
* @return the new TextureKey
@@ -216,7 +217,7 @@ final public class TextureKey implements Savable {
}
// not found
- _keyCache.add(new WeakReference<TextureKey>(key));
+ _keyCache.add(new WeakReference<>(key));
return key;
}
@@ -264,7 +265,7 @@ final public class TextureKey implements Savable {
* Note: This does not remove the texture from the card and is provided for use by code that does remove textures
* from the card.
* </p>
- *
+ *
* @param glContext
* the object representing the OpenGL context this texture belongs to. See
* {@link RenderContext#getGlContextRep()}
@@ -288,7 +289,7 @@ final public class TextureKey implements Savable {
/**
* Sets the id for a texture in regards to the given OpenGL context.
- *
+ *
* @param glContext
* the object representing the OpenGL context a texture belongs to. See
* {@link RenderContext#getGlContextRep()}
@@ -347,13 +348,8 @@ final public class TextureKey implements Savable {
@Override
public int hashCode() {
if (_code == Integer.MAX_VALUE) {
- _code = 17;
-
- _code += 31 * _code + (_source != null ? _source.hashCode() : 0);
- _code += 31 * _code + (_id != null ? _id.hashCode() : 0);
- _code += 31 * _code + _minFilter.hashCode();
- _code += 31 * _code + _format.hashCode();
- _code += 31 * _code + (_flipped ? 1 : 0);
+ _code = Objects.hash(getSource(), getId(), getMinificationFilter(), getFormat(),
+ Boolean.valueOf(isFlipped()));
}
return _code;
}
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 b584647..8118104 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/TextureManager.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/TextureManager.java
@@ -46,7 +46,7 @@ final public class TextureManager {
private static Map<TextureKey, Texture> _tCache = new MapMaker().weakKeys().weakValues().makeMap();
- private static ReferenceQueue<TextureKey> _textureRefQueue = new ReferenceQueue<TextureKey>();
+ private static ReferenceQueue<TextureKey> _textureRefQueue = new ReferenceQueue<>();
static {
ContextManager.addContextCleanListener(new ContextCleanListener() {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryExporter.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryExporter.java
index 61090b2..55414de 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryExporter.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryExporter.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>.
*/
@@ -123,14 +123,14 @@ public class BinaryExporter implements Ardor3dExporter {
protected int _aliasCount = 1;
protected int _idCount = 1;
- protected final Map<Savable, BinaryIdContentPair> _contentTable = new IdentityHashMap<Savable, BinaryIdContentPair>();
+ protected final Map<Savable, BinaryIdContentPair> _contentTable = new IdentityHashMap<>();
- protected final Map<Integer, Integer> _locationTable = new HashMap<Integer, Integer>();
+ protected final Map<Integer, Integer> _locationTable = new HashMap<>();
// key - class name, value = bco
- protected final Map<String, BinaryClassObject> _classes = new HashMap<String, BinaryClassObject>();
+ protected final Map<String, BinaryClassObject> _classes = new HashMap<>();
- protected final List<Savable> _contentKeys = new ArrayList<Savable>();
+ protected final List<Savable> _contentKeys = new ArrayList<>();
public BinaryExporter() {
this(DEFAULT_COMPRESSION);
@@ -138,7 +138,7 @@ public class BinaryExporter implements Ardor3dExporter {
/**
* Construct a new exporter, specifying some options.
- *
+ *
* @param compression
* the compression type to use. One of the constants from {@link java.util.zip.Deflater}
*/
@@ -196,8 +196,7 @@ public class BinaryExporter implements Ardor3dExporter {
// write out data to a seperate stream
int location = 0;
// keep track of location for each piece
- final HashMap<String, List<BinaryIdContentPair>> alreadySaved = new HashMap<String, List<BinaryIdContentPair>>(
- _contentTable.size());
+ final HashMap<String, List<BinaryIdContentPair>> alreadySaved = new HashMap<>(_contentTable.size());
for (final Savable savable : _contentKeys) {
// look back at previous written data for matches
final String savableName = savable.getClassTag().getName();
@@ -211,7 +210,7 @@ public class BinaryExporter implements Ardor3dExporter {
_locationTable.put(pair.getId(), location);
if (bucket == null) {
- bucket = new ArrayList<BinaryIdContentPair>();
+ bucket = new ArrayList<>();
alreadySaved.put(savableName + getChunk(pair), bucket);
}
bucket.add(pair);
@@ -304,9 +303,9 @@ public class BinaryExporter implements Ardor3dExporter {
parentDirectory.mkdirs();
}
- final FileOutputStream fos = new FileOutputStream(file);
- save(object, fos);
- fos.close();
+ try (final FileOutputStream fos = new FileOutputStream(file)) {
+ save(object, fos);
+ }
}
public int processBinarySavable(final Savable object) throws IOException {
@@ -318,7 +317,7 @@ public class BinaryExporter implements Ardor3dExporter {
if (bco == null) {
bco = new BinaryClassObject();
bco._alias = generateTag();
- bco._nameFields = new HashMap<String, BinaryClassField>();
+ bco._nameFields = new HashMap<>();
_classes.put(object.getClassTag().getName(), bco);
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.java
index c9944a2..e048fbf 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.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>.
*/
@@ -37,13 +37,13 @@ public class BinaryImporter implements Ardor3dImporter {
private static final Logger logger = Logger.getLogger(BinaryImporter.class.getName());
// Key - alias, object - bco
- protected final Map<String, BinaryClassObject> _classes = new HashMap<String, BinaryClassObject>();
+ protected final Map<String, BinaryClassObject> _classes = new HashMap<>();
// Key - id, object - the savable
- protected final Map<Integer, Savable> _contentTable = new HashMap<Integer, Savable>();
+ protected final Map<Integer, Savable> _contentTable = new HashMap<>();
// Key - savable, object - capsule
- protected final Map<Savable, BinaryInputCapsule> _capsuleTable = new IdentityHashMap<Savable, BinaryInputCapsule>();
+ protected final Map<Savable, BinaryInputCapsule> _capsuleTable = new IdentityHashMap<>();
// Key - id, opject - location in the file
- protected final Map<Integer, Integer> _locationTable = new HashMap<Integer, Integer>();
+ protected final Map<Integer, Integer> _locationTable = new HashMap<>();
protected byte[] _dataArray = null;
protected int _aliasWidth = 0;
@@ -79,8 +79,8 @@ public class BinaryImporter implements Ardor3dImporter {
final int fields = ByteUtils.readInt(bis);
bytes += (8 + _aliasWidth + classLength);
- bco._nameFields = new HashMap<String, BinaryClassField>(fields);
- bco._aliasFields = new HashMap<Byte, BinaryClassField>(fields);
+ bco._nameFields = new HashMap<>(fields);
+ bco._aliasFields = new HashMap<>(fields);
for (int x = 0; x < fields; x++) {
final byte fieldAlias = (byte) bis.read();
final byte fieldType = (byte) bis.read();
@@ -162,10 +162,10 @@ public class BinaryImporter implements Ardor3dImporter {
}
public Savable load(final URL url, final ReadListener listener) throws IOException {
- final InputStream is = url.openStream();
- final Savable rVal = load(is, listener);
- is.close();
- return rVal;
+ try (final InputStream is = url.openStream()) {
+ final Savable rVal = load(is, listener);
+ return rVal;
+ }
}
@Override
@@ -174,18 +174,18 @@ public class BinaryImporter implements Ardor3dImporter {
}
public Savable load(final File file, final ReadListener listener) throws IOException {
- final FileInputStream fis = new FileInputStream(file);
- final Savable rVal = load(fis, listener);
- fis.close();
- return rVal;
+ try (final FileInputStream fis = new FileInputStream(file)) {
+ final Savable rVal = load(fis, listener);
+ return rVal;
+ }
}
@Override
public Savable load(final byte[] data) throws IOException {
- final ByteArrayInputStream bais = new ByteArrayInputStream(data);
- final Savable rVal = load(bais);
- bais.close();
- return rVal;
+ try (final ByteArrayInputStream bais = new ByteArrayInputStream(data)) {
+ final Savable rVal = load(bais);
+ return rVal;
+ }
}
protected String readString(final InputStream is, final int length) throws IOException {
@@ -218,8 +218,8 @@ public class BinaryImporter implements Ardor3dImporter {
final BinaryClassObject bco = _classes.get(alias);
if (bco == null) {
- logger.logp(Level.SEVERE, this.getClass().toString(), "readObject(int id)", "NULL class object: "
- + alias);
+ logger.logp(Level.SEVERE, this.getClass().toString(), "readObject(int id)",
+ "NULL class object: " + alias);
return null;
}
@@ -244,15 +244,12 @@ public class BinaryImporter implements Ardor3dImporter {
} catch (final InstantiationException e) {
logger.logp(Level.SEVERE, this.getClass().toString(), "readObject(int)",
"Could not access constructor of class '" + bco._className + "'! \n"
- + "Some types may require the annotation SavableFactory. Please double check.", e);
+ + "Some types may require the annotation SavableFactory. Please double check.",
+ e);
throw new Ardor3dException(e);
} catch (final NoSuchMethodException e) {
- logger.logp(
- Level.SEVERE,
- this.getClass().toString(),
- "readObject(int)",
- e.getMessage()
- + " \n"
+ logger.logp(Level.SEVERE, this.getClass().toString(), "readObject(int)",
+ e.getMessage() + " \n"
+ "Method specified in annotation does not appear to exist or has an invalid method signature.",
e);
throw new Ardor3dException(e);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryInputCapsule.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryInputCapsule.java
index 3d99d16..f3fb207 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryInputCapsule.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryInputCapsule.java
@@ -46,7 +46,7 @@ public class BinaryInputCapsule implements InputCapsule {
}
public void setContent(final byte[] content, final int start, final int limit) {
- _fieldData = new HashMap<Byte, Object>();
+ _fieldData = new HashMap<>();
for (_index = start; _index < limit;) {
final byte alias = content[_index];
@@ -543,7 +543,7 @@ public class BinaryInputCapsule implements InputCapsule {
if (savables == null) {
return null;
}
- final List<Savable> list = new ArrayList<Savable>(savables.length);
+ final List<Savable> list = new ArrayList<>(savables.length);
for (int x = 0; x < savables.length; x++) {
list.add(savables[x]);
}
@@ -555,7 +555,7 @@ public class BinaryInputCapsule implements InputCapsule {
if (savables == null) {
return null;
}
- final Map<Savable, Savable> map = new HashMap<Savable, Savable>(savables.length);
+ final Map<Savable, Savable> map = new HashMap<>(savables.length);
for (int x = 0; x < savables.length; x++) {
map.put(savables[x][0], savables[x][1]);
}
@@ -567,7 +567,7 @@ public class BinaryInputCapsule implements InputCapsule {
return null;
}
- final Map<String, Savable> map = new HashMap<String, Savable>(keys.length);
+ final Map<String, Savable> map = new HashMap<>(keys.length);
for (int x = 0; x < keys.length; x++) {
map.put(keys[x], values[x]);
}
@@ -1239,7 +1239,7 @@ public class BinaryInputCapsule implements InputCapsule {
if (length == BinaryOutputCapsule.NULL_OBJECT) {
return null;
}
- final List<FloatBuffer> rVal = new ArrayList<FloatBuffer>(length);
+ final List<FloatBuffer> rVal = new ArrayList<>(length);
for (int x = 0; x < length; x++) {
rVal.add(readFloatBuffer(content));
}
@@ -1253,7 +1253,7 @@ public class BinaryInputCapsule implements InputCapsule {
if (length == BinaryOutputCapsule.NULL_OBJECT) {
return null;
}
- final List<ByteBuffer> rVal = new ArrayList<ByteBuffer>(length);
+ final List<ByteBuffer> rVal = new ArrayList<>(length);
for (int x = 0; x < length; x++) {
rVal.add(readByteBuffer(content));
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryOutputCapsule.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryOutputCapsule.java
index 996cbd7..a3987d5 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryOutputCapsule.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryOutputCapsule.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>.
*/
@@ -441,6 +441,11 @@ public class BinaryOutputCapsule implements OutputCapsule {
return Arrays.equals(_bytes, other);
}
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(_bytes);
+ }
+
public void finish() {
// renamed to finish as 'finalize' in java.lang.Object should not be
// overridden like this
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java
index 54de7e4..6b29554 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java
@@ -48,7 +48,7 @@ public class DOMInputCapsule implements InputCapsule {
private final Document _doc;
private Element _currentElem;
private boolean _isAtRoot = true;
- private final Map<String, Savable> _referencedSavables = new HashMap<String, Savable>();
+ private final Map<String, Savable> _referencedSavables = new HashMap<>();
public DOMInputCapsule(final Document doc) {
_doc = doc;
@@ -882,7 +882,7 @@ public class DOMInputCapsule implements InputCapsule {
private Savable[] readRenderStateList(final Element fromElement, final Savable[] defVal) {
Savable[] ret = defVal;
try {
- final List<RenderState> tmp = new ArrayList<RenderState>();
+ final List<RenderState> tmp = new ArrayList<>();
_currentElem = findFirstChildElement(fromElement);
while (_currentElem != null) {
final Element el = _currentElem;
@@ -1074,7 +1074,7 @@ public class DOMInputCapsule implements InputCapsule {
}
final int size = Integer.parseInt(tmpEl.getAttribute("size"));
- final List<FloatBuffer> tmp = new ArrayList<FloatBuffer>(size);
+ final List<FloatBuffer> tmp = new ArrayList<>(size);
_currentElem = findFirstChildElement(tmpEl);
for (int i = 0; i < size; i++) {
tmp.add(readFloatBuffer(null, null));
@@ -1105,7 +1105,7 @@ public class DOMInputCapsule implements InputCapsule {
} else {
tempEl = _currentElem;
}
- ret = new HashMap<K, V>();
+ ret = new HashMap<>();
final NodeList nodes = tempEl.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
@@ -1135,7 +1135,7 @@ public class DOMInputCapsule implements InputCapsule {
tempEl = _currentElem;
}
if (tempEl != null) {
- ret = new HashMap<String, V>();
+ ret = new HashMap<>();
final NodeList nodes = tempEl.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
@@ -1280,7 +1280,7 @@ public class DOMInputCapsule implements InputCapsule {
}
final int size = Integer.parseInt(tmpEl.getAttribute("size"));
- final List<ByteBuffer> tmp = new ArrayList<ByteBuffer>(size);
+ final List<ByteBuffer> tmp = new ArrayList<>(size);
_currentElem = findFirstChildElement(tmpEl);
for (int i = 0; i < size; i++) {
tmp.add(readByteBuffer(null, null));
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java
index bf781a1..0033fd4 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java
@@ -37,7 +37,7 @@ public class DOMOutputCapsule implements OutputCapsule {
private static final String _dataAttributeName = "data";
private final Document _doc;
private Element _currentElement;
- private final Map<Savable, Element> _writtenSavables = new IdentityHashMap<Savable, Element>();
+ private final Map<Savable, Element> _writtenSavables = new IdentityHashMap<>();
public DOMOutputCapsule(final Document doc) {
_doc = doc;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMSerializer.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMSerializer.java
index 34000f0..21d9d35 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMSerializer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMSerializer.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>.
*/
@@ -26,7 +26,7 @@ import org.w3c.dom.NodeList;
/**
* The DOMSerializer was based primarily off the DOMSerializer.java class from the "Java and XML" 3rd Edition book by
* Brett McLaughlin, and Justin Edelson. Some modifications were made to support formatting of elements and attributes.
- *
+ *
*/
public class DOMSerializer {
@@ -51,7 +51,7 @@ public class DOMSerializer {
}
public void setIndent(final int numSpaces) {
- final StringBuffer buffer = new StringBuffer();
+ final StringBuilder buffer = new StringBuilder();
for (int i = 0; i < numSpaces; i++) {
buffer.append('\t');
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java b/ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java
index e96c951..9e18e0e 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java
@@ -45,7 +45,7 @@ import com.ardor3d.util.Constants;
public final class BufferUtils {
// // -- TRACKER HASH -- ////
- private static final Map<Buffer, Object> trackingHash = new WeakHashMap<Buffer, Object>();
+ private static final Map<Buffer, Object> trackingHash = new WeakHashMap<>();
private static final Object ref = new Object();
// // -- COLORRGBA METHODS -- ////
@@ -1782,7 +1782,7 @@ public final class BufferUtils {
public static void printCurrentDirectMemory(StringBuilder store) {
long totalHeld = 0;
// make a new set to hold the keys to prevent concurrency issues.
- final List<Buffer> bufs = new ArrayList<Buffer>(trackingHash.keySet());
+ final List<Buffer> bufs = new ArrayList<>(trackingHash.keySet());
int fBufs = 0, bBufs = 0, iBufs = 0, sBufs = 0, dBufs = 0;
int fBufsM = 0, bBufsM = 0, iBufsM = 0, sBufsM = 0, dBufsM = 0;
for (final Buffer b : bufs) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/geom/GeometryTool.java b/ardor3d-core/src/main/java/com/ardor3d/util/geom/GeometryTool.java
index 90b9110..3bb8cfd 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/geom/GeometryTool.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/geom/GeometryTool.java
@@ -126,8 +126,8 @@ public class GeometryTool {
}
}
- final Map<VertKey, Integer> store = new HashMap<VertKey, Integer>();
- final Map<Integer, Integer> indexRemap = new HashMap<Integer, Integer>();
+ final Map<VertKey, Integer> store = new HashMap<>();
+ final Map<Integer, Integer> indexRemap = new HashMap<>();
int good = 0;
long group;
for (int x = 0, max = verts.length; x < max; x++) {
@@ -350,7 +350,7 @@ public class GeometryTool {
final int numberOfUnits = meshData.getNumberOfUnits();
if (numberOfUnits > 0) {
final List<FloatBufferData> previousTextureCoordsList = meshData.getTextureCoords();
- final List<FloatBufferData> nextTextureCoordsList = new ArrayList<FloatBufferData>();
+ final List<FloatBufferData> nextTextureCoordsList = new ArrayList<>();
for (int unitIndex = 0; unitIndex < numberOfUnits; unitIndex++) {
final FloatBufferData previousTextureCoords = previousTextureCoordsList.get(unitIndex);
if (previousTextureCoords == null) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/geom/MeshCombiner.java b/ardor3d-core/src/main/java/com/ardor3d/util/geom/MeshCombiner.java
index 369afb6..8377762 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/geom/MeshCombiner.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/geom/MeshCombiner.java
@@ -63,7 +63,7 @@ public class MeshCombiner {
}
public final static Mesh combine(final Spatial source, final MeshCombineLogic logic) {
- final List<Mesh> sources = new ArrayList<Mesh>();
+ final List<Mesh> sources = new ArrayList<>();
source.acceptVisitor(new Visitor() {
@Override
public void visit(final Spatial spatial) {
@@ -86,7 +86,7 @@ public class MeshCombiner {
* @return the combined Mesh.
*/
public final static Mesh combine(final Mesh... sources) {
- return combine(new ArrayList<Mesh>(Arrays.asList(sources)));
+ return combine(new ArrayList<>(Arrays.asList(sources)));
}
/**
@@ -129,7 +129,7 @@ public class MeshCombiner {
protected EnumMap<StateType, RenderState> states = null;
protected MeshData data = new MeshData();
protected BoundingVolume volumeType = null;
- protected List<Mesh> sources = new ArrayList<Mesh>();
+ protected List<Mesh> sources = new ArrayList<>();
private FloatBufferData vertices;
private FloatBufferData colors;
private FloatBufferData normals;
@@ -237,7 +237,7 @@ public class MeshCombiner {
normals = useNormals ? new FloatBufferData(totalVertices * 3, 3) : null;
data.setNormalCoords(normals);
- texCoordsList = new ArrayList<FloatBufferData>(maxTextures);
+ texCoordsList = new ArrayList<>(maxTextures);
for (int i = 0; i < maxTextures; i++) {
texCoordsList.add(new FloatBufferData(totalVertices * texCoords, texCoords));
}
@@ -359,8 +359,8 @@ class IndexCombiner {
}
public void saveTo(final MeshData data) {
- final List<IntBuffer> sections = new ArrayList<IntBuffer>();
- final List<IndexMode> modes = new ArrayList<IndexMode>();
+ final List<IntBuffer> sections = new ArrayList<>();
+ final List<IndexMode> modes = new ArrayList<>();
int max = 0;
// walk through index modes and combine those we can.
for (final IndexMode mode : sectionMap.keySet()) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/geom/NormalGenerator.java b/ardor3d-core/src/main/java/com/ardor3d/util/geom/NormalGenerator.java
index 2d9b019..6f53629 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/geom/NormalGenerator.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/geom/NormalGenerator.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>.
*/
@@ -80,7 +80,7 @@ public class NormalGenerator {
/**
* Generates the normals for one Mesh, using the specified crease angle.
- *
+ *
* @param mesh
* The Mesh to generate the normals for
* @param creaseAngle
@@ -97,7 +97,7 @@ public class NormalGenerator {
/**
* Generates the normals for one Mesh, using the crease angle stored in the field <code>creaseAngle</code>
- *
+ *
* @param mesh
* The Mesh to generate the normals for
*/
@@ -252,12 +252,12 @@ public class NormalGenerator {
*/
private void initialize() {
// Copy the source vertices as a base for the normal generation
- _destVerts = new ArrayList<Vector3>(_sourceVerts.length);
+ _destVerts = new ArrayList<>(_sourceVerts.length);
for (int i = 0; i < _sourceVerts.length; i++) {
_destVerts.add(_sourceVerts[i]);
}
if (_sourceColors != null) {
- _destColors = new ArrayList<ColorRGBA>(_sourceColors.length);
+ _destColors = new ArrayList<>(_sourceColors.length);
for (int i = 0; i < _sourceColors.length; i++) {
_destColors.add(_sourceColors[i]);
}
@@ -265,7 +265,7 @@ public class NormalGenerator {
_destColors = null;
}
if (_sourceTexCoords != null) {
- _destTexCoords = new ArrayList<Vector2>(_sourceTexCoords.length);
+ _destTexCoords = new ArrayList<>(_sourceTexCoords.length);
for (int i = 0; i < _sourceTexCoords.length; i++) {
_destTexCoords.add(_sourceTexCoords[i]);
}
@@ -274,7 +274,7 @@ public class NormalGenerator {
}
// Set up the base triangles of the mesh and their face normals
- _triangles = new LinkedList<Triangle>();
+ _triangles = new LinkedList<>();
for (int i = 0; i * 3 < _sourceInds.length; i++) {
final Triangle tri = new Triangle(_sourceInds[i * 3 + 0], _sourceInds[i * 3 + 1], _sourceInds[i * 3 + 2]);
tri.computeNormal(_sourceVerts);
@@ -283,12 +283,12 @@ public class NormalGenerator {
// Set up the lists to store the created mesh split data
if (_splitMeshes == null) {
- _splitMeshes = new LinkedList<LinkedList<Triangle>>();
+ _splitMeshes = new LinkedList<>();
} else {
_splitMeshes.clear();
}
if (_splitMeshBorders == null) {
- _splitMeshBorders = new LinkedList<LinkedList<Edge>>();
+ _splitMeshBorders = new LinkedList<>();
} else {
_splitMeshBorders.clear();
}
@@ -300,8 +300,8 @@ public class NormalGenerator {
* border of the split mesh in splitMeshBorders.
*/
private void createMeshSplit() {
- _destTris = new LinkedList<Triangle>();
- _edges = new LinkedList<Edge>();
+ _destTris = new LinkedList<>();
+ _edges = new LinkedList<>();
final Triangle tri = _triangles.removeFirst();
_destTris.addLast(tri);
_edges.addLast(tri.edges[0]);
@@ -321,9 +321,10 @@ public class NormalGenerator {
* Finds one triangle connected to the split mesh currently being assembled over an edge whose angle does not exceed
* the creaseAngle. The Triangle is inserted into destTris and the list edges is updated with the edges of the
* triangle accordingly.
- *
+ *
* @return The triangle, if one was found, or <code>null</code> otherwise
*/
+ @SuppressWarnings("null")
private Triangle insertTriangle() {
final ListIterator<Triangle> triIt = _triangles.listIterator();
ListIterator<Edge> edgeIt = null;
@@ -386,7 +387,7 @@ public class NormalGenerator {
* Connects the remaining edges of the given triangle to the split mesh currently being assembled, if possible. The
* respective edges are removed from the border, and if the crease angle at this additional connection is exceeded,
* the vertices at this link are duplicated.
- *
+ *
* @param triangle
* The triangle being connected to the split mesh
* @param i
@@ -431,7 +432,7 @@ public class NormalGenerator {
/**
* Checks if the transition between the tqo given triangles should be smooth, according to the creaseAngle.
- *
+ *
* @param tri1
* The first triangle
* @param tri2
@@ -446,7 +447,7 @@ public class NormalGenerator {
/**
* Copies the vertex, color and texCoord at the given index in each of the source lists (if not null) and adds it to
* the end of the list.
- *
+ *
* @param index
* The index to copy the value in each list from
*/
@@ -542,7 +543,7 @@ public class NormalGenerator {
/**
* If the triangle contains the given index, it is replaced with the replacement index, unless it is already
* overridden with a newIndex (newI0, newI1).
- *
+ *
* @param tri
* The triangle
* @param index
@@ -661,7 +662,7 @@ public class NormalGenerator {
/**
* A helper class for the normal generator. Stores one triangle, consisting of 3 edges, and the normal for the
* triangle.
- *
+ *
* @author M. Sattler
*/
private class Triangle {
@@ -674,7 +675,7 @@ public class NormalGenerator {
/**
* Creates the triangle.
- *
+ *
* @param i0
* The index of vertex 0 in the triangle
* @param i1
@@ -690,7 +691,7 @@ public class NormalGenerator {
/**
* Computes the normal from the three vertices in the given array that are indexed by the edges.
- *
+ *
* @param verts
* The array containing the vertices
*/
@@ -708,6 +709,7 @@ public class NormalGenerator {
* An Edge to get the index of
* @return The index of the edge in the triangle, or -1, if it is not contained in the triangle
*/
+ @SuppressWarnings("unused")
public int indexOf(final Edge edge) {
for (int i = 0; i < 3; i++) {
if (edges[i] == edge) {
@@ -743,7 +745,7 @@ public class NormalGenerator {
/**
* Another helper class for the normal generator. Stores one edge in the mesh, consisting of two vertex indices, the
* triangle the edge belongs to, and, if applicable, another triangle the edge is connected to.
- *
+ *
* @author M. Sattler
*/
private class Edge {
@@ -760,13 +762,14 @@ public class NormalGenerator {
public Triangle parent;
// A Triangle this Edge is connected to, or null, if it is not connected
+ @SuppressWarnings("unused")
public Triangle connected;
// public Edge() {}
/**
* Creates this edge.
- *
+ *
* @param parent
* The Triangle containing this Edge
* @param i0
@@ -782,7 +785,7 @@ public class NormalGenerator {
/**
* Checks if this edge is connected to another one.
- *
+ *
* @param other
* The other edge
* @return <code>true</code>, if the indices in this edge and the other one are identical, but in inverse order
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/geom/VertGroupData.java b/ardor3d-core/src/main/java/com/ardor3d/util/geom/VertGroupData.java
index 429fece..caacbaa 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/geom/VertGroupData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/geom/VertGroupData.java
@@ -20,7 +20,7 @@ public class VertGroupData {
public static final int DEFAULT_GROUP = 0;
- private final Map<Long, EnumSet<MatchCondition>> _groupConditions = new HashMap<Long, EnumSet<MatchCondition>>();
+ private final Map<Long, EnumSet<MatchCondition>> _groupConditions = new HashMap<>();
private long[] _vertGroups = null;
public VertGroupData() {}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/resource/RelativeResourceLocator.java b/ardor3d-core/src/main/java/com/ardor3d/util/resource/RelativeResourceLocator.java
index 47f2f58..29510a2 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/resource/RelativeResourceLocator.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/resource/RelativeResourceLocator.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>.
*/
@@ -20,7 +20,7 @@ public class RelativeResourceLocator implements ResourceLocator {
/**
* Construct a new RelativeResourceLocator using the given source as our base.
- *
+ *
* @param resource
* our base source.
*/
@@ -54,4 +54,9 @@ public class RelativeResourceLocator implements ResourceLocator {
}
return false;
}
+
+ @Override
+ public int hashCode() {
+ return _baseSource.hashCode();
+ }
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/resource/ResourceLocatorTool.java b/ardor3d-core/src/main/java/com/ardor3d/util/resource/ResourceLocatorTool.java
index 353c45a..f00b20d 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/resource/ResourceLocatorTool.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/resource/ResourceLocatorTool.java
@@ -37,7 +37,7 @@ public class ResourceLocatorTool {
public static final String TYPE_AUDIO = "audio";
public static final String TYPE_SHADER = "shader";
- private static final Map<String, List<ResourceLocator>> _locatorMap = new HashMap<String, List<ResourceLocator>>();
+ private static final Map<String, List<ResourceLocator>> _locatorMap = new HashMap<>();
public static ResourceSource locateResource(final String resourceType, String resourceName) {
if (resourceName == null) {
@@ -84,7 +84,7 @@ public class ResourceLocatorTool {
synchronized (_locatorMap) {
List<ResourceLocator> bases = _locatorMap.get(resourceType);
if (bases == null) {
- bases = new ArrayList<ResourceLocator>();
+ bases = new ArrayList<>();
_locatorMap.put(resourceType, bases);
}
@@ -162,7 +162,7 @@ public class ResourceLocatorTool {
* @return a set containing the located URLs of the named resource.
*/
public static Set<URL> getClassPathResources(final Class<?> clazz, final String name) {
- final Set<URL> results = new HashSet<URL>();
+ final Set<URL> results = new HashSet<>();
Enumeration<URL> urls = null;
try {
urls = Thread.currentThread().getContextClassLoader().getResources(name);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.java b/ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.java
index bb6734d..62b9470 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.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>.
*/
@@ -27,7 +27,7 @@ public class SimpleResourceLocator implements ResourceLocator {
/**
* Construct a new SimpleResourceLocator using the given URI as our context.
- *
+ *
* @param baseDir
* our base context. This is meant to be a "directory" wherein we will search for resources. Therefore,
* if it does not end in /, a / will be added to ensure we are talking about children of the given
@@ -52,7 +52,7 @@ public class SimpleResourceLocator implements ResourceLocator {
/**
* Construct a new SimpleResourceLocator using the given URL as our context.
- *
+ *
* @param baseDir
* our base context. This is converted to a URI. This is meant to be a "directory" wherein we will search
* for resources. Therefore, if it does not end in /, a / will be added to ensure we are talking about
@@ -136,4 +136,9 @@ public class SimpleResourceLocator implements ResourceLocator {
}
return false;
}
+
+ @Override
+ public int hashCode() {
+ return _baseDir.hashCode();
+ }
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.java b/ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.java
index a2769a2..79c820e 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.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>.
*/
@@ -15,6 +15,7 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
+import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -38,7 +39,7 @@ public class URLResourceSource implements ResourceSource {
/**
* Construct a new URLResourceSource from a specific URL.
- *
+ *
* @param sourceUrl
* The url to load the resource from. Must not be null. If the URL has a valid URL filename (see
* {@link URL#getFile()}) and an extension (eg. http://url/myFile.png) then the extension (.png in this
@@ -62,7 +63,7 @@ public class URLResourceSource implements ResourceSource {
/**
* Construct a new URLResourceSource from a specific URL and type.
- *
+ *
* @param sourceUrl
* The url to load the resource from. Must not be null.
* @param type
@@ -136,11 +137,7 @@ public class URLResourceSource implements ResourceSource {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((_type == null) ? 0 : _type.hashCode());
- result = prime * result + ((_urlToString == null) ? 0 : _urlToString.hashCode());
- return result;
+ return Objects.hash(getType(), getName());
}
@Override
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/DisplayListDelegate.java b/ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/DisplayListDelegate.java
index 57471ff..16cd314 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/DisplayListDelegate.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/DisplayListDelegate.java
@@ -27,10 +27,10 @@ import com.google.common.collect.Multimap;
public class DisplayListDelegate implements RenderDelegate {
- private static Map<DisplayListDelegate, Object> _identityCache = new WeakHashMap<DisplayListDelegate, Object>();
+ private static Map<DisplayListDelegate, Object> _identityCache = new WeakHashMap<>();
private static final Object STATIC_REF = new Object();
- private static ReferenceQueue<DisplayListDelegate> _refQueue = new ReferenceQueue<DisplayListDelegate>();
+ private static ReferenceQueue<DisplayListDelegate> _refQueue = new ReferenceQueue<>();
static {
ContextManager.addContextCleanListener(new ContextCleanListener() {
@@ -44,7 +44,7 @@ public class DisplayListDelegate implements RenderDelegate {
private final SimpleContextIdReference<DisplayListDelegate> _id;
public DisplayListDelegate(final int id, final Object glContext) {
- _id = new SimpleContextIdReference<DisplayListDelegate>(this, _refQueue, id, glContext);
+ _id = new SimpleContextIdReference<>(this, _refQueue, id, glContext);
_identityCache.put(this, STATIC_REF);
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/shader/ShaderVariable.java b/ardor3d-core/src/main/java/com/ardor3d/util/shader/ShaderVariable.java
index 13f97af..2c211b5 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/shader/ShaderVariable.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/shader/ShaderVariable.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,6 +11,7 @@
package com.ardor3d.util.shader;
import java.io.IOException;
+import java.util.Objects;
import com.ardor3d.util.export.InputCapsule;
import com.ardor3d.util.export.OutputCapsule;
@@ -41,11 +42,7 @@ public class ShaderVariable implements Savable {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + variableID;
- return result;
+ return Objects.hash(name, Integer.valueOf(variableID));
}
@Override
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/MultiStatSample.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/MultiStatSample.java
index 0b85ad2..e2f8d99 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/MultiStatSample.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/MultiStatSample.java
@@ -14,7 +14,7 @@ import java.util.HashMap;
import java.util.Set;
public class MultiStatSample {
- private final HashMap<StatType, StatValue> _values = new HashMap<StatType, StatValue>();
+ private final HashMap<StatType, StatValue> _values = new HashMap<>();
private double _elapsedTime = 0.0;
public static MultiStatSample createNew(final HashMap<StatType, StatValue> current) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/StatCollector.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/StatCollector.java
index 0c54a43..b8fc49e 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/StatCollector.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/StatCollector.java
@@ -38,7 +38,7 @@ public abstract class StatCollector {
* Our map of current stat values. Current means values that have been collected within the current time sample. For
* example, if sampleRate = 1.0, then current will hold values collected since the last 1 second ping.
*/
- protected static HashMap<StatType, StatValue> current = new HashMap<StatType, StatValue>();
+ protected static HashMap<StatType, StatValue> current = new HashMap<>();
protected static List<MultiStatSample> historical = Collections.synchronizedList(new LinkedList<MultiStatSample>());
@@ -51,14 +51,14 @@ public abstract class StatCollector {
protected static double lastTimeCheckMS = 0;
- protected static List<StatListener> listeners = new ArrayList<StatListener>();
+ protected static List<StatListener> listeners = new ArrayList<>();
protected static double startOffset = 0;
protected static boolean ignoreStats = false;
- protected static Stack<StatType> timeStatStack = new Stack<StatType>();
- protected static HashSet<StatType> timedStats = new HashSet<StatType>();
+ protected static Stack<StatType> timeStatStack = new Stack<>();
+ protected static HashSet<StatType> timedStats = new HashSet<>();
protected static Timer timer = new Timer();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/StatType.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/StatType.java
index 42bfee6..6cdfbab 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/StatType.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/StatType.java
@@ -3,13 +3,15 @@
*
* 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.stat;
+import java.util.Objects;
+
public class StatType implements Comparable<StatType> {
public static final StatType STAT_FRAMES = new StatType("_frames");
@@ -56,8 +58,7 @@ public class StatType implements Comparable<StatType> {
@Override
public int hashCode() {
- final int hash = _statName.hashCode();
- return hash;
+ return Objects.hashCode(getStatName());
}
@Override
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/AbstractStatGrapher.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/AbstractStatGrapher.java
index 9b9d3d6..a81c19f 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/AbstractStatGrapher.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/AbstractStatGrapher.java
@@ -31,7 +31,7 @@ public abstract class AbstractStatGrapher implements StatListener {
protected Texture2D _texture;
protected int _gWidth, _gHeight;
- protected TreeMap<StatType, HashMap<String, Object>> _config = new TreeMap<StatType, HashMap<String, Object>>();
+ protected TreeMap<StatType, HashMap<String, Object>> _config = new TreeMap<>();
protected boolean _enabled = true;
@@ -92,7 +92,7 @@ public abstract class AbstractStatGrapher implements StatListener {
public void addConfig(final StatType type, final String key, final Object value) {
HashMap<String, Object> vals = _config.get(type);
if (vals == null) {
- vals = new HashMap<String, Object>();
+ vals = new HashMap<>();
_config.put(type, vals);
}
vals.put(key, value);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/LineGrapher.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/LineGrapher.java
index 6e84991..4ccc49b 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/LineGrapher.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/LineGrapher.java
@@ -53,7 +53,7 @@ public class LineGrapher extends AbstractStatGrapher implements TableLinkable {
private static final int majorHBar = 20;
private static final int majorVBar = 10;
- private final HashMap<StatType, LineEntry> _entries = new HashMap<StatType, LineEntry>();
+ private final HashMap<StatType, LineEntry> _entries = new HashMap<>();
private BlendState _defBlendState = null;
@@ -267,7 +267,7 @@ public class LineGrapher extends AbstractStatGrapher implements TableLinkable {
}
class LineEntry {
- public List<Vector3> verts = new ArrayList<Vector3>();
+ public List<Vector3> verts = new ArrayList<>();
public int maxSamples;
public double min = 0;
public double max = 10;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java
index 316a77e..a81af4f 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java
@@ -48,7 +48,7 @@ public class TabledLabelGrapher extends AbstractStatGrapher {
protected BlendState _defBlendState = null;
- private final HashMap<StatType, LabelEntry> _entries = new HashMap<StatType, LabelEntry>();
+ private final HashMap<StatType, LabelEntry> _entries = new HashMap<>();
private boolean _minimalBackground;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java
index 9f650ea..e423e04 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java
@@ -53,7 +53,7 @@ public class TimedAreaGrapher extends AbstractStatGrapher implements TableLinkab
private static final int majorHBar = 20;
private static final int majorVBar = 10;
- private final HashMap<StatType, AreaEntry> _entries = new HashMap<StatType, AreaEntry>();
+ private final HashMap<StatType, AreaEntry> _entries = new HashMap<>();
private BlendState _defBlendState = null;
@@ -263,7 +263,7 @@ public class TimedAreaGrapher extends AbstractStatGrapher implements TableLinkab
}
class AreaEntry {
- public List<Vector3> verts = new ArrayList<Vector3>();
+ public List<Vector3> verts = new ArrayList<>();
public int maxSamples;
public boolean visited;
public Mesh area;