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