Little bit of type safety, little bit of redundant cast removal.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@548 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Dave Hoover
2008-01-17 01:25:18 +00:00
parent b542ed3afc
commit 16b210affe
6 changed files with 21 additions and 22 deletions
@@ -242,7 +242,7 @@ public class DictionaryManager
for (Character key : keys) for (Character key : keys)
{ {
keycount--; keycount--;
_letters[keycount] = (char) key; _letters[keycount] = key;
_counts[keycount] = ((float) letters.getCount(key)) / total; // normalize _counts[keycount] = ((float) letters.getCount(key)) / total; // normalize
} }
} }
@@ -183,11 +183,11 @@ public class TurnDisplay extends JPanel
{ {
String name = event.getName(); String name = event.getName();
if (name.equals(_turnObj.getTurnHolderFieldName())) { if (name.equals(_turnObj.getTurnHolderFieldName())) {
JLabel oldLabel = (JLabel) _labels.get((Name) event.getOldValue()); JLabel oldLabel = _labels.get(event.getOldValue());
if (oldLabel != null) { if (oldLabel != null) {
oldLabel.setIcon(null); oldLabel.setIcon(null);
} }
JLabel newLabel = (JLabel) _labels.get((Name) event.getValue()); JLabel newLabel = _labels.get(event.getValue());
if (newLabel != null) { if (newLabel != null) {
newLabel.setIcon(_turnIcon); newLabel.setIcon(_turnIcon);
} }
@@ -213,7 +213,7 @@ public class TurnDisplay extends JPanel
protected TurnGameObject _turnObj; protected TurnGameObject _turnObj;
/** A mapping of the labels currently associated with each player. */ /** A mapping of the labels currently associated with each player. */
protected HashMap _labels = new HashMap(); protected HashMap<Name,JLabel> _labels = new HashMap<Name,JLabel>();
/** The game-specified player icons. */ /** The game-specified player icons. */
protected Icon[] _playerIcons; protected Icon[] _playerIcons;
@@ -116,7 +116,7 @@ public class StageLocation extends SimpleStreamableObject
public Object clone () public Object clone ()
{ {
try { try {
return (StageLocation)super.clone(); return super.clone();
} catch (CloneNotSupportedException cnse) { } catch (CloneNotSupportedException cnse) {
throw new RuntimeException(cnse); throw new RuntimeException(cnse);
} }
@@ -77,6 +77,6 @@ public class StageMisoSceneModel extends SparseMisoSceneModel
*/ */
public Section getSection (int key) public Section getSection (int key)
{ {
return (Section)_sections.get(key); return _sections.get(key);
} }
} }
@@ -167,7 +167,7 @@ public class PlacementConstraints
} }
ObjectData[] data = new ObjectData[info.length]; ObjectData[] data = new ObjectData[info.length];
for (int ii = 0; ii < info.length; ii++) { for (int ii = 0; ii < info.length; ii++) {
data[ii] = (ObjectData)_objectData.get(info[ii]); data[ii] = _objectData.get(info[ii]);
if (data[ii] == null) { if (data[ii] == null) {
Log.warning("Couldn't match object info up to data [info=" + Log.warning("Couldn't match object info up to data [info=" +
info[ii] + "]."); info[ii] + "].");
@@ -570,7 +570,7 @@ public class PlacementConstraints
/** For all objects in the scene, maps {@link ObjectInfo}s to /** For all objects in the scene, maps {@link ObjectInfo}s to
* {@link ObjectData}s. */ * {@link ObjectData}s. */
protected HashMap _objectData = new HashMap(); protected HashMap<ObjectInfo,ObjectData> _objectData = new HashMap<ObjectInfo,ObjectData>();
/** One rectangle we'll re-use for all constraints ops. */ /** One rectangle we'll re-use for all constraints ops. */
protected static final Rectangle _constrainRect = new Rectangle(); protected static final Rectangle _constrainRect = new Rectangle();
@@ -111,14 +111,14 @@ public class SceneRegistry
} }
/** /**
* Fetches the scene manager assosciated with the specified scene. * Fetches the scene manager associated with the specified scene.
* *
* @return the scene manager for the specified scene or null if no scene manager is loaded for * @return the scene manager for the specified scene or null if no scene manager is loaded for
* that scene. * that scene.
*/ */
public SceneManager getSceneManager (int sceneId) public SceneManager getSceneManager (int sceneId)
{ {
return (SceneManager)_scenemgrs.get(sceneId); return _scenemgrs.get(sceneId);
} }
/** /**
@@ -151,7 +151,7 @@ public class SceneRegistry
*/ */
public void resolveScene (int sceneId, ResolutionListener target) public void resolveScene (int sceneId, ResolutionListener target)
{ {
SceneManager mgr = (SceneManager)_scenemgrs.get(sceneId); SceneManager mgr = _scenemgrs.get(sceneId);
if (mgr != null) { if (mgr != null) {
// if the scene is already resolved, we're ready to roll // if the scene is already resolved, we're ready to roll
target.sceneWasResolved(mgr); target.sceneWasResolved(mgr);
@@ -164,7 +164,7 @@ public class SceneRegistry
// otherwise we've got to resolve the scene and call them back later; we can manipulate the // otherwise we've got to resolve the scene and call them back later; we can manipulate the
// penders table with impunity here because we only do so on the dobjmgr thread // penders table with impunity here because we only do so on the dobjmgr thread
ArrayList penders = (ArrayList)_penders.get(sceneId); ArrayList<ResolutionListener> penders = _penders.get(sceneId);
// if we're already in the process of resolving this scene, just add these guys to the list // if we're already in the process of resolving this scene, just add these guys to the list
// to be notified when it finally is resolved // to be notified when it finally is resolved
@@ -173,7 +173,7 @@ public class SceneRegistry
} else { } else {
// otherwise we've got to initiate the resolution process, create the penders list // otherwise we've got to initiate the resolution process, create the penders list
_penders.put(sceneId, penders = new ArrayList()); _penders.put(sceneId, penders = new ArrayList<ResolutionListener>());
penders.add(target); penders.add(target);
// i don't like cluttering up method declarations with final keywords... // i don't like cluttering up method declarations with final keywords...
@@ -272,7 +272,7 @@ public class SceneRegistry
} }
}); });
// when the scene manager completes its startup procedings, it will call back to the // when the scene manager completes its startup proceedings, it will call back to the
// scene registry and let us know that we can turn the penders loose // scene registry and let us know that we can turn the penders loose
} catch (Exception e) { } catch (Exception e) {
@@ -293,10 +293,9 @@ public class SceneRegistry
} }
// alas things didn't work out, notify our penders // alas things didn't work out, notify our penders
ArrayList penders = (ArrayList)_penders.remove(sceneId); ArrayList<ResolutionListener> penders = _penders.remove(sceneId);
if (penders != null) { if (penders != null) {
for (int i = 0; i < penders.size(); i++) { for (ResolutionListener rl : penders) {
ResolutionListener rl = (ResolutionListener)penders.get(i);
try { try {
rl.sceneFailedToResolve(sceneId, cause); rl.sceneFailedToResolve(sceneId, cause);
} catch (Exception e) { } catch (Exception e) {
@@ -322,10 +321,9 @@ public class SceneRegistry
} }
// now notify any penders // now notify any penders
ArrayList penders = (ArrayList)_penders.remove(sceneId); ArrayList<ResolutionListener> penders = _penders.remove(sceneId);
if (penders != null) { if (penders != null) {
for (int i = 0; i < penders.size(); i++) { for (ResolutionListener rl : penders) {
ResolutionListener rl = (ResolutionListener)penders.get(i);
try { try {
rl.sceneWasResolved(scmgr); rl.sceneWasResolved(scmgr);
} catch (Exception e) { } catch (Exception e) {
@@ -361,8 +359,9 @@ public class SceneRegistry
protected SceneFactory _scfact; protected SceneFactory _scfact;
/** A mapping from scene ids to scene managers. */ /** A mapping from scene ids to scene managers. */
protected HashIntMap _scenemgrs = new HashIntMap(); protected HashIntMap<SceneManager> _scenemgrs = new HashIntMap<SceneManager>();
/** The table of pending resolution listeners. */ /** The table of pending resolution listeners. */
protected HashIntMap _penders = new HashIntMap(); protected HashIntMap<ArrayList<ResolutionListener>> _penders =
new HashIntMap<ArrayList<ResolutionListener>>();
} }