diff options
author | Julien Gouesse <[email protected]> | 2019-05-27 14:16:01 +0200 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2019-05-27 14:16:01 +0200 |
commit | c9294898d899661a0273d02073fe377190e0c2c6 (patch) | |
tree | 35a2e797ef445ef068d19f380f15cd4c74e0ed4d /ardor3d-ui | |
parent | 96db828395035ad839f282c2d48ca147ac5a1c4f (diff) |
Replaces Guava's Multimap by Java Map in ardor3d-ui (issue #13)
Diffstat (limited to 'ardor3d-ui')
-rw-r--r-- | ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextFactory.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextFactory.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextFactory.java index eb132d9..463e96d 100644 --- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextFactory.java +++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextFactory.java @@ -12,7 +12,6 @@ package com.ardor3d.extension.ui.text; import java.nio.FloatBuffer; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; @@ -33,8 +32,6 @@ import com.ardor3d.renderer.state.BlendState; import com.ardor3d.renderer.state.TextureState; import com.ardor3d.scenegraph.FloatBufferData; import com.ardor3d.scenegraph.MeshData; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; public enum TextFactory { INSTANCE; @@ -119,7 +116,7 @@ public enum TextFactory { final List<Integer> lineEnds = textData._lineEnds; final List<Integer> lineHeights = textData._lineHeights; // indexed by the used Texture - final Multimap<Texture2D, Integer> descIndices = ArrayListMultimap.create(); + final Map<Texture2D, List<Integer>> descIndices = new HashMap<>(); int maxLineHeight = 0, xOffset = 0, maxSizeHeight = 0; UIFont prevFont = null; double scale = 1, prevScale = 0; @@ -232,7 +229,16 @@ public enum TextFactory { maxLineHeight = Math.max((int) Math.round(scale * font.getFontSize()), maxLineHeight); // add a pointer to it for the associated texture - descIndices.put(font.getFontTexture(), descs.size() - 1); + descIndices.compute(font.getFontTexture(), (final Texture2D key, final List<Integer> oldValue) -> { + final List<Integer> value; + if (oldValue == null) { + value = new ArrayList<>(); + } else { + value = oldValue; + } + value.add(Integer.valueOf(descs.size() - 1)); + return value; + }); // store our xOffset and line height descXStarts.add(xOffset); @@ -257,11 +263,11 @@ public enum TextFactory { } // use parsed information to create our textmeshes - Collection<Integer> indices; float t, b, l, r, inverseTextureHeight, inverseTextureWidth; CharacterDescriptor charDesc; int cursorY, lineHeight, maxSizeWidth = 0; - for (final Texture2D tex : descIndices.keySet()) { + for (final Map.Entry<Texture2D, List<Integer>> descIndicesEntry : descIndices.entrySet()) { + final Texture2D tex = descIndicesEntry.getKey(); inverseTextureHeight = 1f / tex.getImage().getHeight(); inverseTextureWidth = 1f / tex.getImage().getWidth(); @@ -270,7 +276,7 @@ public enum TextFactory { // apply render states applyStates(tMesh, tex); - indices = descIndices.get(tex); + final List<Integer> indices = descIndicesEntry.getValue(); // setup buffers based on number of indices we have final MeshData mData = tMesh.getMeshData(); |