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