A healthy splash of google-collections
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@822 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -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<String, ArrayList<TranslatedComponent>> ccomps =
|
||||
new HashMap<String, ArrayList<TranslatedComponent>>();
|
||||
Maps.newHashMap();
|
||||
|
||||
// create colorized versions of all of the source action frames
|
||||
ArrayList<ComponentFrames> sources = new ArrayList<ComponentFrames>(ccount);
|
||||
ArrayList<ComponentFrames> 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<TranslatedComponent> tcomps = ccomps.get(ccomp.componentClass.name);
|
||||
if (tcomps == null) {
|
||||
ccomps.put(ccomp.componentClass.name,
|
||||
tcomps = new ArrayList<TranslatedComponent>());
|
||||
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<String, ArrayList<TranslatedComponent>>();
|
||||
shadows = Maps.newHashMap();
|
||||
}
|
||||
ArrayList<TranslatedComponent> shadlist = shadows.get(ccomp.componentClass.shadow);
|
||||
if (shadlist == null) {
|
||||
shadows.put(ccomp.componentClass.shadow,
|
||||
shadlist = new ArrayList<TranslatedComponent>());
|
||||
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<ComponentFrames> sources = new ArrayList<ComponentFrames>();
|
||||
ArrayList<ComponentFrames> 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<TranslatedComponent> mcomps)
|
||||
{
|
||||
ArrayList<ComponentFrames> sources = new ArrayList<ComponentFrames>();
|
||||
ArrayList<ComponentFrames> 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<Tuple<CharacterDescriptor, String>, ActionFrames> _actionFrames =
|
||||
protected Map<Tuple<CharacterDescriptor, String>, 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.
|
||||
|
||||
@@ -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<Integer> list = _components.get(cclass);
|
||||
if (list == null) {
|
||||
list = new ArrayList<Integer>();
|
||||
list = Lists.newArrayList();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -129,7 +132,7 @@ public class BuilderModel
|
||||
Integer cid = iter.next();
|
||||
ArrayList<Integer> clist = _components.get(cclass);
|
||||
if (clist == null) {
|
||||
_components.put(cclass, clist = new ArrayList<Integer>());
|
||||
_components.put(cclass, clist = Lists.newArrayList());
|
||||
}
|
||||
|
||||
clist.add(cid);
|
||||
@@ -138,14 +141,14 @@ public class BuilderModel
|
||||
}
|
||||
|
||||
/** The currently selected character components. */
|
||||
protected HashMap<ComponentClass, Integer> _selected = new HashMap<ComponentClass, Integer>();
|
||||
protected HashMap<ComponentClass, Integer> _selected = Maps.newHashMap();
|
||||
|
||||
/** The hashtable of available component ids for each class. */
|
||||
protected HashMap<ComponentClass, ArrayList<Integer>> _components = new HashMap<ComponentClass, ArrayList<Integer>>();
|
||||
protected HashMap<ComponentClass, ArrayList<Integer>> _components = Maps.newHashMap();
|
||||
|
||||
/** The list of all available component classes. */
|
||||
protected ArrayList<ComponentClass> _classes = new ArrayList<ComponentClass>();
|
||||
protected ArrayList<ComponentClass> _classes = Lists.newArrayList();
|
||||
|
||||
/** The model listeners. */
|
||||
protected ArrayList<BuilderModelListener> _listeners = new ArrayList<BuilderModelListener>();
|
||||
protected ArrayList<BuilderModelListener> _listeners = Lists.newArrayList();
|
||||
}
|
||||
|
||||
@@ -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<CharacterComponent> comps = _classComps.get(cclass);
|
||||
if (comps == null) {
|
||||
comps = new ArrayList<CharacterComponent>();
|
||||
comps = Lists.newArrayList();
|
||||
_classComps.put(cclass, comps);
|
||||
}
|
||||
if (!comps.contains(component)) {
|
||||
|
||||
@@ -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<Object> sources = new ArrayList<Object>();
|
||||
ArrayList<Object> 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<FileSet> _filesets = new ArrayList<FileSet>();
|
||||
protected ArrayList<FileSet> _filesets = Lists.newArrayList();
|
||||
|
||||
/** Used to separate keys and values in the map file. */
|
||||
protected static final String SEP_STR = " := ";
|
||||
|
||||
@@ -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<String, ActionSequence> actmap = new HashMap<String, ActionSequence>();
|
||||
Map<String, TileSet> setmap = new HashMap<String, TileSet>();
|
||||
Map<String, ActionSequence> actmap = Maps.newHashMap();
|
||||
Map<String, TileSet> 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<String, ComponentClass> clmap = new HashMap<String, ComponentClass>();
|
||||
Map<String, ComponentClass> 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<Object> setlist = new ArrayList<Object>();
|
||||
ArrayList<Object> setlist = Lists.newArrayList();
|
||||
digester.push(setlist);
|
||||
|
||||
// now fire up the digester to parse the stream
|
||||
|
||||
@@ -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<ComponentClass> classes = new ArrayList<ComponentClass>();
|
||||
for (int i = 0; i < CLASSES.length; i++) {
|
||||
String cname = gender + "/" + CLASSES[i];
|
||||
ArrayList<ComponentClass> 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<Integer> choices = new ArrayList<Integer>();
|
||||
ArrayList<Integer> choices = Lists.newArrayList();
|
||||
Iterator<Integer> iter = crepo.enumerateComponentIds(cclass);
|
||||
CollectionUtil.addAll(choices, iter);
|
||||
|
||||
|
||||
@@ -365,7 +365,7 @@ public class Model extends ModelNode
|
||||
protected Model _toCopy;
|
||||
|
||||
/** The set of added properties. */
|
||||
protected HashSet<String> _properties = new HashSet<String>();
|
||||
protected HashSet<String> _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<String, Animation>();
|
||||
_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<String, Animation>();
|
||||
_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<Spatial> targets = new HashSet<Spatial>();
|
||||
HashSet<Spatial> 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<String, Animation>();
|
||||
mstore._anims = Maps.newHashMap();
|
||||
}
|
||||
mstore._pnodes = Maps.newHashMap(properties.originalToCopy);
|
||||
mstore._animMode = _animMode;
|
||||
|
||||
@@ -53,7 +53,7 @@ public abstract class ModelController extends Controller
|
||||
if (anims.length == 0) {
|
||||
return;
|
||||
}
|
||||
_animations = new HashSet<String>();
|
||||
_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<String>();
|
||||
_animations = Sets.newHashSet();
|
||||
Collections.addAll(_animations, anims);
|
||||
} else {
|
||||
_animations = null;
|
||||
|
||||
@@ -161,7 +161,7 @@ public class ModelMesh extends TriMesh
|
||||
public void addOverlay (RenderState[] overlay)
|
||||
{
|
||||
if (_overlays == null) {
|
||||
_overlays = new ArrayList<RenderState[]>(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<GeomBatch>(1);
|
||||
batchList = Lists.newArrayListWithCapacity(1);
|
||||
TriangleBatch batch = createModelBatch();
|
||||
batch.setParentGeom(this);
|
||||
batchList.add(batch);
|
||||
|
||||
@@ -222,7 +222,7 @@ public class SkinMesh extends ModelMesh
|
||||
_weightGroups = weightGroups;
|
||||
|
||||
// compile a list of all referenced bones
|
||||
HashSet<Bone> bones = new HashSet<Bone>();
|
||||
HashSet<Bone> 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<SkinShaderConfig>(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<Bone, Bone> bmap = new HashMap<Bone, Bone>();
|
||||
HashMap<Bone, Bone> bmap = Maps.newHashMap();
|
||||
for (int ii = 0; ii < _bones.length; ii++) {
|
||||
bmap.put(_bones[ii], mstore._bones[ii] =
|
||||
_bones[ii].rebind(properties.originalToCopy));
|
||||
|
||||
@@ -58,7 +58,7 @@ public abstract class TextureController extends ModelController
|
||||
protected void initTextures ()
|
||||
{
|
||||
// find and clone all textures under the target
|
||||
final HashMap<Texture, Texture> clones = new HashMap<Texture, Texture>();
|
||||
final HashMap<Texture, Texture> clones = Maps.newHashMap();
|
||||
new SpatialVisitor<ModelMesh>(ModelMesh.class) {
|
||||
protected void visit (ModelMesh mesh) {
|
||||
TextureState otstate = (TextureState)mesh.getRenderState(RenderState.RS_TEXTURE);
|
||||
|
||||
@@ -53,8 +53,7 @@ public class AnimationDef
|
||||
public static class FrameDef
|
||||
{
|
||||
/** Transform for affected nodes. */
|
||||
public ArrayList<TransformDef> transforms =
|
||||
new ArrayList<TransformDef>();
|
||||
public ArrayList<TransformDef> 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<FrameDef> frames = new ArrayList<FrameDef>();
|
||||
public ArrayList<FrameDef> frames = Lists.newArrayList();
|
||||
|
||||
public void addFrame (FrameDef frame)
|
||||
{
|
||||
@@ -185,8 +183,8 @@ public class AnimationDef
|
||||
Properties props, HashMap<String, Spatial> nodes, HashMap<String, TransformNode> tnodes)
|
||||
{
|
||||
// find all affected nodes
|
||||
HashSet<Spatial> staticTargets = new HashSet<Spatial>(),
|
||||
transformTargets = new HashSet<Spatial>();
|
||||
HashSet<Spatial> staticTargets = Sets.newHashSet(),
|
||||
transformTargets = Sets.newHashSet();
|
||||
for (int ii = 0, nn = frames.size(); ii < nn; ii++) {
|
||||
frames.get(ii).addTransformTargets(nodes, tnodes, staticTargets, transformTargets);
|
||||
}
|
||||
|
||||
@@ -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<String, TransformNode> tnodes = new HashMap<String, TransformNode>();
|
||||
HashMap<String, TransformNode> 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<String, Spatial> nodes = new HashMap<String, Spatial>();
|
||||
HashMap<String, Spatial> nodes = Maps.newHashMap();
|
||||
Model model = mdef.createModel(props, nodes);
|
||||
model.initPrototype();
|
||||
|
||||
|
||||
@@ -81,5 +81,5 @@ public class CompileModelTask extends Task
|
||||
protected File _dest;
|
||||
|
||||
/** A list of filesets that contain XML models. */
|
||||
protected ArrayList<FileSet> _filesets = new ArrayList<FileSet>();
|
||||
protected ArrayList<FileSet> _filesets = Lists.newArrayList();
|
||||
}
|
||||
|
||||
@@ -130,5 +130,5 @@ public class ConvertModelTask extends Task
|
||||
}
|
||||
|
||||
/** A list of filesets that contain tileset bundle definitions. */
|
||||
protected ArrayList<FileSet> _filesets = new ArrayList<FileSet>();
|
||||
protected ArrayList<FileSet> _filesets = Lists.newArrayList();
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public class ModelDef
|
||||
public HashArrayList<Vertex> vertices = new HashArrayList<Vertex>();
|
||||
|
||||
/** The triangle indices. */
|
||||
public ArrayList<Integer> indices = new ArrayList<Integer>();
|
||||
public ArrayList<Integer> 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<Triangle>();
|
||||
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<String, SkinMesh.Bone> bones =
|
||||
new HashMap<String, SkinMesh.Bone>();
|
||||
SkinMesh.WeightGroup[] wgroups = new SkinMesh.WeightGroup[_groups.size()];
|
||||
HashMap<String, SkinMesh.Bone> bones = Maps.newHashMap();
|
||||
int ii = 0;
|
||||
int mweights = 0, tweights = 0;
|
||||
for (Map.Entry<Set<String>, WeightGroupDef> entry :
|
||||
@@ -444,7 +442,7 @@ public class ModelDef
|
||||
protected void configureMesh (Properties props)
|
||||
{
|
||||
// divide the vertices up by weight groups
|
||||
_groups = new HashMap<Set<String>, WeightGroupDef>();
|
||||
_groups = Maps.newHashMap();
|
||||
for (int ii = 0, nn = vertices.size(); ii < nn; ii++) {
|
||||
SkinVertex svertex = (SkinVertex)vertices.get(ii);
|
||||
Set<String> 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<String, BoneWeight> boneWeights =
|
||||
new HashMap<String, BoneWeight>();
|
||||
public HashMap<String, BoneWeight> boneWeights = Maps.newHashMap();
|
||||
|
||||
public void addBoneWeight (BoneWeight weight)
|
||||
{
|
||||
@@ -616,7 +613,7 @@ public class ModelDef
|
||||
/** Finds the bone nodes influencing this vertex. */
|
||||
public HashSet<ModelNode> getBones (HashMap<String, Spatial> nodes)
|
||||
{
|
||||
HashSet<ModelNode> bones = new HashSet<ModelNode>();
|
||||
HashSet<ModelNode> 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<Integer> indices = new ArrayList<Integer>();
|
||||
public ArrayList<Integer> indices = Lists.newArrayList();
|
||||
|
||||
/** The interleaved vertex weights. */
|
||||
public ArrayList<Float> weights = new ArrayList<Float>();
|
||||
public ArrayList<Float> 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<SpatialDef> spatials = new ArrayList<SpatialDef>();
|
||||
public ArrayList<SpatialDef> 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<String> bones = new HashSet<String>();
|
||||
HashSet<String> 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<Tuple<TransformNode, Matrix4f>>();
|
||||
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<Spatial> referenced = new HashSet<Spatial>();
|
||||
// then go through again, resolving any name references and attaching root children
|
||||
HashSet<Spatial> 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<Object, Integer> _indices = new HashMap<Object, Integer>();
|
||||
protected HashMap<Object, Integer> _indices = Maps.newHashMap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -738,8 +738,7 @@ public class ModelViewer extends JmeCanvasApp
|
||||
}
|
||||
return tstate;
|
||||
}
|
||||
protected HashMap<String, TextureState> _tstates =
|
||||
new HashMap<String, TextureState>();
|
||||
protected HashMap<String, TextureState> _tstates = Maps.newHashMap();
|
||||
});
|
||||
_model.updateRenderState();
|
||||
}
|
||||
|
||||
@@ -380,16 +380,13 @@ public class ImageCache
|
||||
protected ResourceManager _rsrcmgr;
|
||||
|
||||
/** A cache of {@link Image} instances. */
|
||||
protected HashMap<String,WeakReference<Image>> _imgcache =
|
||||
new HashMap<String,WeakReference<Image>>();
|
||||
protected HashMap<String,WeakReference<Image>> _imgcache = Maps.newHashMap();
|
||||
|
||||
/** A cache of {@link BImage} instances. */
|
||||
protected HashMap<String,WeakReference<BImage>> _buicache =
|
||||
new HashMap<String,WeakReference<BImage>>();
|
||||
protected HashMap<String,WeakReference<BImage>> _buicache = Maps.newHashMap();
|
||||
|
||||
/** A cache of {@link BufferedImage} instances. */
|
||||
protected HashMap<String,WeakReference<BufferedImage>> _bufcache =
|
||||
new HashMap<String,WeakReference<BufferedImage>>();
|
||||
protected HashMap<String,WeakReference<BufferedImage>> _bufcache = Maps.newHashMap();
|
||||
|
||||
/** Used to create buffered images in a format compatible with OpenGL. */
|
||||
protected static ComponentColorModel GL_ALPHA_MODEL = new ComponentColorModel(
|
||||
|
||||
@@ -218,7 +218,7 @@ public class ShaderCache
|
||||
public String frag;
|
||||
|
||||
/** The set of preprocessor definitions. */
|
||||
public HashSet<String> defs = new HashSet<String>();
|
||||
public HashSet<String> 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<String, String> _sources = new HashMap<String, String>();
|
||||
protected HashMap<String, String> _sources = Maps.newHashMap();
|
||||
|
||||
/** Maps shader keys to linked program ids. */
|
||||
protected HashMap<ShaderKey, Integer> _programIds = new HashMap<ShaderKey, Integer>();
|
||||
protected HashMap<ShaderKey, Integer> _programIds = Maps.newHashMap();
|
||||
}
|
||||
|
||||
@@ -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<String> defs = new ArrayList<String>();
|
||||
ArrayList<String> defs = Lists.newArrayList();
|
||||
getDefinitions(defs);
|
||||
String[] darray = defs.toArray(new String[defs.size()]), ddarray = null;
|
||||
if (!_scache.isLoaded(vert, frag, darray)) {
|
||||
ArrayList<String> ddefs = new ArrayList<String>();
|
||||
ArrayList<String> ddefs = Lists.newArrayList();
|
||||
getDerivedDefinitions(ddefs);
|
||||
ddarray = ddefs.toArray(new String[ddefs.size()]);
|
||||
}
|
||||
|
||||
@@ -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<Obscurer>();
|
||||
_obscurerList = Lists.newArrayList();
|
||||
}
|
||||
_obscurerList.add(obscurer);
|
||||
}
|
||||
@@ -640,7 +642,7 @@ public class MediaPanel extends JComponent
|
||||
*/
|
||||
protected Sprite getHit (MouseEvent me)
|
||||
{
|
||||
ArrayList<Sprite> list = new ArrayList<Sprite>();
|
||||
ArrayList<Sprite> 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);
|
||||
|
||||
@@ -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<ViewTracker> _trackers = new ArrayList<ViewTracker>();
|
||||
protected ArrayList<ViewTracker> _trackers = Lists.newArrayList();
|
||||
}
|
||||
|
||||
@@ -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<Animation> avoidables =
|
||||
@SuppressWarnings("unchecked") ArrayList<Animation> avoidables =
|
||||
(ArrayList<Animation>) _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<Animation> _avoidAnims = new ArrayList<Animation>();
|
||||
protected ArrayList<Animation> _avoidAnims = Lists.newArrayList();
|
||||
|
||||
/** Automatically removes avoid animations when they're done. */
|
||||
protected AnimationAdapter _avoidAnimObs = new AnimationAdapter() {
|
||||
|
||||
@@ -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<AnimRecord> _queued = new ArrayList<AnimRecord>();
|
||||
protected ArrayList<AnimRecord> _queued = Lists.newArrayList();
|
||||
|
||||
/** Animations that are currently running. */
|
||||
protected ArrayList<AnimRecord> _running = new ArrayList<AnimRecord>();
|
||||
protected ArrayList<AnimRecord> _running = Lists.newArrayList();
|
||||
|
||||
/** The timestamp at which we fired the last animation. */
|
||||
protected long _lastStamp;
|
||||
|
||||
@@ -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<ColorRecord> list = new ArrayList<ColorRecord>();
|
||||
ArrayList<ColorRecord> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Tuple<Colorization[], BufferedImage>>();
|
||||
_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<ImageKey, CacheRecord> _ccache;
|
||||
|
||||
/** The set of all keys we've ever seen. */
|
||||
protected HashSet<ImageKey> _keySet = new HashSet<ImageKey>();
|
||||
protected HashSet<ImageKey> _keySet = Sets.newHashSet();
|
||||
|
||||
/** Throttle our cache status logging to once every 300 seconds. */
|
||||
protected Throttle _cacheStatThrottle = new Throttle(1, 300000L);
|
||||
|
||||
@@ -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<SoundKey,byte[][]> _lockedClips = new HashMap<SoundKey,byte[][]>();
|
||||
protected HashMap<SoundKey,byte[][]> _lockedClips = Maps.newHashMap();
|
||||
|
||||
/** Soundkey command constants. */
|
||||
protected static final byte PLAY = 0;
|
||||
|
||||
@@ -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<TileSet> idmap = new HashIntMap<TileSet>();
|
||||
HashMap<String, Integer> namemap = new HashMap<String, Integer>();
|
||||
HashMap<String, Integer> 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
|
||||
|
||||
@@ -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<Mapping> mappings = new ArrayList<Mapping>();
|
||||
ArrayList<Mapping> 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<TileSet> sets = new ArrayList<TileSet>();
|
||||
ArrayList<TileSet> 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<Integer> 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<TileSet> toUpdate = new HashIntMap<TileSet>();
|
||||
|
||||
@@ -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<FileSet> _filesets = new ArrayList<FileSet>();
|
||||
protected ArrayList<FileSet> _filesets = Lists.newArrayList();
|
||||
}
|
||||
|
||||
@@ -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<String, Integer>();
|
||||
_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<String, Integer>();
|
||||
_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();
|
||||
|
||||
@@ -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<TileSet> setlist = new ArrayList<TileSet>();
|
||||
List<TileSet> setlist = Lists.newArrayList();
|
||||
_digester.push(setlist);
|
||||
|
||||
// now fire up the digester to parse the stream
|
||||
|
||||
@@ -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<Integer> sortedKeys = new ArrayList<Integer>();
|
||||
ArrayList<Integer> sortedKeys = Lists.newArrayList();
|
||||
sortedKeys.addAll(colClass.colors.keySet());
|
||||
|
||||
QuickSort.sort(sortedKeys, new Comparator<Integer>() {
|
||||
@@ -340,7 +342,7 @@ public class RecolorImage extends JPanel
|
||||
|
||||
_classList.removeAllItems();
|
||||
Iterator<ColorPository.ClassRecord> iter = _colRepo.enumerateClasses();
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
ArrayList<String> names = Lists.newArrayList();
|
||||
while (iter.hasNext()) {
|
||||
String str = iter.next().name;
|
||||
names.add(str);
|
||||
|
||||
@@ -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<FileSet> _filesets = new ArrayList<FileSet>();
|
||||
|
||||
protected ArrayList<FileSet> _filesets = Lists.newArrayList();
|
||||
|
||||
/** The name of the file to which we should write the index. */
|
||||
protected String _indexFile;
|
||||
}
|
||||
|
||||
@@ -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<Point> getNodePath (Node n)
|
||||
{
|
||||
Node cur = n;
|
||||
ArrayList<Point> path = new ArrayList<Point>();
|
||||
ArrayList<Point> 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<Node>();
|
||||
closed = new ArrayList<Node>();
|
||||
closed = Lists.newArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<PathNode> _nodes = new ArrayList<PathNode>();
|
||||
protected ArrayList<PathNode> _nodes = Lists.newArrayList();
|
||||
|
||||
/** We use this when moving along this path. */
|
||||
protected Iterator<PathNode> _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. */
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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<String, PerformanceAction> actions = _observers.get(obs);
|
||||
if (actions == null) {
|
||||
// create it if it didn't exist
|
||||
_observers.put(obs, actions = new HashMap<String, PerformanceAction>());
|
||||
_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<PerformanceObserver, Map<String, PerformanceAction>> _observers =
|
||||
protected static Map<PerformanceObserver, Map<String, PerformanceAction>> _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. */
|
||||
|
||||
@@ -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<DirtyItem> _rcomp = new RenderComparator();
|
||||
|
||||
/** Unused dirty items. */
|
||||
protected ArrayList<DirtyItem> _freelist = new ArrayList<DirtyItem>();
|
||||
protected ArrayList<DirtyItem> _freelist = Lists.newArrayList();
|
||||
|
||||
/** Whether to log debug info when comparing pairs of dirty items. */
|
||||
protected static final boolean DEBUG_COMPARE = false;
|
||||
|
||||
@@ -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<IntTuple, BlockGlyph> _blocks = new HashMap<IntTuple, BlockGlyph>();
|
||||
protected HashMap<IntTuple, BlockGlyph> _blocks = Maps.newHashMap();
|
||||
|
||||
protected static final int TILE_SIZE = 10;
|
||||
protected static final int MAX_WIDTH = 30;
|
||||
|
||||
@@ -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<SceneObject> scobjs = new ArrayList<SceneObject>();
|
||||
ArrayList<SceneObject> scobjs = Lists.newArrayList();
|
||||
now = System.currentTimeMillis();
|
||||
for (int ii = 0, ll = set.size(); ii < ll; ii++) {
|
||||
SceneObject scobj = makeSceneObject(set.get(ii));
|
||||
|
||||
@@ -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<FringeTileSetRecord> tilesets = new ArrayList<FringeTileSetRecord>();
|
||||
public ArrayList<FringeTileSetRecord> tilesets = Lists.newArrayList();
|
||||
|
||||
/** Used when parsing the tilesets definitions. */
|
||||
public void addTileset (FringeTileSetRecord record)
|
||||
|
||||
@@ -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<ObjectInfo> ilist =
|
||||
@SuppressWarnings("unchecked") ArrayList<ObjectInfo> ilist =
|
||||
(ArrayList<ObjectInfo>)target;
|
||||
ArrayList<ObjectInfo> ulist = new ArrayList<ObjectInfo>();
|
||||
ArrayList<ObjectInfo> ulist = Lists.newArrayList();
|
||||
SimpleMisoSceneModel model = (SimpleMisoSceneModel)
|
||||
digester.peek(1);
|
||||
|
||||
|
||||
@@ -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<QueuedFile> _queue = new ArrayList<QueuedFile>();
|
||||
protected ArrayList<QueuedFile> _queue = Lists.newArrayList();
|
||||
|
||||
/** A file queued for play. */
|
||||
protected class QueuedFile
|
||||
|
||||
@@ -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<PooledSource> _sources = new ArrayList<PooledSource>();
|
||||
protected ArrayList<PooledSource> _sources = Lists.newArrayList();
|
||||
}
|
||||
|
||||
@@ -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<ClipBuffer> _toLoad;
|
||||
|
||||
/** The list of active streams. */
|
||||
protected ArrayList<Stream> _streams = new ArrayList<Stream>();
|
||||
protected ArrayList<Stream> _streams = Lists.newArrayList();
|
||||
|
||||
/** The list of sources to be deleted. */
|
||||
protected int[] _finalizedSources;
|
||||
|
||||
@@ -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<Buffer> _queue = new ArrayList<Buffer>();
|
||||
protected ArrayList<Buffer> _queue = Lists.newArrayList();
|
||||
}
|
||||
|
||||
@@ -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<ResourceBundle> dlist = new ArrayList<ResourceBundle>();
|
||||
List<ResourceBundle> 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<ResourceBundle> list = new ArrayList<ResourceBundle>();
|
||||
ArrayList<ResourceBundle> 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<ResourceBundle> dlist)
|
||||
{
|
||||
List<ResourceBundle> set = new ArrayList<ResourceBundle>();
|
||||
List<ResourceBundle> set = Lists.newArrayList();
|
||||
StringTokenizer tok = new StringTokenizer(definition, ":");
|
||||
while (tok.hasMoreTokens()) {
|
||||
set.add(createResourceBundle(setType, tok.nextToken().trim(), dlist));
|
||||
|
||||
@@ -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<FileSet> _filesets = new ArrayList<FileSet>();
|
||||
protected ArrayList<FileSet> _filesets = Lists.newArrayList();
|
||||
}
|
||||
|
||||
@@ -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<JTextComponent>();
|
||||
|
||||
/** Global key listeners. */
|
||||
protected ArrayList<KeyListener> _listeners = new ArrayList<KeyListener>();
|
||||
protected ArrayList<KeyListener> _listeners = Lists.newArrayList();
|
||||
|
||||
/** Keys that are currently held down. */
|
||||
protected HashIntMap<KeyEvent> _downKeys = new HashIntMap<KeyEvent>();
|
||||
|
||||
@@ -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 <code>0</code> 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 <code>0</code> 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<String> enumeratePressCommands ()
|
||||
{
|
||||
ArrayList<String> commands = new ArrayList<String>();
|
||||
ArrayList<String> 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<String> enumerateReleaseCommands ()
|
||||
{
|
||||
ArrayList<String> commands = new ArrayList<String>();
|
||||
ArrayList<String> 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<KeyRecord> _keys = new HashIntMap<KeyRecord>();
|
||||
|
||||
/**
|
||||
* Any commands we wish to perform upon key typed events for characters.
|
||||
*/
|
||||
protected HashMap<Character,KeyRecord> _charCommands = new HashMap<Character,KeyRecord>();
|
||||
protected HashMap<Character,KeyRecord> _charCommands = Maps.newHashMap();
|
||||
|
||||
/** The default key press repeat rate. */
|
||||
protected static final int DEFAULT_REPEAT_RATE = 5;
|
||||
|
||||
@@ -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<KeyInfo> _keys = new HashIntMap<KeyInfo>();
|
||||
|
||||
|
||||
/** A hashtable mapping characters to {@link KeyInfo} objects. */
|
||||
protected HashMap<Character,KeyInfo> _chars = new HashMap<Character,KeyInfo>();
|
||||
protected HashMap<Character,KeyInfo> _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",
|
||||
|
||||
Reference in New Issue
Block a user