From d237ed758b38397a9142fd2982da5aca60d9cd78 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Fri, 24 May 2013 11:24:22 +0200 Subject: [PATCH] Cleaned up warnings, #50. --- .../.settings/org.eclipse.jdt.core.prefs | 36 +++++++++---------- .../spine/AnimationStateData.java | 8 ++--- .../com/esotericsoftware/spine/Skeleton.java | 3 -- .../spine/SkeletonBinary.java | 9 +++-- .../esotericsoftware/spine/SkeletonJson.java | 8 ++--- .../spine/SkeletonRendererDebug.java | 6 ++-- .../spine/attachments/Attachment.java | 4 --- .../spine/attachments/RegionAttachment.java | 2 -- .../attachments/RegionSequenceAttachment.java | 1 - .../spine/AnimationStateTest.java | 4 +-- .../com/esotericsoftware/spine/MixTest.java | 5 +-- .../esotericsoftware/spine/SkeletonTest.java | 5 +-- 12 files changed, 37 insertions(+), 54 deletions(-) diff --git a/spine-libgdx/.settings/org.eclipse.jdt.core.prefs b/spine-libgdx/.settings/org.eclipse.jdt.core.prefs index 1f51694d7..7f8a35b9c 100644 --- a/spine-libgdx/.settings/org.eclipse.jdt.core.prefs +++ b/spine-libgdx/.settings/org.eclipse.jdt.core.prefs @@ -13,14 +13,14 @@ org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.autoboxing=warning org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=ignore org.eclipse.jdt.core.compiler.problem.deprecation=ignore org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore @@ -39,11 +39,11 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore @@ -54,13 +54,13 @@ org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled @@ -71,25 +71,25 @@ org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled -org.eclipse.jdt.core.compiler.problem.unusedImport=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.6 diff --git a/spine-libgdx/src/com/esotericsoftware/spine/AnimationStateData.java b/spine-libgdx/src/com/esotericsoftware/spine/AnimationStateData.java index 971db62d4..55a169ab6 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/AnimationStateData.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/AnimationStateData.java @@ -25,12 +25,12 @@ package com.esotericsoftware.spine; -import com.badlogic.gdx.utils.ObjectMap; +import com.badlogic.gdx.utils.ObjectFloatMap; /** Stores mixing times between animations. */ public class AnimationStateData { private final SkeletonData skeletonData; - final ObjectMap animationToMixTime = new ObjectMap(); + final ObjectFloatMap animationToMixTime = new ObjectFloatMap(); final Key tempKey = new Key(); public AnimationStateData (SkeletonData skeletonData) { @@ -61,8 +61,8 @@ public class AnimationStateData { public float getMix (Animation from, Animation to) { tempKey.a1 = from; tempKey.a2 = to; - Float time = animationToMixTime.get(tempKey); - if (time == null) return 0; + float time = animationToMixTime.get(tempKey, Float.MIN_VALUE); + if (time == Float.MIN_VALUE) return 0; return time; } diff --git a/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java b/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java index b221eda98..a1a2a6c4c 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java @@ -28,9 +28,6 @@ package com.esotericsoftware.spine; import com.esotericsoftware.spine.attachments.Attachment; import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.graphics.glutils.ShapeRenderer; -import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.utils.Array; public class Skeleton { diff --git a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java index 54b68d281..80074efce 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java @@ -32,20 +32,19 @@ import com.esotericsoftware.spine.Animation.RotateTimeline; import com.esotericsoftware.spine.Animation.ScaleTimeline; import com.esotericsoftware.spine.Animation.Timeline; import com.esotericsoftware.spine.Animation.TranslateTimeline; +import com.esotericsoftware.spine.attachments.AtlasAttachmentLoader; import com.esotericsoftware.spine.attachments.Attachment; import com.esotericsoftware.spine.attachments.AttachmentLoader; import com.esotericsoftware.spine.attachments.AttachmentType; import com.esotericsoftware.spine.attachments.RegionAttachment; import com.esotericsoftware.spine.attachments.RegionSequenceAttachment; import com.esotericsoftware.spine.attachments.RegionSequenceAttachment.Mode; -import com.esotericsoftware.spine.attachments.AtlasAttachmentLoader; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.DataInput; -import com.badlogic.gdx.utils.OrderedMap; import com.badlogic.gdx.utils.SerializationException; import java.io.IOException; @@ -140,9 +139,13 @@ public class SkeletonBinary { for (int i = 0, n = input.readInt(true); i < n; i++) readAnimation(input.readString(), input, skeletonData); - input.close(); } catch (IOException ex) { throw new SerializationException("Error reading skeleton file.", ex); + } finally { + try { + input.close(); + } catch (IOException ignored) { + } } skeletonData.bones.shrink(); diff --git a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java index 974f115a2..e111bff61 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java @@ -44,7 +44,6 @@ import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.utils.Array; -import com.badlogic.gdx.utils.Json; import com.badlogic.gdx.utils.JsonReader; import com.badlogic.gdx.utils.JsonValue; import com.badlogic.gdx.utils.SerializationException; @@ -56,7 +55,6 @@ public class SkeletonJson { static public final String TIMELINE_ATTACHMENT = "attachment"; static public final String TIMELINE_COLOR = "color"; - private final Json json = new Json(); private final AttachmentLoader attachmentLoader; private float scale = 1; @@ -217,8 +215,8 @@ public class SkeletonJson { int frameIndex = 0; for (JsonValue valueMap = timelineMap.child(); valueMap != null; valueMap = valueMap.next()) { float time = valueMap.getFloat("time"); - Float x = valueMap.getFloat("x"), y = valueMap.getFloat("y"); - timeline.setFrame(frameIndex, time, x == null ? 0 : (x * timelineScale), y == null ? 0 : (y * timelineScale)); + float x = valueMap.getFloat("x", 0), y = valueMap.getFloat("y", 0); + timeline.setFrame(frameIndex, time, x * timelineScale, y * timelineScale); readCurve(timeline, frameIndex, valueMap); frameIndex++; } @@ -234,7 +232,7 @@ public class SkeletonJson { int slotIndex = skeletonData.findSlotIndex(slotMap.name()); for (JsonValue timelineMap = slotMap.child(); timelineMap != null; timelineMap = timelineMap.next()) { - String timelineName = (String)timelineMap.name(); + String timelineName = timelineMap.name(); if (timelineName.equals(TIMELINE_COLOR)) { ColorTimeline timeline = new ColorTimeline(timelineMap.size()); timeline.setSlotIndex(slotIndex); diff --git a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRendererDebug.java b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRendererDebug.java index d23e5faf5..e1e5bffed 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRendererDebug.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRendererDebug.java @@ -4,11 +4,11 @@ package com.esotericsoftware.spine; import com.esotericsoftware.spine.attachments.Attachment; import com.esotericsoftware.spine.attachments.RegionAttachment; +import static com.badlogic.gdx.graphics.g2d.SpriteBatch.*; + import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL10; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import static com.badlogic.gdx.graphics.g2d.SpriteBatch.*; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.utils.Array; @@ -22,7 +22,7 @@ public class SkeletonRendererDebug { renderer = new ShapeRenderer(); } - public void draw (SpriteBatch batch, Skeleton skeleton) { + public void draw (Skeleton skeleton) { Gdx.gl.glEnable(GL10.GL_BLEND); renderer.begin(ShapeType.Line); diff --git a/spine-libgdx/src/com/esotericsoftware/spine/attachments/Attachment.java b/spine-libgdx/src/com/esotericsoftware/spine/attachments/Attachment.java index c0b128cea..dfa12a280 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/attachments/Attachment.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/attachments/Attachment.java @@ -25,10 +25,6 @@ package com.esotericsoftware.spine.attachments; -import com.esotericsoftware.spine.Slot; - -import com.badlogic.gdx.graphics.g2d.SpriteBatch; - abstract public class Attachment { final String name; diff --git a/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionAttachment.java b/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionAttachment.java index 271321063..08f4c484a 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionAttachment.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionAttachment.java @@ -31,7 +31,6 @@ import com.esotericsoftware.spine.Slot; import static com.badlogic.gdx.graphics.g2d.SpriteBatch.*; import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.MathUtils; @@ -101,7 +100,6 @@ public class RegionAttachment extends Attachment { public void setRegion (TextureRegion region) { if (region == null) throw new IllegalArgumentException("region cannot be null."); - TextureRegion oldRegion = this.region; this.region = region; float[] vertices = this.vertices; if (region instanceof AtlasRegion && ((AtlasRegion)region).rotate) { diff --git a/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionSequenceAttachment.java b/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionSequenceAttachment.java index 7c762332c..2b002bf1b 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionSequenceAttachment.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionSequenceAttachment.java @@ -27,7 +27,6 @@ package com.esotericsoftware.spine.attachments; import com.esotericsoftware.spine.Slot; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.MathUtils; diff --git a/spine-libgdx/test/com/esotericsoftware/spine/AnimationStateTest.java b/spine-libgdx/test/com/esotericsoftware/spine/AnimationStateTest.java index 249516ff4..2e39ecb19 100644 --- a/spine-libgdx/test/com/esotericsoftware/spine/AnimationStateTest.java +++ b/spine-libgdx/test/com/esotericsoftware/spine/AnimationStateTest.java @@ -28,12 +28,10 @@ package com.esotericsoftware.spine; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.InputAdapter; -import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.backends.lwjgl.LwjglApplication; import com.badlogic.gdx.graphics.GL10; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureAtlas; -import com.badlogic.gdx.graphics.glutils.ShapeRenderer; public class AnimationStateTest extends ApplicationAdapter { SpriteBatch batch; @@ -103,7 +101,7 @@ public class AnimationStateTest extends ApplicationAdapter { renderer.draw(batch, skeleton); batch.end(); - debugRenderer.draw(batch, skeleton); + debugRenderer.draw(skeleton); } public void resize (int width, int height) { diff --git a/spine-libgdx/test/com/esotericsoftware/spine/MixTest.java b/spine-libgdx/test/com/esotericsoftware/spine/MixTest.java index df44e0e4e..aa75cf803 100644 --- a/spine-libgdx/test/com/esotericsoftware/spine/MixTest.java +++ b/spine-libgdx/test/com/esotericsoftware/spine/MixTest.java @@ -28,12 +28,9 @@ package com.esotericsoftware.spine; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.backends.lwjgl.LwjglApplication; -import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; -import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL10; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureAtlas; -import com.badlogic.gdx.graphics.glutils.ShapeRenderer; public class MixTest extends ApplicationAdapter { SpriteBatch batch; @@ -128,7 +125,7 @@ public class MixTest extends ApplicationAdapter { renderer.draw(batch, skeleton); batch.end(); - debugRenderer.draw(batch, skeleton); + debugRenderer.draw(skeleton); } public void resize (int width, int height) { diff --git a/spine-libgdx/test/com/esotericsoftware/spine/SkeletonTest.java b/spine-libgdx/test/com/esotericsoftware/spine/SkeletonTest.java index fdf6e3486..d132e0d30 100644 --- a/spine-libgdx/test/com/esotericsoftware/spine/SkeletonTest.java +++ b/spine-libgdx/test/com/esotericsoftware/spine/SkeletonTest.java @@ -27,10 +27,8 @@ package com.esotericsoftware.spine; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.InputAdapter; import com.badlogic.gdx.backends.lwjgl.LwjglApplication; -import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL10; @@ -41,7 +39,6 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData; -import com.badlogic.gdx.graphics.glutils.ShapeRenderer; public class SkeletonTest extends ApplicationAdapter { SpriteBatch batch; @@ -133,7 +130,7 @@ public class SkeletonTest extends ApplicationAdapter { renderer.draw(batch, skeleton); batch.end(); - debugRenderer.draw(batch, skeleton); + debugRenderer.draw(skeleton); } public void resize (int width, int height) {