diff --git a/src/java/com/threerings/cast/CharacterManager.java b/src/java/com/threerings/cast/CharacterManager.java index 6befd51f..3824c9de 100644 --- a/src/java/com/threerings/cast/CharacterManager.java +++ b/src/java/com/threerings/cast/CharacterManager.java @@ -28,6 +28,7 @@ import java.util.Map; import java.awt.Point; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.samskivert.util.LRUHashMap; @@ -179,7 +180,7 @@ public class CharacterManager frames = createCompositeFrames(descrip, action); _actionFrames.put(key, frames); } - + // periodically report our frame image cache performance if (!_cacheStatThrottle.throttleOp()) { long size = getEstimatedCacheMemoryUsage(); @@ -264,10 +265,10 @@ public class CharacterManager // maps components by class name for masks HashMap> ccomps = - new HashMap>(); + Maps.newHashMap(); // create colorized versions of all of the source action frames - ArrayList sources = new ArrayList(ccount); + ArrayList sources = Lists.newArrayListWithCapacity(ccount); for (int ii = 0; ii < ccount; ii++) { ComponentFrames cframes = new ComponentFrames(); sources.add(cframes); @@ -291,20 +292,18 @@ public class CharacterManager TranslatedComponent tcomp = new TranslatedComponent(ccomp, xlation); ArrayList tcomps = ccomps.get(ccomp.componentClass.name); if (tcomps == null) { - ccomps.put(ccomp.componentClass.name, - tcomps = new ArrayList()); + ccomps.put(ccomp.componentClass.name, tcomps = Lists.newArrayList()); } tcomps.add(tcomp); // if this component has a shadow, make a note of it if (ccomp.componentClass.isShadowed()) { if (shadows == null) { - shadows = new HashMap>(); + shadows = Maps.newHashMap(); } ArrayList shadlist = shadows.get(ccomp.componentClass.shadow); if (shadlist == null) { - shadows.put(ccomp.componentClass.shadow, - shadlist = new ArrayList()); + shadows.put(ccomp.componentClass.shadow, shadlist = Lists.newArrayList()); } shadlist.add(tcomp); } @@ -349,7 +348,7 @@ public class CharacterManager // create a fake component for the shadow layer cframes.ccomp = new CharacterComponent(-1, "shadow", cclass, null); - ArrayList sources = new ArrayList(); + ArrayList sources = Lists.newArrayList(); for (TranslatedComponent scomp : scomps) { ComponentFrames source = new ComponentFrames(); source.ccomp = scomp.ccomp; @@ -384,7 +383,7 @@ public class CharacterManager String action, CharacterComponent ccomp, ActionFrames cframes, ArrayList mcomps) { - ArrayList sources = new ArrayList(); + ArrayList sources = Lists.newArrayList(); sources.add(new ComponentFrames(ccomp, cframes)); for (TranslatedComponent mcomp : mcomps) { ActionFrames mframes = mcomp.getFrames(action, StandardActions.CROP_TYPE); @@ -435,7 +434,7 @@ public class CharacterManager /** A table of composited action sequences (these don't reference the * actual image data directly and thus take up little memory). */ - protected Map, ActionFrames> _actionFrames = + protected Map, ActionFrames> _actionFrames = Maps.newHashMap(); /** A cache of composited animation frames. */ @@ -457,7 +456,7 @@ public class CharacterManager "Size (in kb of memory used) of the character manager LRU " + "action cache [requires restart]", "narya.cast.action_cache_size", CastPrefs.config, 32768); - + /** * Cache size to be used in this run. Adjusted by setCacheSize without affecting * the stored value. diff --git a/src/java/com/threerings/cast/builder/BuilderModel.java b/src/java/com/threerings/cast/builder/BuilderModel.java index e97af56e..f7bef64d 100644 --- a/src/java/com/threerings/cast/builder/BuilderModel.java +++ b/src/java/com/threerings/cast/builder/BuilderModel.java @@ -27,6 +27,9 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + import com.samskivert.util.CollectionUtil; import com.threerings.cast.ComponentClass; @@ -84,7 +87,7 @@ public class BuilderModel { List list = _components.get(cclass); if (list == null) { - list = new ArrayList(); + list = Lists.newArrayList(); } return list; } @@ -129,7 +132,7 @@ public class BuilderModel Integer cid = iter.next(); ArrayList clist = _components.get(cclass); if (clist == null) { - _components.put(cclass, clist = new ArrayList()); + _components.put(cclass, clist = Lists.newArrayList()); } clist.add(cid); @@ -138,14 +141,14 @@ public class BuilderModel } /** The currently selected character components. */ - protected HashMap _selected = new HashMap(); + protected HashMap _selected = Maps.newHashMap(); /** The hashtable of available component ids for each class. */ - protected HashMap> _components = new HashMap>(); + protected HashMap> _components = Maps.newHashMap(); /** The list of all available component classes. */ - protected ArrayList _classes = new ArrayList(); + protected ArrayList _classes = Lists.newArrayList(); /** The model listeners. */ - protected ArrayList _listeners = new ArrayList(); + protected ArrayList _listeners = Lists.newArrayList(); } diff --git a/src/java/com/threerings/cast/bundle/BundledComponentRepository.java b/src/java/com/threerings/cast/bundle/BundledComponentRepository.java index 2f1191ec..a613407e 100644 --- a/src/java/com/threerings/cast/bundle/BundledComponentRepository.java +++ b/src/java/com/threerings/cast/bundle/BundledComponentRepository.java @@ -32,6 +32,7 @@ import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.image.BufferedImage; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.samskivert.util.IntIntMap; @@ -256,7 +257,7 @@ public class BundledComponentRepository // we have a hash of lists for mapping components by class/name ArrayList comps = _classComps.get(cclass); if (comps == null) { - comps = new ArrayList(); + comps = Lists.newArrayList(); _classComps.put(cclass, comps); } if (!comps.contains(component)) { diff --git a/src/java/com/threerings/cast/bundle/tools/ComponentBundlerTask.java b/src/java/com/threerings/cast/bundle/tools/ComponentBundlerTask.java index 372583db..8abe6735 100644 --- a/src/java/com/threerings/cast/bundle/tools/ComponentBundlerTask.java +++ b/src/java/com/threerings/cast/bundle/tools/ComponentBundlerTask.java @@ -51,6 +51,8 @@ import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; +import com.google.common.collect.Lists; + import com.samskivert.io.PersistenceException; import com.samskivert.util.ComparableArrayList; import com.samskivert.util.FileUtil; @@ -152,7 +154,7 @@ public class ComponentBundlerTask extends Task // check to see if any of the source files are newer than the // target file - ArrayList sources = new ArrayList(); + ArrayList sources = Lists.newArrayList(); sources.addAll(_filesets); sources.add(_mapfile); sources.add(_actionDef); @@ -186,8 +188,8 @@ public class ComponentBundlerTask extends Task File fromDir = fs.getDir(getProject()); String[] srcFiles = ds.getIncludedFiles(); - for (int f = 0; f < srcFiles.length; f++) { - File cfile = new File(fromDir, srcFiles[f]); + for (String srcFile : srcFiles) { + File cfile = new File(fromDir, srcFile); // determine the [class, name, action] triplet String[] info = decomposePath(cfile.getPath()); @@ -214,11 +216,11 @@ public class ComponentBundlerTask extends Task // crop files String action = info[2]; String ext = BundleUtil.IMAGE_EXTENSION; - for (int aa = 0; aa < AUX_EXTS.length; aa++) { + for (String element : AUX_EXTS) { File afile = new File( - FileUtil.resuffix(cfile, ext, AUX_EXTS[aa] + ext)); + FileUtil.resuffix(cfile, ext, element + ext)); if (afile.exists()) { - info[2] = action + AUX_EXTS[aa]; + info[2] = action + element; processComponent(info, aset, afile, fout, newest); } } @@ -314,8 +316,8 @@ public class ComponentBundlerTask extends Task File fromDir = fs.getDir(getProject()); String[] srcFiles = ds.getIncludedFiles(); long newest = 0L; - for (int f = 0; f < srcFiles.length; f++) { - File cfile = new File(fromDir, srcFiles[f]); + for (String srcFile : srcFiles) { + File cfile = new File(fromDir, srcFile); newest = Math.max(newest, cfile.lastModified()); } return newest; @@ -667,7 +669,7 @@ public class ComponentBundlerTask extends Task protected String _root; /** A list of filesets that contain tile images. */ - protected ArrayList _filesets = new ArrayList(); + protected ArrayList _filesets = Lists.newArrayList(); /** Used to separate keys and values in the map file. */ protected static final String SEP_STR = " := "; diff --git a/src/java/com/threerings/cast/bundle/tools/MetadataBundlerTask.java b/src/java/com/threerings/cast/bundle/tools/MetadataBundlerTask.java index 66a9ea62..7a54e75d 100644 --- a/src/java/com/threerings/cast/bundle/tools/MetadataBundlerTask.java +++ b/src/java/com/threerings/cast/bundle/tools/MetadataBundlerTask.java @@ -22,7 +22,6 @@ package com.threerings.cast.bundle.tools; import java.util.ArrayList; -import java.util.HashMap; import java.util.Map; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; @@ -41,6 +40,9 @@ import org.apache.commons.digester.Digester; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + import com.samskivert.util.Tuple; import com.threerings.media.tile.TileSet; @@ -203,8 +205,8 @@ public class MetadataBundlerTask extends Task } // now create our mappings - Map actmap = new HashMap(); - Map setmap = new HashMap(); + Map actmap = Maps.newHashMap(); + Map setmap = Maps.newHashMap(); // create the action map for (int i = 0; i < setlist.size(); i++) { @@ -239,7 +241,7 @@ public class MetadataBundlerTask extends Task "add", Object.class.getName()); ArrayList setlist = parseList(digester, _classDef); - Map clmap = new HashMap(); + Map clmap = Maps.newHashMap(); // create the action map for (int i = 0; i < setlist.size(); i++) { @@ -257,7 +259,7 @@ public class MetadataBundlerTask extends Task FileInputStream fin = new FileInputStream(path); BufferedInputStream bin = new BufferedInputStream(fin); - ArrayList setlist = new ArrayList(); + ArrayList setlist = Lists.newArrayList(); digester.push(setlist); // now fire up the digester to parse the stream diff --git a/src/java/com/threerings/cast/util/CastUtil.java b/src/java/com/threerings/cast/util/CastUtil.java index 18526ede..64337495 100644 --- a/src/java/com/threerings/cast/util/CastUtil.java +++ b/src/java/com/threerings/cast/util/CastUtil.java @@ -24,6 +24,8 @@ package com.threerings.cast.util; import java.util.ArrayList; import java.util.Iterator; +import com.google.common.collect.Lists; + import com.samskivert.util.CollectionUtil; import com.samskivert.util.RandomUtil; @@ -46,9 +48,9 @@ public class CastUtil String gender, ComponentRepository crepo) { // get all available classes - ArrayList classes = new ArrayList(); - for (int i = 0; i < CLASSES.length; i++) { - String cname = gender + "/" + CLASSES[i]; + ArrayList classes = Lists.newArrayList(); + for (String element : CLASSES) { + String cname = gender + "/" + element; ComponentClass cclass = crepo.getComponentClass(cname); // make sure the component class exists @@ -76,7 +78,7 @@ public class CastUtil ComponentClass cclass = classes.get(ii); // get the components available for this class - ArrayList choices = new ArrayList(); + ArrayList choices = Lists.newArrayList(); Iterator iter = crepo.enumerateComponentIds(cclass); CollectionUtil.addAll(choices, iter); diff --git a/src/java/com/threerings/jme/model/Model.java b/src/java/com/threerings/jme/model/Model.java index c5254d62..397e38ec 100644 --- a/src/java/com/threerings/jme/model/Model.java +++ b/src/java/com/threerings/jme/model/Model.java @@ -365,7 +365,7 @@ public class Model extends ModelNode protected Model _toCopy; /** The set of added properties. */ - protected HashSet _properties = new HashSet(); + protected HashSet _properties = Sets.newHashSet(); } /** @@ -443,7 +443,7 @@ public class Model extends ModelNode public void addAnimation (String name, Animation anim) { if (_anims == null) { - _anims = new HashMap(); + _anims = Maps.newHashMap(); } _anims.put(name, anim); @@ -727,7 +727,7 @@ public class Model extends ModelNode if (animNames != null) { Savable[] animValues = capsule.readSavableArray( "animValues", null); - _anims = new HashMap(); + _anims = Maps.newHashMap(); for (int ii = 0; ii < animNames.length; ii++) { _anims.put(animNames[ii], (Animation)animValues[ii]); } @@ -839,7 +839,7 @@ public class Model extends ModelNode { // collect the instance's animation and controller targets and lock // recursively - HashSet targets = new HashSet(); + HashSet targets = Sets.newHashSet(); for (String aname : getAnimationNames()) { Collections.addAll(targets, getAnimation(aname).transformTargets); } @@ -872,7 +872,7 @@ public class Model extends ModelNode } mstore._prototype = this; if (_anims != null) { - mstore._anims = new HashMap(); + mstore._anims = Maps.newHashMap(); } mstore._pnodes = Maps.newHashMap(properties.originalToCopy); mstore._animMode = _animMode; diff --git a/src/java/com/threerings/jme/model/ModelController.java b/src/java/com/threerings/jme/model/ModelController.java index c8783d41..31b7ba8c 100644 --- a/src/java/com/threerings/jme/model/ModelController.java +++ b/src/java/com/threerings/jme/model/ModelController.java @@ -53,7 +53,7 @@ public abstract class ModelController extends Controller if (anims.length == 0) { return; } - _animations = new HashSet(); + _animations = Sets.newHashSet(); Collections.addAll(_animations, anims); } @@ -120,7 +120,7 @@ public abstract class ModelController extends Controller _target = (Spatial)capsule.readSavable("target", null); String[] anims = capsule.readStringArray("animations", null); if (anims != null) { - _animations = new HashSet(); + _animations = Sets.newHashSet(); Collections.addAll(_animations, anims); } else { _animations = null; diff --git a/src/java/com/threerings/jme/model/ModelMesh.java b/src/java/com/threerings/jme/model/ModelMesh.java index 2926b898..95afac29 100644 --- a/src/java/com/threerings/jme/model/ModelMesh.java +++ b/src/java/com/threerings/jme/model/ModelMesh.java @@ -161,7 +161,7 @@ public class ModelMesh extends TriMesh public void addOverlay (RenderState[] overlay) { if (_overlays == null) { - _overlays = new ArrayList(1); + _overlays = Lists.newArrayListWithCapacity(1); } _overlays.add(overlay); } @@ -461,7 +461,7 @@ public class ModelMesh extends TriMesh @Override // documentation inherited protected void setupBatchList () { - batchList = new ArrayList(1); + batchList = Lists.newArrayListWithCapacity(1); TriangleBatch batch = createModelBatch(); batch.setParentGeom(this); batchList.add(batch); diff --git a/src/java/com/threerings/jme/model/SkinMesh.java b/src/java/com/threerings/jme/model/SkinMesh.java index 99cc4fd0..791e53a7 100644 --- a/src/java/com/threerings/jme/model/SkinMesh.java +++ b/src/java/com/threerings/jme/model/SkinMesh.java @@ -222,7 +222,7 @@ public class SkinMesh extends ModelMesh _weightGroups = weightGroups; // compile a list of all referenced bones - HashSet bones = new HashSet(); + HashSet bones = Sets.newHashSet(); for (WeightGroup group : weightGroups) { Collections.addAll(bones, group.bones); } @@ -238,7 +238,7 @@ public class SkinMesh extends ModelMesh return; } if (_osconfigs == null) { - _osconfigs = new ArrayList(1); + _osconfigs = Lists.newArrayListWithCapacity(1); } SkinShaderConfig osconfig = (SkinShaderConfig)_sconfig.clone(); osconfig.getState().uniforms = _sconfig.getState().uniforms; @@ -299,7 +299,7 @@ public class SkinMesh extends ModelMesh mstore._useDisplayLists = _useDisplayLists; mstore._invRefTransform = _invRefTransform; mstore._bones = new Bone[_bones.length]; - HashMap bmap = new HashMap(); + HashMap bmap = Maps.newHashMap(); for (int ii = 0; ii < _bones.length; ii++) { bmap.put(_bones[ii], mstore._bones[ii] = _bones[ii].rebind(properties.originalToCopy)); diff --git a/src/java/com/threerings/jme/model/TextureController.java b/src/java/com/threerings/jme/model/TextureController.java index f8066c89..60521ed9 100644 --- a/src/java/com/threerings/jme/model/TextureController.java +++ b/src/java/com/threerings/jme/model/TextureController.java @@ -58,7 +58,7 @@ public abstract class TextureController extends ModelController protected void initTextures () { // find and clone all textures under the target - final HashMap clones = new HashMap(); + final HashMap clones = Maps.newHashMap(); new SpatialVisitor(ModelMesh.class) { protected void visit (ModelMesh mesh) { TextureState otstate = (TextureState)mesh.getRenderState(RenderState.RS_TEXTURE); diff --git a/src/java/com/threerings/jme/tools/AnimationDef.java b/src/java/com/threerings/jme/tools/AnimationDef.java index 67f698d6..be237a12 100644 --- a/src/java/com/threerings/jme/tools/AnimationDef.java +++ b/src/java/com/threerings/jme/tools/AnimationDef.java @@ -53,8 +53,7 @@ public class AnimationDef public static class FrameDef { /** Transform for affected nodes. */ - public ArrayList transforms = - new ArrayList(); + public ArrayList transforms = Lists.newArrayList(); public void addTransform (TransformDef transform) { @@ -122,14 +121,13 @@ public class AnimationDef { return new Model.Transform( new Vector3f(translation[0], translation[1], translation[2]), - new Quaternion(rotation[0], rotation[1], rotation[2], - rotation[3]), + new Quaternion(rotation[0], rotation[1], rotation[2], rotation[3]), new Vector3f(scale[0], scale[1], scale[2])); } } /** The individual frames of the animation. */ - public ArrayList frames = new ArrayList(); + public ArrayList frames = Lists.newArrayList(); public void addFrame (FrameDef frame) { @@ -185,8 +183,8 @@ public class AnimationDef Properties props, HashMap nodes, HashMap tnodes) { // find all affected nodes - HashSet staticTargets = new HashSet(), - transformTargets = new HashSet(); + HashSet staticTargets = Sets.newHashSet(), + transformTargets = Sets.newHashSet(); for (int ii = 0, nn = frames.size(); ii < nn; ii++) { frames.get(ii).addTransformTargets(nodes, tnodes, staticTargets, transformTargets); } diff --git a/src/java/com/threerings/jme/tools/CompileModel.java b/src/java/com/threerings/jme/tools/CompileModel.java index e25c35db..9e4b95b0 100644 --- a/src/java/com/threerings/jme/tools/CompileModel.java +++ b/src/java/com/threerings/jme/tools/CompileModel.java @@ -111,7 +111,7 @@ public class CompileModel // preprocess the model and animations to determine which nodes never move, which never // move within an animation, and which never move with respect to others - HashMap tnodes = new HashMap(); + HashMap tnodes = Maps.newHashMap(); Node troot = mdef.createTransformTree(props, tnodes); for (AnimationDef adef : adefs) { adef.filterTransforms(troot, tnodes); @@ -119,7 +119,7 @@ public class CompileModel mdef.mergeSpatials(tnodes); // load the model content - HashMap nodes = new HashMap(); + HashMap nodes = Maps.newHashMap(); Model model = mdef.createModel(props, nodes); model.initPrototype(); diff --git a/src/java/com/threerings/jme/tools/CompileModelTask.java b/src/java/com/threerings/jme/tools/CompileModelTask.java index e0cab7dc..91bf091d 100644 --- a/src/java/com/threerings/jme/tools/CompileModelTask.java +++ b/src/java/com/threerings/jme/tools/CompileModelTask.java @@ -81,5 +81,5 @@ public class CompileModelTask extends Task protected File _dest; /** A list of filesets that contain XML models. */ - protected ArrayList _filesets = new ArrayList(); + protected ArrayList _filesets = Lists.newArrayList(); } diff --git a/src/java/com/threerings/jme/tools/ConvertModelTask.java b/src/java/com/threerings/jme/tools/ConvertModelTask.java index c174f385..6241218e 100644 --- a/src/java/com/threerings/jme/tools/ConvertModelTask.java +++ b/src/java/com/threerings/jme/tools/ConvertModelTask.java @@ -130,5 +130,5 @@ public class ConvertModelTask extends Task } /** A list of filesets that contain tileset bundle definitions. */ - protected ArrayList _filesets = new ArrayList(); + protected ArrayList _filesets = Lists.newArrayList(); } diff --git a/src/java/com/threerings/jme/tools/ModelDef.java b/src/java/com/threerings/jme/tools/ModelDef.java index 62321f52..743f76c5 100644 --- a/src/java/com/threerings/jme/tools/ModelDef.java +++ b/src/java/com/threerings/jme/tools/ModelDef.java @@ -156,7 +156,7 @@ public class ModelDef public HashArrayList vertices = new HashArrayList(); /** The triangle indices. */ - public ArrayList indices = new ArrayList(); + public ArrayList indices = Lists.newArrayList(); /** Whether or not any of the vertices have texture coordinates. */ public boolean tcoords; @@ -265,7 +265,7 @@ public class ModelDef Triangle triangle = new Triangle(tverts); for (Vertex tvert : tverts) { if (tvert.triangles == null) { - tvert.triangles = new ArrayList(); + tvert.triangles = Lists.newArrayList(); } tvert.triangles.add(triangle); } @@ -410,10 +410,8 @@ public class ModelDef } // create and set the final weight groups - SkinMesh.WeightGroup[] wgroups = - new SkinMesh.WeightGroup[_groups.size()]; - HashMap bones = - new HashMap(); + SkinMesh.WeightGroup[] wgroups = new SkinMesh.WeightGroup[_groups.size()]; + HashMap bones = Maps.newHashMap(); int ii = 0; int mweights = 0, tweights = 0; for (Map.Entry, WeightGroupDef> entry : @@ -444,7 +442,7 @@ public class ModelDef protected void configureMesh (Properties props) { // divide the vertices up by weight groups - _groups = new HashMap, WeightGroupDef>(); + _groups = Maps.newHashMap(); for (int ii = 0, nn = vertices.size(); ii < nn; ii++) { SkinVertex svertex = (SkinVertex)vertices.get(ii); Set bones = svertex.boneWeights.keySet(); @@ -597,8 +595,7 @@ public class ModelDef public static class SkinVertex extends Vertex { /** The bones influencing the vertex, mapped by name. */ - public HashMap boneWeights = - new HashMap(); + public HashMap boneWeights = Maps.newHashMap(); public void addBoneWeight (BoneWeight weight) { @@ -616,7 +613,7 @@ public class ModelDef /** Finds the bone nodes influencing this vertex. */ public HashSet getBones (HashMap nodes) { - HashSet bones = new HashSet(); + HashSet bones = Sets.newHashSet(); for (String bone : boneWeights.keySet()) { Spatial node = nodes.get(bone); if (node instanceof ModelNode) { @@ -651,10 +648,10 @@ public class ModelDef public static class WeightGroupDef { /** The indices of the affected vertex. */ - public ArrayList indices = new ArrayList(); + public ArrayList indices = Lists.newArrayList(); /** The interleaved vertex weights. */ - public ArrayList weights = new ArrayList(); + public ArrayList weights = Lists.newArrayList(); } /** Contains the transform of a node for preprocessing. */ @@ -754,7 +751,7 @@ public class ModelDef } /** The meshes and bones comprising the model. */ - public ArrayList spatials = new ArrayList(); + public ArrayList spatials = Lists.newArrayList(); public void addSpatial (SpatialDef spatial) { @@ -775,7 +772,7 @@ public class ModelDef // resolve the parents and collect the names of the bones Node root = new Node("root"); - HashSet bones = new HashSet(); + HashSet bones = Sets.newHashSet(); for (TransformNode node : nodes.values()) { if (node.spatial.parent == null) { root.attachChild(node); @@ -811,7 +808,7 @@ public class ModelDef root.updateGeometricState(0f, true); for (TransformNode node : nodes.values()) { node.baseLocalTransform = new Matrix4f(node.localTransform); - node.relativeTransforms = new ArrayList>(); + node.relativeTransforms = Lists.newArrayList(); for (TransformNode onode : nodes.values()) { if (node == onode || !node.canMerge(props, onode)) { continue; @@ -858,9 +855,8 @@ public class ModelDef nodes.put(spatial.getName(), spatial); } - // then go through again, resolving any name references and attaching - // root children - HashSet referenced = new HashSet(); + // then go through again, resolving any name references and attaching root children + HashSet referenced = Sets.newHashSet(); for (int ii = 0, nn = spatials.size(); ii < nn; ii++) { SpatialDef sdef = spatials.get(ii); sdef.resolveReferences(nodes, referenced); @@ -1036,6 +1032,6 @@ public class ModelDef } /** Maps elements to their indices in the list. */ - protected HashMap _indices = new HashMap(); + protected HashMap _indices = Maps.newHashMap(); } } diff --git a/src/java/com/threerings/jme/tools/ModelViewer.java b/src/java/com/threerings/jme/tools/ModelViewer.java index 4686a8a8..0d7101f2 100644 --- a/src/java/com/threerings/jme/tools/ModelViewer.java +++ b/src/java/com/threerings/jme/tools/ModelViewer.java @@ -738,8 +738,7 @@ public class ModelViewer extends JmeCanvasApp } return tstate; } - protected HashMap _tstates = - new HashMap(); + protected HashMap _tstates = Maps.newHashMap(); }); _model.updateRenderState(); } diff --git a/src/java/com/threerings/jme/util/ImageCache.java b/src/java/com/threerings/jme/util/ImageCache.java index aac0c0a6..f2962be5 100644 --- a/src/java/com/threerings/jme/util/ImageCache.java +++ b/src/java/com/threerings/jme/util/ImageCache.java @@ -380,16 +380,13 @@ public class ImageCache protected ResourceManager _rsrcmgr; /** A cache of {@link Image} instances. */ - protected HashMap> _imgcache = - new HashMap>(); + protected HashMap> _imgcache = Maps.newHashMap(); /** A cache of {@link BImage} instances. */ - protected HashMap> _buicache = - new HashMap>(); + protected HashMap> _buicache = Maps.newHashMap(); /** A cache of {@link BufferedImage} instances. */ - protected HashMap> _bufcache = - new HashMap>(); + protected HashMap> _bufcache = Maps.newHashMap(); /** Used to create buffered images in a format compatible with OpenGL. */ protected static ComponentColorModel GL_ALPHA_MODEL = new ComponentColorModel( diff --git a/src/java/com/threerings/jme/util/ShaderCache.java b/src/java/com/threerings/jme/util/ShaderCache.java index 6dbd64f0..c04e5be4 100644 --- a/src/java/com/threerings/jme/util/ShaderCache.java +++ b/src/java/com/threerings/jme/util/ShaderCache.java @@ -218,7 +218,7 @@ public class ShaderCache public String frag; /** The set of preprocessor definitions. */ - public HashSet defs = new HashSet(); + public HashSet defs = Sets.newHashSet(); public ShaderKey (String vert, String frag, String[] defs) { @@ -253,8 +253,8 @@ public class ShaderCache protected ResourceManager _rsrcmgr; /** Maps shader names to source strings. */ - protected HashMap _sources = new HashMap(); + protected HashMap _sources = Maps.newHashMap(); /** Maps shader keys to linked program ids. */ - protected HashMap _programIds = new HashMap(); + protected HashMap _programIds = Maps.newHashMap(); } diff --git a/src/java/com/threerings/jme/util/ShaderConfig.java b/src/java/com/threerings/jme/util/ShaderConfig.java index 6656f733..f7f6421c 100644 --- a/src/java/com/threerings/jme/util/ShaderConfig.java +++ b/src/java/com/threerings/jme/util/ShaderConfig.java @@ -74,11 +74,11 @@ public abstract class ShaderConfig // reconfigure the shader state, generating the derived definitions only if the // required configuration isn't in the cache String vert = getVertexShader(), frag = getFragmentShader(); - ArrayList defs = new ArrayList(); + ArrayList defs = Lists.newArrayList(); getDefinitions(defs); String[] darray = defs.toArray(new String[defs.size()]), ddarray = null; if (!_scache.isLoaded(vert, frag, darray)) { - ArrayList ddefs = new ArrayList(); + ArrayList ddefs = Lists.newArrayList(); getDerivedDefinitions(ddefs); ddarray = ddefs.toArray(new String[ddefs.size()]); } diff --git a/src/java/com/threerings/media/MediaPanel.java b/src/java/com/threerings/media/MediaPanel.java index 0a5fbcb7..512581f2 100644 --- a/src/java/com/threerings/media/MediaPanel.java +++ b/src/java/com/threerings/media/MediaPanel.java @@ -37,6 +37,8 @@ import javax.swing.SwingUtilities; import javax.swing.event.AncestorEvent; import javax.swing.event.MouseInputAdapter; +import com.google.common.collect.Lists; + import com.samskivert.swing.Controller; import com.samskivert.swing.event.AncestorAdapter; import com.samskivert.swing.event.CommandEvent; @@ -367,7 +369,7 @@ public class MediaPanel extends JComponent */ public void addObscurer (Obscurer obscurer) { if (_obscurerList == null) { - _obscurerList = new ArrayList(); + _obscurerList = Lists.newArrayList(); } _obscurerList.add(obscurer); } @@ -640,7 +642,7 @@ public class MediaPanel extends JComponent */ protected Sprite getHit (MouseEvent me) { - ArrayList list = new ArrayList(); + ArrayList list = Lists.newArrayList(); getSpriteManager().getHitSprites(list, me.getX(), me.getY()); for (int ii = 0, nn = list.size(); ii < nn; ii++) { Object o = list.get(ii); diff --git a/src/java/com/threerings/media/VirtualMediaPanel.java b/src/java/com/threerings/media/VirtualMediaPanel.java index a4a1090c..027ea708 100644 --- a/src/java/com/threerings/media/VirtualMediaPanel.java +++ b/src/java/com/threerings/media/VirtualMediaPanel.java @@ -31,6 +31,8 @@ import java.awt.event.MouseWheelEvent; import javax.swing.SwingUtilities; +import com.google.common.collect.Lists; + import com.samskivert.util.RunAnywhere; import com.threerings.media.image.ImageUtil; @@ -462,5 +464,5 @@ public class VirtualMediaPanel extends MediaPanel protected Rectangle _abounds = new Rectangle(); /** A list of entities to be informed when the view scrolls. */ - protected ArrayList _trackers = new ArrayList(); + protected ArrayList _trackers = Lists.newArrayList(); } diff --git a/src/java/com/threerings/media/animation/AnimationArranger.java b/src/java/com/threerings/media/animation/AnimationArranger.java index 31c4b4da..5488d54e 100644 --- a/src/java/com/threerings/media/animation/AnimationArranger.java +++ b/src/java/com/threerings/media/animation/AnimationArranger.java @@ -25,6 +25,8 @@ import java.util.ArrayList; import java.awt.Rectangle; +import com.google.common.collect.Lists; + import com.samskivert.swing.util.SwingUtil; import static com.threerings.media.Log.log; @@ -42,7 +44,7 @@ public class AnimationArranger public void positionAvoidAnimation (Animation anim, Rectangle viewBounds) { Rectangle abounds = new Rectangle(anim.getBounds()); - @SuppressWarnings("unchecked") ArrayList avoidables = + @SuppressWarnings("unchecked") ArrayList avoidables = (ArrayList) _avoidAnims.clone(); // if we are able to place it somewhere, do so if (SwingUtil.positionRect(abounds, viewBounds, avoidables)) { @@ -56,7 +58,7 @@ public class AnimationArranger } /** The animations that other animations may wish to avoid. */ - protected ArrayList _avoidAnims = new ArrayList(); + protected ArrayList _avoidAnims = Lists.newArrayList(); /** Automatically removes avoid animations when they're done. */ protected AnimationAdapter _avoidAnimObs = new AnimationAdapter() { diff --git a/src/java/com/threerings/media/animation/AnimationSequencer.java b/src/java/com/threerings/media/animation/AnimationSequencer.java index d4cc67a9..dbf0ce50 100644 --- a/src/java/com/threerings/media/animation/AnimationSequencer.java +++ b/src/java/com/threerings/media/animation/AnimationSequencer.java @@ -26,6 +26,8 @@ import java.util.ArrayList; import java.awt.Graphics2D; import java.awt.Rectangle; +import com.google.common.collect.Lists; + import com.samskivert.util.StringUtil; import static com.threerings.media.Log.log; @@ -284,10 +286,10 @@ public class AnimationSequencer extends Animation protected AnimationManager _animmgr; /** Animations that have not been fired. */ - protected ArrayList _queued = new ArrayList(); + protected ArrayList _queued = Lists.newArrayList(); /** Animations that are currently running. */ - protected ArrayList _running = new ArrayList(); + protected ArrayList _running = Lists.newArrayList(); /** The timestamp at which we fired the last animation. */ protected long _lastStamp; diff --git a/src/java/com/threerings/media/image/ColorPository.java b/src/java/com/threerings/media/image/ColorPository.java index 6ce2b0a5..706a0bdc 100644 --- a/src/java/com/threerings/media/image/ColorPository.java +++ b/src/java/com/threerings/media/image/ColorPository.java @@ -34,6 +34,8 @@ import java.text.ParseException; import java.awt.Color; +import com.google.common.collect.Lists; + import com.samskivert.util.HashIntMap; import com.samskivert.util.RandomUtil; import com.samskivert.util.StringUtil; @@ -133,7 +135,7 @@ public class ColorPository implements Serializable { // figure out our starter ids if we haven't already if (_starters == null) { - ArrayList list = new ArrayList(); + ArrayList list = Lists.newArrayList(); for (ColorRecord color : colors.values()) { if (color.starter) { list.add(color); @@ -144,8 +146,8 @@ public class ColorPository implements Serializable // sanity check if (_starters.length < 1) { - log.warning("Requested random starting color from " + - "colorless component class " + this + "]."); + log.warning("Requested random starting color from colorless component class", + "class", this); return null; } diff --git a/src/java/com/threerings/media/image/ImageManager.java b/src/java/com/threerings/media/image/ImageManager.java index 95978e27..ae2b998a 100644 --- a/src/java/com/threerings/media/image/ImageManager.java +++ b/src/java/com/threerings/media/image/ImageManager.java @@ -36,7 +36,9 @@ import java.awt.Rectangle; import java.awt.Transparency; import java.awt.image.BufferedImage; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import com.samskivert.util.LRUHashMap; import com.samskivert.util.StringUtil; @@ -477,7 +479,7 @@ public class ImageManager } if (_colorized == null) { - _colorized = new ArrayList>(); + _colorized = Lists.newArrayList(); } // we search linearly through our list of colorized copies because it is not likely to @@ -540,7 +542,7 @@ public class ImageManager protected LRUHashMap _ccache; /** The set of all keys we've ever seen. */ - protected HashSet _keySet = new HashSet(); + protected HashSet _keySet = Sets.newHashSet(); /** Throttle our cache status logging to once every 300 seconds. */ protected Throttle _cacheStatThrottle = new Throttle(1, 300000L); diff --git a/src/java/com/threerings/media/sound/JavaSoundPlayer.java b/src/java/com/threerings/media/sound/JavaSoundPlayer.java index 7f199a02..a4982f79 100644 --- a/src/java/com/threerings/media/sound/JavaSoundPlayer.java +++ b/src/java/com/threerings/media/sound/JavaSoundPlayer.java @@ -42,6 +42,8 @@ import javax.sound.sampled.UnsupportedAudioFileException; import org.apache.commons.io.IOUtils; +import com.google.common.collect.Maps; + import com.samskivert.util.LRUHashMap; import com.samskivert.util.Queue; import com.samskivert.util.RandomUtil; @@ -759,7 +761,7 @@ public class JavaSoundPlayer extends SoundPlayer * The set of locked audio clips; this is separate from the LRU so that locking clips doesn't * booch up an otherwise normal caching agenda. */ - protected HashMap _lockedClips = new HashMap(); + protected HashMap _lockedClips = Maps.newHashMap(); /** Soundkey command constants. */ protected static final byte PLAY = 0; diff --git a/src/java/com/threerings/media/tile/bundle/BundledTileSetRepository.java b/src/java/com/threerings/media/tile/bundle/BundledTileSetRepository.java index 9ab5693b..6e802ff7 100644 --- a/src/java/com/threerings/media/tile/bundle/BundledTileSetRepository.java +++ b/src/java/com/threerings/media/tile/bundle/BundledTileSetRepository.java @@ -24,6 +24,8 @@ package com.threerings.media.tile.bundle; import java.util.HashMap; import java.util.Iterator; +import com.google.common.collect.Maps; + import com.samskivert.io.PersistenceException; import com.samskivert.util.HashIntMap; import com.samskivert.util.IntMap; @@ -74,7 +76,7 @@ public class BundledTileSetRepository } /** - * Initializes our bundles, + * Initializes our bundles, */ protected void initBundles (ResourceManager rmgr, String name) { @@ -91,12 +93,12 @@ public class BundledTileSetRepository } HashIntMap idmap = new HashIntMap(); - HashMap namemap = new HashMap(); + HashMap namemap = Maps.newHashMap(); // iterate over the resource bundles in the set, loading up the // tileset bundles in each resource bundle - for (int i = 0; i < rbundles.length; i++) { - addBundle(idmap, namemap, rbundles[i]); + for (ResourceBundle rbundle : rbundles) { + addBundle(idmap, namemap, rbundle); } // fill in our bundles array and wake up any waiters diff --git a/src/java/com/threerings/media/tile/bundle/tools/TileSetBundler.java b/src/java/com/threerings/media/tile/bundle/tools/TileSetBundler.java index 10030072..f7593cb2 100644 --- a/src/java/com/threerings/media/tile/bundle/tools/TileSetBundler.java +++ b/src/java/com/threerings/media/tile/bundle/tools/TileSetBundler.java @@ -43,6 +43,8 @@ import org.xml.sax.SAXException; import org.apache.commons.digester.Digester; import org.apache.commons.io.IOUtils; +import com.google.common.collect.Lists; + import com.samskivert.io.PersistenceException; import com.samskivert.util.HashIntMap; @@ -137,7 +139,7 @@ public class TileSetBundler Digester digester = new Digester(); // push our mappings array onto the stack - ArrayList mappings = new ArrayList(); + ArrayList mappings = Lists.newArrayList(); digester.push(mappings); // create a mapping object for each mapping entry and append it to @@ -232,7 +234,7 @@ public class TileSetBundler { // stick an array list on the top of the stack into which we will // collect parsed tilesets - ArrayList sets = new ArrayList(); + ArrayList sets = Lists.newArrayList(); _digester.push(sets); // parse the tilesets @@ -367,7 +369,7 @@ public class TileSetBundler // write all of the image files to the bundle, converting the // tilesets to trimmed tilesets in the process Iterator iditer = bundle.enumerateTileSetIds(); - + // Store off the updated TileSets in a separate Map so we can wait to change the // bundle till we're done iterating. HashIntMap toUpdate = new HashIntMap(); diff --git a/src/java/com/threerings/media/tile/bundle/tools/TileSetBundlerTask.java b/src/java/com/threerings/media/tile/bundle/tools/TileSetBundlerTask.java index a590b14a..215f005f 100644 --- a/src/java/com/threerings/media/tile/bundle/tools/TileSetBundlerTask.java +++ b/src/java/com/threerings/media/tile/bundle/tools/TileSetBundlerTask.java @@ -31,6 +31,8 @@ import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; +import com.google.common.collect.Lists; + import com.threerings.media.tile.tools.MapFileTileSetIDBroker; /** @@ -92,8 +94,8 @@ public class TileSetBundlerTask extends Task File fromDir = fs.getDir(getProject()); String[] srcFiles = ds.getIncludedFiles(); - for (int f = 0; f < srcFiles.length; f++) { - cfile = new File(fromDir, srcFiles[f]); + for (String srcFile : srcFiles) { + cfile = new File(fromDir, srcFile); // figure out the bundle file based on the definition // file @@ -158,5 +160,5 @@ public class TileSetBundlerTask extends Task protected File _mapfile; /** A list of filesets that contain tileset bundle definitions. */ - protected ArrayList _filesets = new ArrayList(); + protected ArrayList _filesets = Lists.newArrayList(); } diff --git a/src/java/com/threerings/media/tile/tools/MapFileTileSetIDBroker.java b/src/java/com/threerings/media/tile/tools/MapFileTileSetIDBroker.java index 972850bc..1684bb52 100644 --- a/src/java/com/threerings/media/tile/tools/MapFileTileSetIDBroker.java +++ b/src/java/com/threerings/media/tile/tools/MapFileTileSetIDBroker.java @@ -32,6 +32,8 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import com.google.common.collect.Maps; + import com.samskivert.io.PersistenceException; import com.samskivert.util.QuickSort; @@ -60,14 +62,14 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker _nextTileSetID = readInt(bin); _storedTileSetID = _nextTileSetID; // read in our mappings - _map = new HashMap(); + _map = Maps.newHashMap(); readMapFile(bin, _map); bin.close(); } catch (FileNotFoundException fnfe) { // create a blank map if our map file doesn't exist - _map = new HashMap(); + _map = Maps.newHashMap(); } catch (Exception e) { // other errors are more fatal @@ -170,8 +172,8 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker lines[ii] = key + SEP_STR + value; } QuickSort.sort(lines); - for (int ii = 0; ii < lines.length; ii++) { - bout.write(lines[ii], 0, lines[ii].length()); + for (String line : lines) { + bout.write(line, 0, line.length()); bout.newLine(); } bout.flush(); diff --git a/src/java/com/threerings/media/tile/tools/xml/XMLTileSetParser.java b/src/java/com/threerings/media/tile/tools/xml/XMLTileSetParser.java index 4e326106..6137cdab 100644 --- a/src/java/com/threerings/media/tile/tools/xml/XMLTileSetParser.java +++ b/src/java/com/threerings/media/tile/tools/xml/XMLTileSetParser.java @@ -21,7 +21,6 @@ package com.threerings.media.tile.tools.xml; -import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -35,6 +34,8 @@ import org.xml.sax.SAXException; import org.apache.commons.digester.Digester; +import com.google.common.collect.Lists; + import com.samskivert.util.ConfigUtil; import com.samskivert.xml.ValidatedSetNextRule; @@ -144,7 +145,7 @@ public class XMLTileSetParser { // stick an array list on the top of the stack for collecting // parsed tilesets - List setlist = new ArrayList(); + List setlist = Lists.newArrayList(); _digester.push(setlist); // now fire up the digester to parse the stream diff --git a/src/java/com/threerings/media/tools/RecolorImage.java b/src/java/com/threerings/media/tools/RecolorImage.java index f661f53e..1734f7bb 100644 --- a/src/java/com/threerings/media/tools/RecolorImage.java +++ b/src/java/com/threerings/media/tools/RecolorImage.java @@ -56,6 +56,8 @@ import javax.swing.JToggleButton; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import com.google.common.collect.Lists; + import com.samskivert.util.QuickSort; import com.samskivert.swing.HGroupLayout; @@ -250,7 +252,7 @@ public class RecolorImage extends JPanel Graphics gfx = img.getGraphics(); int y = 0; - ArrayList sortedKeys = new ArrayList(); + ArrayList sortedKeys = Lists.newArrayList(); sortedKeys.addAll(colClass.colors.keySet()); QuickSort.sort(sortedKeys, new Comparator() { @@ -340,7 +342,7 @@ public class RecolorImage extends JPanel _classList.removeAllItems(); Iterator iter = _colRepo.enumerateClasses(); - ArrayList names = new ArrayList(); + ArrayList names = Lists.newArrayList(); while (iter.hasNext()) { String str = iter.next().name; names.add(str); diff --git a/src/java/com/threerings/media/tools/ResourceIndexerTask.java b/src/java/com/threerings/media/tools/ResourceIndexerTask.java index e80316ec..08942b3d 100644 --- a/src/java/com/threerings/media/tools/ResourceIndexerTask.java +++ b/src/java/com/threerings/media/tools/ResourceIndexerTask.java @@ -32,6 +32,8 @@ import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; +import com.google.common.collect.Lists; + /** * Creates a file that lists all the resources in a fileset out to an index file. */ @@ -44,19 +46,19 @@ public class ResourceIndexerTask extends Task { _filesets.add(set); } - + public void setIndexFile (String file) { _indexFile = file; } - + @Override public void execute () throws BuildException { PrintWriter fout = null; try { fout = new PrintWriter(new FileWriter(_indexFile)); - + for (FileSet fs : _filesets) { DirectoryScanner ds = fs.getDirectoryScanner(getProject()); String[] srcFiles = ds.getIncludedFiles(); @@ -64,7 +66,7 @@ public class ResourceIndexerTask extends Task fout.println(filename); } } - + } catch (IOException ioe) { throw new BuildException(ioe); } finally { @@ -75,8 +77,8 @@ public class ResourceIndexerTask extends Task } /** A list of filesets that contain files to include in the index. */ - protected ArrayList _filesets = new ArrayList(); - + protected ArrayList _filesets = Lists.newArrayList(); + /** The name of the file to which we should write the index. */ protected String _indexFile; } diff --git a/src/java/com/threerings/media/util/AStarPathUtil.java b/src/java/com/threerings/media/util/AStarPathUtil.java index 2700ce91..d31c52f1 100644 --- a/src/java/com/threerings/media/util/AStarPathUtil.java +++ b/src/java/com/threerings/media/util/AStarPathUtil.java @@ -28,6 +28,8 @@ import java.util.TreeSet; import java.awt.Point; +import com.google.common.collect.Lists; + import com.samskivert.util.HashIntMap; /** @@ -270,7 +272,7 @@ public class AStarPathUtil protected static List getNodePath (Node n) { Node cur = n; - ArrayList path = new ArrayList(); + ArrayList path = Lists.newArrayList(); while (cur != null) { // add to the head of the list since we're traversing from @@ -337,7 +339,7 @@ public class AStarPathUtil // construct the open and closed lists open = new TreeSet(); - closed = new ArrayList(); + closed = Lists.newArrayList(); } /** diff --git a/src/java/com/threerings/media/util/LineSegmentPath.java b/src/java/com/threerings/media/util/LineSegmentPath.java index 4a5cc8a4..b46035b8 100644 --- a/src/java/com/threerings/media/util/LineSegmentPath.java +++ b/src/java/com/threerings/media/util/LineSegmentPath.java @@ -29,6 +29,8 @@ import java.awt.Color; import java.awt.Graphics2D; import java.awt.Point; +import com.google.common.collect.Lists; + import com.samskivert.util.StringUtil; import com.threerings.util.DirectionCodes; @@ -237,7 +239,7 @@ public class LineSegmentPath if (ox != nx || oy != ny) { pable.setLocation(nx, ny); return true; - } + } return false; } @@ -340,7 +342,7 @@ public class LineSegmentPath addNode(p.x, p.y, dir); last = p; } - } + } /** * Gets the next node in the path. @@ -348,10 +350,10 @@ public class LineSegmentPath protected PathNode getNextNode () { return _niter.next(); - } + } /** The nodes that make up the path. */ - protected ArrayList _nodes = new ArrayList(); + protected ArrayList _nodes = Lists.newArrayList(); /** We use this when moving along this path. */ protected Iterator _niter; @@ -371,7 +373,7 @@ public class LineSegmentPath /** The path velocity in pixels per millisecond. */ protected float _vel = DEFAULT_VELOCITY; - /** When moving, the pathable position including fractional pixels. */ + /** When moving, the pathable position including fractional pixels. */ protected float _movex, _movey; /** When moving, the distance to move on each axis per tick. */ diff --git a/src/java/com/threerings/media/util/PathSequence.java b/src/java/com/threerings/media/util/PathSequence.java index 5ff3fec2..061476ae 100644 --- a/src/java/com/threerings/media/util/PathSequence.java +++ b/src/java/com/threerings/media/util/PathSequence.java @@ -35,8 +35,7 @@ public class PathSequence implements Path { /** - * Conveniently construct a path sequence with the two specified - * paths. + * Conveniently construct a path sequence with the two specified paths. */ public PathSequence (Path first, Path second) { diff --git a/src/java/com/threerings/media/util/PerformanceMonitor.java b/src/java/com/threerings/media/util/PerformanceMonitor.java index 5fee954b..c8734a00 100644 --- a/src/java/com/threerings/media/util/PerformanceMonitor.java +++ b/src/java/com/threerings/media/util/PerformanceMonitor.java @@ -21,7 +21,6 @@ package com.threerings.media.util; -import java.util.HashMap; import java.util.Map; import com.google.common.collect.Maps; @@ -64,7 +63,7 @@ public class PerformanceMonitor Map actions = _observers.get(obs); if (actions == null) { // create it if it didn't exist - _observers.put(obs, actions = new HashMap()); + _observers.put(obs, actions = Maps.newHashMap()); } // add the action to the set we're tracking @@ -147,7 +146,7 @@ public class PerformanceMonitor } /** The observers monitoring some set of actions. */ - protected static Map> _observers = + protected static Map> _observers = Maps.newHashMap(); /** Used to obtain high resolution time stamps. */ @@ -207,7 +206,7 @@ class PerformanceAction /** The number of milliseconds between each checkpoint. */ protected long _delta; - /** The time the last time a checkpoint was made. */ + /** The time the last time a checkpoint was made. */ protected long _lastDelta; /** The number of ticks since the last checkpoint. */ diff --git a/src/java/com/threerings/miso/client/DirtyItemList.java b/src/java/com/threerings/miso/client/DirtyItemList.java index 02e390c7..1c6b5bac 100644 --- a/src/java/com/threerings/miso/client/DirtyItemList.java +++ b/src/java/com/threerings/miso/client/DirtyItemList.java @@ -27,6 +27,8 @@ import java.util.Comparator; import java.awt.Graphics2D; +import com.google.common.collect.Lists; + import com.samskivert.util.SortableArrayList; import com.threerings.media.sprite.Sprite; @@ -663,7 +665,7 @@ public class DirtyItemList protected Comparator _rcomp = new RenderComparator(); /** Unused dirty items. */ - protected ArrayList _freelist = new ArrayList(); + protected ArrayList _freelist = Lists.newArrayList(); /** Whether to log debug info when comparing pairs of dirty items. */ protected static final boolean DEBUG_COMPARE = false; diff --git a/src/java/com/threerings/miso/client/ResolutionView.java b/src/java/com/threerings/miso/client/ResolutionView.java index d02aef33..f766cd99 100644 --- a/src/java/com/threerings/miso/client/ResolutionView.java +++ b/src/java/com/threerings/miso/client/ResolutionView.java @@ -33,6 +33,8 @@ import java.awt.geom.AffineTransform; import javax.swing.JPanel; +import com.google.common.collect.Maps; + import com.samskivert.util.IntTuple; import com.threerings.media.util.MathUtil; @@ -159,7 +161,7 @@ public class ResolutionView extends JPanel protected MisoScenePanel _panel; protected MisoSceneMetrics _metrics; - protected HashMap _blocks = new HashMap(); + protected HashMap _blocks = Maps.newHashMap(); protected static final int TILE_SIZE = 10; protected static final int MAX_WIDTH = 30; diff --git a/src/java/com/threerings/miso/client/SceneBlock.java b/src/java/com/threerings/miso/client/SceneBlock.java index a3d56bd9..67487ce8 100644 --- a/src/java/com/threerings/miso/client/SceneBlock.java +++ b/src/java/com/threerings/miso/client/SceneBlock.java @@ -30,6 +30,8 @@ import java.util.Set; import java.awt.Polygon; import java.awt.Rectangle; +import com.google.common.collect.Lists; + import com.samskivert.util.ArrayUtil; import com.samskivert.util.IntMap; import com.samskivert.util.StringUtil; @@ -157,7 +159,7 @@ public class SceneBlock // resolve our objects ObjectSet set = new ObjectSet(); _model.getObjects(_bounds, set); - ArrayList scobjs = new ArrayList(); + ArrayList scobjs = Lists.newArrayList(); now = System.currentTimeMillis(); for (int ii = 0, ll = set.size(); ii < ll; ii++) { SceneObject scobj = makeSceneObject(set.get(ii)); diff --git a/src/java/com/threerings/miso/tile/FringeConfiguration.java b/src/java/com/threerings/miso/tile/FringeConfiguration.java index f4cd1142..f54dc812 100644 --- a/src/java/com/threerings/miso/tile/FringeConfiguration.java +++ b/src/java/com/threerings/miso/tile/FringeConfiguration.java @@ -25,6 +25,8 @@ import java.util.ArrayList; import java.io.Serializable; +import com.google.common.collect.Lists; + import com.samskivert.util.HashIntMap; import com.samskivert.util.StringUtil; @@ -49,7 +51,7 @@ public class FringeConfiguration implements Serializable public int priority; /** A list of the possible tilesets that can be used for fringing. */ - public ArrayList tilesets = new ArrayList(); + public ArrayList tilesets = Lists.newArrayList(); /** Used when parsing the tilesets definitions. */ public void addTileset (FringeTileSetRecord record) diff --git a/src/java/com/threerings/miso/tools/xml/SimpleMisoSceneRuleSet.java b/src/java/com/threerings/miso/tools/xml/SimpleMisoSceneRuleSet.java index 2baac4ed..e8de1c8c 100644 --- a/src/java/com/threerings/miso/tools/xml/SimpleMisoSceneRuleSet.java +++ b/src/java/com/threerings/miso/tools/xml/SimpleMisoSceneRuleSet.java @@ -28,6 +28,8 @@ import org.xml.sax.Attributes; import org.apache.commons.digester.Digester; import org.apache.commons.digester.Rule; +import com.google.common.collect.Lists; + import com.samskivert.xml.CallMethodSpecialRule; import com.samskivert.xml.SetFieldRule; import com.samskivert.xml.SetPropertyFieldsRule; @@ -85,9 +87,9 @@ public class SimpleMisoSceneRuleSet implements NestableRuleSet public void parseAndSet (String bodyText, Object target) throws Exception { - @SuppressWarnings("unchecked") ArrayList ilist = + @SuppressWarnings("unchecked") ArrayList ilist = (ArrayList)target; - ArrayList ulist = new ArrayList(); + ArrayList ulist = Lists.newArrayList(); SimpleMisoSceneModel model = (SimpleMisoSceneModel) digester.peek(1); diff --git a/src/java/com/threerings/openal/FileStream.java b/src/java/com/threerings/openal/FileStream.java index bafa05b2..9dcd021a 100644 --- a/src/java/com/threerings/openal/FileStream.java +++ b/src/java/com/threerings/openal/FileStream.java @@ -28,6 +28,8 @@ import java.io.IOException; import java.nio.ByteBuffer; +import com.google.common.collect.Lists; + /** * An audio stream read from one or more files. */ @@ -93,7 +95,7 @@ public class FileStream extends Stream protected StreamDecoder _decoder; /** The queue of files to play after the current one. */ - protected ArrayList _queue = new ArrayList(); + protected ArrayList _queue = Lists.newArrayList(); /** A file queued for play. */ protected class QueuedFile diff --git a/src/java/com/threerings/openal/SoundGroup.java b/src/java/com/threerings/openal/SoundGroup.java index 7382d3e8..e43e2db5 100644 --- a/src/java/com/threerings/openal/SoundGroup.java +++ b/src/java/com/threerings/openal/SoundGroup.java @@ -25,6 +25,8 @@ import java.util.ArrayList; import org.lwjgl.openal.AL10; +import com.google.common.collect.Lists; + import static com.threerings.openal.Log.log; /** @@ -147,5 +149,5 @@ public class SoundGroup protected SoundManager _manager; protected ClipProvider _provider; - protected ArrayList _sources = new ArrayList(); + protected ArrayList _sources = Lists.newArrayList(); } diff --git a/src/java/com/threerings/openal/SoundManager.java b/src/java/com/threerings/openal/SoundManager.java index b4c38daa..4330255e 100644 --- a/src/java/com/threerings/openal/SoundManager.java +++ b/src/java/com/threerings/openal/SoundManager.java @@ -30,6 +30,7 @@ import org.lwjgl.BufferUtils; import org.lwjgl.openal.AL; import org.lwjgl.openal.AL10; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.samskivert.util.IntListUtil; @@ -393,7 +394,7 @@ public class SoundManager protected Queue _toLoad; /** The list of active streams. */ - protected ArrayList _streams = new ArrayList(); + protected ArrayList _streams = Lists.newArrayList(); /** The list of sources to be deleted. */ protected int[] _finalizedSources; diff --git a/src/java/com/threerings/openal/Source.java b/src/java/com/threerings/openal/Source.java index 7288a8d0..430d4e1a 100644 --- a/src/java/com/threerings/openal/Source.java +++ b/src/java/com/threerings/openal/Source.java @@ -29,6 +29,8 @@ import org.lwjgl.BufferUtils; import org.lwjgl.openal.AL10; import org.lwjgl.openal.AL11; +import com.google.common.collect.Lists; + /** * Represents an OpenAL source object. */ @@ -420,5 +422,5 @@ public class Source protected float _coneOuterGain; /** The source's queue of buffers (storing them keeps them from being garbage-collected). */ - protected ArrayList _queue = new ArrayList(); + protected ArrayList _queue = Lists.newArrayList(); } diff --git a/src/java/com/threerings/resource/ResourceManager.java b/src/java/com/threerings/resource/ResourceManager.java index e4b2c9c3..493ee05c 100644 --- a/src/java/com/threerings/resource/ResourceManager.java +++ b/src/java/com/threerings/resource/ResourceManager.java @@ -50,6 +50,7 @@ import javax.imageio.ImageIO; import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.MemoryCacheImageInputStream; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.samskivert.io.StreamUtil; @@ -293,7 +294,7 @@ public class ResourceManager Properties config = loadConfig(configPath); // resolve the configured resource sets - List dlist = new ArrayList(); + List dlist = Lists.newArrayList(); Enumeration names = config.propertyNames(); while (names.hasMoreElements()) { String key = (String)names.nextElement(); @@ -464,7 +465,7 @@ public class ResourceManager } // start a thread to unpack our bundles - ArrayList list = new ArrayList(); + ArrayList list = Lists.newArrayList(); list.add(bundle); Unpacker unpack = new Unpacker(list, new InitObserver() { public void progress (int percent, long remaining) { @@ -804,7 +805,7 @@ public class ResourceManager protected void resolveResourceSet ( String setName, String definition, String setType, List dlist) { - List set = new ArrayList(); + List set = Lists.newArrayList(); StringTokenizer tok = new StringTokenizer(definition, ":"); while (tok.hasMoreTokens()) { set.add(createResourceBundle(setType, tok.nextToken().trim(), dlist)); diff --git a/src/java/com/threerings/tools/CompiledConfigTask.java b/src/java/com/threerings/tools/CompiledConfigTask.java index ed327058..c155a987 100644 --- a/src/java/com/threerings/tools/CompiledConfigTask.java +++ b/src/java/com/threerings/tools/CompiledConfigTask.java @@ -31,6 +31,8 @@ import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; +import com.google.common.collect.Lists; + import com.samskivert.util.FileUtil; import com.threerings.util.CompiledConfig; @@ -153,5 +155,5 @@ public class CompiledConfigTask extends Task protected File _target; protected File _dest; protected String _parser; - protected ArrayList _filesets = new ArrayList(); + protected ArrayList _filesets = Lists.newArrayList(); } diff --git a/src/java/com/threerings/util/KeyDispatcher.java b/src/java/com/threerings/util/KeyDispatcher.java index 534e5e83..d042ccf4 100644 --- a/src/java/com/threerings/util/KeyDispatcher.java +++ b/src/java/com/threerings/util/KeyDispatcher.java @@ -40,6 +40,8 @@ import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; import javax.swing.text.JTextComponent; +import com.google.common.collect.Lists; + import com.samskivert.util.HashIntMap; /** @@ -266,7 +268,7 @@ public class KeyDispatcher new LinkedList(); /** Global key listeners. */ - protected ArrayList _listeners = new ArrayList(); + protected ArrayList _listeners = Lists.newArrayList(); /** Keys that are currently held down. */ protected HashIntMap _downKeys = new HashIntMap(); diff --git a/src/java/com/threerings/util/KeyTranslatorImpl.java b/src/java/com/threerings/util/KeyTranslatorImpl.java index 339a4537..606cbf3b 100644 --- a/src/java/com/threerings/util/KeyTranslatorImpl.java +++ b/src/java/com/threerings/util/KeyTranslatorImpl.java @@ -25,6 +25,9 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + import com.samskivert.util.HashIntMap; /** @@ -47,7 +50,7 @@ public class KeyTranslatorImpl * Adds a mapping from a key press to an action command string that will auto-repeat at the * specified repeat rate. Overwrites any existing mapping and repeat rate that may have * already been registered. - * + * * @param rate the number of times each second that the key press should be repeated while the * key is down, or 0 to disable auto-repeat for the key. */ @@ -60,7 +63,7 @@ public class KeyTranslatorImpl * Adds a mapping from a key press to an action command string that will auto-repeat at the * specified repeat rate after the specified auto-repeat delay has expired. Overwrites any * existing mapping for the specified key code that may have already been registered. - * + * * @param rate the number of times each second that the key press should be repeated while the * key is down; passing 0 will result in no repeating. * @param repeatDelay the delay in milliseconds before auto-repeating key press events will be @@ -116,7 +119,7 @@ public class KeyTranslatorImpl KeyRecord krec = _keys.get(keyCode); return (krec == null) ? null : krec.pressCommand; } - + // documentation inherited from interface KeyTranslator public String getPressCommand (char ch) { @@ -130,7 +133,7 @@ public class KeyTranslatorImpl KeyRecord krec = _keys.get(keyCode); return (krec == null) ? null : krec.releaseCommand; } - + // documentation inherited from interface KeyTranslator public String getReleaseCommand (char ch) { @@ -144,7 +147,7 @@ public class KeyTranslatorImpl KeyRecord krec = _keys.get(keyCode); return (krec == null) ? DEFAULT_REPEAT_RATE : krec.repeatRate; } - + // documentation inherited from interface KeyTranslator public int getRepeatRate (char ch) { @@ -158,7 +161,7 @@ public class KeyTranslatorImpl KeyRecord krec = _keys.get(keyCode); return (krec == null) ? DEFAULT_REPEAT_DELAY : krec.repeatDelay; } - + // documentation inherited from interface KeyTranslator public long getRepeatDelay (char ch) { @@ -169,7 +172,7 @@ public class KeyTranslatorImpl // documentation inherited from interface KeyTranslator public Iterator enumeratePressCommands () { - ArrayList commands = new ArrayList(); + ArrayList commands = Lists.newArrayList(); for (KeyRecord rec : _keys.values()) { commands.add(rec.pressCommand); } @@ -180,7 +183,7 @@ public class KeyTranslatorImpl // documentation inherited from interface KeyTranslator public Iterator enumerateReleaseCommands () { - ArrayList commands = new ArrayList(); + ArrayList commands = Lists.newArrayList(); for (KeyRecord rec : _keys.values()) { commands.add(rec.releaseCommand); } @@ -195,7 +198,7 @@ public class KeyTranslatorImpl /** The command to be posted when the key is released. */ public String releaseCommand; - + /** The rate in presses per second at which the key is to be auto-repeated. */ public int repeatRate; @@ -205,14 +208,14 @@ public class KeyTranslatorImpl */ public long repeatDelay; } - + /** The keys for which commands are registered. */ protected HashIntMap _keys = new HashIntMap(); /** * Any commands we wish to perform upon key typed events for characters. */ - protected HashMap _charCommands = new HashMap(); + protected HashMap _charCommands = Maps.newHashMap(); /** The default key press repeat rate. */ protected static final int DEFAULT_REPEAT_RATE = 5; diff --git a/src/java/com/threerings/util/KeyboardManager.java b/src/java/com/threerings/util/KeyboardManager.java index 5962eba6..6db05c0f 100644 --- a/src/java/com/threerings/util/KeyboardManager.java +++ b/src/java/com/threerings/util/KeyboardManager.java @@ -36,6 +36,8 @@ import javax.swing.SwingUtilities; import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; +import com.google.common.collect.Maps; + import com.samskivert.util.HashIntMap; import com.samskivert.util.Interval; import com.samskivert.util.ObserverList; @@ -69,7 +71,7 @@ public class KeyboardManager public interface KeyObserver { /** - * Called whenever a key event occurs for a particular key. + * Called whenever a key event occurs for a particular key. */ public void handleKeyEvent (int id, int keyCode, long timestamp); } @@ -180,7 +182,7 @@ public class KeyboardManager if (_window != null) { _window.addWindowFocusListener(this); } - } + } // assume the keyboard focus since we were just enabled _focus = true; @@ -275,7 +277,7 @@ public class KeyboardManager case KeyEvent.KEY_TYPED: return keyTyped(e); - + default: return false; } @@ -311,7 +313,7 @@ public class KeyboardManager return hasCommand; } - + /** * Called when Swing notifies us that a key has been typed while the * keyboard manager is active. @@ -330,18 +332,18 @@ public class KeyboardManager // keyboard repeating turned on. Oh well. if (_shouldDisableNativeRepeat) { _shouldDisableNativeRepeat = false; - + if (Keyboard.isAvailable()) { Keyboard.setKeyRepeat(!_shouldDisableNativeRepeat); } } - + KeyInfo info = _chars.get(keyChar); if (info == null) { info = new KeyInfo(keyChar); _chars.put(keyChar, info); } - + // remember the last time this key was pressed info.setPressTime(RunAnywhere.getWhen(e)); } @@ -351,7 +353,7 @@ public class KeyboardManager return hasCommand; } - + /** * Called when Swing notifies us that a key has been released while * the keyboard manager is active. @@ -453,7 +455,7 @@ public class KeyboardManager _pressDelay = (rate == 0) ? 0 : (1000L / rate); _repeatDelay = _xlate.getRepeatDelay(_keyCode); } - + /** * Constructs a key info object for the given character. */ @@ -467,7 +469,7 @@ public class KeyboardManager _pressDelay = (rate == 0) ? 0 : (1000L / rate); _repeatDelay = _xlate.getRepeatDelay(_keyChar); } - + /** * Returns true if we're based off a character & key typed events rather than a keycode * and key pressed/released events. @@ -494,7 +496,7 @@ public class KeyboardManager "repeatDelay", _repeatDelay, "scheduled", _scheduled); } - + if (_lastPress == 0 && _pressCommand != null) { // post the initial key press command postPress(time); @@ -527,7 +529,7 @@ public class KeyboardManager { release(time); _lastRelease = time; - + if (_debugTyping.getValue()) { log.info("setReleaseTime", "time", time, @@ -585,7 +587,7 @@ public class KeyboardManager "repeatDelay", _repeatDelay, "scheduled", _scheduled); } - + // bail if we're not currently pressed if (_lastPress == 0) { return; @@ -616,7 +618,7 @@ public class KeyboardManager long now = System.currentTimeMillis(); long deltaPress = now - _lastPress; long deltaRelease = now - _lastRelease; - + if (_debugTyping.getValue()) { log.info("expired", "time", now, @@ -636,7 +638,7 @@ public class KeyboardManager log.info("Interval", "key", _keyText, "deltaPress", deltaPress, "deltaRelease", deltaRelease); } - + // cease repeating if we're certain the key is now up, or repeat the key // command if we're certain the key is still down if (_lastRelease != _lastPress) { @@ -674,7 +676,7 @@ public class KeyboardManager "repeatDelay", _repeatDelay, "scheduled", _scheduled); } - + if (!isCharacterBased()) { notifyObservers(KeyEvent.KEY_PRESSED, _keyCode, timestamp); } else { @@ -700,7 +702,7 @@ public class KeyboardManager "repeatDelay", _repeatDelay, "scheduled", _scheduled); } - + notifyObservers(KeyEvent.KEY_RELEASED, _keyCode, timestamp); Controller.postAction(_target, _releaseCommand); } @@ -731,7 +733,7 @@ public class KeyboardManager /** The key code associated with this key info object, if any. */ protected int _keyCode = KeyEvent.VK_UNDEFINED; - + /** The character associated with this key info object, if any. */ protected char _keyChar; @@ -785,9 +787,9 @@ public class KeyboardManager /** A hashtable mapping key codes to {@link KeyInfo} objects. */ protected HashIntMap _keys = new HashIntMap(); - + /** A hashtable mapping characters to {@link KeyInfo} objects. */ - protected HashMap _chars = new HashMap(); + protected HashMap _chars = Maps.newHashMap(); /** Whether the keyboard manager currently has the keyboard focus. */ protected boolean _focus; @@ -814,13 +816,13 @@ public class KeyboardManager /** Whether native key auto-repeating was enabled when the keyboard manager was last enabled. */ protected boolean _nativeRepeat; - + /** Whether we want to disable native key auto-repeating. If we're dealing with wacky keys that * send only key typed events, we might need to fall back to letting that happen so things work * right. */ protected boolean _shouldDisableNativeRepeat = true; - + /** A debug hook that toggles excessive logging to help debug keyTyped behavior. */ protected static RuntimeAdjust.BooleanAdjust _debugTyping = new RuntimeAdjust.BooleanAdjust( "Toggles key typed debugging", "nenya.util.keyboard",