Code hygiene. Not as pedantic as I'd like, but I couldn't resist the huge time
saver that is Eclipse's "Infer generic types" which leaves HashMap and ArrayList as the declared type where I would normally prefer to change those to Map and List and use Maps and Lists to instantiate them. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@593 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -28,6 +28,8 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import com.samskivert.swing.RuntimeAdjust;
|
import com.samskivert.swing.RuntimeAdjust;
|
||||||
import com.samskivert.util.LRUHashMap;
|
import com.samskivert.util.LRUHashMap;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
@@ -38,6 +40,7 @@ import com.threerings.media.image.ImageManager;
|
|||||||
import com.threerings.util.DirectionCodes;
|
import com.threerings.util.DirectionCodes;
|
||||||
|
|
||||||
import com.threerings.cast.CompositedActionFrames.ComponentFrames;
|
import com.threerings.cast.CompositedActionFrames.ComponentFrames;
|
||||||
|
import com.threerings.cast.CompositedActionFrames.CompositedFramesKey;
|
||||||
|
|
||||||
import static com.threerings.cast.Log.log;
|
import static com.threerings.cast.Log.log;
|
||||||
|
|
||||||
@@ -68,18 +71,18 @@ public class CharacterManager
|
|||||||
_crepo = crepo;
|
_crepo = crepo;
|
||||||
|
|
||||||
// populate our actions table
|
// populate our actions table
|
||||||
Iterator iter = crepo.enumerateActionSequences();
|
Iterator<ActionSequence> iter = crepo.enumerateActionSequences();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
ActionSequence action = (ActionSequence)iter.next();
|
ActionSequence action = iter.next();
|
||||||
_actions.put(action.name, action);
|
_actions.put(action.name, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a cache for our composited action frames
|
// create a cache for our composited action frames
|
||||||
log.debug("Creating action cache [size=" + _runCacheSize + "k].");
|
log.debug("Creating action cache [size=" + _runCacheSize + "k].");
|
||||||
_frameCache = new LRUHashMap(_runCacheSize * 1024, new LRUHashMap.ItemSizer() {
|
_frameCache = new LRUHashMap<CompositedFramesKey, CompositedMultiFrameImage>(
|
||||||
public int computeSize (Object value) {
|
_runCacheSize * 1024, new LRUHashMap.ItemSizer<CompositedMultiFrameImage>() {
|
||||||
return (int)((CompositedMultiFrameImage)
|
public int computeSize (CompositedMultiFrameImage value) {
|
||||||
value).getEstimatedMemoryUsage();
|
return (int)value.getEstimatedMemoryUsage();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_frameCache.setTracking(true); // TODO
|
_frameCache.setTracking(true); // TODO
|
||||||
@@ -100,16 +103,8 @@ public class CharacterManager
|
|||||||
* @exception IllegalArgumentException thrown if the supplied class
|
* @exception IllegalArgumentException thrown if the supplied class
|
||||||
* does not derive from {@link CharacterSprite}.
|
* does not derive from {@link CharacterSprite}.
|
||||||
*/
|
*/
|
||||||
public void setCharacterClass (Class charClass)
|
public void setCharacterClass (Class<? extends CharacterSprite> charClass)
|
||||||
{
|
{
|
||||||
// sanity check
|
|
||||||
if (!CharacterSprite.class.isAssignableFrom(charClass)) {
|
|
||||||
String errmsg = "Requested to use character sprite class that " +
|
|
||||||
"does not derive from CharacterSprite " +
|
|
||||||
"[class=" + charClass.getName() + "].";
|
|
||||||
throw new IllegalArgumentException(errmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// make a note of it
|
// make a note of it
|
||||||
_charClass = charClass;
|
_charClass = charClass;
|
||||||
}
|
}
|
||||||
@@ -173,8 +168,8 @@ public class CharacterManager
|
|||||||
CharacterDescriptor descrip, String action)
|
CharacterDescriptor descrip, String action)
|
||||||
throws NoSuchComponentException
|
throws NoSuchComponentException
|
||||||
{
|
{
|
||||||
Tuple key = new Tuple(descrip, action);
|
Tuple<CharacterDescriptor, String> key = new Tuple<CharacterDescriptor, String>(descrip, action);
|
||||||
ActionFrames frames = (ActionFrames)_actionFrames.get(key);
|
ActionFrames frames = _actionFrames.get(key);
|
||||||
if (frames == null) {
|
if (frames == null) {
|
||||||
// this doesn't actually composite the images, but prepares an
|
// this doesn't actually composite the images, but prepares an
|
||||||
// object to be able to do so
|
// object to be able to do so
|
||||||
@@ -223,7 +218,7 @@ public class CharacterManager
|
|||||||
*/
|
*/
|
||||||
public ActionSequence getActionSequence (String action)
|
public ActionSequence getActionSequence (String action)
|
||||||
{
|
{
|
||||||
return (ActionSequence)_actions.get(action);
|
return _actions.get(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -233,10 +228,9 @@ public class CharacterManager
|
|||||||
protected long getEstimatedCacheMemoryUsage ()
|
protected long getEstimatedCacheMemoryUsage ()
|
||||||
{
|
{
|
||||||
long size = 0;
|
long size = 0;
|
||||||
Iterator iter = _frameCache.values().iterator();
|
Iterator<CompositedMultiFrameImage> iter = _frameCache.values().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
size += ((CompositedMultiFrameImage)
|
size += iter.next().getEstimatedMemoryUsage();
|
||||||
iter.next()).getEstimatedMemoryUsage();
|
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@@ -434,17 +428,18 @@ public class CharacterManager
|
|||||||
protected ComponentRepository _crepo;
|
protected ComponentRepository _crepo;
|
||||||
|
|
||||||
/** A table of our action sequences. */
|
/** A table of our action sequences. */
|
||||||
protected HashMap _actions = new HashMap();
|
protected Map<String, ActionSequence> _actions = Maps.newHashMap();
|
||||||
|
|
||||||
/** A table of composited action sequences (these don't reference the
|
/** A table of composited action sequences (these don't reference the
|
||||||
* actual image data directly and thus take up little memory). */
|
* actual image data directly and thus take up little memory). */
|
||||||
protected HashMap _actionFrames = new HashMap();
|
protected Map<Tuple<CharacterDescriptor, String>, ActionFrames> _actionFrames =
|
||||||
|
Maps.newHashMap();
|
||||||
|
|
||||||
/** A cache of composited animation frames. */
|
/** A cache of composited animation frames. */
|
||||||
protected LRUHashMap _frameCache;
|
protected LRUHashMap<CompositedFramesKey, CompositedMultiFrameImage> _frameCache;
|
||||||
|
|
||||||
/** The character class to be created. */
|
/** The character class to be created. */
|
||||||
protected Class<CharacterSprite> _charClass = CharacterSprite.class;
|
protected Class<? extends CharacterSprite> _charClass = CharacterSprite.class;
|
||||||
|
|
||||||
/** The action animation cache, if we have one. */
|
/** The action animation cache, if we have one. */
|
||||||
protected ActionCache _acache;
|
protected ActionCache _acache;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class ComponentClass implements Serializable
|
|||||||
/** Used to effect custom render orders for particular actions,
|
/** Used to effect custom render orders for particular actions,
|
||||||
* orientations, etc. */
|
* orientations, etc. */
|
||||||
public static class PriorityOverride
|
public static class PriorityOverride
|
||||||
implements Comparable, Serializable
|
implements Comparable<PriorityOverride>, Serializable
|
||||||
{
|
{
|
||||||
/** The overridden render priority value. */
|
/** The overridden render priority value. */
|
||||||
public int renderPriority;
|
public int renderPriority;
|
||||||
@@ -69,11 +69,10 @@ public class ComponentClass implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int compareTo (Object other)
|
public int compareTo (PriorityOverride po)
|
||||||
{
|
{
|
||||||
// overrides with both an action and an orientation should
|
// overrides with both an action and an orientation should
|
||||||
// come first in the list
|
// come first in the list
|
||||||
PriorityOverride po = (PriorityOverride)other;
|
|
||||||
int pri = priority(), opri = po.priority();
|
int pri = priority(), opri = po.priority();
|
||||||
if (pri == opri) {
|
if (pri == opri) {
|
||||||
return hashCode() - po.hashCode();
|
return hashCode() - po.hashCode();
|
||||||
@@ -150,7 +149,7 @@ public class ComponentClass implements Serializable
|
|||||||
// closest match
|
// closest match
|
||||||
int ocount = (_overrides != null) ? _overrides.size() : 0;
|
int ocount = (_overrides != null) ? _overrides.size() : 0;
|
||||||
for (int ii = 0; ii < ocount; ii++) {
|
for (int ii = 0; ii < ocount; ii++) {
|
||||||
PriorityOverride over = (PriorityOverride)_overrides.get(ii);
|
PriorityOverride over = _overrides.get(ii);
|
||||||
// based on the way the overrides are sorted, the first match
|
// based on the way the overrides are sorted, the first match
|
||||||
// is the most specific and the one we want
|
// is the most specific and the one we want
|
||||||
if (over.matches(action, orientation)) {
|
if (over.matches(action, orientation)) {
|
||||||
@@ -168,7 +167,7 @@ public class ComponentClass implements Serializable
|
|||||||
public void addPriorityOverride (PriorityOverride override)
|
public void addPriorityOverride (PriorityOverride override)
|
||||||
{
|
{
|
||||||
if (_overrides == null) {
|
if (_overrides == null) {
|
||||||
_overrides = new ComparableArrayList();
|
_overrides = new ComparableArrayList<PriorityOverride>();
|
||||||
}
|
}
|
||||||
_overrides.insertSorted(override);
|
_overrides.insertSorted(override);
|
||||||
}
|
}
|
||||||
@@ -235,7 +234,7 @@ public class ComponentClass implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** A list of render priority overrides. */
|
/** A list of render priority overrides. */
|
||||||
protected ComparableArrayList _overrides;
|
protected ComparableArrayList<PriorityOverride> _overrides;
|
||||||
|
|
||||||
/** Increase this value when object's serialized state is impacted by
|
/** Increase this value when object's serialized state is impacted by
|
||||||
* a class change (modification of fields, inheritance). */
|
* a class change (modification of fields, inheritance). */
|
||||||
|
|||||||
@@ -55,17 +55,17 @@ public interface ComponentRepository
|
|||||||
* Iterates over the {@link ComponentClass} instances representing all
|
* Iterates over the {@link ComponentClass} instances representing all
|
||||||
* available character component classes.
|
* available character component classes.
|
||||||
*/
|
*/
|
||||||
public Iterator enumerateComponentClasses ();
|
public Iterator<ComponentClass> enumerateComponentClasses ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over the {@link ActionSequence} instances representing
|
* Iterates over the {@link ActionSequence} instances representing
|
||||||
* every available action sequence.
|
* every available action sequence.
|
||||||
*/
|
*/
|
||||||
public Iterator enumerateActionSequences ();
|
public Iterator<ActionSequence> enumerateActionSequences ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over the component ids of all components in the specified
|
* Iterates over the component ids of all components in the specified
|
||||||
* class.
|
* class.
|
||||||
*/
|
*/
|
||||||
public Iterator enumerateComponentIds (ComponentClass compClass);
|
public Iterator<Integer> enumerateComponentIds (ComponentClass compClass);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
|
|
||||||
package com.threerings.cast;
|
package com.threerings.cast;
|
||||||
|
|
||||||
import com.samskivert.util.LRUHashMap;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
import com.threerings.media.image.ImageManager;
|
import com.threerings.media.image.ImageManager;
|
||||||
@@ -66,8 +67,9 @@ public class CompositedActionFrames
|
|||||||
* source frames and colorization configuration. The actual component
|
* source frames and colorization configuration. The actual component
|
||||||
* frame images will not be composited until they are requested.
|
* frame images will not be composited until they are requested.
|
||||||
*/
|
*/
|
||||||
public CompositedActionFrames (ImageManager imgr, LRUHashMap frameCache,
|
public CompositedActionFrames (
|
||||||
String action, ComponentFrames[] sources)
|
ImageManager imgr, Map<CompositedFramesKey, CompositedMultiFrameImage> frameCache,
|
||||||
|
String action, ComponentFrames[] sources)
|
||||||
{
|
{
|
||||||
// sanity check
|
// sanity check
|
||||||
if (sources == null || sources.length == 0) {
|
if (sources == null || sources.length == 0) {
|
||||||
@@ -98,7 +100,7 @@ public class CompositedActionFrames
|
|||||||
{
|
{
|
||||||
_key.setOrient(orient);
|
_key.setOrient(orient);
|
||||||
CompositedMultiFrameImage cmfi =
|
CompositedMultiFrameImage cmfi =
|
||||||
(CompositedMultiFrameImage)_frameCache.get(_key);
|
_frameCache.get(_key);
|
||||||
if (cmfi == null) {
|
if (cmfi == null) {
|
||||||
cmfi = createFrames(orient);
|
cmfi = createFrames(orient);
|
||||||
_frameCache.put(new CompositedFramesKey(orient), cmfi);
|
_frameCache.put(new CompositedFramesKey(orient), cmfi);
|
||||||
@@ -183,7 +185,7 @@ public class CompositedActionFrames
|
|||||||
protected ImageManager _imgr;
|
protected ImageManager _imgr;
|
||||||
|
|
||||||
/** Used to cache our composited action frame images. */
|
/** Used to cache our composited action frame images. */
|
||||||
protected LRUHashMap _frameCache;
|
protected Map<CompositedFramesKey, CompositedMultiFrameImage> _frameCache;
|
||||||
|
|
||||||
/** The action for which we're compositing frames. */
|
/** The action for which we're compositing frames. */
|
||||||
protected String _action;
|
protected String _action;
|
||||||
|
|||||||
@@ -65,14 +65,14 @@ public class BuilderModel
|
|||||||
{
|
{
|
||||||
int size = _listeners.size();
|
int size = _listeners.size();
|
||||||
for (int ii = 0; ii < size; ii++) {
|
for (int ii = 0; ii < size; ii++) {
|
||||||
((BuilderModelListener)_listeners.get(ii)).modelChanged(event);
|
_listeners.get(ii).modelChanged(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of the available component classes.
|
* Returns a list of the available component classes.
|
||||||
*/
|
*/
|
||||||
public List getComponentClasses ()
|
public List<ComponentClass> getComponentClasses ()
|
||||||
{
|
{
|
||||||
return Collections.unmodifiableList(_classes);
|
return Collections.unmodifiableList(_classes);
|
||||||
}
|
}
|
||||||
@@ -80,11 +80,11 @@ public class BuilderModel
|
|||||||
/**
|
/**
|
||||||
* Returns the list of components available in the specified class.
|
* Returns the list of components available in the specified class.
|
||||||
*/
|
*/
|
||||||
public List getComponents (ComponentClass cclass)
|
public List<Integer> getComponents (ComponentClass cclass)
|
||||||
{
|
{
|
||||||
List list = (List)_components.get(cclass);
|
List<Integer> list = _components.get(cclass);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = new ArrayList();
|
list = new ArrayList<Integer>();
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -95,9 +95,9 @@ public class BuilderModel
|
|||||||
public int[] getSelectedComponents ()
|
public int[] getSelectedComponents ()
|
||||||
{
|
{
|
||||||
int[] values = new int[_selected.size()];
|
int[] values = new int[_selected.size()];
|
||||||
Iterator iter = _selected.values().iterator();
|
Iterator<Integer> iter = _selected.values().iterator();
|
||||||
for (int i = 0; iter.hasNext(); i++) {
|
for (int i = 0; iter.hasNext(); i++) {
|
||||||
values[i] = ((Integer)iter.next()).intValue();
|
values[i] = iter.next().intValue();
|
||||||
}
|
}
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
@@ -122,14 +122,14 @@ public class BuilderModel
|
|||||||
|
|
||||||
for (int ii = 0; ii < _classes.size(); ii++) {
|
for (int ii = 0; ii < _classes.size(); ii++) {
|
||||||
// get the list of components available for this class
|
// get the list of components available for this class
|
||||||
ComponentClass cclass = (ComponentClass)_classes.get(ii);
|
ComponentClass cclass = _classes.get(ii);
|
||||||
Iterator iter = crepo.enumerateComponentIds(cclass);
|
Iterator<Integer> iter = crepo.enumerateComponentIds(cclass);
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Integer cid = (Integer)iter.next();
|
Integer cid = iter.next();
|
||||||
ArrayList clist = (ArrayList)_components.get(cclass);
|
ArrayList<Integer> clist = _components.get(cclass);
|
||||||
if (clist == null) {
|
if (clist == null) {
|
||||||
_components.put(cclass, clist = new ArrayList());
|
_components.put(cclass, clist = new ArrayList<Integer>());
|
||||||
}
|
}
|
||||||
|
|
||||||
clist.add(cid);
|
clist.add(cid);
|
||||||
@@ -138,14 +138,14 @@ public class BuilderModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The currently selected character components. */
|
/** The currently selected character components. */
|
||||||
protected HashMap _selected = new HashMap();
|
protected HashMap<ComponentClass, Integer> _selected = new HashMap<ComponentClass, Integer>();
|
||||||
|
|
||||||
/** The hashtable of available component ids for each class. */
|
/** The hashtable of available component ids for each class. */
|
||||||
protected HashMap _components = new HashMap();
|
protected HashMap<ComponentClass, ArrayList<Integer>> _components = new HashMap<ComponentClass, ArrayList<Integer>>();
|
||||||
|
|
||||||
/** The list of all available component classes. */
|
/** The list of all available component classes. */
|
||||||
protected ArrayList _classes = new ArrayList();
|
protected ArrayList<ComponentClass> _classes = new ArrayList<ComponentClass>();
|
||||||
|
|
||||||
/** The model listeners. */
|
/** The model listeners. */
|
||||||
protected ArrayList _listeners = new ArrayList();
|
protected ArrayList<BuilderModelListener> _listeners = new ArrayList<BuilderModelListener>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ public class ClassEditor extends JPanel implements ChangeListener
|
|||||||
/**
|
/**
|
||||||
* Constructs a class editor.
|
* Constructs a class editor.
|
||||||
*/
|
*/
|
||||||
public ClassEditor (
|
public ClassEditor (BuilderModel model, ComponentClass cclass, List<Integer> components)
|
||||||
BuilderModel model, ComponentClass cclass, List components)
|
|
||||||
{
|
{
|
||||||
_model = model;
|
_model = model;
|
||||||
_components = components;
|
_components = components;
|
||||||
@@ -92,7 +91,7 @@ public class ClassEditor extends JPanel implements ChangeListener
|
|||||||
*/
|
*/
|
||||||
protected void setSelectedComponent (int idx)
|
protected void setSelectedComponent (int idx)
|
||||||
{
|
{
|
||||||
int cid = ((Integer)_components.get(idx)).intValue();
|
int cid = _components.get(idx).intValue();
|
||||||
_model.setSelectedComponent(_cclass, cid);
|
_model.setSelectedComponent(_cclass, cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +99,7 @@ public class ClassEditor extends JPanel implements ChangeListener
|
|||||||
protected ComponentClass _cclass;
|
protected ComponentClass _cclass;
|
||||||
|
|
||||||
/** The components selectable via this editor. */
|
/** The components selectable via this editor. */
|
||||||
protected List _components;
|
protected List<Integer> _components;
|
||||||
|
|
||||||
/** The label denoting the currently selected component index. */
|
/** The label denoting the currently selected component index. */
|
||||||
protected JLabel _clabel;
|
protected JLabel _clabel;
|
||||||
|
|||||||
@@ -56,14 +56,14 @@ public class ComponentPanel extends JPanel
|
|||||||
*/
|
*/
|
||||||
protected void addClassEditors (BuilderModel model, String cprefix)
|
protected void addClassEditors (BuilderModel model, String cprefix)
|
||||||
{
|
{
|
||||||
List classes = model.getComponentClasses();
|
List<ComponentClass> classes = model.getComponentClasses();
|
||||||
int size = classes.size();
|
int size = classes.size();
|
||||||
for (int ii = 0; ii < size; ii++) {
|
for (int ii = 0; ii < size; ii++) {
|
||||||
ComponentClass cclass = (ComponentClass)classes.get(ii);
|
ComponentClass cclass = classes.get(ii);
|
||||||
if (!cclass.name.startsWith(cprefix)) {
|
if (!cclass.name.startsWith(cprefix)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List ccomps = model.getComponents(cclass);
|
List<Integer> ccomps = model.getComponents(cclass);
|
||||||
if (ccomps.size() > 0) {
|
if (ccomps.size() > 0) {
|
||||||
add(new ClassEditor(model, cclass, ccomps));
|
add(new ClassEditor(model, cclass, ccomps));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -28,12 +28,15 @@ import java.awt.Rectangle;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.samskivert.util.HashIntMap;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import com.samskivert.util.IntIntMap;
|
import com.samskivert.util.IntIntMap;
|
||||||
|
import com.samskivert.util.IntMap;
|
||||||
|
import com.samskivert.util.IntMaps;
|
||||||
import com.samskivert.util.Predicate;
|
import com.samskivert.util.Predicate;
|
||||||
import com.samskivert.util.Tuple;
|
import com.samskivert.util.Tuple;
|
||||||
|
|
||||||
@@ -94,24 +97,30 @@ public class BundledComponentRepository
|
|||||||
int rcount = (rbundles == null) ? 0 : rbundles.length;
|
int rcount = (rbundles == null) ? 0 : rbundles.length;
|
||||||
for (int i = 0; i < rcount; i++) {
|
for (int i = 0; i < rcount; i++) {
|
||||||
if (_actions == null) {
|
if (_actions == null) {
|
||||||
_actions = (HashMap)BundleUtil.loadObject(
|
@SuppressWarnings("unchecked") Map<String, ActionSequence> amap =
|
||||||
rbundles[i], BundleUtil.ACTIONS_PATH, true);
|
(Map<String, ActionSequence>)BundleUtil.loadObject(
|
||||||
|
rbundles[i], BundleUtil.ACTIONS_PATH, true);
|
||||||
|
_actions = amap;
|
||||||
}
|
}
|
||||||
if (_actionSets == null) {
|
if (_actionSets == null) {
|
||||||
_actionSets = (HashMap)BundleUtil.loadObject(
|
@SuppressWarnings("unchecked") Map<String, TileSet> asets =
|
||||||
rbundles[i], BundleUtil.ACTION_SETS_PATH, true);
|
(Map<String, TileSet>)BundleUtil.loadObject(
|
||||||
|
rbundles[i], BundleUtil.ACTION_SETS_PATH, true);
|
||||||
|
_actionSets = asets;
|
||||||
}
|
}
|
||||||
if (_classes == null) {
|
if (_classes == null) {
|
||||||
_classes = (HashMap)BundleUtil.loadObject(
|
@SuppressWarnings("unchecked") Map<String, ComponentClass> cmap =
|
||||||
rbundles[i], BundleUtil.CLASSES_PATH, true);
|
(Map<String, ComponentClass>)BundleUtil.loadObject(
|
||||||
|
rbundles[i], BundleUtil.CLASSES_PATH, true);
|
||||||
|
_classes = cmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now go back and load up all of the component information
|
// now go back and load up all of the component information
|
||||||
for (int i = 0; i < rcount; i++) {
|
for (int i = 0; i < rcount; i++) {
|
||||||
HashIntMap comps = null;
|
@SuppressWarnings("unchecked") IntMap<Tuple<String, String>> comps =
|
||||||
comps = (HashIntMap)BundleUtil.loadObject(
|
(IntMap<Tuple<String, String>>)BundleUtil.loadObject(
|
||||||
rbundles[i], BundleUtil.COMPONENTS_PATH, true);
|
rbundles[i], BundleUtil.COMPONENTS_PATH, true);
|
||||||
if (comps == null) {
|
if (comps == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -120,11 +129,11 @@ public class BundledComponentRepository
|
|||||||
FrameProvider fprov = new ResourceBundleProvider(_imgr, rbundles[i]);
|
FrameProvider fprov = new ResourceBundleProvider(_imgr, rbundles[i]);
|
||||||
|
|
||||||
// now create char. component instances for each component in the serialized table
|
// now create char. component instances for each component in the serialized table
|
||||||
Iterator iter = comps.keySet().iterator();
|
Iterator<Integer> iter = comps.keySet().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
int componentId = ((Integer)iter.next()).intValue();
|
int componentId = iter.next().intValue();
|
||||||
Tuple info = (Tuple)comps.get(componentId);
|
Tuple<String, String> info = comps.get(componentId);
|
||||||
createComponent(componentId, (String)info.left, (String)info.right, fprov);
|
createComponent(componentId, info.left, info.right, fprov);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,10 +145,10 @@ public class BundledComponentRepository
|
|||||||
// if we failed to load our classes or actions, create empty hashtables so that we can
|
// if we failed to load our classes or actions, create empty hashtables so that we can
|
||||||
// safely enumerate our emptiness
|
// safely enumerate our emptiness
|
||||||
if (_actions == null) {
|
if (_actions == null) {
|
||||||
_actions = new HashMap();
|
_actions = Maps.newHashMap();
|
||||||
}
|
}
|
||||||
if (_classes == null) {
|
if (_classes == null) {
|
||||||
_classes = new HashMap();
|
_classes = Maps.newHashMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +167,7 @@ public class BundledComponentRepository
|
|||||||
public CharacterComponent getComponent (int componentId)
|
public CharacterComponent getComponent (int componentId)
|
||||||
throws NoSuchComponentException
|
throws NoSuchComponentException
|
||||||
{
|
{
|
||||||
CharacterComponent component = (CharacterComponent)_components.get(componentId);
|
CharacterComponent component = _components.get(componentId);
|
||||||
if (component == null) {
|
if (component == null) {
|
||||||
throw new NoSuchComponentException(componentId);
|
throw new NoSuchComponentException(componentId);
|
||||||
}
|
}
|
||||||
@@ -170,12 +179,12 @@ public class BundledComponentRepository
|
|||||||
throws NoSuchComponentException
|
throws NoSuchComponentException
|
||||||
{
|
{
|
||||||
// look up the list for that class
|
// look up the list for that class
|
||||||
ArrayList comps = (ArrayList)_classComps.get(className);
|
ArrayList<CharacterComponent> comps = _classComps.get(className);
|
||||||
if (comps != null) {
|
if (comps != null) {
|
||||||
// scan the list for the named component
|
// scan the list for the named component
|
||||||
int ccount = comps.size();
|
int ccount = comps.size();
|
||||||
for (int i = 0; i < ccount; i++) {
|
for (int i = 0; i < ccount; i++) {
|
||||||
CharacterComponent comp = (CharacterComponent)comps.get(i);
|
CharacterComponent comp = comps.get(i);
|
||||||
if (comp.name.equals(compName)) {
|
if (comp.name.equals(compName)) {
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
@@ -187,28 +196,28 @@ public class BundledComponentRepository
|
|||||||
// documentation inherited
|
// documentation inherited
|
||||||
public ComponentClass getComponentClass (String className)
|
public ComponentClass getComponentClass (String className)
|
||||||
{
|
{
|
||||||
return (ComponentClass)_classes.get(className);
|
return _classes.get(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public Iterator enumerateComponentClasses ()
|
public Iterator<ComponentClass> enumerateComponentClasses ()
|
||||||
{
|
{
|
||||||
return _classes.values().iterator();
|
return _classes.values().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public Iterator enumerateActionSequences ()
|
public Iterator<ActionSequence> enumerateActionSequences ()
|
||||||
{
|
{
|
||||||
return _actions.values().iterator();
|
return _actions.values().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public Iterator enumerateComponentIds (final ComponentClass compClass)
|
public Iterator<Integer> enumerateComponentIds (final ComponentClass compClass)
|
||||||
{
|
{
|
||||||
return new Predicate<Integer>() {
|
return new Predicate<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isMatch (Integer input) {
|
public boolean isMatch (Integer input) {
|
||||||
CharacterComponent comp = (CharacterComponent)_components.get(input);
|
CharacterComponent comp = _components.get(input);
|
||||||
return comp.componentClass.equals(compClass);
|
return comp.componentClass.equals(compClass);
|
||||||
}
|
}
|
||||||
}.filter(_components.keySet().iterator());
|
}.filter(_components.keySet().iterator());
|
||||||
@@ -221,7 +230,7 @@ public class BundledComponentRepository
|
|||||||
int componentId, String cclass, String cname, FrameProvider fprov)
|
int componentId, String cclass, String cname, FrameProvider fprov)
|
||||||
{
|
{
|
||||||
// look up the component class information
|
// look up the component class information
|
||||||
ComponentClass clazz = (ComponentClass)_classes.get(cclass);
|
ComponentClass clazz = _classes.get(cclass);
|
||||||
if (clazz == null) {
|
if (clazz == null) {
|
||||||
log.warning("Non-existent component class [class=" + cclass + ", name=" + cname +
|
log.warning("Non-existent component class [class=" + cclass + ", name=" + cname +
|
||||||
", id=" + componentId + "].");
|
", id=" + componentId + "].");
|
||||||
@@ -235,9 +244,9 @@ public class BundledComponentRepository
|
|||||||
_components.put(componentId, component);
|
_components.put(componentId, component);
|
||||||
|
|
||||||
// we have a hash of lists for mapping components by class/name
|
// we have a hash of lists for mapping components by class/name
|
||||||
ArrayList comps = (ArrayList)_classComps.get(cclass);
|
ArrayList<CharacterComponent> comps = _classComps.get(cclass);
|
||||||
if (comps == null) {
|
if (comps == null) {
|
||||||
comps = new ArrayList();
|
comps = new ArrayList<CharacterComponent>();
|
||||||
_classComps.put(cclass, comps);
|
_classComps.put(cclass, comps);
|
||||||
}
|
}
|
||||||
if (!comps.contains(component)) {
|
if (!comps.contains(component)) {
|
||||||
@@ -280,7 +289,7 @@ public class BundledComponentRepository
|
|||||||
public ActionFrames getFrames (CharacterComponent component, String action, String type)
|
public ActionFrames getFrames (CharacterComponent component, String action, String type)
|
||||||
{
|
{
|
||||||
// obtain the action sequence definition for this action
|
// obtain the action sequence definition for this action
|
||||||
ActionSequence actseq = (ActionSequence)_actions.get(action);
|
ActionSequence actseq = _actions.get(action);
|
||||||
if (actseq == null) {
|
if (actseq == null) {
|
||||||
log.warning("Missing action sequence definition [action=" + action +
|
log.warning("Missing action sequence definition [action=" + action +
|
||||||
", component=" + component + "].");
|
", component=" + component + "].");
|
||||||
@@ -300,9 +309,9 @@ public class BundledComponentRepository
|
|||||||
|
|
||||||
// look to see if this tileset is already cached (as the custom action or the default
|
// look to see if this tileset is already cached (as the custom action or the default
|
||||||
// action)
|
// action)
|
||||||
TileSet aset = (TileSet)_setcache.get(cpath);
|
TileSet aset = _setcache.get(cpath);
|
||||||
if (aset == null) {
|
if (aset == null) {
|
||||||
aset = (TileSet)_setcache.get(dpath);
|
aset = _setcache.get(dpath);
|
||||||
if (aset != null) {
|
if (aset != null) {
|
||||||
// save ourselves a lookup next time
|
// save ourselves a lookup next time
|
||||||
_setcache.put(cpath, aset);
|
_setcache.put(cpath, aset);
|
||||||
@@ -384,7 +393,7 @@ public class BundledComponentRepository
|
|||||||
protected ResourceBundle _bundle;
|
protected ResourceBundle _bundle;
|
||||||
|
|
||||||
/** Cache of tilesets loaded from our bundle. */
|
/** Cache of tilesets loaded from our bundle. */
|
||||||
protected HashMap _setcache = new HashMap();
|
protected Map<String, TileSet> _setcache = Maps.newHashMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -527,19 +536,19 @@ public class BundledComponentRepository
|
|||||||
protected ImageManager _imgr;
|
protected ImageManager _imgr;
|
||||||
|
|
||||||
/** A table of action sequences. */
|
/** A table of action sequences. */
|
||||||
protected HashMap _actions;
|
protected Map<String, ActionSequence> _actions;
|
||||||
|
|
||||||
/** A table of action sequence tilesets. */
|
/** A table of action sequence tilesets. */
|
||||||
protected HashMap _actionSets;
|
protected Map<String, TileSet> _actionSets;
|
||||||
|
|
||||||
/** A table of component classes. */
|
/** A table of component classes. */
|
||||||
protected HashMap _classes;
|
protected Map<String, ComponentClass> _classes;
|
||||||
|
|
||||||
/** A table of component lists indexed on classname. */
|
/** A table of component lists indexed on classname. */
|
||||||
protected HashMap _classComps = new HashMap();
|
protected Map<String, ArrayList<CharacterComponent>> _classComps = Maps.newHashMap();
|
||||||
|
|
||||||
/** The component table. */
|
/** The component table. */
|
||||||
protected HashIntMap _components = new HashIntMap();
|
protected IntMap<CharacterComponent> _components = IntMaps.newHashIntMap();
|
||||||
|
|
||||||
/** Whether or not we wipe our bundles on any failure. */
|
/** Whether or not we wipe our bundles on any failure. */
|
||||||
protected boolean _wipeOnFailure;
|
protected boolean _wipeOnFailure;
|
||||||
|
|||||||
@@ -141,14 +141,15 @@ public class ComponentBundlerTask extends Task
|
|||||||
"definitions via the 'actiondef' attribute.");
|
"definitions via the 'actiondef' attribute.");
|
||||||
|
|
||||||
// parse in the action tilesets
|
// parse in the action tilesets
|
||||||
HashMap actsets = parseActionTileSets();
|
HashMap<String, TileSet> actsets = parseActionTileSets();
|
||||||
|
|
||||||
// load up our component ID broker
|
// load up our component ID broker
|
||||||
ComponentIDBroker broker = loadBroker(_mapfile);
|
ComponentIDBroker broker = loadBroker(_mapfile);
|
||||||
|
|
||||||
// check to see if any of the source files are newer than the
|
// check to see if any of the source files are newer than the
|
||||||
// target file
|
// target file
|
||||||
ArrayList sources = (ArrayList)_filesets.clone();
|
ArrayList<Object> sources = new ArrayList<Object>();
|
||||||
|
sources.addAll(_filesets);
|
||||||
sources.add(_mapfile);
|
sources.add(_mapfile);
|
||||||
sources.add(_actionDef);
|
sources.add(_actionDef);
|
||||||
long newest = getNewestDate(sources);
|
long newest = getNewestDate(sources);
|
||||||
@@ -187,7 +188,7 @@ public class ComponentBundlerTask extends Task
|
|||||||
String[] info = decomposePath(cfile.getPath());
|
String[] info = decomposePath(cfile.getPath());
|
||||||
|
|
||||||
// make sure we have an action tileset definition
|
// make sure we have an action tileset definition
|
||||||
TileSet aset = (TileSet)actsets.get(info[2]);
|
TileSet aset = actsets.get(info[2]);
|
||||||
if (aset == null) {
|
if (aset == null) {
|
||||||
System.err.println(
|
System.err.println(
|
||||||
"No tileset definition for component action " +
|
"No tileset definition for component action " +
|
||||||
@@ -292,7 +293,7 @@ public class ComponentBundlerTask extends Task
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected long getNewestDate (ArrayList sources)
|
protected long getNewestDate (ArrayList<Object> sources)
|
||||||
{
|
{
|
||||||
long newest = 0L;
|
long newest = 0L;
|
||||||
for (int ii = 0; ii < sources.size(); ii++) {
|
for (int ii = 0; ii < sources.size(); ii++) {
|
||||||
@@ -414,7 +415,7 @@ public class ComponentBundlerTask extends Task
|
|||||||
* Parses the action tileset definitions and puts them into a hash
|
* Parses the action tileset definitions and puts them into a hash
|
||||||
* map, keyed on action name.
|
* map, keyed on action name.
|
||||||
*/
|
*/
|
||||||
protected HashMap parseActionTileSets ()
|
protected HashMap<String, TileSet> parseActionTileSets ()
|
||||||
{
|
{
|
||||||
Digester digester = new Digester();
|
Digester digester = new Digester();
|
||||||
digester.addSetProperties("actions" + ActionRuleSet.ACTION_PATH);
|
digester.addSetProperties("actions" + ActionRuleSet.ACTION_PATH);
|
||||||
@@ -422,7 +423,7 @@ public class ComponentBundlerTask extends Task
|
|||||||
addTileSetRuleSet(digester, new UniformTileSetRuleSet("/uniformTileset"));
|
addTileSetRuleSet(digester, new UniformTileSetRuleSet("/uniformTileset"));
|
||||||
|
|
||||||
|
|
||||||
HashMap actsets = new ActionMap();
|
HashMap<String, TileSet> actsets = new ActionMap();
|
||||||
digester.push(actsets);
|
digester.push(actsets);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -484,7 +485,7 @@ public class ComponentBundlerTask extends Task
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Used when parsing action tilesets. */
|
/** Used when parsing action tilesets. */
|
||||||
public static class ActionMap extends HashMap
|
public static class ActionMap extends HashMap<String, TileSet>
|
||||||
{
|
{
|
||||||
public void setName (String name) {
|
public void setName (String name) {
|
||||||
_name = name;
|
_name = name;
|
||||||
@@ -546,13 +547,13 @@ public class ComponentBundlerTask extends Task
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static class HashMapIDBroker
|
protected static class HashMapIDBroker
|
||||||
extends HashMap implements ComponentIDBroker
|
extends HashMap<Tuple<String, String>, Integer> implements ComponentIDBroker
|
||||||
{
|
{
|
||||||
public int getComponentID (String cclass, String cname)
|
public int getComponentID (String cclass, String cname)
|
||||||
throws PersistenceException
|
throws PersistenceException
|
||||||
{
|
{
|
||||||
Tuple key = new Tuple(cclass, cname);
|
Tuple<String, String> key = new Tuple<String, String>(cclass, cname);
|
||||||
Integer cid = (Integer)get(key);
|
Integer cid = get(key);
|
||||||
if (cid == null) {
|
if (cid == null) {
|
||||||
cid = Integer.valueOf(++_nextCID);
|
cid = Integer.valueOf(++_nextCID);
|
||||||
put(key, cid);
|
put(key, cid);
|
||||||
@@ -580,11 +581,11 @@ public class ComponentBundlerTask extends Task
|
|||||||
bout.newLine();
|
bout.newLine();
|
||||||
|
|
||||||
// write out the keys and values
|
// write out the keys and values
|
||||||
ComparableArrayList lines = new ComparableArrayList();
|
ComparableArrayList<String> lines = new ComparableArrayList<String>();
|
||||||
Iterator keys = keySet().iterator();
|
Iterator<Tuple<String, String>> keys = keySet().iterator();
|
||||||
while (keys.hasNext()) {
|
while (keys.hasNext()) {
|
||||||
Tuple key = (Tuple)keys.next();
|
Tuple<String, String> key = keys.next();
|
||||||
Integer value = (Integer)get(key);
|
Integer value = get(key);
|
||||||
String line = key.left + SEP_STR + key.right + SEP_STR + value;
|
String line = key.left + SEP_STR + key.right + SEP_STR + value;
|
||||||
lines.add(line);
|
lines.add(line);
|
||||||
}
|
}
|
||||||
@@ -595,7 +596,7 @@ public class ComponentBundlerTask extends Task
|
|||||||
// now write it to the file
|
// now write it to the file
|
||||||
int lcount = lines.size();
|
int lcount = lines.size();
|
||||||
for (int ii = 0; ii < lcount; ii++) {
|
for (int ii = 0; ii < lcount; ii++) {
|
||||||
String line = (String)lines.get(ii);
|
String line = lines.get(ii);
|
||||||
bout.write(line, 0, line.length());
|
bout.write(line, 0, line.length());
|
||||||
bout.newLine();
|
bout.newLine();
|
||||||
}
|
}
|
||||||
@@ -626,7 +627,7 @@ public class ComponentBundlerTask extends Task
|
|||||||
String cname = line.substring(0, sidx);
|
String cname = line.substring(0, sidx);
|
||||||
line = line.substring(sidx + SEP_STR.length());
|
line = line.substring(sidx + SEP_STR.length());
|
||||||
try {
|
try {
|
||||||
put(new Tuple(cclass, cname), Integer.valueOf(line));
|
put(new Tuple<String, String>(cclass, cname), Integer.valueOf(line));
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
String err = "Malformed line, invalid code '" + orig + "'";
|
String err = "Malformed line, invalid code '" + orig + "'";
|
||||||
throw new IOException(err);
|
throw new IOException(err);
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ package com.threerings.cast.bundle.tools;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.samskivert.util.HashIntMap;
|
import com.samskivert.util.HashIntMap;
|
||||||
@@ -51,19 +50,19 @@ public class DumpBundle
|
|||||||
try {
|
try {
|
||||||
ResourceBundle bundle = new FileResourceBundle(file);
|
ResourceBundle bundle = new FileResourceBundle(file);
|
||||||
|
|
||||||
HashMap actions = (HashMap)BundleUtil.loadObject(
|
HashMap<?, ?> actions = (HashMap<?, ?>)BundleUtil.loadObject(
|
||||||
bundle, BundleUtil.ACTIONS_PATH, false);
|
bundle, BundleUtil.ACTIONS_PATH, false);
|
||||||
dumpTable("actions: ", actions);
|
dumpTable("actions: ", actions);
|
||||||
|
|
||||||
HashMap actionSets = (HashMap)BundleUtil.loadObject(
|
HashMap<?, ?> actionSets = (HashMap<?, ?>)BundleUtil.loadObject(
|
||||||
bundle, BundleUtil.ACTION_SETS_PATH, false);
|
bundle, BundleUtil.ACTION_SETS_PATH, false);
|
||||||
dumpTable("actionSets: ", actionSets);
|
dumpTable("actionSets: ", actionSets);
|
||||||
|
|
||||||
HashMap classes = (HashMap)BundleUtil.loadObject(
|
HashMap<?, ?> classes = (HashMap<?, ?>)BundleUtil.loadObject(
|
||||||
bundle, BundleUtil.CLASSES_PATH, false);
|
bundle, BundleUtil.CLASSES_PATH, false);
|
||||||
dumpTable("classes: ", classes);
|
dumpTable("classes: ", classes);
|
||||||
|
|
||||||
HashIntMap comps = (HashIntMap)BundleUtil.loadObject(
|
HashIntMap<?> comps = (HashIntMap<?>)BundleUtil.loadObject(
|
||||||
bundle, BundleUtil.COMPONENTS_PATH, false);
|
bundle, BundleUtil.COMPONENTS_PATH, false);
|
||||||
dumpTable("components: ", comps);
|
dumpTable("components: ", comps);
|
||||||
|
|
||||||
@@ -75,11 +74,10 @@ public class DumpBundle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void dumpTable (String prefix, Map table)
|
protected static void dumpTable (String prefix, Map<?, ?> table)
|
||||||
{
|
{
|
||||||
if (table != null) {
|
if (table != null) {
|
||||||
Iterator iter = table.entrySet().iterator();
|
System.out.println(prefix + StringUtil.toString(table.entrySet().iterator()));
|
||||||
System.out.println(prefix + StringUtil.toString(iter));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import java.io.ObjectOutputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarOutputStream;
|
import java.util.jar.JarOutputStream;
|
||||||
import java.util.zip.Deflater;
|
import java.util.zip.Deflater;
|
||||||
@@ -98,10 +99,10 @@ public class MetadataBundlerTask extends Task
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
// parse our metadata
|
// parse our metadata
|
||||||
Tuple tuple = parseActions();
|
Tuple<Map<String, ActionSequence>, Map<String, TileSet>> tuple = parseActions();
|
||||||
HashMap actions = (HashMap)tuple.left;
|
Map<String, ActionSequence> actions = tuple.left;
|
||||||
HashMap actionSets = (HashMap)tuple.right;
|
Map<String, TileSet> actionSets = tuple.right;
|
||||||
HashMap classes = parseClasses();
|
Map<String, ComponentClass> classes = parseClasses();
|
||||||
|
|
||||||
fout = createOutputStream(_target);
|
fout = createOutputStream(_target);
|
||||||
|
|
||||||
@@ -174,7 +175,7 @@ public class MetadataBundlerTask extends Task
|
|||||||
digester.addSetNext(ruleSet.getPath(), "add", Object.class.getName());
|
digester.addSetNext(ruleSet.getPath(), "add", Object.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Tuple parseActions ()
|
protected Tuple<Map<String, ActionSequence>, Map<String, TileSet>> parseActions ()
|
||||||
throws BuildException
|
throws BuildException
|
||||||
{
|
{
|
||||||
// scan through the XML once to read the actions
|
// scan through the XML once to read the actions
|
||||||
@@ -183,13 +184,13 @@ public class MetadataBundlerTask extends Task
|
|||||||
arules.setPrefix("actions");
|
arules.setPrefix("actions");
|
||||||
digester.addRuleSet(arules);
|
digester.addRuleSet(arules);
|
||||||
digester.addSetNext("actions" + ActionRuleSet.ACTION_PATH, "add", Object.class.getName());
|
digester.addSetNext("actions" + ActionRuleSet.ACTION_PATH, "add", Object.class.getName());
|
||||||
ArrayList actlist = parseList(digester, _actionDef);
|
ArrayList<?> actlist = parseList(digester, _actionDef);
|
||||||
|
|
||||||
// now go through a second time reading the tileset info
|
// now go through a second time reading the tileset info
|
||||||
digester = new Digester();
|
digester = new Digester();
|
||||||
addTileSetRuleSet(digester, new SwissArmyTileSetRuleSet());
|
addTileSetRuleSet(digester, new SwissArmyTileSetRuleSet());
|
||||||
addTileSetRuleSet(digester, new UniformTileSetRuleSet("/uniformTileset"));
|
addTileSetRuleSet(digester, new UniformTileSetRuleSet("/uniformTileset"));
|
||||||
ArrayList setlist = parseList(digester, _actionDef);
|
ArrayList<?> setlist = parseList(digester, _actionDef);
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
if (actlist.size() != setlist.size()) {
|
if (actlist.size() != setlist.size()) {
|
||||||
@@ -199,8 +200,8 @@ public class MetadataBundlerTask extends Task
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now create our mappings
|
// now create our mappings
|
||||||
HashMap actmap = new HashMap();
|
Map<String, ActionSequence> actmap = new HashMap<String, ActionSequence>();
|
||||||
HashMap setmap = new HashMap();
|
Map<String, TileSet> setmap = new HashMap<String, TileSet>();
|
||||||
|
|
||||||
// create the action map
|
// create the action map
|
||||||
for (int i = 0; i < setlist.size(); i++) {
|
for (int i = 0; i < setlist.size(); i++) {
|
||||||
@@ -218,10 +219,10 @@ public class MetadataBundlerTask extends Task
|
|||||||
setmap.put(act.name, set);
|
setmap.put(act.name, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Tuple(actmap, setmap);
|
return new Tuple<Map<String, ActionSequence>, Map<String, TileSet>>(actmap, setmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HashMap parseClasses ()
|
protected Map<String, ComponentClass> parseClasses ()
|
||||||
throws BuildException
|
throws BuildException
|
||||||
{
|
{
|
||||||
// load up our action and class info
|
// load up our action and class info
|
||||||
@@ -234,8 +235,8 @@ public class MetadataBundlerTask extends Task
|
|||||||
digester.addSetNext("classes" + ClassRuleSet.CLASS_PATH,
|
digester.addSetNext("classes" + ClassRuleSet.CLASS_PATH,
|
||||||
"add", Object.class.getName());
|
"add", Object.class.getName());
|
||||||
|
|
||||||
ArrayList setlist = parseList(digester, _classDef);
|
ArrayList<?> setlist = parseList(digester, _classDef);
|
||||||
HashMap clmap = new HashMap();
|
Map<String, ComponentClass> clmap = new HashMap<String, ComponentClass>();
|
||||||
|
|
||||||
// create the action map
|
// create the action map
|
||||||
for (int i = 0; i < setlist.size(); i++) {
|
for (int i = 0; i < setlist.size(); i++) {
|
||||||
@@ -246,14 +247,14 @@ public class MetadataBundlerTask extends Task
|
|||||||
return clmap;
|
return clmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArrayList parseList (Digester digester, String path)
|
protected ArrayList<?> parseList (Digester digester, String path)
|
||||||
throws BuildException
|
throws BuildException
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
FileInputStream fin = new FileInputStream(path);
|
FileInputStream fin = new FileInputStream(path);
|
||||||
BufferedInputStream bin = new BufferedInputStream(fin);
|
BufferedInputStream bin = new BufferedInputStream(fin);
|
||||||
|
|
||||||
ArrayList setlist = new ArrayList();
|
ArrayList<Object> setlist = new ArrayList<Object>();
|
||||||
digester.push(setlist);
|
digester.push(setlist);
|
||||||
|
|
||||||
// now fire up the digester to parse the stream
|
// now fire up the digester to parse the stream
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class CastUtil
|
|||||||
String gender, ComponentRepository crepo)
|
String gender, ComponentRepository crepo)
|
||||||
{
|
{
|
||||||
// get all available classes
|
// get all available classes
|
||||||
ArrayList classes = new ArrayList();
|
ArrayList<ComponentClass> classes = new ArrayList<ComponentClass>();
|
||||||
for (int i = 0; i < CLASSES.length; i++) {
|
for (int i = 0; i < CLASSES.length; i++) {
|
||||||
String cname = gender + "/" + CLASSES[i];
|
String cname = gender + "/" + CLASSES[i];
|
||||||
ComponentClass cclass = crepo.getComponentClass(cname);
|
ComponentClass cclass = crepo.getComponentClass(cname);
|
||||||
@@ -59,7 +59,7 @@ public class CastUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make sure there are some components in this class
|
// make sure there are some components in this class
|
||||||
Iterator iter = crepo.enumerateComponentIds(cclass);
|
Iterator<Integer> iter = crepo.enumerateComponentIds(cclass);
|
||||||
if (!iter.hasNext()) {
|
if (!iter.hasNext()) {
|
||||||
log.info("Skipping class for which we have no components " +
|
log.info("Skipping class for which we have no components " +
|
||||||
"[class=" + cclass + "].");
|
"[class=" + cclass + "].");
|
||||||
@@ -73,17 +73,17 @@ public class CastUtil
|
|||||||
int size = classes.size();
|
int size = classes.size();
|
||||||
int components[] = new int[size];
|
int components[] = new int[size];
|
||||||
for (int ii = 0; ii < size; ii++) {
|
for (int ii = 0; ii < size; ii++) {
|
||||||
ComponentClass cclass = (ComponentClass)classes.get(ii);
|
ComponentClass cclass = classes.get(ii);
|
||||||
|
|
||||||
// get the components available for this class
|
// get the components available for this class
|
||||||
ArrayList choices = new ArrayList();
|
ArrayList<Integer> choices = new ArrayList<Integer>();
|
||||||
Iterator iter = crepo.enumerateComponentIds(cclass);
|
Iterator<Integer> iter = crepo.enumerateComponentIds(cclass);
|
||||||
CollectionUtil.addAll(choices, iter);
|
CollectionUtil.addAll(choices, iter);
|
||||||
|
|
||||||
// choose a random component
|
// choose a random component
|
||||||
if (choices.size() > 0) {
|
if (choices.size() > 0) {
|
||||||
int idx = RandomUtil.getInt(choices.size());
|
int idx = RandomUtil.getInt(choices.size());
|
||||||
components[ii] = ((Integer)choices.get(idx)).intValue();
|
components[ii] = choices.get(idx).intValue();
|
||||||
} else {
|
} else {
|
||||||
log.info("Have no components in class [class=" + cclass + "].");
|
log.info("Have no components in class [class=" + cclass + "].");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ package com.threerings.media;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import com.samskivert.util.SortableArrayList;
|
import com.samskivert.util.SortableArrayList;
|
||||||
import com.samskivert.util.ObserverList.ObserverOp;
|
import com.samskivert.util.ObserverList.ObserverOp;
|
||||||
@@ -265,9 +267,9 @@ public abstract class AbstractMediaManager
|
|||||||
/**
|
/**
|
||||||
* Queues the notification for dispatching after we've ticked all the media.
|
* Queues the notification for dispatching after we've ticked all the media.
|
||||||
*/
|
*/
|
||||||
public void queueNotification (ObserverList observers, ObserverOp event)
|
public void queueNotification (ObserverList<Object> observers, ObserverOp<Object> event)
|
||||||
{
|
{
|
||||||
_notify.add(new Tuple<ObserverList,ObserverOp>(observers, event));
|
_notify.add(new Tuple<ObserverList<Object>,ObserverOp<Object>>(observers, event));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Type safety jockeying. */
|
/** Type safety jockeying. */
|
||||||
@@ -279,7 +281,7 @@ public abstract class AbstractMediaManager
|
|||||||
protected void dispatchNotifications ()
|
protected void dispatchNotifications ()
|
||||||
{
|
{
|
||||||
for (int ii = 0, nn = _notify.size(); ii < nn; ii++) {
|
for (int ii = 0, nn = _notify.size(); ii < nn; ii++) {
|
||||||
Tuple<ObserverList,ObserverOp> tuple = _notify.get(ii);
|
Tuple<ObserverList<Object>,ObserverOp<Object>> tuple = _notify.get(ii);
|
||||||
tuple.left.apply(tuple.right);
|
tuple.left.apply(tuple.right);
|
||||||
}
|
}
|
||||||
_notify.clear();
|
_notify.clear();
|
||||||
@@ -299,8 +301,7 @@ public abstract class AbstractMediaManager
|
|||||||
protected RegionManager _remgr;
|
protected RegionManager _remgr;
|
||||||
|
|
||||||
/** List of observers to notify at the end of the tick. */
|
/** List of observers to notify at the end of the tick. */
|
||||||
protected ArrayList<Tuple<ObserverList,ObserverOp>> _notify =
|
protected List<Tuple<ObserverList<Object>,ObserverOp<Object>>> _notify = Lists.newArrayList();
|
||||||
new ArrayList<Tuple<ObserverList,ObserverOp>>();
|
|
||||||
|
|
||||||
/** Our render-order sorted list of media. */
|
/** Our render-order sorted list of media. */
|
||||||
@SuppressWarnings("unchecked") protected SortableArrayList<AbstractMedia> _media =
|
@SuppressWarnings("unchecked") protected SortableArrayList<AbstractMedia> _media =
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
package com.threerings.media;
|
package com.threerings.media;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
@@ -110,7 +111,7 @@ public class IconManager
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// see if the tileset is already loaded
|
// see if the tileset is already loaded
|
||||||
TileSet set = (TileSet)_icons.get(iconSet);
|
TileSet set = _icons.get(iconSet);
|
||||||
|
|
||||||
// load it up if not
|
// load it up if not
|
||||||
if (set == null) {
|
if (set == null) {
|
||||||
@@ -166,7 +167,7 @@ public class IconManager
|
|||||||
protected String _rsrcSet;
|
protected String _rsrcSet;
|
||||||
|
|
||||||
/** A cache of our icon tilesets. */
|
/** A cache of our icon tilesets. */
|
||||||
protected LRUHashMap _icons = new LRUHashMap(ICON_CACHE_SIZE);
|
protected Map<String, TileSet> _icons = new LRUHashMap<String, TileSet>(ICON_CACHE_SIZE);
|
||||||
|
|
||||||
/** The suffix we append to an icon set name to obtain the tileset
|
/** The suffix we append to an icon set name to obtain the tileset
|
||||||
* image path configuration parameter. */
|
* image path configuration parameter. */
|
||||||
|
|||||||
@@ -645,7 +645,7 @@ public class MediaPanel extends JComponent
|
|||||||
*/
|
*/
|
||||||
protected Sprite getHit (MouseEvent me)
|
protected Sprite getHit (MouseEvent me)
|
||||||
{
|
{
|
||||||
ArrayList list = new ArrayList();
|
ArrayList<Sprite> list = new ArrayList<Sprite>();
|
||||||
getSpriteManager().getHitSprites(list, me.getX(), me.getY());
|
getSpriteManager().getHitSprites(list, me.getX(), me.getY());
|
||||||
for (int ii = 0, nn = list.size(); ii < nn; ii++) {
|
for (int ii = 0, nn = list.size(); ii < nn; ii++) {
|
||||||
Object o = list.get(ii);
|
Object o = list.get(ii);
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
{
|
{
|
||||||
// inform our view trackers
|
// inform our view trackers
|
||||||
for (int ii = 0, ll = _trackers.size(); ii < ll; ii++) {
|
for (int ii = 0, ll = _trackers.size(); ii < ll; ii++) {
|
||||||
((ViewTracker)_trackers.get(ii)).viewLocationDidChange(dx, dy);
|
_trackers.get(ii).viewLocationDidChange(dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// pass the word on to our sprite/anim managers via the meta manager
|
// pass the word on to our sprite/anim managers via the meta manager
|
||||||
@@ -459,5 +459,5 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
protected Rectangle _abounds = new Rectangle();
|
protected Rectangle _abounds = new Rectangle();
|
||||||
|
|
||||||
/** A list of entities to be informed when the view scrolls. */
|
/** A list of entities to be informed when the view scrolls. */
|
||||||
protected ArrayList _trackers = new ArrayList();
|
protected ArrayList<ViewTracker> _trackers = new ArrayList<ViewTracker>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ public abstract class Animation extends AbstractMedia
|
|||||||
protected boolean _finished = false;
|
protected boolean _finished = false;
|
||||||
|
|
||||||
/** Used to dispatch {@link AnimationObserver#animationStarted}. */
|
/** Used to dispatch {@link AnimationObserver#animationStarted}. */
|
||||||
protected static class AnimStartedOp implements ObserverList.ObserverOp
|
protected static class AnimStartedOp implements ObserverList.ObserverOp<Object>
|
||||||
{
|
{
|
||||||
public AnimStartedOp (Animation anim, long when) {
|
public AnimStartedOp (Animation anim, long when) {
|
||||||
_anim = anim;
|
_anim = anim;
|
||||||
@@ -140,7 +140,7 @@ public abstract class Animation extends AbstractMedia
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Used to dispatch {@link AnimationObserver#animationCompleted}. */
|
/** Used to dispatch {@link AnimationObserver#animationCompleted}. */
|
||||||
protected static class AnimCompletedOp implements ObserverList.ObserverOp
|
protected static class AnimCompletedOp implements ObserverList.ObserverOp<Object>
|
||||||
{
|
{
|
||||||
public AnimCompletedOp (Animation anim, long when) {
|
public AnimCompletedOp (Animation anim, long when) {
|
||||||
_anim = anim;
|
_anim = anim;
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ public class AnimationArranger
|
|||||||
public void positionAvoidAnimation (Animation anim, Rectangle viewBounds)
|
public void positionAvoidAnimation (Animation anim, Rectangle viewBounds)
|
||||||
{
|
{
|
||||||
Rectangle abounds = new Rectangle(anim.getBounds());
|
Rectangle abounds = new Rectangle(anim.getBounds());
|
||||||
ArrayList avoidables = (ArrayList) _avoidAnims.clone();
|
@SuppressWarnings("unchecked") ArrayList<Animation> avoidables =
|
||||||
|
(ArrayList<Animation>) _avoidAnims.clone();
|
||||||
// if we are able to place it somewhere, do so
|
// if we are able to place it somewhere, do so
|
||||||
if (SwingUtil.positionRect(abounds, viewBounds, avoidables)) {
|
if (SwingUtil.positionRect(abounds, viewBounds, avoidables)) {
|
||||||
anim.setLocation(abounds.x, abounds.y);
|
anim.setLocation(abounds.x, abounds.y);
|
||||||
@@ -55,7 +56,7 @@ public class AnimationArranger
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The animations that other animations may wish to avoid. */
|
/** The animations that other animations may wish to avoid. */
|
||||||
protected ArrayList _avoidAnims = new ArrayList();
|
protected ArrayList<Animation> _avoidAnims = new ArrayList<Animation>();
|
||||||
|
|
||||||
/** Automatically removes avoid animations when they're done. */
|
/** Automatically removes avoid animations when they're done. */
|
||||||
protected AnimationAdapter _avoidAnimObs = new AnimationAdapter() {
|
protected AnimationAdapter _avoidAnimObs = new AnimationAdapter() {
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ public interface AnimationFrameSequencer extends FrameSequencer
|
|||||||
protected Animation _animation;
|
protected Animation _animation;
|
||||||
|
|
||||||
/** Used to dispatch {@link SequencedAnimationObserver#frameReached}. */
|
/** Used to dispatch {@link SequencedAnimationObserver#frameReached}. */
|
||||||
protected static class FrameReachedOp implements ObserverList.ObserverOp
|
protected static class FrameReachedOp implements ObserverList.ObserverOp<Object>
|
||||||
{
|
{
|
||||||
public FrameReachedOp (Animation anim, long when,
|
public FrameReachedOp (Animation anim, long when,
|
||||||
int frameIdx, int frameSeq) {
|
int frameIdx, int frameSeq) {
|
||||||
|
|||||||
@@ -89,11 +89,11 @@ public class AnimationSequencer extends Animation
|
|||||||
if (_queued.size() > 0) {
|
if (_queued.size() > 0) {
|
||||||
// if there are queued animations we want the most
|
// if there are queued animations we want the most
|
||||||
// recently queued animation
|
// recently queued animation
|
||||||
trigger = (AnimRecord)_queued.get(_queued.size()-1);
|
trigger = _queued.get(_queued.size()-1);
|
||||||
} else if (_running.size() > 0) {
|
} else if (_running.size() > 0) {
|
||||||
// otherwise, if there are running animations, we want the
|
// otherwise, if there are running animations, we want the
|
||||||
// last one in that list
|
// last one in that list
|
||||||
trigger = (AnimRecord)_running.get(_running.size()-1);
|
trigger = _running.get(_running.size()-1);
|
||||||
}
|
}
|
||||||
// otherwise we have no trigger, we'll just start ASAP
|
// otherwise we have no trigger, we'll just start ASAP
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ public class AnimationSequencer extends Animation
|
|||||||
|
|
||||||
// add all animations whose time has come
|
// add all animations whose time has come
|
||||||
while (_queued.size() > 0) {
|
while (_queued.size() > 0) {
|
||||||
AnimRecord arec = (AnimRecord)_queued.get(0);
|
AnimRecord arec = _queued.get(0);
|
||||||
if (!arec.readyToFire(tickStamp, _lastStamp)) {
|
if (!arec.readyToFire(tickStamp, _lastStamp)) {
|
||||||
// if it's not time to add this animation, all subsequent
|
// if it's not time to add this animation, all subsequent
|
||||||
// animations must surely wait as well
|
// animations must surely wait as well
|
||||||
@@ -284,10 +284,10 @@ public class AnimationSequencer extends Animation
|
|||||||
protected AnimationManager _animmgr;
|
protected AnimationManager _animmgr;
|
||||||
|
|
||||||
/** Animations that have not been fired. */
|
/** Animations that have not been fired. */
|
||||||
protected ArrayList _queued = new ArrayList();
|
protected ArrayList<AnimRecord> _queued = new ArrayList<AnimRecord>();
|
||||||
|
|
||||||
/** Animations that are currently running. */
|
/** Animations that are currently running. */
|
||||||
protected ArrayList _running = new ArrayList();
|
protected ArrayList<AnimRecord> _running = new ArrayList<AnimRecord>();
|
||||||
|
|
||||||
/** The timestamp at which we fired the last animation. */
|
/** The timestamp at which we fired the last animation. */
|
||||||
protected long _lastStamp;
|
protected long _lastStamp;
|
||||||
|
|||||||
@@ -13,9 +13,11 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import com.samskivert.util.LRUHashMap;
|
import com.samskivert.util.LRUHashMap;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
@@ -97,9 +99,10 @@ public class ImageManager
|
|||||||
// create our image cache
|
// create our image cache
|
||||||
int icsize = getCacheSize();
|
int icsize = getCacheSize();
|
||||||
log.debug("Creating image cache [size=" + icsize + "k].");
|
log.debug("Creating image cache [size=" + icsize + "k].");
|
||||||
_ccache = new LRUHashMap(icsize * 1024, new LRUHashMap.ItemSizer() {
|
_ccache = new LRUHashMap<ImageKey, CacheRecord>(
|
||||||
public int computeSize (Object value) {
|
icsize * 1024, new LRUHashMap.ItemSizer<CacheRecord>() {
|
||||||
return (int)((CacheRecord)value).getEstimatedMemoryUsage();
|
public int computeSize (CacheRecord value) {
|
||||||
|
return (int)value.getEstimatedMemoryUsage();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_ccache.setTracking(true);
|
_ccache.setTracking(true);
|
||||||
@@ -257,7 +260,7 @@ public class ImageManager
|
|||||||
{
|
{
|
||||||
CacheRecord crec = null;
|
CacheRecord crec = null;
|
||||||
synchronized (_ccache) {
|
synchronized (_ccache) {
|
||||||
crec = (CacheRecord)_ccache.get(key);
|
crec = _ccache.get(key);
|
||||||
}
|
}
|
||||||
if (crec != null) {
|
if (crec != null) {
|
||||||
// Log.info("Cache hit [key=" + key + ", crec=" + crec + "].");
|
// Log.info("Cache hit [key=" + key + ", crec=" + crec + "].");
|
||||||
@@ -360,7 +363,7 @@ public class ImageManager
|
|||||||
return _defaultProvider;
|
return _defaultProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageDataProvider dprov = (ImageDataProvider)_providers.get(rset);
|
ImageDataProvider dprov = _providers.get(rset);
|
||||||
if (dprov == null) {
|
if (dprov == null) {
|
||||||
dprov = new ImageDataProvider() {
|
dprov = new ImageDataProvider() {
|
||||||
public BufferedImage loadImage (String path)
|
public BufferedImage loadImage (String path)
|
||||||
@@ -427,9 +430,9 @@ public class ImageManager
|
|||||||
|
|
||||||
int[] eff = null;
|
int[] eff = null;
|
||||||
synchronized (_ccache) {
|
synchronized (_ccache) {
|
||||||
Iterator iter = _ccache.values().iterator();
|
Iterator<CacheRecord> iter = _ccache.values().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
size += ((CacheRecord)iter.next()).getEstimatedMemoryUsage();
|
size += iter.next().getEstimatedMemoryUsage();
|
||||||
}
|
}
|
||||||
eff = _ccache.getTrackedEffectiveness();
|
eff = _ccache.getTrackedEffectiveness();
|
||||||
}
|
}
|
||||||
@@ -446,7 +449,7 @@ public class ImageManager
|
|||||||
_source = source;
|
_source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferedImage getImage (Colorization[] zations, LRUHashMap cache)
|
public BufferedImage getImage (Colorization[] zations, LRUHashMap<ImageKey, CacheRecord> cache)
|
||||||
{
|
{
|
||||||
if (zations == null) {
|
if (zations == null) {
|
||||||
return _source;
|
return _source;
|
||||||
@@ -513,10 +516,10 @@ public class ImageManager
|
|||||||
protected OptimalImageCreator _icreator;
|
protected OptimalImageCreator _icreator;
|
||||||
|
|
||||||
/** A cache of loaded images. */
|
/** A cache of loaded images. */
|
||||||
protected LRUHashMap _ccache;
|
protected LRUHashMap<ImageKey, CacheRecord> _ccache;
|
||||||
|
|
||||||
/** The set of all keys we've ever seen. */
|
/** The set of all keys we've ever seen. */
|
||||||
protected HashSet _keySet = new HashSet();
|
protected HashSet<ImageKey> _keySet = new HashSet<ImageKey>();
|
||||||
|
|
||||||
/** Throttle our cache status logging to once every 300 seconds. */
|
/** Throttle our cache status logging to once every 300 seconds. */
|
||||||
protected Throttle _cacheStatThrottle = new Throttle(1, 300000L);
|
protected Throttle _cacheStatThrottle = new Throttle(1, 300000L);
|
||||||
@@ -532,7 +535,7 @@ public class ImageManager
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Data providers for different resource sets. */
|
/** Data providers for different resource sets. */
|
||||||
protected HashMap _providers = new HashMap();
|
protected Map<String, ImageDataProvider> _providers = Maps.newHashMap();
|
||||||
|
|
||||||
/** Default amount of data we'll store in our image cache. */
|
/** Default amount of data we'll store in our image cache. */
|
||||||
protected static int DEFAULT_CACHE_SIZE = 32768;
|
protected static int DEFAULT_CACHE_SIZE = 32768;
|
||||||
|
|||||||
@@ -602,11 +602,11 @@ public class ImageUtil
|
|||||||
* Returns the estimated memory usage in bytes for all buffered images
|
* Returns the estimated memory usage in bytes for all buffered images
|
||||||
* in the supplied iterator.
|
* in the supplied iterator.
|
||||||
*/
|
*/
|
||||||
public static long getEstimatedMemoryUsage (Iterator iter)
|
public static long getEstimatedMemoryUsage (Iterator<BufferedImage> iter)
|
||||||
{
|
{
|
||||||
long size = 0;
|
long size = 0;
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
BufferedImage image = (BufferedImage)iter.next();
|
BufferedImage image = iter.next();
|
||||||
size += getEstimatedMemoryUsage(image);
|
size += getEstimatedMemoryUsage(image);
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class DumpColorPository
|
|||||||
try {
|
try {
|
||||||
ColorPository pos = ColorPository.loadColorPository(
|
ColorPository pos = ColorPository.loadColorPository(
|
||||||
new FileInputStream(args[0]));
|
new FileInputStream(args[0]));
|
||||||
Iterator iter = pos.enumerateClasses();
|
Iterator<ColorPository.ClassRecord> iter = pos.enumerateClasses();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
System.out.println(iter.next());
|
System.out.println(iter.next());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ public class MusicManager
|
|||||||
}
|
}
|
||||||
String music = names[RandomUtil.getInt(names.length)];
|
String music = names[RandomUtil.getInt(names.length)];
|
||||||
|
|
||||||
Class playerClass = getMusicPlayerClass(music);
|
Class<?> playerClass = getMusicPlayerClass(music);
|
||||||
|
|
||||||
// if we don't have a player for this song, play the next song
|
// if we don't have a player for this song, play the next song
|
||||||
if (playerClass == null) {
|
if (playerClass == null) {
|
||||||
@@ -246,7 +246,7 @@ public class MusicManager
|
|||||||
/**
|
/**
|
||||||
* Get the appropriate music player for the specified music file.
|
* Get the appropriate music player for the specified music file.
|
||||||
*/
|
*/
|
||||||
protected static Class getMusicPlayerClass (String path)
|
protected static Class<?> getMusicPlayerClass (String path)
|
||||||
{
|
{
|
||||||
path = path.toLowerCase();
|
path = path.toLowerCase();
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class Sounds
|
|||||||
* a <code>sounds.properties</code> file in the
|
* a <code>sounds.properties</code> file in the
|
||||||
* <code>com.threerings.happy.fun</code> package.
|
* <code>com.threerings.happy.fun</code> package.
|
||||||
*/
|
*/
|
||||||
protected static String getPackagePath (Class clazz)
|
protected static String getPackagePath (Class<?> clazz)
|
||||||
{
|
{
|
||||||
return clazz.getPackage().getName().replace('.', '/') + "/";
|
return clazz.getPackage().getName().replace('.', '/') + "/";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ public abstract class Sprite extends AbstractMedia
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Used to dispatch {@link PathObserver#pathCancelled}. */
|
/** Used to dispatch {@link PathObserver#pathCancelled}. */
|
||||||
protected static class CancelledOp implements ObserverList.ObserverOp
|
protected static class CancelledOp implements ObserverList.ObserverOp<Object>
|
||||||
{
|
{
|
||||||
public CancelledOp (Sprite sprite, Path path) {
|
public CancelledOp (Sprite sprite, Path path) {
|
||||||
_sprite = sprite;
|
_sprite = sprite;
|
||||||
@@ -406,7 +406,7 @@ public abstract class Sprite extends AbstractMedia
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Used to dispatch {@link PathObserver#pathCompleted}. */
|
/** Used to dispatch {@link PathObserver#pathCompleted}. */
|
||||||
protected static class CompletedOp implements ObserverList.ObserverOp
|
protected static class CompletedOp implements ObserverList.ObserverOp<Object>
|
||||||
{
|
{
|
||||||
public CompletedOp (Sprite sprite, Path path, long when) {
|
public CompletedOp (Sprite sprite, Path path, long when) {
|
||||||
_sprite = sprite;
|
_sprite = sprite;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ package com.threerings.media.tile;
|
|||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.samskivert.util.LRUHashMap;
|
import com.samskivert.util.LRUHashMap;
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ public abstract class SimpleCachingImageProvider implements ImageProvider
|
|||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public BufferedImage getTileSetImage (String path, Colorization[] zations)
|
public BufferedImage getTileSetImage (String path, Colorization[] zations)
|
||||||
{
|
{
|
||||||
BufferedImage image = (BufferedImage)_cache.get(path);
|
BufferedImage image = _cache.get(path);
|
||||||
if (image == null) {
|
if (image == null) {
|
||||||
try {
|
try {
|
||||||
image = loadImage(path);
|
image = loadImage(path);
|
||||||
@@ -69,5 +70,5 @@ public abstract class SimpleCachingImageProvider implements ImageProvider
|
|||||||
protected abstract BufferedImage loadImage (String path)
|
protected abstract BufferedImage loadImage (String path)
|
||||||
throws IOException;
|
throws IOException;
|
||||||
|
|
||||||
protected LRUHashMap _cache = new LRUHashMap(10);
|
protected Map<String, BufferedImage> _cache = new LRUHashMap<String, BufferedImage>(10);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ import java.awt.Rectangle;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.ref.SoftReference;
|
import java.lang.ref.SoftReference;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
import com.samskivert.util.Throttle;
|
import com.samskivert.util.Throttle;
|
||||||
@@ -35,6 +37,8 @@ import com.threerings.media.image.Colorization;
|
|||||||
import com.threerings.media.image.Mirage;
|
import com.threerings.media.image.Mirage;
|
||||||
import com.threerings.media.image.ImageUtil;
|
import com.threerings.media.image.ImageUtil;
|
||||||
import com.threerings.media.image.BufferedMirage;
|
import com.threerings.media.image.BufferedMirage;
|
||||||
|
import com.threerings.media.tile.Tile.Key;
|
||||||
|
|
||||||
import static com.threerings.media.Log.log;
|
import static com.threerings.media.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -205,9 +209,9 @@ public abstract class TileSet
|
|||||||
_key.tileSet = this;
|
_key.tileSet = this;
|
||||||
_key.tileIndex = tileIndex;
|
_key.tileIndex = tileIndex;
|
||||||
_key.zations = zations;
|
_key.zations = zations;
|
||||||
SoftReference sref = (SoftReference)_atiles.get(_key);
|
SoftReference<Tile> sref = _atiles.get(_key);
|
||||||
if (sref != null) {
|
if (sref != null) {
|
||||||
tile = (Tile)sref.get();
|
tile = sref.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +221,7 @@ public abstract class TileSet
|
|||||||
tile.key = new Tile.Key(this, tileIndex, zations);
|
tile.key = new Tile.Key(this, tileIndex, zations);
|
||||||
initTile(tile, tileIndex, zations);
|
initTile(tile, tileIndex, zations);
|
||||||
synchronized (_atiles) {
|
synchronized (_atiles) {
|
||||||
_atiles.put(tile.key, new SoftReference(tile));
|
_atiles.put(tile.key, new SoftReference<Tile>(tile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,10 +376,10 @@ public abstract class TileSet
|
|||||||
int asize = 0;
|
int asize = 0;
|
||||||
synchronized (_atiles) {
|
synchronized (_atiles) {
|
||||||
// first total up the active tiles
|
// first total up the active tiles
|
||||||
Iterator iter = _atiles.values().iterator();
|
Iterator<SoftReference<Tile>> iter = _atiles.values().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
SoftReference sref = (SoftReference)iter.next();
|
SoftReference<Tile> sref = iter.next();
|
||||||
Tile tile = (Tile)sref.get();
|
Tile tile = sref.get();
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
asize++;
|
asize++;
|
||||||
amem += tile.getEstimatedMemoryUsage();
|
amem += tile.getEstimatedMemoryUsage();
|
||||||
@@ -415,7 +419,7 @@ public abstract class TileSet
|
|||||||
private static final long serialVersionUID = 1;
|
private static final long serialVersionUID = 1;
|
||||||
|
|
||||||
/** A map containing weak references to all "active" tiles. */
|
/** A map containing weak references to all "active" tiles. */
|
||||||
protected static HashMap _atiles = new HashMap();
|
protected static Map<Key, SoftReference<Tile>> _atiles = Maps.newHashMap();
|
||||||
|
|
||||||
/** A key used to look things up in the cache without creating craploads of keys unduly. */
|
/** A key used to look things up in the cache without creating craploads of keys unduly. */
|
||||||
protected static Tile.Key _key = new Tile.Key(null, 0, null);
|
protected static Tile.Key _key = new Tile.Key(null, 0, null);
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import java.util.Iterator;
|
|||||||
|
|
||||||
import com.samskivert.io.PersistenceException;
|
import com.samskivert.io.PersistenceException;
|
||||||
import com.samskivert.util.HashIntMap;
|
import com.samskivert.util.HashIntMap;
|
||||||
|
import com.samskivert.util.IntMap;
|
||||||
|
|
||||||
import com.threerings.resource.ResourceBundle;
|
import com.threerings.resource.ResourceBundle;
|
||||||
import com.threerings.resource.ResourceManager;
|
import com.threerings.resource.ResourceManager;
|
||||||
|
|
||||||
@@ -88,8 +90,8 @@ public class BundledTileSetRepository
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashIntMap idmap = new HashIntMap();
|
HashIntMap<TileSet> idmap = new HashIntMap<TileSet>();
|
||||||
HashMap namemap = new HashMap();
|
HashMap<String, Integer> namemap = new HashMap<String, Integer>();
|
||||||
|
|
||||||
// iterate over the resource bundles in the set, loading up the
|
// iterate over the resource bundles in the set, loading up the
|
||||||
// tileset bundles in each resource bundle
|
// tileset bundles in each resource bundle
|
||||||
@@ -118,7 +120,7 @@ public class BundledTileSetRepository
|
|||||||
* Extracts the tileset bundle from the supplied resource bundle
|
* Extracts the tileset bundle from the supplied resource bundle
|
||||||
* and registers it.
|
* and registers it.
|
||||||
*/
|
*/
|
||||||
protected void addBundle (HashIntMap idmap, HashMap namemap,
|
protected void addBundle (HashIntMap<TileSet> idmap, HashMap<String, Integer> namemap,
|
||||||
ResourceBundle bundle)
|
ResourceBundle bundle)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -137,17 +139,16 @@ public class BundledTileSetRepository
|
|||||||
* Adds the tilesets in the supplied bundle to our tileset mapping
|
* Adds the tilesets in the supplied bundle to our tileset mapping
|
||||||
* tables. Any tilesets with the same name or id will be overwritten.
|
* tables. Any tilesets with the same name or id will be overwritten.
|
||||||
*/
|
*/
|
||||||
protected void addBundle (HashIntMap idmap, HashMap namemap,
|
protected void addBundle (HashIntMap<TileSet> idmap, HashMap<String, Integer> namemap,
|
||||||
TileSetBundle bundle)
|
TileSetBundle bundle)
|
||||||
{
|
{
|
||||||
IMImageProvider improv = (_imgr == null) ?
|
IMImageProvider improv = (_imgr == null) ?
|
||||||
null : new IMImageProvider(_imgr, bundle);
|
null : new IMImageProvider(_imgr, bundle);
|
||||||
|
|
||||||
// map all of the tilesets in this bundle
|
// map all of the tilesets in this bundle
|
||||||
for (Iterator iter = bundle.entrySet().iterator(); iter.hasNext(); ) {
|
for (IntMap.IntEntry<TileSet> entry : bundle.intEntrySet()) {
|
||||||
HashIntMap.Entry entry = (HashIntMap.Entry)iter.next();
|
Integer tsid = entry.getKey();
|
||||||
Integer tsid = (Integer)entry.getKey();
|
TileSet tset = entry.getValue();
|
||||||
TileSet tset = (TileSet)entry.getValue();
|
|
||||||
tset.setImageProvider(improv);
|
tset.setImageProvider(improv);
|
||||||
idmap.put(tsid.intValue(), tset);
|
idmap.put(tsid.intValue(), tset);
|
||||||
namemap.put(tset.getName(), tsid);
|
namemap.put(tset.getName(), tsid);
|
||||||
@@ -155,7 +156,7 @@ public class BundledTileSetRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public Iterator enumerateTileSetIds ()
|
public Iterator<Integer> enumerateTileSetIds ()
|
||||||
throws PersistenceException
|
throws PersistenceException
|
||||||
{
|
{
|
||||||
waitForBundles();
|
waitForBundles();
|
||||||
@@ -163,7 +164,7 @@ public class BundledTileSetRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public Iterator enumerateTileSets ()
|
public Iterator<TileSet> enumerateTileSets ()
|
||||||
throws PersistenceException
|
throws PersistenceException
|
||||||
{
|
{
|
||||||
waitForBundles();
|
waitForBundles();
|
||||||
@@ -175,7 +176,7 @@ public class BundledTileSetRepository
|
|||||||
throws NoSuchTileSetException, PersistenceException
|
throws NoSuchTileSetException, PersistenceException
|
||||||
{
|
{
|
||||||
waitForBundles();
|
waitForBundles();
|
||||||
TileSet tset = (TileSet)_idmap.get(tileSetId);
|
TileSet tset = _idmap.get(tileSetId);
|
||||||
if (tset == null) {
|
if (tset == null) {
|
||||||
throw new NoSuchTileSetException(tileSetId);
|
throw new NoSuchTileSetException(tileSetId);
|
||||||
}
|
}
|
||||||
@@ -187,7 +188,7 @@ public class BundledTileSetRepository
|
|||||||
throws NoSuchTileSetException, PersistenceException
|
throws NoSuchTileSetException, PersistenceException
|
||||||
{
|
{
|
||||||
waitForBundles();
|
waitForBundles();
|
||||||
Integer tsid = (Integer)_namemap.get(setName);
|
Integer tsid = _namemap.get(setName);
|
||||||
if (tsid != null) {
|
if (tsid != null) {
|
||||||
return tsid.intValue();
|
return tsid.intValue();
|
||||||
}
|
}
|
||||||
@@ -199,7 +200,7 @@ public class BundledTileSetRepository
|
|||||||
throws NoSuchTileSetException, PersistenceException
|
throws NoSuchTileSetException, PersistenceException
|
||||||
{
|
{
|
||||||
waitForBundles();
|
waitForBundles();
|
||||||
Integer tsid = (Integer)_namemap.get(setName);
|
Integer tsid = _namemap.get(setName);
|
||||||
if (tsid != null) {
|
if (tsid != null) {
|
||||||
return getTileSet(tsid.intValue());
|
return getTileSet(tsid.intValue());
|
||||||
}
|
}
|
||||||
@@ -222,8 +223,8 @@ public class BundledTileSetRepository
|
|||||||
protected ImageManager _imgr;
|
protected ImageManager _imgr;
|
||||||
|
|
||||||
/** A mapping from tileset id to tileset. */
|
/** A mapping from tileset id to tileset. */
|
||||||
protected HashIntMap _idmap;
|
protected HashIntMap<TileSet> _idmap;
|
||||||
|
|
||||||
/** A mapping from tileset name to tileset id. */
|
/** A mapping from tileset name to tileset id. */
|
||||||
protected HashMap _namemap;
|
protected HashMap<String, Integer> _namemap;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import com.threerings.media.tile.TileSet;
|
|||||||
* A tileset bundle is used to load up tilesets by id from a persistent bundle of tilesets stored
|
* A tileset bundle is used to load up tilesets by id from a persistent bundle of tilesets stored
|
||||||
* on the local filesystem.
|
* on the local filesystem.
|
||||||
*/
|
*/
|
||||||
public class TileSetBundle extends HashIntMap
|
public class TileSetBundle extends HashIntMap<TileSet>
|
||||||
implements Serializable, ImageDataProvider
|
implements Serializable, ImageDataProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -65,13 +65,13 @@ public class TileSetBundle extends HashIntMap
|
|||||||
*/
|
*/
|
||||||
public final TileSet getTileSet (int tileSetId)
|
public final TileSet getTileSet (int tileSetId)
|
||||||
{
|
{
|
||||||
return (TileSet)get(tileSetId);
|
return get(tileSetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enumerates the tileset ids in this tileset bundle.
|
* Enumerates the tileset ids in this tileset bundle.
|
||||||
*/
|
*/
|
||||||
public Iterator enumerateTileSetIds ()
|
public Iterator<Integer> enumerateTileSetIds ()
|
||||||
{
|
{
|
||||||
return keySet().iterator();
|
return keySet().iterator();
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ public class TileSetBundle extends HashIntMap
|
|||||||
/**
|
/**
|
||||||
* Enumerates the tilesets in this tileset bundle.
|
* Enumerates the tilesets in this tileset bundle.
|
||||||
*/
|
*/
|
||||||
public Iterator enumerateTileSets ()
|
public Iterator<TileSet> enumerateTileSets ()
|
||||||
{
|
{
|
||||||
return values().iterator();
|
return values().iterator();
|
||||||
}
|
}
|
||||||
@@ -103,9 +103,7 @@ public class TileSetBundle extends HashIntMap
|
|||||||
{
|
{
|
||||||
out.writeInt(size());
|
out.writeInt(size());
|
||||||
|
|
||||||
Iterator entries = intEntrySet().iterator();
|
for (IntEntry<TileSet> entry : intEntrySet()) {
|
||||||
while (entries.hasNext()) {
|
|
||||||
IntEntry entry = (IntEntry)entries.next();
|
|
||||||
out.writeInt(entry.getIntKey());
|
out.writeInt(entry.getIntKey());
|
||||||
out.writeObject(entry.getValue());
|
out.writeObject(entry.getValue());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ public class DirectoryTileSetBundler extends TileSetBundler
|
|||||||
try {
|
try {
|
||||||
// write all of the image files to the bundle's target path, converting the
|
// write all of the image files to the bundle's target path, converting the
|
||||||
// tilesets to trimmed tilesets in the process
|
// tilesets to trimmed tilesets in the process
|
||||||
Iterator iditer = bundle.enumerateTileSetIds();
|
Iterator<Integer> iditer = bundle.enumerateTileSetIds();
|
||||||
while (iditer.hasNext()) {
|
while (iditer.hasNext()) {
|
||||||
int tileSetId = ((Integer)iditer.next()).intValue();
|
int tileSetId = iditer.next().intValue();
|
||||||
TileSet set = bundle.getTileSet(tileSetId);
|
TileSet set = bundle.getTileSet(tileSetId);
|
||||||
String imagePath = set.getImagePath();
|
String imagePath = set.getImagePath();
|
||||||
|
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ public class DumpBundle
|
|||||||
tsb = BundleUtil.extractBundle(file);
|
tsb = BundleUtil.extractBundle(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator tsids = tsb.enumerateTileSetIds();
|
Iterator<Integer> tsids = tsb.enumerateTileSetIds();
|
||||||
while (tsids.hasNext()) {
|
while (tsids.hasNext()) {
|
||||||
Integer tsid = (Integer)tsids.next();
|
Integer tsid = tsids.next();
|
||||||
TileSet set = tsb.getTileSet(tsid.intValue());
|
TileSet set = tsb.getTileSet(tsid.intValue());
|
||||||
System.out.println(tsid + " => " + set);
|
System.out.println(tsid + " => " + set);
|
||||||
if (dumpTiles) {
|
if (dumpTiles) {
|
||||||
|
|||||||
@@ -132,15 +132,13 @@ public class TileSetBundler
|
|||||||
Digester digester = new Digester();
|
Digester digester = new Digester();
|
||||||
|
|
||||||
// push our mappings array onto the stack
|
// push our mappings array onto the stack
|
||||||
ArrayList mappings = new ArrayList();
|
ArrayList<Mapping> mappings = new ArrayList<Mapping>();
|
||||||
digester.push(mappings);
|
digester.push(mappings);
|
||||||
|
|
||||||
// create a mapping object for each mapping entry and append it to
|
// create a mapping object for each mapping entry and append it to
|
||||||
// our mapping list
|
// our mapping list
|
||||||
digester.addObjectCreate("bundler-config/mapping",
|
digester.addObjectCreate("bundler-config/mapping", Mapping.class.getName());
|
||||||
Mapping.class.getName());
|
digester.addSetNext("bundler-config/mapping", "add", "java.lang.Object");
|
||||||
digester.addSetNext("bundler-config/mapping",
|
|
||||||
"add", "java.lang.Object");
|
|
||||||
|
|
||||||
// configure each mapping object with the path and ruleset
|
// configure each mapping object with the path and ruleset
|
||||||
digester.addCallMethod("bundler-config/mapping", "init", 2);
|
digester.addCallMethod("bundler-config/mapping", "init", 2);
|
||||||
@@ -164,7 +162,7 @@ public class TileSetBundler
|
|||||||
// use the mappings we parsed to configure our actual digester
|
// use the mappings we parsed to configure our actual digester
|
||||||
int msize = mappings.size();
|
int msize = mappings.size();
|
||||||
for (int i = 0; i < msize; i++) {
|
for (int i = 0; i < msize; i++) {
|
||||||
Mapping map = (Mapping)mappings.get(i);
|
Mapping map = mappings.get(i);
|
||||||
try {
|
try {
|
||||||
TileSetRuleSet ruleset = (TileSetRuleSet)Class.forName(map.ruleset).newInstance();
|
TileSetRuleSet ruleset = (TileSetRuleSet)Class.forName(map.ruleset).newInstance();
|
||||||
|
|
||||||
@@ -229,7 +227,7 @@ public class TileSetBundler
|
|||||||
{
|
{
|
||||||
// stick an array list on the top of the stack into which we will
|
// stick an array list on the top of the stack into which we will
|
||||||
// collect parsed tilesets
|
// collect parsed tilesets
|
||||||
ArrayList sets = new ArrayList();
|
ArrayList<TileSet> sets = new ArrayList<TileSet>();
|
||||||
_digester.push(sets);
|
_digester.push(sets);
|
||||||
|
|
||||||
// parse the tilesets
|
// parse the tilesets
|
||||||
@@ -255,7 +253,7 @@ public class TileSetBundler
|
|||||||
// add all of the parsed tilesets to the tileset bundle
|
// add all of the parsed tilesets to the tileset bundle
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < sets.size(); i++) {
|
for (int i = 0; i < sets.size(); i++) {
|
||||||
TileSet set = (TileSet)sets.get(i);
|
TileSet set = sets.get(i);
|
||||||
String name = set.getName();
|
String name = set.getName();
|
||||||
|
|
||||||
// let's be robust
|
// let's be robust
|
||||||
@@ -363,13 +361,13 @@ public class TileSetBundler
|
|||||||
try {
|
try {
|
||||||
// write all of the image files to the bundle, converting the
|
// write all of the image files to the bundle, converting the
|
||||||
// tilesets to trimmed tilesets in the process
|
// tilesets to trimmed tilesets in the process
|
||||||
Iterator iditer = bundle.enumerateTileSetIds();
|
Iterator<Integer> iditer = bundle.enumerateTileSetIds();
|
||||||
|
|
||||||
// Store off the updated TileSets in a separate Map so we can wait to change the
|
// Store off the updated TileSets in a separate Map so we can wait to change the
|
||||||
// bundle till we're done iterating.
|
// bundle till we're done iterating.
|
||||||
HashIntMap<TileSet> toUpdate = new HashIntMap<TileSet>();
|
HashIntMap<TileSet> toUpdate = new HashIntMap<TileSet>();
|
||||||
while (iditer.hasNext()) {
|
while (iditer.hasNext()) {
|
||||||
int tileSetId = ((Integer)iditer.next()).intValue();
|
int tileSetId = iditer.next().intValue();
|
||||||
TileSet set = bundle.getTileSet(tileSetId);
|
TileSet set = bundle.getTileSet(tileSetId);
|
||||||
String imagePath = set.getImagePath();
|
String imagePath = set.getImagePath();
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class TileSetBundlerTask extends Task
|
|||||||
|
|
||||||
// deal with the filesets
|
// deal with the filesets
|
||||||
for (int i = 0; i < _filesets.size(); i++) {
|
for (int i = 0; i < _filesets.size(); i++) {
|
||||||
FileSet fs = (FileSet)_filesets.get(i);
|
FileSet fs = _filesets.get(i);
|
||||||
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
|
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
|
||||||
File fromDir = fs.getDir(getProject());
|
File fromDir = fs.getDir(getProject());
|
||||||
String[] srcFiles = ds.getIncludedFiles();
|
String[] srcFiles = ds.getIncludedFiles();
|
||||||
@@ -157,5 +157,5 @@ public class TileSetBundlerTask extends Task
|
|||||||
protected File _mapfile;
|
protected File _mapfile;
|
||||||
|
|
||||||
/** A list of filesets that contain tileset bundle definitions. */
|
/** A list of filesets that contain tileset bundle definitions. */
|
||||||
protected ArrayList _filesets = new ArrayList();
|
protected ArrayList<FileSet> _filesets = new ArrayList<FileSet>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,13 +39,11 @@ public class DumpTileSetMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MapFileTileSetIDBroker broker =
|
MapFileTileSetIDBroker broker = new MapFileTileSetIDBroker(new File(args[0]));
|
||||||
new MapFileTileSetIDBroker(new File(args[0]));
|
Iterator<String> iter = broker.enumerateMappings();
|
||||||
Iterator iter = broker.enumerateMappings();
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
String tsname = iter.next().toString();
|
String tsname = iter.next().toString();
|
||||||
System.out.println(tsname + " => " +
|
System.out.println(tsname + " => " + broker.getTileSetID(tsname));
|
||||||
broker.getTileSetID(tsname));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (PersistenceException pe) {
|
} catch (PersistenceException pe) {
|
||||||
|
|||||||
@@ -60,14 +60,14 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker
|
|||||||
_nextTileSetID = readInt(bin);
|
_nextTileSetID = readInt(bin);
|
||||||
_storedTileSetID = _nextTileSetID;
|
_storedTileSetID = _nextTileSetID;
|
||||||
// read in our mappings
|
// read in our mappings
|
||||||
_map = new HashMap();
|
_map = new HashMap<String, Integer>();
|
||||||
readMapFile(bin, _map);
|
readMapFile(bin, _map);
|
||||||
|
|
||||||
bin.close();
|
bin.close();
|
||||||
|
|
||||||
} catch (FileNotFoundException fnfe) {
|
} catch (FileNotFoundException fnfe) {
|
||||||
// create a blank map if our map file doesn't exist
|
// create a blank map if our map file doesn't exist
|
||||||
_map = new HashMap();
|
_map = new HashMap<String, Integer>();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// other errors are more fatal
|
// other errors are more fatal
|
||||||
@@ -91,7 +91,7 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker
|
|||||||
public int getTileSetID (String tileSetName)
|
public int getTileSetID (String tileSetName)
|
||||||
throws PersistenceException
|
throws PersistenceException
|
||||||
{
|
{
|
||||||
Integer tsid = (Integer)_map.get(tileSetName);
|
Integer tsid = _map.get(tileSetName);
|
||||||
if (tsid == null) {
|
if (tsid == null) {
|
||||||
tsid = Integer.valueOf(++_nextTileSetID);
|
tsid = Integer.valueOf(++_nextTileSetID);
|
||||||
_map.put(tileSetName, tsid);
|
_map.put(tileSetName, tsid);
|
||||||
@@ -135,7 +135,7 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker
|
|||||||
* Reads in a mapping from strings to integers, which should have been
|
* Reads in a mapping from strings to integers, which should have been
|
||||||
* written via {@link #writeMapFile}.
|
* written via {@link #writeMapFile}.
|
||||||
*/
|
*/
|
||||||
public static void readMapFile (BufferedReader bin, HashMap map)
|
public static void readMapFile (BufferedReader bin, HashMap<String, Integer> map)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
String line;
|
String line;
|
||||||
@@ -159,14 +159,14 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker
|
|||||||
* Writes out a mapping from strings to integers in a manner that can
|
* Writes out a mapping from strings to integers in a manner that can
|
||||||
* be read back in via {@link #readMapFile}.
|
* be read back in via {@link #readMapFile}.
|
||||||
*/
|
*/
|
||||||
public static void writeMapFile (BufferedWriter bout, HashMap map)
|
public static void writeMapFile (BufferedWriter bout, HashMap<String, Integer> map)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
String[] lines = new String[map.size()];
|
String[] lines = new String[map.size()];
|
||||||
Iterator iter = map.keySet().iterator();
|
Iterator<String> iter = map.keySet().iterator();
|
||||||
for (int ii = 0; iter.hasNext(); ii++) {
|
for (int ii = 0; iter.hasNext(); ii++) {
|
||||||
String key = (String)iter.next();
|
String key = iter.next();
|
||||||
Integer value = (Integer)map.get(key);
|
Integer value = map.get(key);
|
||||||
lines[ii] = key + SEP_STR + value;
|
lines[ii] = key + SEP_STR + value;
|
||||||
}
|
}
|
||||||
QuickSort.sort(lines);
|
QuickSort.sort(lines);
|
||||||
@@ -184,7 +184,7 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker
|
|||||||
*/
|
*/
|
||||||
protected boolean renameTileSet (String oldName, String newName)
|
protected boolean renameTileSet (String oldName, String newName)
|
||||||
{
|
{
|
||||||
Integer tsid = (Integer)_map.get(oldName);
|
Integer tsid = _map.get(oldName);
|
||||||
if (tsid != null) {
|
if (tsid != null) {
|
||||||
_map.put(newName, tsid);
|
_map.put(newName, tsid);
|
||||||
// fudge our stored tileset ID so that we flush ourselves when
|
// fudge our stored tileset ID so that we flush ourselves when
|
||||||
@@ -201,7 +201,7 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker
|
|||||||
* Used by {@link DumpTileSetMap} to enumerate our tileset ID
|
* Used by {@link DumpTileSetMap} to enumerate our tileset ID
|
||||||
* mappings.
|
* mappings.
|
||||||
*/
|
*/
|
||||||
protected Iterator enumerateMappings ()
|
protected Iterator<String> enumerateMappings ()
|
||||||
{
|
{
|
||||||
return _map.keySet().iterator();
|
return _map.keySet().iterator();
|
||||||
}
|
}
|
||||||
@@ -216,7 +216,7 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker
|
|||||||
protected int _storedTileSetID;
|
protected int _storedTileSetID;
|
||||||
|
|
||||||
/** Our mapping from tileset names to ids. */
|
/** Our mapping from tileset names to ids. */
|
||||||
protected HashMap _map;
|
protected HashMap<String, Integer> _map;
|
||||||
|
|
||||||
/** The character we use to separate tileset name from code in the map
|
/** The character we use to separate tileset name from code in the map
|
||||||
* file. */
|
* file. */
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import com.samskivert.util.StringUtil;
|
|||||||
import com.samskivert.xml.CallMethodSpecialRule;
|
import com.samskivert.xml.CallMethodSpecialRule;
|
||||||
|
|
||||||
import com.threerings.media.tile.ObjectTileSet;
|
import com.threerings.media.tile.ObjectTileSet;
|
||||||
|
import com.threerings.media.tile.TileSet;
|
||||||
|
|
||||||
import com.threerings.util.DirectionUtil;
|
import com.threerings.util.DirectionUtil;
|
||||||
|
|
||||||
@@ -191,7 +192,7 @@ public class ObjectTileSetRuleSet extends SwissArmyTileSetRuleSet
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class getTileSetClass ()
|
protected Class<? extends TileSet> getTileSetClass ()
|
||||||
{
|
{
|
||||||
return ObjectTileSet.class;
|
return ObjectTileSet.class;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import com.samskivert.util.StringUtil;
|
|||||||
import com.samskivert.xml.CallMethodSpecialRule;
|
import com.samskivert.xml.CallMethodSpecialRule;
|
||||||
|
|
||||||
import com.threerings.media.tile.SwissArmyTileSet;
|
import com.threerings.media.tile.SwissArmyTileSet;
|
||||||
|
import com.threerings.media.tile.TileSet;
|
||||||
|
|
||||||
import static com.threerings.media.Log.log;
|
import static com.threerings.media.Log.log;
|
||||||
|
|
||||||
@@ -155,7 +156,7 @@ public class SwissArmyTileSetRuleSet extends TileSetRuleSet
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class getTileSetClass ()
|
protected Class<? extends TileSet> getTileSetClass ()
|
||||||
{
|
{
|
||||||
return SwissArmyTileSet.class;
|
return SwissArmyTileSet.class;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public abstract class TileSetRuleSet
|
|||||||
* A tileset rule set will create tilesets of a particular class,
|
* A tileset rule set will create tilesets of a particular class,
|
||||||
* which must be provided by the derived class via this method.
|
* which must be provided by the derived class via this method.
|
||||||
*/
|
*/
|
||||||
protected abstract Class getTileSetClass ();
|
protected abstract Class<? extends TileSet> getTileSetClass ();
|
||||||
|
|
||||||
/** The tileset path we append to the prefix to get the full path. */
|
/** The tileset path we append to the prefix to get the full path. */
|
||||||
protected String _tilesetPath = TILESET_PATH;
|
protected String _tilesetPath = TILESET_PATH;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ package com.threerings.media.tile.tools.xml;
|
|||||||
|
|
||||||
import org.apache.commons.digester.Digester;
|
import org.apache.commons.digester.Digester;
|
||||||
|
|
||||||
|
import com.threerings.media.tile.TileSet;
|
||||||
import com.threerings.media.tile.UniformTileSet;
|
import com.threerings.media.tile.UniformTileSet;
|
||||||
|
|
||||||
import static com.threerings.media.Log.log;
|
import static com.threerings.media.Log.log;
|
||||||
@@ -86,7 +87,7 @@ public class UniformTileSetRuleSet extends TileSetRuleSet
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class getTileSetClass ()
|
protected Class<? extends TileSet> getTileSetClass ()
|
||||||
{
|
{
|
||||||
return UniformTileSet.class;
|
return UniformTileSet.class;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,18 +339,16 @@ public class RecolorImage extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
_classList.removeAllItems();
|
_classList.removeAllItems();
|
||||||
Iterator iter = _colRepo.enumerateClasses();
|
Iterator<ColorPository.ClassRecord> iter = _colRepo.enumerateClasses();
|
||||||
ArrayList names = new ArrayList();
|
ArrayList<String> names = new ArrayList<String>();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
String str = ((ColorPository.ClassRecord)iter.next()).name;
|
String str = iter.next().name;
|
||||||
names.add(str);
|
names.add(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(names);
|
Collections.sort(names);
|
||||||
|
for (String name : names) {
|
||||||
iter = names.iterator();
|
_classList.addItem(name);
|
||||||
while (iter.hasNext()) {
|
|
||||||
_classList.addItem(iter.next());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_classList.setSelectedIndex(0);
|
_classList.setSelectedIndex(0);
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ public class AStarPathUtil
|
|||||||
* A class that represents a single traversable node in the tile array
|
* A class that represents a single traversable node in the tile array
|
||||||
* along with its current A*-specific search information.
|
* along with its current A*-specific search information.
|
||||||
*/
|
*/
|
||||||
protected static class Node implements Comparable
|
protected static class Node implements Comparable<Node>
|
||||||
{
|
{
|
||||||
/** The node coordinates. */
|
/** The node coordinates. */
|
||||||
public int x, y;
|
public int x, y;
|
||||||
@@ -435,9 +435,9 @@ public class AStarPathUtil
|
|||||||
id = _nextid++;
|
id = _nextid++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo (Object o)
|
public int compareTo (Node o)
|
||||||
{
|
{
|
||||||
int bf = ((Node)o).f;
|
int bf = o.f;
|
||||||
|
|
||||||
// since the set contract is fulfilled using the equality results
|
// since the set contract is fulfilled using the equality results
|
||||||
// returned here, and we'd like to allow multiple nodes with
|
// returned here, and we'd like to allow multiple nodes with
|
||||||
@@ -446,7 +446,7 @@ public class AStarPathUtil
|
|||||||
// unique node id since it will return a consistent ordering for
|
// unique node id since it will return a consistent ordering for
|
||||||
// the objects.
|
// the objects.
|
||||||
if (f == bf) {
|
if (f == bf) {
|
||||||
return (this == o) ? 0 : (id - ((Node)o).id);
|
return (this == o) ? 0 : (id - o.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return f - bf;
|
return f - bf;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class LineSegmentPath
|
|||||||
* Constructs a line segment path with the specified list of points.
|
* Constructs a line segment path with the specified list of points.
|
||||||
* An arbitrary direction will be assigned to the starting node.
|
* An arbitrary direction will be assigned to the starting node.
|
||||||
*/
|
*/
|
||||||
public LineSegmentPath (List points)
|
public LineSegmentPath (List<Point> points)
|
||||||
{
|
{
|
||||||
createPath(points);
|
createPath(points);
|
||||||
}
|
}
|
||||||
@@ -331,12 +331,12 @@ public class LineSegmentPath
|
|||||||
* its starting position to the given destination coordinates
|
* its starting position to the given destination coordinates
|
||||||
* following the given list of screen coordinates.
|
* following the given list of screen coordinates.
|
||||||
*/
|
*/
|
||||||
protected void createPath (List points)
|
protected void createPath (List<Point> points)
|
||||||
{
|
{
|
||||||
Point last = null;
|
Point last = null;
|
||||||
int size = points.size();
|
int size = points.size();
|
||||||
for (int ii = 0; ii < size; ii++) {
|
for (int ii = 0; ii < size; ii++) {
|
||||||
Point p = (Point)points.get(ii);
|
Point p = points.get(ii);
|
||||||
|
|
||||||
int dir = (ii == 0) ? NORTH : DirectionUtil.getDirection(last, p);
|
int dir = (ii == 0) ? NORTH : DirectionUtil.getDirection(last, p);
|
||||||
addNode(p.x, p.y, dir);
|
addNode(p.x, p.y, dir);
|
||||||
@@ -349,14 +349,14 @@ public class LineSegmentPath
|
|||||||
*/
|
*/
|
||||||
protected PathNode getNextNode ()
|
protected PathNode getNextNode ()
|
||||||
{
|
{
|
||||||
return (PathNode)_niter.next();
|
return _niter.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The nodes that make up the path. */
|
/** The nodes that make up the path. */
|
||||||
protected ArrayList<PathNode> _nodes = new ArrayList<PathNode>();
|
protected ArrayList<PathNode> _nodes = new ArrayList<PathNode>();
|
||||||
|
|
||||||
/** We use this when moving along this path. */
|
/** We use this when moving along this path. */
|
||||||
protected Iterator _niter;
|
protected Iterator<PathNode> _niter;
|
||||||
|
|
||||||
/** When moving, the pathable's source path node. */
|
/** When moving, the pathable's source path node. */
|
||||||
protected PathNode _src;
|
protected PathNode _src;
|
||||||
|
|||||||
@@ -41,17 +41,14 @@ public class ModeUtil
|
|||||||
* desired mode is also used.
|
* desired mode is also used.
|
||||||
*/
|
*/
|
||||||
public static DisplayMode getDisplayMode (
|
public static DisplayMode getDisplayMode (
|
||||||
GraphicsDevice gd, int width, int height,
|
GraphicsDevice gd, int width, int height, int desiredDepth, int minimumDepth)
|
||||||
int desiredDepth, int minimumDepth)
|
|
||||||
{
|
{
|
||||||
DisplayMode[] modes = gd.getDisplayModes();
|
DisplayMode[] modes = gd.getDisplayModes();
|
||||||
final int ddepth = desiredDepth;
|
final int ddepth = desiredDepth;
|
||||||
|
|
||||||
// we sort modes in order of desirability
|
// we sort modes in order of desirability
|
||||||
Comparator mcomp = new Comparator () {
|
Comparator<DisplayMode> mcomp = new Comparator<DisplayMode>() {
|
||||||
public int compare (Object o1, Object o2) {
|
public int compare (DisplayMode m1, DisplayMode m2) {
|
||||||
DisplayMode m1 = (DisplayMode)o1;
|
|
||||||
DisplayMode m2 = (DisplayMode)o2;
|
|
||||||
int bd1 = m1.getBitDepth(), bd2 = m2.getBitDepth();
|
int bd1 = m1.getBitDepth(), bd2 = m2.getBitDepth();
|
||||||
int rr1 = m1.getRefreshRate(), rr2 = m2.getRefreshRate();
|
int rr1 = m1.getRefreshRate(), rr2 = m2.getRefreshRate();
|
||||||
|
|
||||||
@@ -73,7 +70,7 @@ public class ModeUtil
|
|||||||
};
|
};
|
||||||
|
|
||||||
// but we only add modes that meet our minimum requirements
|
// but we only add modes that meet our minimum requirements
|
||||||
TreeSet mset = new TreeSet(mcomp);
|
TreeSet<DisplayMode> mset = new TreeSet<DisplayMode>(mcomp);
|
||||||
for (int i = 0; i < modes.length; i++) {
|
for (int i = 0; i < modes.length; i++) {
|
||||||
if (modes[i].getWidth() == width &&
|
if (modes[i].getWidth() == width &&
|
||||||
modes[i].getHeight() == height &&
|
modes[i].getHeight() == height &&
|
||||||
@@ -83,7 +80,7 @@ public class ModeUtil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (mset.size() > 0) ? (DisplayMode)mset.first() : null;
|
return (mset.size() > 0) ? mset.first() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class PathSequence
|
|||||||
*/
|
*/
|
||||||
public PathSequence (Path first, Path second)
|
public PathSequence (Path first, Path second)
|
||||||
{
|
{
|
||||||
this(new ArrayList());
|
this(new ArrayList<Path>());
|
||||||
_paths.add(first);
|
_paths.add(first);
|
||||||
_paths.add(second);
|
_paths.add(second);
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ public class PathSequence
|
|||||||
* Note: Paths may be added to the end of the list while
|
* Note: Paths may be added to the end of the list while
|
||||||
* the pathable is still traversing earlier paths!
|
* the pathable is still traversing earlier paths!
|
||||||
*/
|
*/
|
||||||
public PathSequence (List paths)
|
public PathSequence (List<Path> paths)
|
||||||
{
|
{
|
||||||
_paths = paths;
|
_paths = paths;
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ public class PathSequence
|
|||||||
_pable.pathCompleted(tickStamp);
|
_pable.pathCompleted(tickStamp);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_curPath = (Path) _paths.remove(0);
|
_curPath = _paths.remove(0);
|
||||||
_lastInit = initStamp;
|
_lastInit = initStamp;
|
||||||
|
|
||||||
_curPath.init(_pableRep, initStamp);
|
_curPath.init(_pableRep, initStamp);
|
||||||
@@ -128,7 +128,7 @@ public class PathSequence
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The list of paths. */
|
/** The list of paths. */
|
||||||
protected List _paths;
|
protected List<Path> _paths;
|
||||||
|
|
||||||
/** The timestamp at which we last inited a path. */
|
/** The timestamp at which we last inited a path. */
|
||||||
protected long _lastInit;
|
protected long _lastInit;
|
||||||
|
|||||||
@@ -22,6 +22,9 @@
|
|||||||
package com.threerings.media.util;
|
package com.threerings.media.util;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import com.threerings.media.timer.MediaTimer;
|
import com.threerings.media.timer.MediaTimer;
|
||||||
import com.threerings.media.timer.NanoTimer;
|
import com.threerings.media.timer.NanoTimer;
|
||||||
@@ -58,10 +61,10 @@ public class PerformanceMonitor
|
|||||||
public static void register (PerformanceObserver obs, String name, long delta)
|
public static void register (PerformanceObserver obs, String name, long delta)
|
||||||
{
|
{
|
||||||
// get the observer's action hashtable
|
// get the observer's action hashtable
|
||||||
HashMap actions = (HashMap)_observers.get(obs);
|
Map<String, PerformanceAction> actions = _observers.get(obs);
|
||||||
if (actions == null) {
|
if (actions == null) {
|
||||||
// create it if it didn't exist
|
// create it if it didn't exist
|
||||||
_observers.put(obs, actions = new HashMap());
|
_observers.put(obs, actions = new HashMap<String, PerformanceAction>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the action to the set we're tracking
|
// add the action to the set we're tracking
|
||||||
@@ -77,7 +80,7 @@ public class PerformanceMonitor
|
|||||||
public static void unregister (PerformanceObserver obs, String name)
|
public static void unregister (PerformanceObserver obs, String name)
|
||||||
{
|
{
|
||||||
// get the observer's action hashtable
|
// get the observer's action hashtable
|
||||||
HashMap actions = (HashMap)_observers.get(obs);
|
Map<String, PerformanceAction> actions = _observers.get(obs);
|
||||||
if (actions == null) {
|
if (actions == null) {
|
||||||
log.warning("Attempt to unregister by unknown observer " +
|
log.warning("Attempt to unregister by unknown observer " +
|
||||||
"[observer=" + obs + ", name=" + name + "].");
|
"[observer=" + obs + ", name=" + name + "].");
|
||||||
@@ -85,7 +88,7 @@ public class PerformanceMonitor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// attempt to remove the specified action
|
// attempt to remove the specified action
|
||||||
PerformanceAction action = (PerformanceAction)actions.remove(name);
|
PerformanceAction action = actions.remove(name);
|
||||||
if (action == null) {
|
if (action == null) {
|
||||||
log.warning("Attempt to unregister unknown action " +
|
log.warning("Attempt to unregister unknown action " +
|
||||||
"[observer=" + obs + ", name=" + name + "].");
|
"[observer=" + obs + ", name=" + name + "].");
|
||||||
@@ -108,7 +111,7 @@ public class PerformanceMonitor
|
|||||||
public static void tick (PerformanceObserver obs, String name)
|
public static void tick (PerformanceObserver obs, String name)
|
||||||
{
|
{
|
||||||
// get the observer's action hashtable
|
// get the observer's action hashtable
|
||||||
HashMap actions = (HashMap)_observers.get(obs);
|
Map<String, PerformanceAction> actions = _observers.get(obs);
|
||||||
if (actions == null) {
|
if (actions == null) {
|
||||||
log.warning("Attempt to tick by unknown observer " +
|
log.warning("Attempt to tick by unknown observer " +
|
||||||
"[observer=" + obs + ", name=" + name + "].");
|
"[observer=" + obs + ", name=" + name + "].");
|
||||||
@@ -116,7 +119,7 @@ public class PerformanceMonitor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the specified action
|
// get the specified action
|
||||||
PerformanceAction action = (PerformanceAction)actions.get(name);
|
PerformanceAction action = actions.get(name);
|
||||||
if (action == null) {
|
if (action == null) {
|
||||||
log.warning("Attempt to tick unknown value " +
|
log.warning("Attempt to tick unknown value " +
|
||||||
"[observer=" + obs + ", name=" + name + "].");
|
"[observer=" + obs + ", name=" + name + "].");
|
||||||
@@ -144,7 +147,8 @@ public class PerformanceMonitor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The observers monitoring some set of actions. */
|
/** The observers monitoring some set of actions. */
|
||||||
protected static HashMap _observers = new HashMap();
|
protected static Map<PerformanceObserver, Map<String, PerformanceAction>> _observers =
|
||||||
|
Maps.newHashMap();
|
||||||
|
|
||||||
/** Used to obtain high resolution time stamps. */
|
/** Used to obtain high resolution time stamps. */
|
||||||
protected static MediaTimer _timer = new NanoTimer();
|
protected static MediaTimer _timer = new NanoTimer();
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class DirtyItemList
|
|||||||
*/
|
*/
|
||||||
public DirtyItem get (int idx)
|
public DirtyItem get (int idx)
|
||||||
{
|
{
|
||||||
return (DirtyItem)_items.get(idx);
|
return _items.get(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,9 +121,9 @@ public class DirtyItemList
|
|||||||
_items.clear();
|
_items.clear();
|
||||||
POS_LOOP:
|
POS_LOOP:
|
||||||
for (int ii = 0; ii < size; ii++) {
|
for (int ii = 0; ii < size; ii++) {
|
||||||
DirtyItem item = (DirtyItem)_ditems.get(ii);
|
DirtyItem item = _ditems.get(ii);
|
||||||
for (int rr = _items.size()-1; rr >= 0; rr--) {
|
for (int rr = _items.size()-1; rr >= 0; rr--) {
|
||||||
DirtyItem pitem = (DirtyItem)_items.get(rr);
|
DirtyItem pitem = _items.get(rr);
|
||||||
// if we render in front of this item, insert
|
// if we render in front of this item, insert
|
||||||
// ourselves immediately following it
|
// ourselves immediately following it
|
||||||
if (_rcomp.compare(item, pitem) > 0) {
|
if (_rcomp.compare(item, pitem) > 0) {
|
||||||
@@ -145,8 +145,8 @@ public class DirtyItemList
|
|||||||
if (DEBUG_SORT) {
|
if (DEBUG_SORT) {
|
||||||
log.info("Sorted for render [items=" + toString(_items) + "].");
|
log.info("Sorted for render [items=" + toString(_items) + "].");
|
||||||
for (int ii = 0, ll = _items.size()-1; ii < ll; ii++) {
|
for (int ii = 0, ll = _items.size()-1; ii < ll; ii++) {
|
||||||
DirtyItem a = (DirtyItem)_items.get(ii);
|
DirtyItem a = _items.get(ii);
|
||||||
DirtyItem b = (DirtyItem)_items.get(ii+1);
|
DirtyItem b = _items.get(ii+1);
|
||||||
if (_rcomp.compare(a, b) > 0) {
|
if (_rcomp.compare(a, b) > 0) {
|
||||||
log.warning("Invalid ordering [a=" + a + ", b=" + b + "].");
|
log.warning("Invalid ordering [a=" + a + ", b=" + b + "].");
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ public class DirtyItemList
|
|||||||
{
|
{
|
||||||
int icount = _items.size();
|
int icount = _items.size();
|
||||||
for (int ii = 0; ii < icount; ii++) {
|
for (int ii = 0; ii < icount; ii++) {
|
||||||
DirtyItem item = (DirtyItem)_items.get(ii);
|
DirtyItem item = _items.get(ii);
|
||||||
item.paint(gfx);
|
item.paint(gfx);
|
||||||
item.clear();
|
item.clear();
|
||||||
_freelist.add(item);
|
_freelist.add(item);
|
||||||
@@ -177,7 +177,7 @@ public class DirtyItemList
|
|||||||
public void clear ()
|
public void clear ()
|
||||||
{
|
{
|
||||||
for (int icount = _items.size(); icount > 0; icount--) {
|
for (int icount = _items.size(); icount > 0; icount--) {
|
||||||
DirtyItem item = (DirtyItem)_items.remove(0);
|
DirtyItem item = _items.remove(0);
|
||||||
item.clear();
|
item.clear();
|
||||||
_freelist.add(item);
|
_freelist.add(item);
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ public class DirtyItemList
|
|||||||
protected DirtyItem getDirtyItem ()
|
protected DirtyItem getDirtyItem ()
|
||||||
{
|
{
|
||||||
if (_freelist.size() > 0) {
|
if (_freelist.size() > 0) {
|
||||||
return (DirtyItem)_freelist.remove(0);
|
return _freelist.remove(0);
|
||||||
} else {
|
} else {
|
||||||
return new DirtyItem();
|
return new DirtyItem();
|
||||||
}
|
}
|
||||||
@@ -232,12 +232,12 @@ public class DirtyItemList
|
|||||||
* Returns an abbreviated string representation of the given dirty
|
* Returns an abbreviated string representation of the given dirty
|
||||||
* items. See {@link #toString(DirtyItem)}.
|
* items. See {@link #toString(DirtyItem)}.
|
||||||
*/
|
*/
|
||||||
protected static String toString (SortableArrayList items)
|
protected static String toString (SortableArrayList<DirtyItem> items)
|
||||||
{
|
{
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("[");
|
buf.append("[");
|
||||||
for (int ii = 0; ii < items.size(); ii++) {
|
for (int ii = 0; ii < items.size(); ii++) {
|
||||||
DirtyItem item = (DirtyItem)items.get(ii);
|
DirtyItem item = items.get(ii);
|
||||||
toString(buf, item);
|
toString(buf, item);
|
||||||
if (ii < (items.size() - 1)) {
|
if (ii < (items.size() - 1)) {
|
||||||
buf.append(", ");
|
buf.append(", ");
|
||||||
@@ -381,7 +381,7 @@ public class DirtyItemList
|
|||||||
* A comparator class for use in sorting dirty items in ascending
|
* A comparator class for use in sorting dirty items in ascending
|
||||||
* origin x- or y-axis coordinate order.
|
* origin x- or y-axis coordinate order.
|
||||||
*/
|
*/
|
||||||
protected static class OriginComparator implements Comparator
|
protected static class OriginComparator implements Comparator<DirtyItem>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructs an origin comparator that sorts dirty items in
|
* Constructs an origin comparator that sorts dirty items in
|
||||||
@@ -394,11 +394,8 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public int compare (Object a, Object b)
|
public int compare (DirtyItem da, DirtyItem db)
|
||||||
{
|
{
|
||||||
DirtyItem da = (DirtyItem)a;
|
|
||||||
DirtyItem db = (DirtyItem)b;
|
|
||||||
|
|
||||||
// if they don't overlap, sort them normally
|
// if they don't overlap, sort them normally
|
||||||
if (_axis == X_AXIS) {
|
if (_axis == X_AXIS) {
|
||||||
if (da.ox != db.ox) {
|
if (da.ox != db.ox) {
|
||||||
@@ -425,14 +422,11 @@ public class DirtyItemList
|
|||||||
* suitable for rendering in the isometric view with proper visual
|
* suitable for rendering in the isometric view with proper visual
|
||||||
* results.
|
* results.
|
||||||
*/
|
*/
|
||||||
protected class RenderComparator implements Comparator
|
protected class RenderComparator implements Comparator<DirtyItem>
|
||||||
{
|
{
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public int compare (Object a, Object b)
|
public int compare (DirtyItem da, DirtyItem db)
|
||||||
{
|
{
|
||||||
DirtyItem da = (DirtyItem)a;
|
|
||||||
DirtyItem db = (DirtyItem)b;
|
|
||||||
|
|
||||||
// if the two objects are scene objects and they overlap, we
|
// if the two objects are scene objects and they overlap, we
|
||||||
// compare them solely based on their human assigned priority
|
// compare them solely based on their human assigned priority
|
||||||
if ((da.obj instanceof SceneObject) &&
|
if ((da.obj instanceof SceneObject) &&
|
||||||
@@ -490,8 +484,8 @@ public class DirtyItemList
|
|||||||
protected int comparePartitioned (int axis, DirtyItem da, DirtyItem db)
|
protected int comparePartitioned (int axis, DirtyItem da, DirtyItem db)
|
||||||
{
|
{
|
||||||
// prepare for the partitioning check
|
// prepare for the partitioning check
|
||||||
SortableArrayList sitems;
|
SortableArrayList<DirtyItem> sitems;
|
||||||
Comparator comp;
|
Comparator<DirtyItem> comp;
|
||||||
boolean swapped = false;
|
boolean swapped = false;
|
||||||
switch (axis) {
|
switch (axis) {
|
||||||
case X_AXIS:
|
case X_AXIS:
|
||||||
@@ -543,7 +537,7 @@ public class DirtyItemList
|
|||||||
// check each potentially partitioning item
|
// check each potentially partitioning item
|
||||||
int startidx = aidx + 1, endidx = startidx + size;
|
int startidx = aidx + 1, endidx = startidx + size;
|
||||||
for (int pidx = startidx; pidx < endidx; pidx++) {
|
for (int pidx = startidx; pidx < endidx; pidx++) {
|
||||||
DirtyItem dp = (DirtyItem)sitems.get(pidx);
|
DirtyItem dp = sitems.get(pidx);
|
||||||
if (dp.obj instanceof Sprite) {
|
if (dp.obj instanceof Sprite) {
|
||||||
// sprites can't partition things
|
// sprites can't partition things
|
||||||
continue;
|
continue;
|
||||||
@@ -652,22 +646,22 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The list of dirty items. */
|
/** The list of dirty items. */
|
||||||
protected SortableArrayList _items = new SortableArrayList();
|
protected SortableArrayList<DirtyItem> _items = new SortableArrayList<DirtyItem>();
|
||||||
|
|
||||||
/** The list of dirty items sorted by x-position. */
|
/** The list of dirty items sorted by x-position. */
|
||||||
protected SortableArrayList _xitems = new SortableArrayList();
|
protected SortableArrayList<DirtyItem> _xitems = new SortableArrayList<DirtyItem>();
|
||||||
|
|
||||||
/** The list of dirty items sorted by y-position. */
|
/** The list of dirty items sorted by y-position. */
|
||||||
protected SortableArrayList _yitems = new SortableArrayList();
|
protected SortableArrayList<DirtyItem> _yitems = new SortableArrayList<DirtyItem>();
|
||||||
|
|
||||||
/** The list of dirty items sorted by rear-depth. */
|
/** The list of dirty items sorted by rear-depth. */
|
||||||
protected SortableArrayList _ditems = new SortableArrayList();
|
protected SortableArrayList<DirtyItem> _ditems = new SortableArrayList<DirtyItem>();
|
||||||
|
|
||||||
/** The render comparator we'll use for our final, magical sort. */
|
/** The render comparator we'll use for our final, magical sort. */
|
||||||
protected Comparator _rcomp = new RenderComparator();
|
protected Comparator<DirtyItem> _rcomp = new RenderComparator();
|
||||||
|
|
||||||
/** Unused dirty items. */
|
/** Unused dirty items. */
|
||||||
protected ArrayList _freelist = new ArrayList();
|
protected ArrayList<DirtyItem> _freelist = new ArrayList<DirtyItem>();
|
||||||
|
|
||||||
/** Whether to log debug info when comparing pairs of dirty items. */
|
/** Whether to log debug info when comparing pairs of dirty items. */
|
||||||
protected static final boolean DEBUG_COMPARE = false;
|
protected static final boolean DEBUG_COMPARE = false;
|
||||||
@@ -681,20 +675,17 @@ public class DirtyItemList
|
|||||||
|
|
||||||
/** The comparator used to sort dirty items in ascending origin
|
/** The comparator used to sort dirty items in ascending origin
|
||||||
* x-coordinate order. */
|
* x-coordinate order. */
|
||||||
protected static final Comparator ORIGIN_X_COMP =
|
protected static final Comparator<DirtyItem> ORIGIN_X_COMP = new OriginComparator(X_AXIS);
|
||||||
new OriginComparator(X_AXIS);
|
|
||||||
|
|
||||||
/** The comparator used to sort dirty items in ascending origin
|
/** The comparator used to sort dirty items in ascending origin
|
||||||
* y-coordinate order. */
|
* y-coordinate order. */
|
||||||
protected static final Comparator ORIGIN_Y_COMP =
|
protected static final Comparator<DirtyItem> ORIGIN_Y_COMP = new OriginComparator(Y_AXIS);
|
||||||
new OriginComparator(Y_AXIS);
|
|
||||||
|
|
||||||
/** The comparator used to sort dirty items in ascending "rear-depth"
|
/** The comparator used to sort dirty items in ascending "rear-depth"
|
||||||
* order. */
|
* order. */
|
||||||
protected static final Comparator REAR_DEPTH_COMP = new Comparator() {
|
protected static final Comparator<DirtyItem> REAR_DEPTH_COMP = new Comparator<DirtyItem>() {
|
||||||
public int compare (Object o1, Object o2) {
|
public int compare (DirtyItem o1, DirtyItem o2) {
|
||||||
return (((DirtyItem)o1).getRearDepth() -
|
return (o1.getRearDepth() - o2.getRearDepth());
|
||||||
((DirtyItem)o2).getRearDepth());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class ResolutionView extends JPanel
|
|||||||
protected void assignColor (SceneBlock block, Color color)
|
protected void assignColor (SceneBlock block, Color color)
|
||||||
{
|
{
|
||||||
IntTuple key = blockKey(block);
|
IntTuple key = blockKey(block);
|
||||||
BlockGlyph glyph = (BlockGlyph)_blocks.get(key);
|
BlockGlyph glyph = _blocks.get(key);
|
||||||
if (glyph == null) {
|
if (glyph == null) {
|
||||||
glyph = new BlockGlyph(_metrics, key.left, key.right);
|
glyph = new BlockGlyph(_metrics, key.left, key.right);
|
||||||
_blocks.put(key, glyph);
|
_blocks.put(key, glyph);
|
||||||
@@ -117,8 +117,8 @@ public class ResolutionView extends JPanel
|
|||||||
gfx.scale(0.25, 0.25);
|
gfx.scale(0.25, 0.25);
|
||||||
|
|
||||||
// draw our block glyphs
|
// draw our block glyphs
|
||||||
for (Iterator iter = _blocks.values().iterator(); iter.hasNext(); ) {
|
for (Iterator<BlockGlyph> iter = _blocks.values().iterator(); iter.hasNext(); ) {
|
||||||
((BlockGlyph)iter.next()).paint(gfx);
|
iter.next().paint(gfx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the view bounds
|
// draw the view bounds
|
||||||
@@ -158,7 +158,7 @@ public class ResolutionView extends JPanel
|
|||||||
|
|
||||||
protected MisoScenePanel _panel;
|
protected MisoScenePanel _panel;
|
||||||
protected MisoSceneMetrics _metrics;
|
protected MisoSceneMetrics _metrics;
|
||||||
protected HashMap _blocks = new HashMap();
|
protected HashMap<IntTuple, BlockGlyph> _blocks = new HashMap<IntTuple, BlockGlyph>();
|
||||||
|
|
||||||
protected static final int TILE_SIZE = 10;
|
protected static final int TILE_SIZE = 10;
|
||||||
protected static final int MAX_WIDTH = 30;
|
protected static final int MAX_WIDTH = 30;
|
||||||
|
|||||||
@@ -501,14 +501,13 @@ public class SceneBlock
|
|||||||
* Links this block to its neighbors; informs neighboring blocks of
|
* Links this block to its neighbors; informs neighboring blocks of
|
||||||
* object coverage.
|
* object coverage.
|
||||||
*/
|
*/
|
||||||
protected void update (IntMap blocks)
|
protected void update (IntMap<SceneBlock> blocks)
|
||||||
{
|
{
|
||||||
boolean recover = false;
|
boolean recover = false;
|
||||||
|
|
||||||
// link up to our neighbors
|
// link up to our neighbors
|
||||||
for (int ii = 0; ii < DX.length; ii++) {
|
for (int ii = 0; ii < DX.length; ii++) {
|
||||||
SceneBlock neigh = (SceneBlock)
|
SceneBlock neigh = blocks.get(neighborKey(DX[ii], DY[ii]));
|
||||||
blocks.get(neighborKey(DX[ii], DY[ii]));
|
|
||||||
if (neigh != _neighbors[ii]) {
|
if (neigh != _neighbors[ii]) {
|
||||||
_neighbors[ii] = neigh;
|
_neighbors[ii] = neigh;
|
||||||
// if we're linking up to a neighbor for the first time;
|
// if we're linking up to a neighbor for the first time;
|
||||||
@@ -546,14 +545,14 @@ public class SceneBlock
|
|||||||
/**
|
/**
|
||||||
* Sets the footprint of this object tile
|
* Sets the footprint of this object tile
|
||||||
*/
|
*/
|
||||||
protected void setCovered (IntMap blocks, SceneObject scobj)
|
protected void setCovered (IntMap<SceneBlock> blocks, SceneObject scobj)
|
||||||
{
|
{
|
||||||
int endx = scobj.info.x - scobj.tile.getBaseWidth() + 1;
|
int endx = scobj.info.x - scobj.tile.getBaseWidth() + 1;
|
||||||
int endy = scobj.info.y - scobj.tile.getBaseHeight() + 1;
|
int endy = scobj.info.y - scobj.tile.getBaseHeight() + 1;
|
||||||
|
|
||||||
for (int xx = scobj.info.x; xx >= endx; xx--) {
|
for (int xx = scobj.info.x; xx >= endx; xx--) {
|
||||||
for (int yy = scobj.info.y; yy >= endy; yy--) {
|
for (int yy = scobj.info.y; yy >= endy; yy--) {
|
||||||
SceneBlock block = (SceneBlock)blocks.get(blockKey(xx, yy));
|
SceneBlock block = blocks.get(blockKey(xx, yy));
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
block.setCovered(xx, yy);
|
block.setCovered(xx, yy);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class TilePath extends LineSegmentPath
|
|||||||
* coordinates.
|
* coordinates.
|
||||||
*/
|
*/
|
||||||
public TilePath (MisoSceneMetrics metrics, Sprite sprite,
|
public TilePath (MisoSceneMetrics metrics, Sprite sprite,
|
||||||
List tiles, int destx, int desty)
|
List<Point> tiles, int destx, int desty)
|
||||||
{
|
{
|
||||||
// constrain destination pixels to fine coordinates
|
// constrain destination pixels to fine coordinates
|
||||||
Point fpos = new Point();
|
Point fpos = new Point();
|
||||||
@@ -74,7 +74,7 @@ public class TilePath extends LineSegmentPath
|
|||||||
Point spos = new Point();
|
Point spos = new Point();
|
||||||
int size = tiles.size();
|
int size = tiles.size();
|
||||||
for (int ii = 1; ii < size - 1; ii++) {
|
for (int ii = 1; ii < size - 1; ii++) {
|
||||||
Point next = (Point)tiles.get(ii);
|
Point next = tiles.get(ii);
|
||||||
|
|
||||||
// determine the direction from previous to next node
|
// determine the direction from previous to next node
|
||||||
int dir = MisoUtil.getIsoDirection(prev.x, prev.y, next.x, next.y);
|
int dir = MisoUtil.getIsoDirection(prev.x, prev.y, next.x, next.y);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
package com.threerings.miso.data;
|
package com.threerings.miso.data;
|
||||||
|
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
import com.samskivert.util.ArrayUtil;
|
import com.samskivert.util.ArrayUtil;
|
||||||
import com.samskivert.util.IntListUtil;
|
import com.samskivert.util.IntListUtil;
|
||||||
@@ -259,8 +259,8 @@ public class SimpleMisoSceneModel extends MisoSceneModel
|
|||||||
* Populates the interesting and uninteresting parts of a miso scene
|
* Populates the interesting and uninteresting parts of a miso scene
|
||||||
* model given lists of {@link ObjectInfo} records for each.
|
* model given lists of {@link ObjectInfo} records for each.
|
||||||
*/
|
*/
|
||||||
public static void populateObjects (SimpleMisoSceneModel model,
|
public static void populateObjects (
|
||||||
ArrayList ilist, ArrayList ulist)
|
SimpleMisoSceneModel model, List<ObjectInfo> ilist, List<ObjectInfo> ulist)
|
||||||
{
|
{
|
||||||
// set up the uninteresting arrays
|
// set up the uninteresting arrays
|
||||||
int ucount = ulist.size();
|
int ucount = ulist.size();
|
||||||
@@ -268,7 +268,7 @@ public class SimpleMisoSceneModel extends MisoSceneModel
|
|||||||
model.objectXs = new short[ucount];
|
model.objectXs = new short[ucount];
|
||||||
model.objectYs = new short[ucount];
|
model.objectYs = new short[ucount];
|
||||||
for (int ii = 0; ii < ucount; ii++) {
|
for (int ii = 0; ii < ucount; ii++) {
|
||||||
ObjectInfo info = (ObjectInfo)ulist.get(ii);
|
ObjectInfo info = ulist.get(ii);
|
||||||
model.objectTileIds[ii] = info.tileId;
|
model.objectTileIds[ii] = info.tileId;
|
||||||
model.objectXs[ii] = (short)info.x;
|
model.objectXs[ii] = (short)info.x;
|
||||||
model.objectYs[ii] = (short)info.y;
|
model.objectYs[ii] = (short)info.y;
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ public class SparseMisoSceneModel extends MisoSceneModel
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getAllObjects (ArrayList list) {
|
public void getAllObjects (ArrayList<ObjectInfo> list) {
|
||||||
for (ObjectInfo info : objectInfo) {
|
for (ObjectInfo info : objectInfo) {
|
||||||
list.add(info);
|
list.add(info);
|
||||||
}
|
}
|
||||||
@@ -276,10 +276,10 @@ public class SparseMisoSceneModel extends MisoSceneModel
|
|||||||
* Adds all interesting {@link ObjectInfo} records in this scene to
|
* Adds all interesting {@link ObjectInfo} records in this scene to
|
||||||
* the supplied list.
|
* the supplied list.
|
||||||
*/
|
*/
|
||||||
public void getInterestingObjects (ArrayList list)
|
public void getInterestingObjects (ArrayList<ObjectInfo> list)
|
||||||
{
|
{
|
||||||
for (Iterator iter = getSections(); iter.hasNext(); ) {
|
for (Iterator<Section> iter = getSections(); iter.hasNext(); ) {
|
||||||
Section sect = (Section)iter.next();
|
Section sect = iter.next();
|
||||||
for (int oo = 0; oo < sect.objectInfo.length; oo++) {
|
for (int oo = 0; oo < sect.objectInfo.length; oo++) {
|
||||||
list.add(sect.objectInfo[oo]);
|
list.add(sect.objectInfo[oo]);
|
||||||
}
|
}
|
||||||
@@ -289,12 +289,10 @@ public class SparseMisoSceneModel extends MisoSceneModel
|
|||||||
/**
|
/**
|
||||||
* Adds all {@link ObjectInfo} records in this scene to the supplied list.
|
* Adds all {@link ObjectInfo} records in this scene to the supplied list.
|
||||||
*/
|
*/
|
||||||
public void getAllObjects (ArrayList list)
|
public void getAllObjects (ArrayList<ObjectInfo> list)
|
||||||
{
|
{
|
||||||
for (Iterator iter = getSections(); iter.hasNext(); ) {
|
for (Iterator<Section> iter = getSections(); iter.hasNext(); ) {
|
||||||
Section sect = (Section)iter.next();
|
iter.next().getAllObjects(list);
|
||||||
|
|
||||||
sect.getAllObjects(list);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,8 +312,8 @@ public class SparseMisoSceneModel extends MisoSceneModel
|
|||||||
*/
|
*/
|
||||||
public void visitObjects (ObjectVisitor visitor, boolean interestingOnly)
|
public void visitObjects (ObjectVisitor visitor, boolean interestingOnly)
|
||||||
{
|
{
|
||||||
for (Iterator iter = getSections(); iter.hasNext(); ) {
|
for (Iterator<Section> iter = getSections(); iter.hasNext(); ) {
|
||||||
Section sect = (Section)iter.next();
|
Section sect = iter.next();
|
||||||
for (int oo = 0; oo < sect.objectInfo.length; oo++) {
|
for (int oo = 0; oo < sect.objectInfo.length; oo++) {
|
||||||
ObjectInfo oinfo = sect.objectInfo[oo];
|
ObjectInfo oinfo = sect.objectInfo[oo];
|
||||||
visitor.visit(oinfo);
|
visitor.visit(oinfo);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class FringeConfiguration implements Serializable
|
|||||||
public int priority;
|
public int priority;
|
||||||
|
|
||||||
/** A list of the possible tilesets that can be used for fringing. */
|
/** A list of the possible tilesets that can be used for fringing. */
|
||||||
public ArrayList tilesets = new ArrayList();
|
public ArrayList<FringeTileSetRecord> tilesets = new ArrayList<FringeTileSetRecord>();
|
||||||
|
|
||||||
/** Used when parsing the tilesets definitions. */
|
/** Used when parsing the tilesets definitions. */
|
||||||
public void addTileset (FringeTileSetRecord record)
|
public void addTileset (FringeTileSetRecord record)
|
||||||
@@ -117,7 +117,7 @@ public class FringeConfiguration implements Serializable
|
|||||||
*/
|
*/
|
||||||
public int fringesOn (int first, int second)
|
public int fringesOn (int first, int second)
|
||||||
{
|
{
|
||||||
FringeRecord f1 = (FringeRecord) _frecs.get(first);
|
FringeRecord f1 = _frecs.get(first);
|
||||||
|
|
||||||
// we better have a fringe record for the first
|
// we better have a fringe record for the first
|
||||||
if (null != f1) {
|
if (null != f1) {
|
||||||
@@ -125,7 +125,7 @@ public class FringeConfiguration implements Serializable
|
|||||||
// it had better have some tilesets defined
|
// it had better have some tilesets defined
|
||||||
if (f1.tilesets.size() > 0) {
|
if (f1.tilesets.size() > 0) {
|
||||||
|
|
||||||
FringeRecord f2 = (FringeRecord) _frecs.get(second);
|
FringeRecord f2 = _frecs.get(second);
|
||||||
|
|
||||||
// and we only fringe if second doesn't exist or has a lower
|
// and we only fringe if second doesn't exist or has a lower
|
||||||
// priority
|
// priority
|
||||||
@@ -144,13 +144,13 @@ public class FringeConfiguration implements Serializable
|
|||||||
*/
|
*/
|
||||||
public FringeTileSetRecord getFringe (int baseset, int hashValue)
|
public FringeTileSetRecord getFringe (int baseset, int hashValue)
|
||||||
{
|
{
|
||||||
FringeRecord f = (FringeRecord) _frecs.get(baseset);
|
FringeRecord f = _frecs.get(baseset);
|
||||||
return (FringeTileSetRecord) f.tilesets.get(
|
return f.tilesets.get(
|
||||||
hashValue % f.tilesets.size());
|
hashValue % f.tilesets.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The mapping from base tileset id to fringerecord. */
|
/** The mapping from base tileset id to fringerecord. */
|
||||||
protected HashIntMap _frecs = new HashIntMap();
|
protected HashIntMap<FringeRecord> _frecs = new HashIntMap<FringeRecord>();
|
||||||
|
|
||||||
/** Increase this value when object's serialized state is impacted by
|
/** Increase this value when object's serialized state is impacted by
|
||||||
* a class change (modification of fields, inheritance). */
|
* a class change (modification of fields, inheritance). */
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.apache.commons.digester.Digester;
|
|||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
import com.samskivert.xml.CallMethodSpecialRule;
|
import com.samskivert.xml.CallMethodSpecialRule;
|
||||||
|
|
||||||
|
import com.threerings.media.tile.TileSet;
|
||||||
import com.threerings.media.tile.tools.xml.SwissArmyTileSetRuleSet;
|
import com.threerings.media.tile.tools.xml.SwissArmyTileSetRuleSet;
|
||||||
|
|
||||||
import com.threerings.miso.tile.BaseTileSet;
|
import com.threerings.miso.tile.BaseTileSet;
|
||||||
@@ -77,7 +78,7 @@ public class BaseTileSetRuleSet extends SwissArmyTileSetRuleSet
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class getTileSetClass ()
|
protected Class<? extends TileSet> getTileSetClass ()
|
||||||
{
|
{
|
||||||
return BaseTileSet.class;
|
return BaseTileSet.class;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,14 +84,15 @@ public class SimpleMisoSceneRuleSet implements NestableRuleSet
|
|||||||
public void parseAndSet (String bodyText, Object target)
|
public void parseAndSet (String bodyText, Object target)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
ArrayList ilist = (ArrayList)target;
|
@SuppressWarnings("unchecked") ArrayList<ObjectInfo> ilist =
|
||||||
ArrayList ulist = new ArrayList();
|
(ArrayList<ObjectInfo>)target;
|
||||||
|
ArrayList<ObjectInfo> ulist = new ArrayList<ObjectInfo>();
|
||||||
SimpleMisoSceneModel model = (SimpleMisoSceneModel)
|
SimpleMisoSceneModel model = (SimpleMisoSceneModel)
|
||||||
digester.peek(1);
|
digester.peek(1);
|
||||||
|
|
||||||
// filter interesting and uninteresting into two lists
|
// filter interesting and uninteresting into two lists
|
||||||
for (int ii = 0; ii < ilist.size(); ii++) {
|
for (int ii = 0; ii < ilist.size(); ii++) {
|
||||||
ObjectInfo info = (ObjectInfo)ilist.get(ii);
|
ObjectInfo info = ilist.get(ii);
|
||||||
if (!info.isInteresting()) {
|
if (!info.isInteresting()) {
|
||||||
ilist.remove(ii--);
|
ilist.remove(ii--);
|
||||||
ulist.add(info);
|
ulist.add(info);
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ public class ObjectSet
|
|||||||
|
|
||||||
/** We simply sort the objects in order of their hash code. We don't
|
/** We simply sort the objects in order of their hash code. We don't
|
||||||
* care about their order, it exists only to support binary search. */
|
* care about their order, it exists only to support binary search. */
|
||||||
protected static final Comparator INFO_COMP = new Comparator() {
|
protected static final Comparator<Object> INFO_COMP = new Comparator<Object>() {
|
||||||
public int compare (Object o1, Object o2) {
|
public int compare (Object o1, Object o2) {
|
||||||
ObjectInfo do1 = (ObjectInfo)o1;
|
ObjectInfo do1 = (ObjectInfo)o1;
|
||||||
ObjectInfo do2 = (ObjectInfo)o2;
|
ObjectInfo do2 = (ObjectInfo)o2;
|
||||||
|
|||||||
@@ -207,8 +207,8 @@ public class ResourceManager
|
|||||||
{
|
{
|
||||||
// set up a URL handler so that things can be loaded via urls with the 'resource' protocol
|
// set up a URL handler so that things can be loaded via urls with the 'resource' protocol
|
||||||
try {
|
try {
|
||||||
AccessController.doPrivileged(new PrivilegedAction() {
|
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||||
public Object run () {
|
public Void run () {
|
||||||
Handler.registerHandler(ResourceManager.this);
|
Handler.registerHandler(ResourceManager.this);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -272,7 +272,7 @@ public class ResourceManager
|
|||||||
|
|
||||||
// resolve the configured resource sets
|
// resolve the configured resource sets
|
||||||
List<ResourceBundle> dlist = new ArrayList<ResourceBundle>();
|
List<ResourceBundle> dlist = new ArrayList<ResourceBundle>();
|
||||||
Enumeration names = config.propertyNames();
|
Enumeration<?> names = config.propertyNames();
|
||||||
while (names.hasMoreElements()) {
|
while (names.hasMoreElements()) {
|
||||||
String key = (String)names.nextElement();
|
String key = (String)names.nextElement();
|
||||||
if (!key.startsWith(RESOURCE_SET_PREFIX)) {
|
if (!key.startsWith(RESOURCE_SET_PREFIX)) {
|
||||||
@@ -421,7 +421,7 @@ public class ResourceManager
|
|||||||
* already resolved, or it may be notified on a brand new thread if the bundle requires
|
* already resolved, or it may be notified on a brand new thread if the bundle requires
|
||||||
* unpacking.
|
* unpacking.
|
||||||
*/
|
*/
|
||||||
public void resolveBundle (String path, final ResultListener listener)
|
public void resolveBundle (String path, final ResultListener<FileResourceBundle> listener)
|
||||||
{
|
{
|
||||||
File bfile = getResourceFile(path);
|
File bfile = getResourceFile(path);
|
||||||
if (bfile == null) {
|
if (bfile == null) {
|
||||||
@@ -442,7 +442,7 @@ public class ResourceManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start a thread to unpack our bundles
|
// start a thread to unpack our bundles
|
||||||
ArrayList list = new ArrayList();
|
ArrayList<ResourceBundle> list = new ArrayList<ResourceBundle>();
|
||||||
list.add(bundle);
|
list.add(bundle);
|
||||||
Unpacker unpack = new Unpacker(list, new InitObserver() {
|
Unpacker unpack = new Unpacker(list, new InitObserver() {
|
||||||
public void progress (int percent, long remaining) {
|
public void progress (int percent, long remaining) {
|
||||||
@@ -513,8 +513,8 @@ public class ResourceManager
|
|||||||
if (_localePrefix != null) {
|
if (_localePrefix != null) {
|
||||||
final String rpath = PathUtil.appendPath(
|
final String rpath = PathUtil.appendPath(
|
||||||
_rootPath, PathUtil.appendPath(_localePrefix, path));
|
_rootPath, PathUtil.appendPath(_localePrefix, path));
|
||||||
in = (InputStream)AccessController.doPrivileged(new PrivilegedAction() {
|
in = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
|
||||||
public Object run () {
|
public InputStream run () {
|
||||||
return _loader.getResourceAsStream(rpath);
|
return _loader.getResourceAsStream(rpath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -525,8 +525,8 @@ public class ResourceManager
|
|||||||
|
|
||||||
// if we didn't find that, try locale-neutral
|
// if we didn't find that, try locale-neutral
|
||||||
final String rpath = PathUtil.appendPath(_rootPath, path);
|
final String rpath = PathUtil.appendPath(_rootPath, path);
|
||||||
in = (InputStream)AccessController.doPrivileged(new PrivilegedAction() {
|
in = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
|
||||||
public Object run () {
|
public InputStream run () {
|
||||||
return _loader.getResourceAsStream(rpath);
|
return _loader.getResourceAsStream(rpath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -578,8 +578,8 @@ public class ResourceManager
|
|||||||
if (_localePrefix != null) {
|
if (_localePrefix != null) {
|
||||||
final String rpath = PathUtil.appendPath(
|
final String rpath = PathUtil.appendPath(
|
||||||
_rootPath, PathUtil.appendPath(_localePrefix, path));
|
_rootPath, PathUtil.appendPath(_localePrefix, path));
|
||||||
InputStream in = (InputStream)AccessController.doPrivileged(new PrivilegedAction() {
|
InputStream in = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
|
||||||
public Object run () {
|
public InputStream run () {
|
||||||
return _loader.getResourceAsStream(rpath);
|
return _loader.getResourceAsStream(rpath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -590,8 +590,8 @@ public class ResourceManager
|
|||||||
|
|
||||||
// if we still didn't find anything, try the classloader
|
// if we still didn't find anything, try the classloader
|
||||||
final String rpath = PathUtil.appendPath(_rootPath, path);
|
final String rpath = PathUtil.appendPath(_rootPath, path);
|
||||||
InputStream in = (InputStream)AccessController.doPrivileged(new PrivilegedAction() {
|
InputStream in = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
|
||||||
public Object run () {
|
public InputStream run () {
|
||||||
return _loader.getResourceAsStream(rpath);
|
return _loader.getResourceAsStream(rpath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class CompiledConfigTask extends Task
|
|||||||
// instantiate and sanity check the parser class
|
// instantiate and sanity check the parser class
|
||||||
Object pobj = null;
|
Object pobj = null;
|
||||||
try {
|
try {
|
||||||
Class pclass = Class.forName(_parser);
|
Class<?> pclass = Class.forName(_parser);
|
||||||
pobj = pclass.newInstance();
|
pobj = pclass.newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BuildException("Error instantiating config parser", e);
|
throw new BuildException("Error instantiating config parser", e);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class BrowserUtil
|
|||||||
* @param listener a listener to be notified if we failed to launch the
|
* @param listener a listener to be notified if we failed to launch the
|
||||||
* browser. <em>Note:</em> it will not be notified of success.
|
* browser. <em>Note:</em> it will not be notified of success.
|
||||||
*/
|
*/
|
||||||
public static void browseURL (URL url, ResultListener listener)
|
public static void browseURL (URL url, ResultListener<Void> listener)
|
||||||
{
|
{
|
||||||
browseURL(url, listener, "firefox");
|
browseURL(url, listener, "firefox");
|
||||||
}
|
}
|
||||||
@@ -56,8 +56,7 @@ public class BrowserUtil
|
|||||||
* @param genagent the path to the browser to execute on non-Windows,
|
* @param genagent the path to the browser to execute on non-Windows,
|
||||||
* non-MacOS.
|
* non-MacOS.
|
||||||
*/
|
*/
|
||||||
public static void browseURL (
|
public static void browseURL (URL url, ResultListener<Void> listener, String genagent)
|
||||||
URL url, ResultListener listener, String genagent)
|
|
||||||
{
|
{
|
||||||
String[] cmd;
|
String[] cmd;
|
||||||
if (RunAnywhere.isWindows()) {
|
if (RunAnywhere.isWindows()) {
|
||||||
@@ -98,7 +97,7 @@ public class BrowserUtil
|
|||||||
|
|
||||||
protected static class BrowserTracker extends Thread
|
protected static class BrowserTracker extends Thread
|
||||||
{
|
{
|
||||||
public BrowserTracker (Process process, URL url, ResultListener rl) {
|
public BrowserTracker (Process process, URL url, ResultListener<Void> rl) {
|
||||||
super("BrowserLaunchWaiter");
|
super("BrowserLaunchWaiter");
|
||||||
setDaemon(true);
|
setDaemon(true);
|
||||||
_process = process;
|
_process = process;
|
||||||
@@ -142,6 +141,6 @@ public class BrowserUtil
|
|||||||
|
|
||||||
protected Process _process;
|
protected Process _process;
|
||||||
protected URL _url;
|
protected URL _url;
|
||||||
protected ResultListener _listener;
|
protected ResultListener<Void> _listener;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -804,7 +804,7 @@ public class KeyboardManager
|
|||||||
protected KeyTranslator _xlate;
|
protected KeyTranslator _xlate;
|
||||||
|
|
||||||
/** The list of key observers. */
|
/** The list of key observers. */
|
||||||
protected ObserverList _observers = new ObserverList(ObserverList.FAST_UNSAFE_NOTIFY);
|
protected ObserverList<KeyObserver> _observers = ObserverList.newFastUnsafe();
|
||||||
|
|
||||||
/** The operation used to notify observers of actual key events. */
|
/** The operation used to notify observers of actual key events. */
|
||||||
protected KeyObserverOp _keyOp = new KeyObserverOp();
|
protected KeyObserverOp _keyOp = new KeyObserverOp();
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ package com.threerings.cast.bundle;
|
|||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import com.threerings.cast.ComponentClass;
|
||||||
import com.threerings.media.image.ClientImageManager;
|
import com.threerings.media.image.ClientImageManager;
|
||||||
import com.threerings.resource.ResourceManager;
|
import com.threerings.resource.ResourceManager;
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ public class BundledComponentRepositoryTest extends TestCase
|
|||||||
// System.out.println("Action sets: " + StringUtil.toString(
|
// System.out.println("Action sets: " + StringUtil.toString(
|
||||||
// repo._actionSets.values().iterator()));
|
// repo._actionSets.values().iterator()));
|
||||||
|
|
||||||
Iterator iter = repo.enumerateComponentClasses();
|
Iterator<ComponentClass> iter = repo.enumerateComponentClasses();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
// ComponentClass cclass = (ComponentClass)
|
// ComponentClass cclass = (ComponentClass)
|
||||||
iter.next();
|
iter.next();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.awt.Component;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import com.threerings.media.image.ClientImageManager;
|
import com.threerings.media.image.ClientImageManager;
|
||||||
|
import com.threerings.media.tile.TileSet;
|
||||||
import com.threerings.resource.ResourceManager;
|
import com.threerings.resource.ResourceManager;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
@@ -46,7 +47,7 @@ public class BundledTileSetRepositoryTest extends TestCase
|
|||||||
null, "config/resource/manager.properties", null);
|
null, "config/resource/manager.properties", null);
|
||||||
BundledTileSetRepository repo = new BundledTileSetRepository(
|
BundledTileSetRepository repo = new BundledTileSetRepository(
|
||||||
rmgr, new ClientImageManager(rmgr, (Component)null), "tilesets");
|
rmgr, new ClientImageManager(rmgr, (Component)null), "tilesets");
|
||||||
Iterator sets = repo.enumerateTileSets();
|
Iterator<TileSet> sets = repo.enumerateTileSets();
|
||||||
while (sets.hasNext()) {
|
while (sets.hasNext()) {
|
||||||
sets.next();
|
sets.next();
|
||||||
// System.out.println(sets.next());
|
// System.out.println(sets.next());
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import java.io.IOException;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.threerings.media.tile.TileSet;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
@@ -38,7 +40,7 @@ public class XMLTileSetParserTest extends TestCase
|
|||||||
@Override
|
@Override
|
||||||
public void runTest ()
|
public void runTest ()
|
||||||
{
|
{
|
||||||
HashMap sets = new HashMap();
|
HashMap<String, TileSet> sets = new HashMap<String, TileSet>();
|
||||||
|
|
||||||
XMLTileSetParser parser = new XMLTileSetParser();
|
XMLTileSetParser parser = new XMLTileSetParser();
|
||||||
// add some rulesets
|
// add some rulesets
|
||||||
@@ -51,7 +53,7 @@ public class XMLTileSetParserTest extends TestCase
|
|||||||
parser.loadTileSets(TILESET_PATH, sets);
|
parser.loadTileSets(TILESET_PATH, sets);
|
||||||
|
|
||||||
// print them out
|
// print them out
|
||||||
Iterator iter = sets.values().iterator();
|
Iterator<TileSet> iter = sets.values().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
iter.next();
|
iter.next();
|
||||||
// System.out.println(iter.next());
|
// System.out.println(iter.next());
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ public class ScrollingScene extends MisoSceneModel
|
|||||||
{
|
{
|
||||||
// locate the water tileset
|
// locate the water tileset
|
||||||
TileSetRepository tsrepo = ctx.getTileManager().getTileSetRepository();
|
TileSetRepository tsrepo = ctx.getTileManager().getTileSetRepository();
|
||||||
Iterator iter = tsrepo.enumerateTileSets();
|
Iterator<TileSet> iter = tsrepo.enumerateTileSets();
|
||||||
String tsname = null;
|
String tsname = null;
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
TileSet tset = (TileSet)iter.next();
|
TileSet tset = iter.next();
|
||||||
// yay for built-in regex support!
|
// yay for built-in regex support!
|
||||||
if (tset.getName().matches(".*[Ww]ater.*") &&
|
if (tset.getName().matches(".*[Ww]ater.*") &&
|
||||||
tset instanceof BaseTileSet) {
|
tset instanceof BaseTileSet) {
|
||||||
|
|||||||
Reference in New Issue
Block a user