From bb0d6c5ba40f5649db4f5745e9a0b818ba452d95 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 1 Aug 2008 14:40:54 +0000 Subject: [PATCH] More code hygiene. Need to do some fiddling to make dispatchers not generate generics warnings when calling methods with generic types. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@698 c613c5cb-e716-0410-b11b-feb51c14d237 --- .../micasa/client/OccupantList.java | 5 +- .../micasa/lobby/LobbyMarshaller.java | 8 +-- .../micasa/lobby/LobbyRegistry.java | 2 +- .../micasa/lobby/LobbySelector.java | 29 ++++++---- .../threerings/micasa/lobby/LobbyService.java | 2 +- .../micasa/lobby/table/TableListView.java | 6 +- .../micasa/lobby/table/TableLobbyObject.java | 12 ++-- .../micasa/simulator/client/SimulatorApp.java | 4 +- .../micasa/simulator/server/SimpleServer.java | 2 +- .../simulator/server/SimulatorManager.java | 3 +- .../simulator/server/SimulatorServer.java | 2 +- .../parlor/card/client/CardPanel.java | 22 ++++---- .../com/threerings/parlor/card/data/Card.java | 8 +-- .../com/threerings/parlor/card/data/Deck.java | 4 +- .../trick/data/TrickCardGameMarshaller.java | 4 +- .../server/TrickCardGameManagerDelegate.java | 5 +- .../parlor/client/ParlorDirector.java | 12 ++-- .../parlor/client/TableDirector.java | 14 ++--- .../parlor/data/ParlorMarshaller.java | 2 +- .../com/threerings/parlor/data/Table.java | 2 +- .../parlor/tourney/data/EntryFee.java | 2 +- .../parlor/tourney/data/Participant.java | 7 +-- .../parlor/tourney/server/TourneyManager.java | 10 ++-- .../tourney/server/TourniesManager.java | 4 +- .../threerings/parlor/util/RobotPlayer.java | 7 ++- .../puzzle/client/PuzzleBoardView.java | 5 +- .../puzzle/client/PuzzleController.java | 8 +-- .../puzzle/drop/client/DropBoardView.java | 4 +- .../puzzle/drop/client/DropSprite.java | 2 +- .../puzzle/drop/util/PieceDestroyer.java | 9 +-- .../com/threerings/puzzle/util/PointSet.java | 14 ++--- .../stage/client/SceneColorizer.java | 12 ++-- .../stage/client/StageSceneController.java | 8 ++- .../stage/client/StageScenePanel.java | 5 +- .../stage/server/StageSceneManager.java | 55 +++++++++---------- .../stage/tools/editor/EditorApp.java | 4 +- .../stage/tools/editor/EditorModel.java | 8 ++- .../stage/tools/editor/EditorScenePanel.java | 20 +++---- .../tools/editor/EditorToolBarPanel.java | 25 ++++++--- .../tools/editor/ObjectEditorDialog.java | 6 +- .../stage/tools/editor/PortalTool.java | 3 +- .../stage/tools/editor/SceneInfoPanel.java | 8 +-- .../stage/tools/editor/TestTileLoader.java | 19 ++++--- .../stage/tools/editor/TileInfoPanel.java | 53 +++++++++--------- .../tools/editor/util/EditorContext.java | 2 +- .../stage/tools/xml/StageSceneRuleSet.java | 3 +- .../stage/util/PlacementConstraints.java | 32 ++++++----- .../threerings/stage/util/StageSceneUtil.java | 15 ++--- .../whirled/client/SceneDirector.java | 7 ++- .../whirled/data/SceneMarshaller.java | 2 +- .../server/persist/SceneUpdateMarshaller.java | 16 +++--- .../spot/client/SpotSceneDirector.java | 9 +-- .../threerings/whirled/spot/data/Cluster.java | 2 +- .../whirled/spot/data/SceneLocation.java | 2 +- .../whirled/spot/data/SpotScene.java | 2 +- .../whirled/spot/server/SpotSceneManager.java | 8 +-- .../spot/tools/xml/SpotSceneRuleSet.java | 4 +- .../spot/tools/xml/SpotSceneWriter.java | 2 +- .../whirled/tools/xml/SceneRuleSet.java | 2 +- .../whirled/tools/xml/SceneWriter.java | 8 +-- .../whirled/zone/client/ZoneDirector.java | 2 +- .../whirled/zone/data/ZoneMarshaller.java | 2 +- 62 files changed, 292 insertions(+), 274 deletions(-) diff --git a/src/java/com/threerings/micasa/client/OccupantList.java b/src/java/com/threerings/micasa/client/OccupantList.java index 55d654ab..80b816eb 100644 --- a/src/java/com/threerings/micasa/client/OccupantList.java +++ b/src/java/com/threerings/micasa/client/OccupantList.java @@ -21,7 +21,6 @@ package com.threerings.micasa.client; -import java.util.Iterator; import javax.swing.DefaultListModel; import javax.swing.JList; @@ -59,9 +58,7 @@ public class OccupantList public void willEnterPlace (PlaceObject plobj) { // add all of the occupants of the place to our list - Iterator users = plobj.occupantInfo.iterator(); - while (users.hasNext()) { - OccupantInfo info = (OccupantInfo)users.next(); + for (OccupantInfo info : plobj.occupantInfo) { _model.addElement(info.username); } } diff --git a/src/java/com/threerings/micasa/lobby/LobbyMarshaller.java b/src/java/com/threerings/micasa/lobby/LobbyMarshaller.java index a3283340..33c0532c 100644 --- a/src/java/com/threerings/micasa/lobby/LobbyMarshaller.java +++ b/src/java/com/threerings/micasa/lobby/LobbyMarshaller.java @@ -37,7 +37,7 @@ public class LobbyMarshaller extends InvocationMarshaller implements LobbyService { /** - * Marshalls results to implementations of {@link CategoriesListener}. + * Marshalls results to implementations of {@link LobbyService.CategoriesListener}. */ public static class CategoriesMarshaller extends ListenerMarshaller implements CategoriesListener @@ -72,7 +72,7 @@ public class LobbyMarshaller extends InvocationMarshaller } /** - * Marshalls results to implementations of {@link LobbiesListener}. + * Marshalls results to implementations of {@link LobbyService.LobbiesListener}. */ public static class LobbiesMarshaller extends ListenerMarshaller implements LobbiesListener @@ -82,7 +82,7 @@ public class LobbyMarshaller extends InvocationMarshaller public static final int GOT_LOBBIES = 1; // from interface LobbiesMarshaller - public void gotLobbies (List arg1) + public void gotLobbies (List arg1) { _invId = null; omgr.postEvent(new InvocationResponseEvent( @@ -96,7 +96,7 @@ public class LobbyMarshaller extends InvocationMarshaller switch (methodId) { case GOT_LOBBIES: ((LobbiesListener)listener).gotLobbies( - (List)args[0]); + (List)args[0]); return; default: diff --git a/src/java/com/threerings/micasa/lobby/LobbyRegistry.java b/src/java/com/threerings/micasa/lobby/LobbyRegistry.java index 77cebe6f..9806da9c 100644 --- a/src/java/com/threerings/micasa/lobby/LobbyRegistry.java +++ b/src/java/com/threerings/micasa/lobby/LobbyRegistry.java @@ -206,7 +206,7 @@ public class LobbyRegistry */ public void getLobbies (ClientObject caller, String category, LobbiesListener listener) { - StreamableArrayList target = new StreamableArrayList(); + List target = new StreamableArrayList(); List list = _lobbies.get(category); if (list != null) { target.addAll(list); diff --git a/src/java/com/threerings/micasa/lobby/LobbySelector.java b/src/java/com/threerings/micasa/lobby/LobbySelector.java index 251674dd..8ffc721e 100644 --- a/src/java/com/threerings/micasa/lobby/LobbySelector.java +++ b/src/java/com/threerings/micasa/lobby/LobbySelector.java @@ -23,14 +23,22 @@ package com.threerings.micasa.lobby; import java.awt.BorderLayout; import java.awt.Component; -import java.awt.event.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.HashMap; +import java.util.List; +import java.util.Map; -import java.util.*; - -import javax.swing.*; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.JComboBox; +import javax.swing.JList; +import javax.swing.JPanel; import com.threerings.crowd.data.PlaceObject; - import com.threerings.micasa.util.MiCasaContext; import static com.threerings.micasa.Log.log; @@ -115,15 +123,14 @@ public class LobbySelector extends JPanel } // documentation inherited from interface - public void gotLobbies (List lobbies) + public void gotLobbies (List lobbies) { // create a list model for this category DefaultListModel model = new DefaultListModel(); // populate it with the lobby info - Iterator iter = lobbies.iterator(); - while (iter.hasNext()) { - model.addElement(iter.next()); + for (Lobby lobby : lobbies) { + model.addElement(lobby); } // stick it in the table @@ -156,7 +163,7 @@ public class LobbySelector extends JPanel */ protected void selectCategory (String category) { - DefaultListModel model = (DefaultListModel)_catlists.get(category); + DefaultListModel model = _catlists.get(category); if (model != null) { _loblist.setModel(model); @@ -213,7 +220,7 @@ public class LobbySelector extends JPanel protected JComboBox _combo; protected JList _loblist; - protected HashMap _catlists = new HashMap(); + protected Map _catlists = new HashMap(); protected String _pendingCategory; protected static final String CAT_FIRST_ITEM = ""; diff --git a/src/java/com/threerings/micasa/lobby/LobbyService.java b/src/java/com/threerings/micasa/lobby/LobbyService.java index afc11122..fb74c628 100644 --- a/src/java/com/threerings/micasa/lobby/LobbyService.java +++ b/src/java/com/threerings/micasa/lobby/LobbyService.java @@ -55,7 +55,7 @@ public interface LobbyService extends InvocationService * Supplies the listener with the results of a {@link * #getLobbies} request. */ - public void gotLobbies (List lobbies); + public void gotLobbies (List lobbies); } /** diff --git a/src/java/com/threerings/micasa/lobby/table/TableListView.java b/src/java/com/threerings/micasa/lobby/table/TableListView.java index 7ac22277..8980f36d 100644 --- a/src/java/com/threerings/micasa/lobby/table/TableListView.java +++ b/src/java/com/threerings/micasa/lobby/table/TableListView.java @@ -23,7 +23,6 @@ package com.threerings.micasa.lobby.table; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.Iterator; import javax.swing.BorderFactory; import javax.swing.JButton; @@ -153,9 +152,8 @@ public class TableListView extends JPanel // iterate over the tables already active in this lobby and put // them in their respective lists TableLobbyObject tlobj = (TableLobbyObject)place; - Iterator iter = tlobj.tableSet.iterator(); - while (iter.hasNext()) { - tableAdded((Table)iter.next()); + for (Table table : tlobj.tableSet) { + tableAdded(table); } } diff --git a/src/java/com/threerings/micasa/lobby/table/TableLobbyObject.java b/src/java/com/threerings/micasa/lobby/table/TableLobbyObject.java index b74f6d61..2cc3ca69 100644 --- a/src/java/com/threerings/micasa/lobby/table/TableLobbyObject.java +++ b/src/java/com/threerings/micasa/lobby/table/TableLobbyObject.java @@ -39,13 +39,13 @@ public class TableLobbyObject extends LobbyObject // AUTO-GENERATED: FIELDS END /** A set containing all of the tables being managed by this lobby. */ - public DSet tableSet = new DSet(); + public DSet tableSet = new DSet
(); /** Handles our table services. */ public TableMarshaller tableService; // from interface TableLobbyObject - public DSet getTables () + public DSet
getTables () { return tableSet; } @@ -80,7 +80,7 @@ public class TableLobbyObject extends LobbyObject * tableSet set. The set will not change until the event is * actually propagated through the system. */ - public void addToTableSet (DSet.Entry elem) + public void addToTableSet (Table elem) { requestEntryAdd(TABLE_SET, tableSet, elem); } @@ -100,7 +100,7 @@ public class TableLobbyObject extends LobbyObject * tableSet set. The set will not change until the event is * actually propagated through the system. */ - public void updateTableSet (DSet.Entry elem) + public void updateTableSet (Table elem) { requestEntryUpdate(TABLE_SET, tableSet, elem); } @@ -115,10 +115,10 @@ public class TableLobbyObject extends LobbyObject * change. Proxied copies of this object (on clients) will apply the * value change when they received the attribute changed notification. */ - public void setTableSet (DSet value) + public void setTableSet (DSet
value) { requestAttributeChange(TABLE_SET, value, this.tableSet); - DSet clone = (value == null) ? null : value.typedClone(); + DSet
clone = (value == null) ? null : value.typedClone(); this.tableSet = clone; } diff --git a/src/java/com/threerings/micasa/simulator/client/SimulatorApp.java b/src/java/com/threerings/micasa/simulator/client/SimulatorApp.java index 5b951f01..08215d46 100644 --- a/src/java/com/threerings/micasa/simulator/client/SimulatorApp.java +++ b/src/java/com/threerings/micasa/simulator/client/SimulatorApp.java @@ -69,8 +69,8 @@ public class SimulatorApp // create the server Injector injector = Guice.createInjector(new SimpleServer.Module()); SimulatorServer server = createSimulatorServer(injector); - server.init(injector, new ResultListener() { - public void requestCompleted (Object result) { + server.init(injector, new ResultListener() { + public void requestCompleted (SimulatorServer result) { try { run(); } catch (Exception e) { diff --git a/src/java/com/threerings/micasa/simulator/server/SimpleServer.java b/src/java/com/threerings/micasa/simulator/server/SimpleServer.java index 55450e4f..8b4e4619 100644 --- a/src/java/com/threerings/micasa/simulator/server/SimpleServer.java +++ b/src/java/com/threerings/micasa/simulator/server/SimpleServer.java @@ -36,7 +36,7 @@ import com.threerings.micasa.server.MiCasaServer; public class SimpleServer extends MiCasaServer implements SimulatorServer { - public void init (Injector injector, ResultListener obs) + public void init (Injector injector, ResultListener obs) throws Exception { init(injector); // do our standard initialization diff --git a/src/java/com/threerings/micasa/simulator/server/SimulatorManager.java b/src/java/com/threerings/micasa/simulator/server/SimulatorManager.java index 22fd6d59..30f9e546 100644 --- a/src/java/com/threerings/micasa/simulator/server/SimulatorManager.java +++ b/src/java/com/threerings/micasa/simulator/server/SimulatorManager.java @@ -22,6 +22,7 @@ package com.threerings.micasa.simulator.server; import java.util.ArrayList; +import java.util.List; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -172,7 +173,7 @@ public class SimulatorManager } /** The simulant body objects. */ - protected ArrayList _sims = new ArrayList(); + protected List _sims = new ArrayList(); /** The game object for the game being created. */ protected GameObject _gobj; diff --git a/src/java/com/threerings/micasa/simulator/server/SimulatorServer.java b/src/java/com/threerings/micasa/simulator/server/SimulatorServer.java index d564e52a..099f2d12 100644 --- a/src/java/com/threerings/micasa/simulator/server/SimulatorServer.java +++ b/src/java/com/threerings/micasa/simulator/server/SimulatorServer.java @@ -39,7 +39,7 @@ public interface SimulatorServer * * @exception Exception thrown if anything goes wrong initializing the server. */ - public void init (Injector injector, ResultListener obs) throws Exception; + public void init (Injector injector, ResultListener obs) throws Exception; /** * Called to perform the main body of server processing. This is called from the server thread diff --git a/src/java/com/threerings/parlor/card/client/CardPanel.java b/src/java/com/threerings/parlor/card/client/CardPanel.java index e8a61f26..95d715c6 100644 --- a/src/java/com/threerings/parlor/card/client/CardPanel.java +++ b/src/java/com/threerings/parlor/card/client/CardPanel.java @@ -30,6 +30,7 @@ import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; +import java.util.List; import javax.swing.event.MouseInputAdapter; @@ -620,10 +621,10 @@ public abstract class CardPanel extends VirtualMediaPanel * Returns the first card sprite in the specified list that represents the specified card, or * null if there is no such sprite in the list. */ - protected CardSprite getCardSprite (ArrayList list, Card card) + protected CardSprite getCardSprite (List list, Card card) { for (int i = 0; i < list.size(); i++) { - CardSprite cs = (CardSprite)list.get(i); + CardSprite cs = list.get(i); if (card.equals(cs.getCard())) { return cs; } @@ -800,10 +801,10 @@ public abstract class CardPanel extends VirtualMediaPanel /** * Clears an array of sprites from the specified list and from the panel. */ - protected void clearSprites (ArrayList sprites) + protected void clearSprites (List sprites) { - for (Iterator it = sprites.iterator(); it.hasNext(); ) { - removeSprite((CardSprite)it.next()); + for (Iterator it = sprites.iterator(); it.hasNext(); ) { + removeSprite(it.next()); it.remove(); } } @@ -972,7 +973,7 @@ public abstract class CardPanel extends VirtualMediaPanel /** Calls CardSpriteObserver.cardSpriteClicked. */ protected static class CardSpriteClickedOp implements - ObserverList.ObserverOp + ObserverList.ObserverOp { public CardSpriteClickedOp (CardSprite sprite, MouseEvent me) { @@ -995,7 +996,7 @@ public abstract class CardPanel extends VirtualMediaPanel /** Calls CardSpriteObserver.cardSpriteEntered. */ protected static class CardSpriteEnteredOp implements - ObserverList.ObserverOp + ObserverList.ObserverOp { public CardSpriteEnteredOp (CardSprite sprite, MouseEvent me) { @@ -1006,8 +1007,7 @@ public abstract class CardPanel extends VirtualMediaPanel public boolean apply (Object observer) { if (observer instanceof CardSpriteObserver) { - ((CardSpriteObserver)observer).cardSpriteEntered(_sprite, - _me); + ((CardSpriteObserver)observer).cardSpriteEntered(_sprite, _me); } return true; } @@ -1018,7 +1018,7 @@ public abstract class CardPanel extends VirtualMediaPanel /** Calls CardSpriteObserver.cardSpriteExited. */ protected static class CardSpriteExitedOp implements - ObserverList.ObserverOp + ObserverList.ObserverOp { public CardSpriteExitedOp (CardSprite sprite, MouseEvent me) { @@ -1040,7 +1040,7 @@ public abstract class CardPanel extends VirtualMediaPanel /** Calls CardSpriteObserver.cardSpriteDragged. */ protected static class CardSpriteDraggedOp implements - ObserverList.ObserverOp + ObserverList.ObserverOp { public CardSpriteDraggedOp (CardSprite sprite, MouseEvent me) { diff --git a/src/java/com/threerings/parlor/card/data/Card.java b/src/java/com/threerings/parlor/card/data/Card.java index a4196dc9..01c7b025 100644 --- a/src/java/com/threerings/parlor/card/data/Card.java +++ b/src/java/com/threerings/parlor/card/data/Card.java @@ -28,7 +28,7 @@ import com.threerings.presents.dobj.DSet; /** * Instances of this class represent individual playing cards. */ -public class Card implements DSet.Entry, Comparable, CardCodes +public class Card implements DSet.Entry, Comparable, CardCodes { /** * No-arg constructor for deserialization. @@ -131,7 +131,7 @@ public class Card implements DSet.Entry, Comparable, CardCodes } // Documentation inherited. - public Comparable getKey () + public Comparable getKey () { if (_key == null) { _key = Byte.valueOf(_value); @@ -167,9 +167,9 @@ public class Card implements DSet.Entry, Comparable, CardCodes * @return -1, 0, or +1, depending on whether this card is less than, * equal to, or greater than the other card */ - public int compareTo (Object other) + public int compareTo (Card other) { - int otherValue = ((Card)other)._value; + int otherValue = other._value; if (_value > otherValue) { return +1; diff --git a/src/java/com/threerings/parlor/card/data/Deck.java b/src/java/com/threerings/parlor/card/data/Deck.java index b6bf1bce..16faf840 100644 --- a/src/java/com/threerings/parlor/card/data/Deck.java +++ b/src/java/com/threerings/parlor/card/data/Deck.java @@ -29,7 +29,7 @@ import com.threerings.util.StreamableArrayList; /** * Instances of this class represent decks of cards. */ -public class Deck extends StreamableArrayList +public class Deck extends StreamableArrayList implements CardCodes { /** @@ -100,7 +100,7 @@ public class Deck extends StreamableArrayList Hand hand = new Hand(); // use a sublist view to manipulate the top of the deck - List sublist = subList(dsize - size, dsize); + List sublist = subList(dsize - size, dsize); hand.addAll(sublist); sublist.clear(); diff --git a/src/java/com/threerings/parlor/card/trick/data/TrickCardGameMarshaller.java b/src/java/com/threerings/parlor/card/trick/data/TrickCardGameMarshaller.java index be4454a1..04f262ed 100644 --- a/src/java/com/threerings/parlor/card/trick/data/TrickCardGameMarshaller.java +++ b/src/java/com/threerings/parlor/card/trick/data/TrickCardGameMarshaller.java @@ -53,9 +53,7 @@ public class TrickCardGameMarshaller extends InvocationMarshaller // from interface TrickCardGameService public void requestRematch (Client arg1) { - sendRequest(arg1, REQUEST_REMATCH, new Object[] { - - }); + sendRequest(arg1, REQUEST_REMATCH, new Object[] {}); } /** The method id used to dispatch {@link #sendCardsToPlayer} requests. */ diff --git a/src/java/com/threerings/parlor/card/trick/server/TrickCardGameManagerDelegate.java b/src/java/com/threerings/parlor/card/trick/server/TrickCardGameManagerDelegate.java index 838b33d0..7f5ea32e 100644 --- a/src/java/com/threerings/parlor/card/trick/server/TrickCardGameManagerDelegate.java +++ b/src/java/com/threerings/parlor/card/trick/server/TrickCardGameManagerDelegate.java @@ -23,6 +23,7 @@ package com.threerings.parlor.card.trick.server; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import com.samskivert.util.ArrayUtil; import com.samskivert.util.Interval; @@ -441,14 +442,14 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate */ protected Card pickRandomPlayableCard (Hand hand) { - ArrayList playableCards = new ArrayList(); + List playableCards = new ArrayList(); for (int i = 0; i < hand.size(); i++) { Card card = hand.get(i); if (_trickCardGame.isCardPlayable(hand, card)) { playableCards.add(card); } } - return (Card)RandomUtil.pickRandom(playableCards); + return RandomUtil.pickRandom(playableCards); } /** diff --git a/src/java/com/threerings/parlor/client/ParlorDirector.java b/src/java/com/threerings/parlor/client/ParlorDirector.java index 5f3431fb..1bb9eefb 100644 --- a/src/java/com/threerings/parlor/client/ParlorDirector.java +++ b/src/java/com/threerings/parlor/client/ParlorDirector.java @@ -21,7 +21,9 @@ package com.threerings.parlor.client; -import java.util.ArrayList; +import java.util.List; + +import com.google.common.collect.Lists; import com.samskivert.util.HashIntMap; import com.threerings.util.Name; @@ -138,7 +140,7 @@ public class ParlorDirector extends BasicDirector // see what our observers have to say about it boolean handled = false; for (int i = 0; i < _grobs.size(); i++) { - GameReadyObserver grob = (GameReadyObserver)_grobs.get(i); + GameReadyObserver grob = _grobs.get(i); handled = grob.receivedGameReady(gameOid) || handled; } @@ -172,7 +174,7 @@ public class ParlorDirector extends BasicDirector public void receivedInviteResponse (int remoteId, int code, Object arg) { // look up the invitation record for this invitation - Invitation invite = (Invitation)_pendingInvites.get(remoteId); + Invitation invite = _pendingInvites.get(remoteId); if (invite == null) { log.warning("Have no record of invitation for which we received a response?! " + "[remoteId=" + remoteId + ", code=" + code + ", arg=" + arg + "]."); @@ -230,8 +232,8 @@ public class ParlorDirector extends BasicDirector /** A table of acknowledged (but not yet accepted or refused) invitation requests, keyed on * invitation id. */ - protected HashIntMap _pendingInvites = new HashIntMap(); + protected HashIntMap _pendingInvites = new HashIntMap(); /** We notify the entities on this list when we get a game ready notification. */ - protected ArrayList _grobs = new ArrayList(); + protected List _grobs = Lists.newArrayList(); } diff --git a/src/java/com/threerings/parlor/client/TableDirector.java b/src/java/com/threerings/parlor/client/TableDirector.java index df77149c..a652e093 100644 --- a/src/java/com/threerings/parlor/client/TableDirector.java +++ b/src/java/com/threerings/parlor/client/TableDirector.java @@ -58,7 +58,7 @@ import static com.threerings.parlor.Log.log; * matchmaking takes place implements the {@link TableLobbyObject} interface. */ public class TableDirector extends BasicDirector - implements SetListener, TableService.ResultListener + implements SetListener
, TableService.ResultListener { /** * Creates a new table director to manage tables with the specified observer which will receive @@ -227,10 +227,10 @@ public class TableDirector extends BasicDirector } // documentation inherited - public void entryAdded (EntryAddedEvent event) + public void entryAdded (EntryAddedEvent
event) { if (event.getName().equals(_tableField)) { - Table table = (Table)event.getEntry(); + Table table = event.getEntry(); // check to see if we just joined a table checkSeatedness(table); // now let the observer know what's up @@ -239,10 +239,10 @@ public class TableDirector extends BasicDirector } // documentation inherited - public void entryUpdated (EntryUpdatedEvent event) + public void entryUpdated (EntryUpdatedEvent
event) { if (event.getName().equals(_tableField)) { - Table table = (Table)event.getEntry(); + Table table = event.getEntry(); // check to see if we just joined or left a table checkSeatedness(table); // now let the observer know what's up @@ -251,7 +251,7 @@ public class TableDirector extends BasicDirector } // documentation inherited - public void entryRemoved (EntryRemovedEvent event) + public void entryRemoved (EntryRemovedEvent
event) { if (event.getName().equals(_tableField)) { int tableId = ((Integer) event.getKey()).intValue(); @@ -275,7 +275,7 @@ public class TableDirector extends BasicDirector return; } - Table table = (Table) _tlobj.getTables().get(tableId); + Table table = _tlobj.getTables().get(tableId); if (table == null) { log.warning("Table created, but where is it? [tableId=" + tableId + "]"); return; diff --git a/src/java/com/threerings/parlor/data/ParlorMarshaller.java b/src/java/com/threerings/parlor/data/ParlorMarshaller.java index 3db5da8f..22f7e702 100644 --- a/src/java/com/threerings/parlor/data/ParlorMarshaller.java +++ b/src/java/com/threerings/parlor/data/ParlorMarshaller.java @@ -40,7 +40,7 @@ public class ParlorMarshaller extends InvocationMarshaller implements ParlorService { /** - * Marshalls results to implementations of {@link InviteListener}. + * Marshalls results to implementations of {@link ParlorService.InviteListener}. */ public static class InviteMarshaller extends ListenerMarshaller implements InviteListener diff --git a/src/java/com/threerings/parlor/data/Table.java b/src/java/com/threerings/parlor/data/Table.java index 4f8ab894..bc08f396 100644 --- a/src/java/com/threerings/parlor/data/Table.java +++ b/src/java/com/threerings/parlor/data/Table.java @@ -380,7 +380,7 @@ public class Table } // documentation inherited - public Comparable getKey () + public Comparable getKey () { return tableId; } diff --git a/src/java/com/threerings/parlor/tourney/data/EntryFee.java b/src/java/com/threerings/parlor/tourney/data/EntryFee.java index e940c8a8..3ae0dea7 100644 --- a/src/java/com/threerings/parlor/tourney/data/EntryFee.java +++ b/src/java/com/threerings/parlor/tourney/data/EntryFee.java @@ -45,7 +45,7 @@ public abstract class EntryFee extends SimpleStreamableObject /** * Attempts to reserve the entry fee. */ - public abstract void reserveFee (BodyObject body, ResultListener listener); + public abstract void reserveFee (BodyObject body, ResultListener listener); /** * Returns the entry fee. diff --git a/src/java/com/threerings/parlor/tourney/data/Participant.java b/src/java/com/threerings/parlor/tourney/data/Participant.java index 8d524a52..f0002391 100644 --- a/src/java/com/threerings/parlor/tourney/data/Participant.java +++ b/src/java/com/threerings/parlor/tourney/data/Participant.java @@ -31,21 +31,20 @@ import com.threerings.presents.dobj.DSet; * Contains information on a particular tourney participant. */ public class Participant extends SimpleStreamableObject - implements DSet.Entry, Comparable + implements DSet.Entry, Comparable { /** The username of the participant. */ public Name username; // documentation inherited from interface DSet.Entry - public Comparable getKey () + public Comparable getKey () { return username; } // documentation inherited from interface Comparable - public int compareTo (Object o) + public int compareTo (Participant op) { - Participant op = (Participant)o; return username.compareTo(op.username); } diff --git a/src/java/com/threerings/parlor/tourney/server/TourneyManager.java b/src/java/com/threerings/parlor/tourney/server/TourneyManager.java index 29c6194a..294f5997 100644 --- a/src/java/com/threerings/parlor/tourney/server/TourneyManager.java +++ b/src/java/com/threerings/parlor/tourney/server/TourneyManager.java @@ -50,7 +50,7 @@ public abstract class TourneyManager * * @return the oid of this manager's tourney object. */ - public int init (TourneyConfig config, Comparable key) + public int init (TourneyConfig config, Comparable key) { _config = config; _key = key; @@ -120,8 +120,8 @@ public abstract class TourneyManager // make the assumption that they're going to get in _trobj.addToParticipants(part); - ResultListener rl = new ResultListener() { - public void requestCompleted (Object result) { + ResultListener rl = new ResultListener() { + public void requestCompleted (Void result) { listener.requestProcessed(); } public void requestFailed (Exception cause) { @@ -150,7 +150,7 @@ public abstract class TourneyManager throw new InvocationException(TOO_LATE_LEAVE); } - Comparable key = body.username; + Comparable key = body.username; if (!_trobj.participants.containsKey(key)) { throw new InvocationException(NOT_IN_TOURNEY); } @@ -283,7 +283,7 @@ public abstract class TourneyManager protected long _startTime; /** The key this tourney is recorded under. */ - protected Comparable _key; + protected Comparable _key; // services on which we depend @Inject protected RootDObjectManager _omgr; diff --git a/src/java/com/threerings/parlor/tourney/server/TourniesManager.java b/src/java/com/threerings/parlor/tourney/server/TourniesManager.java index a3548cc0..579ace87 100644 --- a/src/java/com/threerings/parlor/tourney/server/TourniesManager.java +++ b/src/java/com/threerings/parlor/tourney/server/TourniesManager.java @@ -103,7 +103,7 @@ public abstract class TourniesManager /** * Called by the tourney manager to remove itself from the tournies. */ - protected void releaseTourney (Comparable key) + protected void releaseTourney (Comparable key) { _tourneys.remove(key); } @@ -148,7 +148,7 @@ public abstract class TourniesManager protected int _tourneyCount; /** Holds all the current tournies in the game. */ - protected Map _tourneys = Maps.newHashMap(); + protected Map, TourneyManager> _tourneys = Maps.newHashMap(); // our dependencies @Inject protected RootDObjectManager _omgr; diff --git a/src/java/com/threerings/parlor/util/RobotPlayer.java b/src/java/com/threerings/parlor/util/RobotPlayer.java index 8ba62e40..49c61a60 100644 --- a/src/java/com/threerings/parlor/util/RobotPlayer.java +++ b/src/java/com/threerings/parlor/util/RobotPlayer.java @@ -23,6 +23,7 @@ package com.threerings.parlor.util; import java.awt.Component; import java.util.ArrayList; +import java.util.List; import com.samskivert.swing.Controller; import com.samskivert.util.CollectionUtil; @@ -100,7 +101,7 @@ public class RobotPlayer extends Interval { // post a random key press command int idx = RandomUtil.getInt(_press.size()); - String command = (String)_press.get(idx); + String command = _press.get(idx); // Log.info("Posting artificial command [cmd=" + command + "]."); Controller.postAction(_target, command); } @@ -115,10 +116,10 @@ public class RobotPlayer extends Interval protected long _robotDelay = DEFAULT_ROBOT_DELAY; /** The list of available key press action commands. */ - protected ArrayList _press = new ArrayList(); + protected List _press = new ArrayList(); /** The list of available key release action commands. */ - protected ArrayList _release = new ArrayList(); + protected List _release = new ArrayList(); /** The key translator that describes available keys and commands. */ protected KeyTranslator _xlate; diff --git a/src/java/com/threerings/puzzle/client/PuzzleBoardView.java b/src/java/com/threerings/puzzle/client/PuzzleBoardView.java index 628add74..997baca7 100644 --- a/src/java/com/threerings/puzzle/client/PuzzleBoardView.java +++ b/src/java/com/threerings/puzzle/client/PuzzleBoardView.java @@ -28,6 +28,7 @@ import java.awt.Font; import java.awt.Graphics2D; import java.awt.Rectangle; import java.util.ArrayList; +import java.util.List; import com.samskivert.swing.Label; import com.samskivert.util.StringUtil; @@ -381,10 +382,10 @@ public abstract class PuzzleBoardView extends VirtualMediaPanel protected Rectangle _bounds; /** The action animations on the board. */ - protected ArrayList _actionAnims = new ArrayList(); + protected List _actionAnims = new ArrayList(); /** The action sprites on the board. */ - protected ArrayList _actionSprites = new ArrayList(); + protected List _actionSprites = new ArrayList(); /** Prevents certain animations from overlapping others. */ protected AnimationArranger _avoidArranger; diff --git a/src/java/com/threerings/puzzle/client/PuzzleController.java b/src/java/com/threerings/puzzle/client/PuzzleController.java index 3cec798a..df70e84a 100644 --- a/src/java/com/threerings/puzzle/client/PuzzleController.java +++ b/src/java/com/threerings/puzzle/client/PuzzleController.java @@ -625,9 +625,9 @@ public abstract class PuzzleController extends GameController // notify any penders that the action has cleared final int[] results = new int[2]; - _clearPenders.apply(new ObserverList.ObserverOp() { - public boolean apply (Object observer) { - switch (((ClearPender)observer).actionCleared()) { + _clearPenders.apply(new ObserverList.ObserverOp() { + public boolean apply (ClearPender observer) { + switch (observer.actionCleared()) { case ClearPender.RESTART_ACTION: results[0]++; break; case ClearPender.NO_RESTART_ACTION: results[1]++; break; } @@ -941,7 +941,7 @@ public abstract class PuzzleController extends GameController protected int _astate = ACTION_CLEARED; /** The action cleared penders. */ - protected ObserverList _clearPenders = ObserverList.newSafeInOrder(); + protected ObserverList _clearPenders = ObserverList.newSafeInOrder(); /** A key listener that currently just toggles pause in the puzzle. */ protected KeyListener _globalKeyListener = new KeyAdapter() { diff --git a/src/java/com/threerings/puzzle/drop/client/DropBoardView.java b/src/java/com/threerings/puzzle/drop/client/DropBoardView.java index e583a64f..c000e1c5 100644 --- a/src/java/com/threerings/puzzle/drop/client/DropBoardView.java +++ b/src/java/com/threerings/puzzle/drop/client/DropBoardView.java @@ -330,8 +330,8 @@ public abstract class DropBoardView extends PuzzleBoardView { // when a new board arrives, we want to remove all drop sprites // so that they don't modify the new board with their old ideas - for (Iterator iter = _actionSprites.iterator(); iter.hasNext(); ) { - Sprite s = (Sprite) iter.next(); + for (Iterator iter = _actionSprites.iterator(); iter.hasNext(); ) { + Sprite s = iter.next(); if (s instanceof DropSprite) { // remove it from _sprites safely iter.remove(); diff --git a/src/java/com/threerings/puzzle/drop/client/DropSprite.java b/src/java/com/threerings/puzzle/drop/client/DropSprite.java index 0845d08e..563ea1be 100644 --- a/src/java/com/threerings/puzzle/drop/client/DropSprite.java +++ b/src/java/com/threerings/puzzle/drop/client/DropSprite.java @@ -501,7 +501,7 @@ public class DropSprite extends Sprite } /** Used to dispatch {@link DropSpriteObserver#pieceMoved}. */ - protected static class PieceMovedOp implements ObserverList.ObserverOp + protected static class PieceMovedOp implements ObserverList.ObserverOp { public PieceMovedOp (DropSprite sprite, long when, int col, int row) { diff --git a/src/java/com/threerings/puzzle/drop/util/PieceDestroyer.java b/src/java/com/threerings/puzzle/drop/util/PieceDestroyer.java index b73c9103..dc2d4d70 100644 --- a/src/java/com/threerings/puzzle/drop/util/PieceDestroyer.java +++ b/src/java/com/threerings/puzzle/drop/util/PieceDestroyer.java @@ -21,9 +21,10 @@ package com.threerings.puzzle.drop.util; -import java.util.ArrayList; import java.util.List; +import com.google.common.collect.Lists; + import com.threerings.puzzle.drop.data.DropBoard; import com.threerings.puzzle.drop.data.DropBoard.PieceOperation; import com.threerings.puzzle.drop.data.DropPieceCodes; @@ -74,7 +75,7 @@ public class PieceDestroyer * the pieces in the segments may overlap, i.e., two segments may * contain the same piece. */ - public List destroyPieces (DropBoard board, PieceOperation destroyOp) + public List destroyPieces (DropBoard board, PieceOperation destroyOp) { // find all horizontally-oriented destroyed segments int bwid = board.getWidth(), bhei = board.getHeight(); @@ -99,7 +100,7 @@ public class PieceDestroyer // destroy the pieces int size = _destroyed.size(); for (int ii = 0; ii < size; ii++) { - SegmentInfo si = (SegmentInfo)_destroyed.get(ii); + SegmentInfo si = _destroyed.get(ii); board.applyOp(si.dir, si.x, si.y, si.len, destroyOp); } @@ -177,5 +178,5 @@ public class PieceDestroyer protected SegmentLengthOperation _lengthOp = new SegmentLengthOperation(); /** The list of destroyed piece segments. */ - protected ArrayList _destroyed = new ArrayList(); + protected List _destroyed = Lists.newArrayList(); } diff --git a/src/java/com/threerings/puzzle/util/PointSet.java b/src/java/com/threerings/puzzle/util/PointSet.java index e3c30f63..d8da02c1 100644 --- a/src/java/com/threerings/puzzle/util/PointSet.java +++ b/src/java/com/threerings/puzzle/util/PointSet.java @@ -72,9 +72,9 @@ public class PointSet */ public void addAll (PointSet set) { - Iterator iter = set.iterator(); Point pt; - while ((pt = (Point)iter.next()) != null) { + Iterator iter = set.iterator(); + while ((pt = iter.next()) != null) { add(pt.x, pt.y); } } @@ -129,7 +129,7 @@ public class PointSet * * @return the iterator over the set's points. */ - public Iterator iterator () + public Iterator iterator () { return new PointIterator(); } @@ -168,9 +168,9 @@ public class PointSet { StringBuilder buf = new StringBuilder(); buf.append("["); - Iterator iter = iterator(); + Iterator iter = iterator(); Point val; - while ((val = (Point)iter.next()) != null) { + while ((val = iter.next()) != null) { buf.append("(").append(val.x); buf.append(",").append(val.y); buf.append(")"); @@ -182,14 +182,14 @@ public class PointSet return buf.append("]").toString(); } - protected class PointIterator implements Iterator + protected class PointIterator implements Iterator { public boolean hasNext () { return (_curCount < _count); } - public Object next () + public Point next () { if (_curCount == _count) { return null; diff --git a/src/java/com/threerings/stage/client/SceneColorizer.java b/src/java/com/threerings/stage/client/SceneColorizer.java index 80cb4d65..02a86ef7 100644 --- a/src/java/com/threerings/stage/client/SceneColorizer.java +++ b/src/java/com/threerings/stage/client/SceneColorizer.java @@ -23,6 +23,7 @@ package com.threerings.stage.client; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; import com.threerings.media.image.ColorPository; import com.threerings.media.image.Colorization; @@ -48,8 +49,8 @@ public class SceneColorizer implements TileSet.Colorizer _scene = scene; // enumerate the color ids for all possible colorization classes - for (Iterator iter = _cpos.enumerateClasses(); iter.hasNext(); ) { - String cname = ((ColorPository.ClassRecord)iter.next()).name; + for (Iterator iter = _cpos.enumerateClasses(); iter.hasNext(); ) { + String cname = iter.next().name; _cids.put(cname, _cpos.enumerateColorIds(cname)); } } @@ -122,10 +123,9 @@ public class SceneColorizer implements TileSet.Colorizer } // 3. If there are no defaults whatsoever, just hash on the sceneId. - int[] cids = (int[])_cids.get(zation); + int[] cids = _cids.get(zation); if (cids == null) { - log.warning("Zoiks, have no colorizations for '" + - zation + "'."); + log.warning("Zoiks, have no colorizations for '" + zation + "'."); return -1; } else { colorId = cids[_scene.getZoneId() % cids.length]; @@ -145,5 +145,5 @@ public class SceneColorizer implements TileSet.Colorizer protected StageScene _scene; /** Contains our colorization class information. */ - protected HashMap _cids = new HashMap(); + protected Map _cids = new HashMap(); } diff --git a/src/java/com/threerings/stage/client/StageSceneController.java b/src/java/com/threerings/stage/client/StageSceneController.java index 2804b4cc..a2b435a4 100644 --- a/src/java/com/threerings/stage/client/StageSceneController.java +++ b/src/java/com/threerings/stage/client/StageSceneController.java @@ -21,6 +21,8 @@ package com.threerings.stage.client; +import java.awt.Point; + import com.samskivert.util.Tuple; import com.threerings.crowd.client.PlaceView; @@ -28,6 +30,7 @@ import com.threerings.crowd.util.CrowdContext; import com.threerings.whirled.data.SceneUpdate; import com.threerings.whirled.spot.client.SpotSceneController; +import com.threerings.whirled.spot.data.Cluster; import com.threerings.stage.data.StageLocation; import com.threerings.stage.util.StageContext; @@ -51,10 +54,9 @@ public class StageSceneController extends SpotSceneController /** * Handles a cluster clicked event. * - * @param tuple a Tuple containing (Cluster, Point) with the Cluster - * that was clicked and the Point being the screen coords of the click. + * @param tuple the cluster that was clicked and the screen coords of the click. */ - public void handleClusterClicked (Object source, Tuple tuple) + public void handleClusterClicked (Object source, Tuple tuple) { log.warning("handleClusterClicked(" + source + ", " + tuple + ")"); } diff --git a/src/java/com/threerings/stage/client/StageScenePanel.java b/src/java/com/threerings/stage/client/StageScenePanel.java index e71a558d..cea18650 100644 --- a/src/java/com/threerings/stage/client/StageScenePanel.java +++ b/src/java/com/threerings/stage/client/StageScenePanel.java @@ -36,7 +36,6 @@ import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.geom.Ellipse2D; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -274,7 +273,7 @@ public class StageScenePanel extends MisoScenePanel // if the hover object is a cluster, we clicked it! if (event.getButton() == MouseEvent.BUTTON1) { if (hobject instanceof Cluster) { - Object actarg = new Tuple(hobject, event.getPoint()); + Object actarg = new Tuple(hobject, event.getPoint()); Controller.postAction(this, CLUSTER_CLICKED, actarg); } else { // post an action indicating that we've clicked on a location @@ -311,7 +310,7 @@ public class StageScenePanel extends MisoScenePanel { // compute a screen rectangle that contains all possible "spots" // in this cluster - ArrayList spots = StageSceneUtil.getClusterLocs(cluster); + List spots = StageSceneUtil.getClusterLocs(cluster); Rectangle cbounds = null; for (int ii = 0, ll = spots.size(); ii < ll; ii++) { StageLocation loc = ((StageLocation) spots.get(ii).loc); diff --git a/src/java/com/threerings/stage/server/StageSceneManager.java b/src/java/com/threerings/stage/server/StageSceneManager.java index ab119ffd..ab4a096a 100644 --- a/src/java/com/threerings/stage/server/StageSceneManager.java +++ b/src/java/com/threerings/stage/server/StageSceneManager.java @@ -26,6 +26,7 @@ import java.awt.Rectangle; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import com.samskivert.util.HashIntMap; import com.threerings.media.util.AStarPathUtil; @@ -159,7 +160,7 @@ public class StageSceneManager extends SpotSceneManager { return (StageSceneUtil.isPassable( StageServer.tilemgr, _mmodel.getBaseTileId(tx, ty)) && - !checkContains(_footprints.iterator(), tx, ty)); + !checkContains(_footprints, tx, ty)); } /** @@ -311,8 +312,8 @@ public class StageSceneManager extends SpotSceneManager // place the tile coordinates of our portals into a set for // efficient comparison with location coordinates _plocs.clear(); - for (Iterator iter = _sscene.getPortals(); iter.hasNext(); ) { - Portal port = (Portal)iter.next(); + for (Iterator iter = _sscene.getPortals(); iter.hasNext(); ) { + Portal port = iter.next(); StageLocation loc = (StageLocation) port.loc; _plocs.add(new Point(MisoUtil.fullToTile(loc.x), MisoUtil.fullToTile(loc.y))); @@ -355,9 +356,9 @@ public class StageSceneManager extends SpotSceneManager // make sure they're not standing in a cluster footprint, an // object footprint, or in the same tile as another scene occupant - if (checkContains(_ssobj.clusters.iterator(), tx, ty) || - checkContains(_footprints.iterator(), tx, ty) || - checkContains(_loners.values().iterator(), tx, ty)) { + if (checkContains(_ssobj.clusters, tx, ty) || + checkContains(_footprints, tx, ty) || + checkContains(_loners.values(), tx, ty)) { // Log.info("Rejecting loc [who=" + source.who() + // ", loc=" + loc + ", inCluster=" + // checkContains(_ssobj.clusters.iterator(), tx, ty) + @@ -373,10 +374,9 @@ public class StageSceneManager extends SpotSceneManager } /** Helper function for {@link #validateLocation}. */ - protected boolean checkContains (Iterator iter, int tx, int ty) + protected boolean checkContains (Iterable rects, int tx, int ty) { - while (iter.hasNext()) { - Rectangle rect = (Rectangle)iter.next(); + for (Rectangle rect : rects) { if (rect.contains(tx, ty)) { // Log.info(StringUtil.toString(rect) + " contains " + // StringUtil.coordsToString(tx, ty) + "."); @@ -517,8 +517,8 @@ public class StageSceneManager extends SpotSceneManager // if this rect overlaps objects, other clusters, portals or // impassable tiles, it's no good - if (checkIntersects(_ssobj.clusters.iterator(), rect, cl) || - checkIntersects(_footprints.iterator(), rect, cl) || + if (checkIntersects(_ssobj.clusters, rect, cl) || + checkIntersects(_footprints, rect, cl) || checkPortals(rect) || checkViolatesPassability(rect)) { rect = null; } else { @@ -595,11 +595,10 @@ public class StageSceneManager extends SpotSceneManager } /** Helper function for {@link #canAddBody}. */ - protected boolean checkIntersects (Iterator iter, Rectangle rect, - Rectangle ignore) + protected boolean checkIntersects ( + Iterable rects, Rectangle rect, Rectangle ignore) { - while (iter.hasNext()) { - Rectangle trect = (Rectangle)iter.next(); + for (Rectangle trect : rects) { if (ignore != null && trect.equals(ignore)) { continue; } @@ -613,8 +612,8 @@ public class StageSceneManager extends SpotSceneManager /** Helper function for {@link #canAddBody}. */ protected boolean checkPortals (Rectangle rect) { - for (Iterator iter = _plocs.iterator(); iter.hasNext(); ) { - Point ppoint = (Point)iter.next(); + for (Iterator iter = _plocs.iterator(); iter.hasNext(); ) { + Point ppoint = iter.next(); if (rect.contains(ppoint)) { return true; } @@ -683,14 +682,14 @@ public class StageSceneManager extends SpotSceneManager } // generate a list of all valid locations for this cluster - ArrayList locs = StageSceneUtil.getClusterLocs(cl); + List locs = StageSceneUtil.getClusterLocs(cl); // Log.info("Positioning " + clrec.size() + " bodies in " + // StringUtil.toString(locs) + " for " + cl + "."); // make sure everyone is in their proper position - for (Iterator iter = clrec.keySet().iterator(); iter.hasNext(); ) { - int tbodyOid = ((Integer)iter.next()).intValue(); + for (Iterator iter = clrec.keySet().iterator(); iter.hasNext(); ) { + int tbodyOid = iter.next().intValue(); // leave the newly added player to last if (tbodyOid != bodyOid) { positionBody(cl, tbodyOid, locs); @@ -702,7 +701,7 @@ public class StageSceneManager extends SpotSceneManager } /** Helper function for {@link #bodyAdded}. */ - protected void positionBody (Cluster cl, int bodyOid, ArrayList locs) + protected void positionBody (Cluster cl, int bodyOid, List locs) { SceneLocation sloc = _ssobj.occupantLocs.get(Integer.valueOf(bodyOid)); if (sloc == null) { @@ -751,11 +750,11 @@ public class StageSceneManager extends SpotSceneManager cl.height = target; // generate a list of all valid locations for this cluster - ArrayList locs = StageSceneUtil.getClusterLocs(cl); + List locs = StageSceneUtil.getClusterLocs(cl); // make sure everyone is in their proper position - for (Iterator iter = clrec.keySet().iterator(); iter.hasNext(); ) { - int bodyOid = ((Integer)iter.next()).intValue(); + for (Iterator iter = clrec.keySet().iterator(); iter.hasNext(); ) { + int bodyOid = iter.next().intValue(); // leave the newly added player to last if (bodyOid != body.getOid()) { positionBody(cl, bodyOid, locs); @@ -786,14 +785,14 @@ public class StageSceneManager extends SpotSceneManager * supplied location. */ protected static SceneLocation getClosestLoc ( - ArrayList locs, SceneLocation optimalLocation) + Listlocs, SceneLocation optimalLocation) { StageLocation loc = (StageLocation) optimalLocation.loc; SceneLocation cloc = null; float cdist = Integer.MAX_VALUE; int cidx = -1; for (int ii = 0, ll = locs.size(); ii < ll; ii++) { - SceneLocation tloc = (SceneLocation)locs.get(ii); + SceneLocation tloc = locs.get(ii); StageLocation sl = (StageLocation) tloc.loc; float tdist = MathUtil.distance(loc.x, loc.y, sl.x, sl.y); if (tdist < cdist) { @@ -819,14 +818,14 @@ public class StageSceneManager extends SpotSceneManager /** Rectangles describing the footprints (in tile coordinates) of all * of our scene objects. */ - protected ArrayList _footprints = new ArrayList(); + protected ArrayList _footprints = new ArrayList(); /** Rectangles containing a "footprint" for the users that aren't in * any clusters. */ protected HashIntMap _loners = new HashIntMap(); /** Contains the (tile) coordinates of all of our portals. */ - protected HashSet _plocs = new HashSet(); + protected HashSet _plocs = new HashSet(); /** The dimensions of a cluster with the specified number of * occupants. */ diff --git a/src/java/com/threerings/stage/tools/editor/EditorApp.java b/src/java/com/threerings/stage/tools/editor/EditorApp.java index 0f703513..2b9bc573 100644 --- a/src/java/com/threerings/stage/tools/editor/EditorApp.java +++ b/src/java/com/threerings/stage/tools/editor/EditorApp.java @@ -261,7 +261,7 @@ public class EditorApp implements Runnable * Derived classes can override this method and add additional scene * types. */ - protected void enumerateSceneTypes (List types) + protected void enumerateSceneTypes (List types) { types.add(StageSceneModel.WORLD); } @@ -344,7 +344,7 @@ public class EditorApp implements Runnable return _colpos; } - public void enumerateSceneTypes (List types) { + public void enumerateSceneTypes (List types) { EditorApp.this.enumerateSceneTypes(types); } } diff --git a/src/java/com/threerings/stage/tools/editor/EditorModel.java b/src/java/com/threerings/stage/tools/editor/EditorModel.java index ffc463ed..35ecb4a1 100644 --- a/src/java/com/threerings/stage/tools/editor/EditorModel.java +++ b/src/java/com/threerings/stage/tools/editor/EditorModel.java @@ -21,7 +21,9 @@ package com.threerings.stage.tools.editor; -import java.util.ArrayList; +import java.util.List; + +import com.google.common.collect.Lists; import com.threerings.media.tile.Tile; import com.threerings.media.tile.TileManager; @@ -89,7 +91,7 @@ public class EditorModel { int size = _listeners.size(); for (int ii = 0; ii < size; ii++) { - ((EditorModelListener)_listeners.get(ii)).modelChanged(event); + _listeners.get(ii).modelChanged(event); } } @@ -270,7 +272,7 @@ public class EditorModel protected Tile _tile; /** The model listeners. */ - protected ArrayList _listeners = new ArrayList(); + protected List _listeners = Lists.newArrayList(); /** The tile manager. */ protected TileManager _tilemgr; diff --git a/src/java/com/threerings/stage/tools/editor/EditorScenePanel.java b/src/java/com/threerings/stage/tools/editor/EditorScenePanel.java index 4eb94f50..ea1e5944 100644 --- a/src/java/com/threerings/stage/tools/editor/EditorScenePanel.java +++ b/src/java/com/threerings/stage/tools/editor/EditorScenePanel.java @@ -40,6 +40,7 @@ import java.awt.geom.Ellipse2D; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import javax.swing.BoundedRangeModel; import javax.swing.DefaultBoundedRangeModel; @@ -47,6 +48,8 @@ import javax.swing.JFrame; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import com.google.common.collect.Lists; + import com.samskivert.swing.Controller; import com.samskivert.swing.TGraphics2D; import com.samskivert.swing.util.SwingUtil; @@ -169,12 +172,10 @@ public class EditorScenePanel extends StageScenePanel { StageMisoSceneModel ysmodel = (StageMisoSceneModel)_model; _area = null; - for (Iterator iter = ysmodel.getSections(); iter.hasNext(); ) { - StageMisoSceneModel.Section sect = - (StageMisoSceneModel.Section)iter.next(); + for (Iterator iter = ysmodel.getSections(); iter.hasNext(); ) { + StageMisoSceneModel.Section sect = iter.next(); Rectangle sbounds = MisoUtil.getFootprintPolygon( - _metrics, sect.x, sect.y, - ysmodel.swidth, ysmodel.sheight).getBounds(); + _metrics, sect.x, sect.y, ysmodel.swidth, ysmodel.sheight).getBounds(); if (_area == null) { _area = sbounds; } else { @@ -263,16 +264,15 @@ public class EditorScenePanel extends StageScenePanel case EditorModel.OBJECT_LAYER: if (drag != null) { // locate any object that intersects this rectangle - ArrayList hits = new ArrayList(); - for (Iterator iter = _vizobjs.iterator(); iter.hasNext(); ) { - SceneObject scobj = (SceneObject)iter.next(); + List hits = Lists.newArrayList(); + for (SceneObject scobj: _vizobjs) { if (scobj.objectFootprintOverlaps(drag)) { hits.add(scobj); } } // and delete 'em for (int ii = 0; ii < hits.size(); ii++) { - deleteObject((SceneObject)hits.get(ii)); + deleteObject(hits.get(ii)); } } else { @@ -926,7 +926,7 @@ public class EditorScenePanel extends StageScenePanel */ protected void paintPortals (Graphics2D gfx) { - Iterator iter = _scene.getPortals(); + Iterator iter = _scene.getPortals(); while (iter.hasNext()) { paintPortal(gfx, (EditablePortal)iter.next()); } diff --git a/src/java/com/threerings/stage/tools/editor/EditorToolBarPanel.java b/src/java/com/threerings/stage/tools/editor/EditorToolBarPanel.java index 089b764b..526f5359 100644 --- a/src/java/com/threerings/stage/tools/editor/EditorToolBarPanel.java +++ b/src/java/com/threerings/stage/tools/editor/EditorToolBarPanel.java @@ -21,11 +21,18 @@ package com.threerings.stage.tools.editor; -import java.awt.*; -import java.awt.event.*; -import java.util.ArrayList; -import javax.swing.*; -import com.samskivert.swing.*; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JToolBar; + +import com.google.common.collect.Lists; + +import com.samskivert.swing.DimmedIcon; import com.threerings.media.tile.Tile; import com.threerings.media.tile.TileIcon; @@ -50,7 +57,7 @@ public class EditorToolBarPanel extends JPanel implements ActionListener JToolBar toolbar = new JToolBar(); // add all of the toolbar buttons - _buttons = new ArrayList(); + _buttons = Lists.newArrayList(); for (int ii = 0; ii < EditorModel.NUM_ACTIONS; ii++) { // get the button icon images Tile tile = tbset.getTile(ii); @@ -71,7 +78,7 @@ public class EditorToolBarPanel extends JPanel implements ActionListener } // default to the first button - setSelectedButton((JButton)_buttons.get(0)); + setSelectedButton(_buttons.get(0)); // add the toolbar add(toolbar); @@ -96,7 +103,7 @@ public class EditorToolBarPanel extends JPanel implements ActionListener protected void setSelectedButton (JButton button) { for (int ii = 0; ii < _buttons.size(); ii++) { - JButton tb = (JButton)_buttons.get(ii); + JButton tb = _buttons.get(ii); tb.setSelected(tb == button); } } @@ -120,7 +127,7 @@ public class EditorToolBarPanel extends JPanel implements ActionListener } /** The buttons in the tool bar. */ - protected ArrayList _buttons; + protected List _buttons; /** The editor data model. */ protected EditorModel _model; diff --git a/src/java/com/threerings/stage/tools/editor/ObjectEditorDialog.java b/src/java/com/threerings/stage/tools/editor/ObjectEditorDialog.java index ea7e026f..c140b20b 100644 --- a/src/java/com/threerings/stage/tools/editor/ObjectEditorDialog.java +++ b/src/java/com/threerings/stage/tools/editor/ObjectEditorDialog.java @@ -200,7 +200,7 @@ public class ObjectEditorDialog extends EditorDialog /** Used to display colorization choices. */ protected static class ZationChoice - implements Comparable + implements Comparable { public short colorId; public String name; @@ -211,9 +211,9 @@ public class ObjectEditorDialog extends EditorDialog this.name = name; } - public int compareTo (Object other) + public int compareTo (ZationChoice other) { - return colorId - ((ZationChoice)other).colorId; + return colorId - other.colorId; } @Override diff --git a/src/java/com/threerings/stage/tools/editor/PortalTool.java b/src/java/com/threerings/stage/tools/editor/PortalTool.java index 3dad88ac..30f2eef7 100644 --- a/src/java/com/threerings/stage/tools/editor/PortalTool.java +++ b/src/java/com/threerings/stage/tools/editor/PortalTool.java @@ -32,6 +32,7 @@ import com.threerings.miso.util.MisoUtil; import com.threerings.util.DirectionCodes; import com.threerings.util.DirectionUtil; +import com.threerings.whirled.spot.data.Portal; import com.threerings.whirled.spot.tools.EditablePortal; import com.threerings.stage.data.StageLocation; @@ -152,7 +153,7 @@ public class PortalTool extends MouseInputAdapter */ protected boolean portalNameExists (String name) { - Iterator iter = _scene.getPortals(); + Iterator iter = _scene.getPortals(); while (iter.hasNext()) { if (((EditablePortal)iter.next()).name.equals(name)) { return true; diff --git a/src/java/com/threerings/stage/tools/editor/SceneInfoPanel.java b/src/java/com/threerings/stage/tools/editor/SceneInfoPanel.java index 7bbc7904..108e43f0 100644 --- a/src/java/com/threerings/stage/tools/editor/SceneInfoPanel.java +++ b/src/java/com/threerings/stage/tools/editor/SceneInfoPanel.java @@ -97,7 +97,7 @@ public class SceneInfoPanel extends JPanel }); // create a drop-down for selecting the scene type - ComparableArrayList types = new ComparableArrayList(); + ComparableArrayList types = new ComparableArrayList(); ctx.enumerateSceneTypes(types); types.sort(); types.add(0, ""); @@ -172,7 +172,7 @@ public class SceneInfoPanel extends JPanel { // add all possible colorization names to the list final TileManager tilemgr = _ctx.getTileManager(); - final HashSet set = new HashSet(); + final HashSet set = new HashSet(); StageMisoSceneModel msmodel = StageMisoSceneModel.getSceneModel( _scene.getSceneModel()); msmodel.visitObjects(new ObjectVisitor() { @@ -202,7 +202,7 @@ public class SceneInfoPanel extends JPanel DefaultComboBoxModel model = (DefaultComboBoxModel) _colorClasses.getModel(); model.removeAllElements(); - for (Iterator itr = Collections.getSortedIterator(set); + for (Iterator itr = Collections.getSortedIterator(set); itr.hasNext(); ) { model.addElement(itr.next()); } @@ -235,7 +235,7 @@ public class SceneInfoPanel extends JPanel int pick = _scene.getDefaultColor(classRec.classId); ColorPository.ColorRecord[] colors = cpos.enumerateColors(cclass); - ComparableArrayList list = new ComparableArrayList(); + ComparableArrayList list = new ComparableArrayList(); for (int ii=0; ii < colors.length; ii++) { list.insertSorted(colors[ii].name); if (colors[ii].colorId == pick) { diff --git a/src/java/com/threerings/stage/tools/editor/TestTileLoader.java b/src/java/com/threerings/stage/tools/editor/TestTileLoader.java index ee67a77f..4f813303 100644 --- a/src/java/com/threerings/stage/tools/editor/TestTileLoader.java +++ b/src/java/com/threerings/stage/tools/editor/TestTileLoader.java @@ -28,6 +28,8 @@ import java.io.FilenameFilter; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; + import javax.imageio.ImageIO; import com.samskivert.util.HashIntMap; @@ -74,10 +76,10 @@ public class TestTileLoader implements TileSetIDBroker * @return a HashIntMap containing a TileSetId -> TileSet mapping for * all the tilesets we create. */ - public HashIntMap loadTestTiles () + public HashIntMap loadTestTiles () { String directory = EditorConfig.getTestTileDirectory(); - HashIntMap map = new HashIntMap(); + HashIntMap map = new HashIntMap(); // recurse test directory, making a tileset from the xml file inside // and cloning it for each image we find in there. @@ -98,8 +100,7 @@ public class TestTileLoader implements TileSetIDBroker /** * Load xml tile sets from a directory. */ - protected void loadTestTilesFromDir (File directory, - HashIntMap sets) + protected void loadTestTilesFromDir (File directory, HashIntMap sets) { // first recurse File[] subdirs = directory.listFiles(new FileFilter() { @@ -121,7 +122,7 @@ public class TestTileLoader implements TileSetIDBroker for (int ii=0; ii < xml.length; ii++) { File xmlfile = new File(directory, xml[ii]); - HashMap tiles = new HashMap(); + Map tiles = new HashMap(); try { _parser.loadTileSets(xmlfile, tiles); } catch (IOException ioe) { @@ -129,9 +130,9 @@ public class TestTileLoader implements TileSetIDBroker continue; } - Iterator iter = tiles.values().iterator(); + Iterator iter = tiles.values().iterator(); while (iter.hasNext()) { - TileSet ts = (TileSet) iter.next(); + TileSet ts = iter.next(); String path = new File(directory, ts.getImagePath()).getPath(); // before we insert, make sure we can load the image @@ -150,7 +151,7 @@ public class TestTileLoader implements TileSetIDBroker */ public int getTileSetID (String tileSetPath) { - Integer id = (Integer) _idmap.get(tileSetPath); + Integer id = _idmap.get(tileSetPath); if (null == id) { id = Integer.valueOf(_fakeID--); _idmap.put(tileSetPath, id); @@ -176,7 +177,7 @@ public class TestTileLoader implements TileSetIDBroker protected int _fakeID = Short.MAX_VALUE; /** A mapping of pathname -> tileset id. */ - protected HashMap _idmap = new HashMap(); + protected Map _idmap = new HashMap(); /** Our xml parser. */ protected XMLTileSetParser _parser; diff --git a/src/java/com/threerings/stage/tools/editor/TileInfoPanel.java b/src/java/com/threerings/stage/tools/editor/TileInfoPanel.java index 77084f47..29b65ef9 100644 --- a/src/java/com/threerings/stage/tools/editor/TileInfoPanel.java +++ b/src/java/com/threerings/stage/tools/editor/TileInfoPanel.java @@ -31,6 +31,8 @@ import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; +import java.util.Map; import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; @@ -54,6 +56,8 @@ import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; +import com.google.common.collect.Maps; + import com.samskivert.util.HashIntMap; import com.samskivert.util.QuickSort; import com.samskivert.util.StringUtil; @@ -92,27 +96,25 @@ public class TileInfoPanel extends JSplitPane // we're going to sort all of the available tilesets into those // which are applicable to each layer try { - _layerSets = new ArrayList[2]; _layerLengths = new int[2]; for (int ii=0; ii < 2; ii++) { - _layerSets[ii] = new ArrayList(); + _layerSets.put(ii, new ArrayList()); } - Iterator tsids = tsrepo.enumerateTileSetIds(); + Iterator tsids = tsrepo.enumerateTileSetIds(); while (tsids.hasNext()) { - Integer tsid = (Integer)tsids.next(); + Integer tsid = tsids.next(); TileSet set = tsrepo.getTileSet(tsid.intValue()); // determine which layer to which this tileset applies int lidx = TileSetUtil.getLayerIndex(set); if (lidx != -1) { - _layerSets[lidx].add( - new TileSetRecord(lidx, tsid.intValue(), set)); + _layerSets.get(lidx).add(new TileSetRecord(lidx, tsid.intValue(), set)); } } for (int ii=0; ii < 2; ii++) { - _layerLengths[ii] = _layerSets[ii].size(); + _layerLengths[ii] = _layerSets.get(ii).size(); } } catch (Exception e) { @@ -316,13 +318,13 @@ public class TileInfoPanel extends JSplitPane /** * Remove previous test tiles and insert the new batch. */ - protected void insertTestTiles (HashIntMap tests) + protected void insertTestTiles (HashIntMap tests) { // trim the tilesets back to remove any previous test tiles for (int ii=0; ii < 2; ii++) { - for (int jj=_layerSets[ii].size() - 1; jj >= _layerLengths[ii]; + for (int jj=_layerSets.get(ii).size() - 1; jj >= _layerLengths[ii]; jj--) { - _layerSets[ii].remove(jj); + _layerSets.get(ii).remove(jj); } } @@ -332,18 +334,14 @@ public class TileInfoPanel extends JSplitPane } // insert the new test tiles - Iterator iter = tests.keys(); - while (iter.hasNext()) { - Integer tsid = (Integer) iter.next(); - - TileSet set = (TileSet) tests.get(tsid); + for (Integer tsid : tests.keySet()) { + TileSet set = tests.get(tsid); // determine which layer to which this tileset applies int lidx = TileSetUtil.getLayerIndex(set); if (lidx != -1) { // make up a negative number to refer to this temporary tileset - _layerSets[lidx].add( - new TileSetRecord(lidx, tsid, set)); + _layerSets.get(lidx).add(new TileSetRecord(lidx, tsid, set)); } if (tileMgr instanceof EditorTileManager) { @@ -365,7 +363,7 @@ public class TileInfoPanel extends JSplitPane DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); root.removeAllChildren(); - ArrayList expand = new ArrayList(); + ArrayList expand = new ArrayList(); // add all the elements in the base layer DefaultMutableTreeNode base = new DefaultMutableTreeNode("Base Layer"); @@ -383,8 +381,8 @@ public class TileInfoPanel extends JSplitPane model.reload(); // expand our container categories - for (Iterator iter = expand.iterator(); iter.hasNext(); ) { - _tsettree.expandPath((TreePath)iter.next()); + for (Iterator iter = expand.iterator(); iter.hasNext(); ) { + _tsettree.expandPath(iter.next()); } // now select the previously selected item, or the first... @@ -400,7 +398,7 @@ public class TileInfoPanel extends JSplitPane protected TileSetRecord[] getSortedTileSets (int layer) { // get the list of tilesets we now want to show - ArrayList sets = _layerSets[layer]; + List sets = _layerSets.get(layer); // we don't want to sort the actual array since we have // kept the test tiles at the end @@ -421,7 +419,7 @@ public class TileInfoPanel extends JSplitPane */ protected int addNodes (DefaultMutableTreeNode node, TileSetRecord[] list, String prefix, int position, - ArrayList expand) + ArrayList expand) { int prefixlen = prefix.length(); @@ -634,7 +632,7 @@ public class TileInfoPanel extends JSplitPane } @Override - public Class getColumnClass (int c) + public Class getColumnClass (int c) { // return the object associated with the column to force // rendering of our icon images rather than straight text @@ -648,7 +646,7 @@ public class TileInfoPanel extends JSplitPane /** * Used to manage tilesets in the tileset selection combobox. */ - protected static class TileSetRecord implements Comparable + protected static class TileSetRecord implements Comparable { public int layer; public int tileSetId; @@ -681,10 +679,9 @@ public class TileInfoPanel extends JSplitPane return shortname; } - public int compareTo (Object o) + public int compareTo (TileSetRecord o) { - return fullname().compareToIgnoreCase( - ((TileSetRecord) o).fullname()); + return fullname().compareToIgnoreCase(o.fullname()); } @Override @@ -707,7 +704,7 @@ public class TileInfoPanel extends JSplitPane protected static final int EDGE_TILE_V = 4; /** An ArrayList of TileSetRecords for each layer. */ - protected ArrayList[] _layerSets; + protected Map> _layerSets = Maps.newHashMap(); /** The original number of TileSetRecords for each layer. */ protected int[] _layerLengths; diff --git a/src/java/com/threerings/stage/tools/editor/util/EditorContext.java b/src/java/com/threerings/stage/tools/editor/util/EditorContext.java index 1ab07fcf..e4b4280c 100644 --- a/src/java/com/threerings/stage/tools/editor/util/EditorContext.java +++ b/src/java/com/threerings/stage/tools/editor/util/EditorContext.java @@ -45,5 +45,5 @@ public interface EditorContext extends StageContext /** * Inserts all known scene types into the supplied list. */ - public void enumerateSceneTypes (List types); + public void enumerateSceneTypes (List types); } diff --git a/src/java/com/threerings/stage/tools/xml/StageSceneRuleSet.java b/src/java/com/threerings/stage/tools/xml/StageSceneRuleSet.java index c5ee0b37..85714dcd 100644 --- a/src/java/com/threerings/stage/tools/xml/StageSceneRuleSet.java +++ b/src/java/com/threerings/stage/tools/xml/StageSceneRuleSet.java @@ -21,6 +21,7 @@ package com.threerings.stage.tools.xml; +import com.threerings.whirled.data.SceneModel; import com.threerings.whirled.tools.xml.SceneRuleSet; import com.threerings.stage.data.StageScene; @@ -32,7 +33,7 @@ import com.threerings.stage.data.StageSceneModel; public class StageSceneRuleSet extends SceneRuleSet { @Override - protected Class getSceneClass () + protected Class getSceneClass () { return StageSceneModel.class; } diff --git a/src/java/com/threerings/stage/util/PlacementConstraints.java b/src/java/com/threerings/stage/util/PlacementConstraints.java index ed5928ad..e03204cb 100644 --- a/src/java/com/threerings/stage/util/PlacementConstraints.java +++ b/src/java/com/threerings/stage/util/PlacementConstraints.java @@ -23,9 +23,11 @@ package com.threerings.stage.util; import java.awt.Rectangle; -import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; + +import com.google.common.collect.Lists; import com.samskivert.util.ListUtil; import com.threerings.util.DirectionCodes; @@ -252,9 +254,9 @@ public class PlacementConstraints protected boolean hasOnSurface (ObjectData data, ObjectData[] added, ObjectData[] removed) { - ArrayList objects = getObjectData(data.bounds, added, removed); + List objects = getObjectData(data.bounds, added, removed); for (int i = 0, size = objects.size(); i < size; i++) { - ObjectData odata = (ObjectData)objects.get(i); + ObjectData odata = objects.get(i); if (odata.tile.hasConstraint(ObjectTileSet.ON_SURFACE) && !isOnSurface(odata, added, removed)) { return true; @@ -270,9 +272,9 @@ public class PlacementConstraints protected boolean hasOnWall (ObjectData data, ObjectData[] added, ObjectData[] removed, int dir) { - ArrayList objects = getObjectData(data.bounds, added, removed); + List objects = getObjectData(data.bounds, added, removed); for (int i = 0, size = objects.size(); i < size; i++) { - ObjectData odata = (ObjectData)objects.get(i); + ObjectData odata = objects.get(i); if (getConstraintDirection(odata, ObjectTileSet.ON_WALL) == dir && !isOnWall(odata, added, removed, dir)) { return true; @@ -290,10 +292,10 @@ public class PlacementConstraints { DirectionHeight dirheight = new DirectionHeight(); - ArrayList objects = getObjectData(getAdjacentEdge(data.bounds, + List objects = getObjectData(getAdjacentEdge(data.bounds, DirectionUtil.getOpposite(dir)), added, removed); for (int i = 0, size = objects.size(); i < size; i++) { - ObjectData odata = (ObjectData)objects.get(i); + ObjectData odata = objects.get(i); if (getConstraintDirectionHeight(odata, ObjectTileSet.ATTACH, dirheight) && !isAttached(odata, added, removed, dirheight.dir, dirheight.low)) { @@ -314,9 +316,9 @@ public class PlacementConstraints // grow the ObjectData bounds 1 square in each direction _constrainRect.setBounds(r.x - 1, r.y - 1, r.width + 2, r.height + 2); - ArrayList objects = getObjectData(_constrainRect, added, removed); + List objects = getObjectData(_constrainRect, added, removed); for (int i = 0, size = objects.size(); i < size; i++) { - ObjectData odata = (ObjectData)objects.get(i); + ObjectData odata = objects.get(i); int dir = getConstraintDirection(odata, ObjectTileSet.SPACE); if (dir != NONE && !hasSpace(odata, added, removed, dir)) { return true; @@ -378,12 +380,12 @@ public class PlacementConstraints protected boolean isCovered (Rectangle rect, ObjectData[] added, ObjectData[] removed, String constraint, String altstraint) { - ArrayList objects = getObjectData(rect, added, removed); + List objects = getObjectData(rect, added, removed); for (int y = rect.y, ymax = rect.y + rect.height; y < ymax; y++) { for (int x = rect.x, xmax = rect.x + rect.width; x < xmax; x++) { boolean covered = false; for (int i = 0, size = objects.size(); i < size; i++) { - ObjectData data = (ObjectData)objects.get(i); + ObjectData data = objects.get(i); if (data.bounds.contains(x, y) && (constraint == null || data.tile.hasConstraint(constraint) || (altstraint != null && @@ -495,13 +497,13 @@ public class PlacementConstraints * @param added an array of objects to add to the search * @param removed an array of objects to exclude from the search */ - protected ArrayList getObjectData (Rectangle rect, ObjectData[] added, + protected List getObjectData (Rectangle rect, ObjectData[] added, ObjectData[] removed) { - ArrayList list = new ArrayList(); + List list = Lists.newArrayList(); - for (Iterator it = _objectData.values().iterator(); it.hasNext(); ) { - ObjectData data = (ObjectData)it.next(); + for (Iterator it = _objectData.values().iterator(); it.hasNext(); ) { + ObjectData data = it.next(); if (rect.intersects(data.bounds) && !ListUtil.contains(removed, data)) { list.add(data); diff --git a/src/java/com/threerings/stage/util/StageSceneUtil.java b/src/java/com/threerings/stage/util/StageSceneUtil.java index 62b25565..da73c879 100644 --- a/src/java/com/threerings/stage/util/StageSceneUtil.java +++ b/src/java/com/threerings/stage/util/StageSceneUtil.java @@ -25,6 +25,7 @@ import java.awt.Point; import java.awt.Rectangle; import java.util.ArrayList; import java.util.Comparator; +import java.util.List; import com.samskivert.util.SortableArrayList; import com.threerings.util.DirectionCodes; @@ -242,9 +243,9 @@ public class StageSceneUtil /** * Computes a list of the valid locations in this cluster. */ - public static ArrayList getClusterLocs (Cluster cluster) + public static List getClusterLocs (Cluster cluster) { - ArrayList list = new ArrayList(); + List list = new ArrayList(); // convert our tile coordinates into a cartesian coordinate system // with units equal to one fine coordinate in size @@ -340,7 +341,7 @@ public class StageSceneUtil { // generate a list of the tile coordinates of all squares around // this footprint - SortableArrayList spots = new SortableArrayList(); + SortableArrayList spots = new SortableArrayList(); for (int dd = 1; dd <= dist; dd++) { int yy1 = foot.y-dd, yy2 = foot.y+foot.height+dd-1; @@ -372,9 +373,9 @@ public class StageSceneUtil // sort them in order of closeness to the players current // coordinate - spots.sort(new Comparator() { - public int compare (Object o1, Object o2) { - return dist((StageLocation)o1) - dist((StageLocation)o2); + spots.sort(new Comparator() { + public int compare (StageLocation o1, StageLocation o2) { + return dist(o1) - dist(o2); } private final int dist (StageLocation l) { return Math.round(100*MathUtil.distance( @@ -385,7 +386,7 @@ public class StageSceneUtil // return the first spot that can be "traversed" which we're // taking to mean "stood upon" for (int ii = 0, ll = spots.size(); ii < ll; ii++) { - StageLocation loc = (StageLocation)spots.get(ii); + StageLocation loc = spots.get(ii); if (pred.canTraverse(traverser, loc.x, loc.y)) { // convert to full coordinates loc.x = MisoUtil.toFull(loc.x, 2); diff --git a/src/java/com/threerings/whirled/client/SceneDirector.java b/src/java/com/threerings/whirled/client/SceneDirector.java index f519d01f..ae89ac6c 100644 --- a/src/java/com/threerings/whirled/client/SceneDirector.java +++ b/src/java/com/threerings/whirled/client/SceneDirector.java @@ -22,6 +22,7 @@ package com.threerings.whirled.client; import java.io.IOException; +import java.util.Map; import com.samskivert.util.LRUHashMap; import com.samskivert.util.ResultListener; @@ -164,7 +165,7 @@ public class SceneDirector extends BasicDirector * and our pending scene mode is loaded from the scene repository. This can be called by * cooperating directors that need to coopt the moveTo process. */ - public boolean prepareMoveTo (int sceneId, ResultListener rl) + public boolean prepareMoveTo (int sceneId, ResultListener rl) { // first check to see if our observers are happy with this move request if (!_locdir.mayMoveTo(sceneId, rl)) { @@ -449,7 +450,7 @@ public class SceneDirector extends BasicDirector { // first look in the model cache Integer key = Integer.valueOf(sceneId); - SceneModel model = (SceneModel)_scache.get(key); + SceneModel model = _scache.get(key); // load from the repository if it's not cached if (model == null) { @@ -526,7 +527,7 @@ public class SceneDirector extends BasicDirector protected SceneFactory _fact; /** A cache of scene model information. */ - protected LRUHashMap _scache = new LRUHashMap(5); + protected Map _scache = new LRUHashMap(5); /** The display scene object for the scene we currently occupy. */ protected Scene _scene; diff --git a/src/java/com/threerings/whirled/data/SceneMarshaller.java b/src/java/com/threerings/whirled/data/SceneMarshaller.java index bdad0c60..be4acb96 100644 --- a/src/java/com/threerings/whirled/data/SceneMarshaller.java +++ b/src/java/com/threerings/whirled/data/SceneMarshaller.java @@ -38,7 +38,7 @@ public class SceneMarshaller extends InvocationMarshaller implements SceneService { /** - * Marshalls results to implementations of {@link SceneMoveListener}. + * Marshalls results to implementations of {@link SceneService.SceneMoveListener}. */ public static class SceneMoveMarshaller extends ListenerMarshaller implements SceneMoveListener diff --git a/src/java/com/threerings/whirled/server/persist/SceneUpdateMarshaller.java b/src/java/com/threerings/whirled/server/persist/SceneUpdateMarshaller.java index 349f8222..e02fe8b9 100644 --- a/src/java/com/threerings/whirled/server/persist/SceneUpdateMarshaller.java +++ b/src/java/com/threerings/whirled/server/persist/SceneUpdateMarshaller.java @@ -48,9 +48,9 @@ public class SceneUpdateMarshaller * used again. If you need to remove an update type, it should be replaced with null in the * class list to reserve the old type id that it represented. */ - public SceneUpdateMarshaller (Class ... typesClasses) + public SceneUpdateMarshaller (Class ... typesClasses) { - for (Class c : typesClasses) { + for (Class c : typesClasses) { registerUpdateClass(c); } } @@ -66,7 +66,7 @@ public class SceneUpdateMarshaller /** * Returns the type code that is assigned to the specified SceneUpdate class, or -1. */ - public int getUpdateType (Class typeClass) + public int getUpdateType (Class typeClass) { Integer type = _classToType.get(typeClass); return (type == null) ? -1 : type.intValue(); @@ -75,7 +75,7 @@ public class SceneUpdateMarshaller /** * Returns the update class associated with the specified type code, or null. */ - public Class getUpdateClass (int type) + public Class getUpdateClass (int type) { return _typeToClass.get(type); } @@ -105,7 +105,7 @@ public class SceneUpdateMarshaller Exception error = null; try { - Class updateClass = getUpdateClass(updateType); + Class updateClass = getUpdateClass(updateType); if (updateClass == null) { errmsg = "No class registered for update type [sceneId=" + sceneId + ", sceneVersion=" + sceneVersion + ", updateType=" + updateType + "]."; @@ -146,7 +146,7 @@ public class SceneUpdateMarshaller * Registers the update class with the update factory. This should be called below in the * canonical list of update registrations. */ - protected void registerUpdateClass (Class typeClass) + protected void registerUpdateClass (Class typeClass) { // ensure that callers can't fuck up the reciprocal nature of our two maps. if (_classToType.containsKey(typeClass)) { @@ -164,10 +164,10 @@ public class SceneUpdateMarshaller } /** The table mapping update types to classes. */ - protected HashIntMap _typeToClass = new HashIntMap(); + protected HashIntMap> _typeToClass = new HashIntMap>(); /** The table mapping update classes to types. */ - protected HashMap _classToType = new HashMap(); + protected HashMap,Integer> _classToType = new HashMap,Integer>(); /** A counter used in assigning update types to classes. */ protected int _nextType = 0; diff --git a/src/java/com/threerings/whirled/spot/client/SpotSceneDirector.java b/src/java/com/threerings/whirled/spot/client/SpotSceneDirector.java index b632e806..1382cb12 100644 --- a/src/java/com/threerings/whirled/spot/client/SpotSceneDirector.java +++ b/src/java/com/threerings/whirled/spot/client/SpotSceneDirector.java @@ -39,6 +39,7 @@ import com.threerings.crowd.chat.data.ChatCodes; import com.threerings.crowd.client.LocationAdapter; import com.threerings.crowd.client.LocationDirector; import com.threerings.crowd.data.BodyObject; +import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceObject; import com.threerings.whirled.client.SceneDirector; @@ -58,7 +59,7 @@ import static com.threerings.whirled.spot.Log.log; * Extends the standard scene director with facilities to move between locations within a scene. */ public class SpotSceneDirector extends BasicDirector - implements SpotCodes, Subscriber, AttributeChangeListener + implements SpotCodes, Subscriber, AttributeChangeListener { /** * Creates a new spot scene director with the specified context and which will cooperate with @@ -121,7 +122,7 @@ public class SpotSceneDirector extends BasicDirector * request will be made and when the response is received, the location observers will be * notified of success or failure. */ - public boolean traversePortal (int portalId, ResultListener rl) + public boolean traversePortal (int portalId, ResultListener rl) { // look up the destination scene and location SpotScene scene = (SpotScene)_scdir.getScene(); @@ -178,7 +179,7 @@ public class SpotSceneDirector extends BasicDirector * anticipation of a successful location change (like by starting a sprite moving toward the * new location), but backtrack if it finds out that the location change failed. */ - public void changeLocation (Location loc, final ResultListener listener) + public void changeLocation (Location loc, final ResultListener listener) { // refuse if there's a pending location change or if we're already at the specified // location @@ -243,7 +244,7 @@ public class SpotSceneDirector extends BasicDirector * user's cluster. * @param listener will be notified of success or failure. */ - public void joinCluster (int froid, final ResultListener listener) + public void joinCluster (int froid, final ResultListener listener) { SpotScene scene = (SpotScene)_scdir.getScene(); if (scene == null) { diff --git a/src/java/com/threerings/whirled/spot/data/Cluster.java b/src/java/com/threerings/whirled/spot/data/Cluster.java index 454ffc64..e764006e 100644 --- a/src/java/com/threerings/whirled/spot/data/Cluster.java +++ b/src/java/com/threerings/whirled/spot/data/Cluster.java @@ -41,7 +41,7 @@ public class Cluster extends Rectangle public int clusterOid; // documentation inherited - public Comparable getKey () + public Comparable getKey () { if (_key == null) { _key = Integer.valueOf(clusterOid); diff --git a/src/java/com/threerings/whirled/spot/data/SceneLocation.java b/src/java/com/threerings/whirled/spot/data/SceneLocation.java index fa39f254..07293948 100644 --- a/src/java/com/threerings/whirled/spot/data/SceneLocation.java +++ b/src/java/com/threerings/whirled/spot/data/SceneLocation.java @@ -55,7 +55,7 @@ public class SceneLocation extends SimpleStreamableObject } // documentation inherited - public Comparable getKey () + public Comparable getKey () { if (_key == null) { _key = Integer.valueOf(bodyOid); diff --git a/src/java/com/threerings/whirled/spot/data/SpotScene.java b/src/java/com/threerings/whirled/spot/data/SpotScene.java index 2440bed2..572e2cbb 100644 --- a/src/java/com/threerings/whirled/spot/data/SpotScene.java +++ b/src/java/com/threerings/whirled/spot/data/SpotScene.java @@ -43,7 +43,7 @@ public interface SpotScene /** * Returns an iterator over the portals in this scene. */ - public Iterator getPortals (); + public Iterator getPortals (); /** * Returns the portal id that should be assigned to the next portal diff --git a/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java b/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java index 42259f70..97abbf1b 100644 --- a/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java +++ b/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java @@ -452,7 +452,7 @@ public class SpotSceneManager extends SceneManager /** * Used to manage clusters which are groups of users that can chat to one another. */ - protected class ClusterRecord extends HashIntMap + protected class ClusterRecord extends HashIntMap { public ClusterRecord () { @@ -460,9 +460,7 @@ public class SpotSceneManager extends SceneManager _clusters.put(_clobj.getOid(), this); // let any mapped users know about our cluster - Iterator iter = values().iterator(); - while (iter.hasNext()) { - ClusteredBodyObject body = (ClusteredBodyObject)iter.next(); + for (ClusteredBodyObject body : values()) { body.setClusterOid(_clobj.getOid()); _clobj.addToOccupants(((BodyObject)body).getOid()); } @@ -495,7 +493,7 @@ public class SpotSceneManager extends SceneManager // make sure our intrepid joiner is not in any another cluster removeFromCluster(body.getOid()); - put(body.getOid(), body); + put(body.getOid(), (ClusteredBodyObject)body); _ssobj.startTransaction(); try { body.startTransaction(); diff --git a/src/java/com/threerings/whirled/spot/tools/xml/SpotSceneRuleSet.java b/src/java/com/threerings/whirled/spot/tools/xml/SpotSceneRuleSet.java index bfc74439..e4a0f32a 100644 --- a/src/java/com/threerings/whirled/spot/tools/xml/SpotSceneRuleSet.java +++ b/src/java/com/threerings/whirled/spot/tools/xml/SpotSceneRuleSet.java @@ -110,9 +110,9 @@ public abstract class SpotSceneRuleSet implements NestableRuleSet throws Exception { Portal portal = (Portal) digester.peek(); - Class portalClass = portal.getClass(); + Class portalClass = portal.getClass(); Location loc = portal.loc; - Class locClass = loc.getClass(); + Class locClass = loc.getClass(); // iterate over the attributes, setting public fields where // applicable diff --git a/src/java/com/threerings/whirled/spot/tools/xml/SpotSceneWriter.java b/src/java/com/threerings/whirled/spot/tools/xml/SpotSceneWriter.java index a2657185..30f7e4bd 100644 --- a/src/java/com/threerings/whirled/spot/tools/xml/SpotSceneWriter.java +++ b/src/java/com/threerings/whirled/spot/tools/xml/SpotSceneWriter.java @@ -87,7 +87,7 @@ public class SpotSceneWriter { // we just add all the visible fields of the location, but something // more sophisticated could be done - Class clazz = portalLoc.getClass(); + Class clazz = portalLoc.getClass(); Field[] fields = clazz.getFields(); for (int ii=0; ii < fields.length; ii++) { try { diff --git a/src/java/com/threerings/whirled/tools/xml/SceneRuleSet.java b/src/java/com/threerings/whirled/tools/xml/SceneRuleSet.java index 322a08fd..bda4c0ec 100644 --- a/src/java/com/threerings/whirled/tools/xml/SceneRuleSet.java +++ b/src/java/com/threerings/whirled/tools/xml/SceneRuleSet.java @@ -53,7 +53,7 @@ public class SceneRuleSet implements NestableRuleSet * This indicates the class (which should extend {@link SceneModel}) * to be instantiated during the parsing process. */ - protected Class getSceneClass () + protected Class getSceneClass () { return SceneModel.class; } diff --git a/src/java/com/threerings/whirled/tools/xml/SceneWriter.java b/src/java/com/threerings/whirled/tools/xml/SceneWriter.java index ac50d131..9c4608e9 100644 --- a/src/java/com/threerings/whirled/tools/xml/SceneWriter.java +++ b/src/java/com/threerings/whirled/tools/xml/SceneWriter.java @@ -25,6 +25,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.HashMap; +import java.util.Map; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; @@ -49,7 +50,7 @@ public class SceneWriter * Registers a writer for writing auxiliary scene models of the * supplied class. */ - public void registerAuxWriter (Class aclass, NestableWriter writer) + public void registerAuxWriter (Class aclass, NestableWriter writer) { _auxers.put(aclass, writer); } @@ -107,8 +108,7 @@ public class SceneWriter // write out our auxiliary scene models for (int ii = 0; ii < model.auxModels.length; ii++) { AuxModel amodel = model.auxModels[ii]; - NestableWriter awriter = (NestableWriter) - _auxers.get(amodel.getClass()); + NestableWriter awriter = _auxers.get(amodel.getClass()); if (awriter != null) { awriter.write(amodel, writer); } else { @@ -118,5 +118,5 @@ public class SceneWriter } } - protected HashMap _auxers = new HashMap(); + protected Map, NestableWriter> _auxers = new HashMap, NestableWriter>(); } diff --git a/src/java/com/threerings/whirled/zone/client/ZoneDirector.java b/src/java/com/threerings/whirled/zone/client/ZoneDirector.java index db123fb8..e63f556c 100644 --- a/src/java/com/threerings/whirled/zone/client/ZoneDirector.java +++ b/src/java/com/threerings/whirled/zone/client/ZoneDirector.java @@ -109,7 +109,7 @@ public class ZoneDirector extends BasicDirector * made and when the response is received, the location observers will be notified of success * or failure. */ - public boolean moveTo (int zoneId, int sceneId, ResultListener rl) + public boolean moveTo (int zoneId, int sceneId, ResultListener rl) { // make sure the zoneId and sceneId are valid if (zoneId < 0 || sceneId < 0) { diff --git a/src/java/com/threerings/whirled/zone/data/ZoneMarshaller.java b/src/java/com/threerings/whirled/zone/data/ZoneMarshaller.java index 64c97b5e..2079494d 100644 --- a/src/java/com/threerings/whirled/zone/data/ZoneMarshaller.java +++ b/src/java/com/threerings/whirled/zone/data/ZoneMarshaller.java @@ -40,7 +40,7 @@ public class ZoneMarshaller extends InvocationMarshaller implements ZoneService { /** - * Marshalls results to implementations of {@link ZoneMoveListener}. + * Marshalls results to implementations of {@link ZoneService.ZoneMoveListener}. */ public static class ZoneMoveMarshaller extends ListenerMarshaller implements ZoneMoveListener