A healthy swig of google-collections
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@839 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -39,6 +38,8 @@ import javax.swing.JComboBox;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
|
||||
import com.threerings.micasa.util.MiCasaContext;
|
||||
@@ -119,8 +120,8 @@ public class LobbySelector extends JPanel
|
||||
public void gotCategories (String[] categories)
|
||||
{
|
||||
// append these to our "unselected" item
|
||||
for (int i = 0; i < categories.length; i++) {
|
||||
_combo.addItem(categories[i]);
|
||||
for (String categorie : categories) {
|
||||
_combo.addItem(categorie);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +223,7 @@ public class LobbySelector extends JPanel
|
||||
protected JComboBox _combo;
|
||||
protected JList _loblist;
|
||||
|
||||
protected Map<String, DefaultListModel> _catlists = new HashMap<String, DefaultListModel>();
|
||||
protected Map<String, DefaultListModel> _catlists = Maps.newHashMap();
|
||||
protected String _pendingCategory;
|
||||
|
||||
protected static final String CAT_FIRST_ITEM = "<categories...>";
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
|
||||
package com.threerings.micasa.simulator.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@@ -174,7 +174,7 @@ public class SimulatorManager
|
||||
}
|
||||
|
||||
/** The simulant body objects. */
|
||||
protected List<ClientObject> _sims = new ArrayList<ClientObject>();
|
||||
protected List<ClientObject> _sims = Lists.newArrayList();
|
||||
|
||||
/** The game object for the game being created. */
|
||||
protected GameObject _gobj;
|
||||
|
||||
@@ -34,6 +34,8 @@ import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.samskivert.util.ObserverList;
|
||||
import com.samskivert.util.Predicate;
|
||||
import com.samskivert.util.QuickSort;
|
||||
@@ -259,8 +261,8 @@ public abstract class CardPanel extends VirtualMediaPanel
|
||||
public void clearHandSelection ()
|
||||
{
|
||||
CardSprite[] sprites = getSelectedHandSprites();
|
||||
for (int i = 0; i < sprites.length; i++) {
|
||||
deselectHandSprite(sprites[i]);
|
||||
for (CardSprite sprite : sprites) {
|
||||
deselectHandSprite(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,11 +396,11 @@ public abstract class CardPanel extends VirtualMediaPanel
|
||||
{
|
||||
// fly each sprite over, removing it from the hand immediately and from the board when it
|
||||
// finishes its path
|
||||
for (int i = 0; i < cards.length; i++) {
|
||||
removeFromHand(cards[i]);
|
||||
for (CardSprite card : cards) {
|
||||
removeFromHand(card);
|
||||
LinePath flight = new LinePath(dest, flightDuration);
|
||||
cards[i].addSpriteObserver(_pathEndRemover);
|
||||
cards[i].moveAndFadeOut(flight, flightDuration, fadePortion);
|
||||
card.addSpriteObserver(_pathEndRemover);
|
||||
card.moveAndFadeOut(flight, flightDuration, fadePortion);
|
||||
}
|
||||
|
||||
// adjust the hand to cover the hole
|
||||
@@ -433,21 +435,21 @@ public abstract class CardPanel extends VirtualMediaPanel
|
||||
|
||||
// then set the layers and fly the cards in
|
||||
int size = _handSprites.size();
|
||||
for (int i = 0; i < sprites.length; i++) {
|
||||
int idx = _handSprites.indexOf(sprites[i]);
|
||||
sprites[i].setLocation(src.x, src.y);
|
||||
sprites[i].setRenderOrder(idx);
|
||||
sprites[i].addSpriteObserver(_handSpriteObserver);
|
||||
addSprite(sprites[i]);
|
||||
for (CardSprite sprite : sprites) {
|
||||
int idx = _handSprites.indexOf(sprite);
|
||||
sprite.setLocation(src.x, src.y);
|
||||
sprite.setRenderOrder(idx);
|
||||
sprite.addSpriteObserver(_handSpriteObserver);
|
||||
addSprite(sprite);
|
||||
|
||||
// create a path sequence containing flight, pause, and drop
|
||||
ArrayList<Path> paths = new ArrayList<Path>();
|
||||
ArrayList<Path> paths = Lists.newArrayList();
|
||||
Point hp2 = new Point(getHandX(size, idx), _handLocation.y),
|
||||
hp1 = new Point(hp2.x, hp2.y - _selectedCardOffset);
|
||||
paths.add(new LinePath(hp1, flightDuration));
|
||||
paths.add(new LinePath(hp1, pauseDuration));
|
||||
paths.add(new LinePath(hp2, dropDuration));
|
||||
sprites[i].moveAndFadeIn(new PathSequence(paths), flightDuration +
|
||||
sprite.moveAndFadeIn(new PathSequence(paths), flightDuration +
|
||||
pauseDuration + dropDuration, fadePortion);
|
||||
}
|
||||
}
|
||||
@@ -587,11 +589,11 @@ public abstract class CardPanel extends VirtualMediaPanel
|
||||
public void flyFromBoard (CardSprite[] cards, Point dest, long flightDuration,
|
||||
float fadePortion)
|
||||
{
|
||||
for (int i = 0; i < cards.length; i++) {
|
||||
for (CardSprite card : cards) {
|
||||
LinePath flight = new LinePath(dest, flightDuration);
|
||||
cards[i].addSpriteObserver(_pathEndRemover);
|
||||
cards[i].moveAndFadeOut(flight, flightDuration, fadePortion);
|
||||
_boardSprites.remove(cards[i]);
|
||||
card.addSpriteObserver(_pathEndRemover);
|
||||
card.moveAndFadeOut(flight, flightDuration, fadePortion);
|
||||
_boardSprites.remove(card);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,13 +610,13 @@ public abstract class CardPanel extends VirtualMediaPanel
|
||||
public void flyFromBoard (CardSprite[] cards, Point dest1, Point dest2, long flightDuration,
|
||||
float fadePortion)
|
||||
{
|
||||
for (int i = 0; i < cards.length; i++) {
|
||||
for (CardSprite card : cards) {
|
||||
PathSequence flight = new PathSequence(
|
||||
new LinePath(dest1, flightDuration/2),
|
||||
new LinePath(dest1, dest2, flightDuration/2));
|
||||
cards[i].addSpriteObserver(_pathEndRemover);
|
||||
cards[i].moveAndFadeOut(flight, flightDuration, fadePortion);
|
||||
_boardSprites.remove(cards[i]);
|
||||
card.addSpriteObserver(_pathEndRemover);
|
||||
card.moveAndFadeOut(flight, flightDuration, fadePortion);
|
||||
_boardSprites.remove(card);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1072,11 +1074,10 @@ public abstract class CardPanel extends VirtualMediaPanel
|
||||
protected CardSprite _activeCardSprite;
|
||||
|
||||
/** The sprites for cards within the hand. */
|
||||
protected ArrayList<CardSprite> _handSprites = new ArrayList<CardSprite>();
|
||||
protected ArrayList<CardSprite> _handSprites = Lists.newArrayList();
|
||||
|
||||
/** The sprites for cards within the hand that have been selected. */
|
||||
protected ArrayList<CardSprite> _selectedHandSprites =
|
||||
new ArrayList<CardSprite>();
|
||||
protected ArrayList<CardSprite> _selectedHandSprites = Lists.newArrayList();
|
||||
|
||||
/** The current selection mode for the hand. */
|
||||
protected int _handSelectionMode;
|
||||
@@ -1103,7 +1104,7 @@ public abstract class CardPanel extends VirtualMediaPanel
|
||||
protected int _selectedCardOffset;
|
||||
|
||||
/** The sprites for cards on the board. */
|
||||
protected ArrayList<CardSprite> _boardSprites = new ArrayList<CardSprite>();
|
||||
protected ArrayList<CardSprite> _boardSprites = Lists.newArrayList();
|
||||
|
||||
/** The hand sprite observer instance. */
|
||||
protected HandSpriteObserver _handSpriteObserver = new HandSpriteObserver();
|
||||
|
||||
@@ -21,10 +21,11 @@
|
||||
|
||||
package com.threerings.parlor.card.trick.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.samskivert.util.ArrayUtil;
|
||||
import com.samskivert.util.Interval;
|
||||
import com.samskivert.util.RandomUtil;
|
||||
@@ -451,7 +452,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
|
||||
*/
|
||||
protected Card pickRandomPlayableCard (Hand hand)
|
||||
{
|
||||
List<Card> playableCards = new ArrayList<Card>();
|
||||
List<Card> playableCards = Lists.newArrayList();
|
||||
for (int i = 0; i < hand.size(); i++) {
|
||||
Card card = hand.get(i);
|
||||
if (_trickCardGame.isCardPlayable(hand, card)) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import com.samskivert.util.ArrayIntSet;
|
||||
import com.samskivert.util.ListUtil;
|
||||
@@ -129,8 +130,8 @@ public class Table
|
||||
@ActionScript(omit=true)
|
||||
public boolean isEmpty ()
|
||||
{
|
||||
for (int i = 0; i < bodyOids.length; i++) {
|
||||
if (bodyOids[i] != 0) {
|
||||
for (int bodyOid : bodyOids) {
|
||||
if (bodyOid != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -144,8 +145,8 @@ public class Table
|
||||
{
|
||||
int count = 0;
|
||||
if (players != null) {
|
||||
for (int ii = 0; ii < players.length; ii++) {
|
||||
if (players[ii] != null) {
|
||||
for (Name player : players) {
|
||||
if (player != null) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -270,7 +271,7 @@ public class Table
|
||||
public void addBannedUser (Name player)
|
||||
{
|
||||
if (_bannedUsers == null) {
|
||||
_bannedUsers = new HashSet<Name>();
|
||||
_bannedUsers = Sets.newHashSet();
|
||||
}
|
||||
|
||||
_bannedUsers.add(player);
|
||||
@@ -373,10 +374,10 @@ public class Table
|
||||
} else {
|
||||
// for a team game, make sure each team has the minimum players
|
||||
int[][] teams = tconfig.teamMemberIndices;
|
||||
for (int ii=0; ii < teams.length; ii++) {
|
||||
for (int[] team : teams) {
|
||||
int teamCount = 0;
|
||||
for (int jj=0; jj < teams[ii].length; jj++) {
|
||||
if (players[teams[ii][jj]] != null) {
|
||||
for (int jj=0; jj < team.length; jj++) {
|
||||
if (players[team[jj]] != null) {
|
||||
teamCount++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,10 @@
|
||||
|
||||
package com.threerings.parlor.game.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
@@ -121,7 +122,7 @@ public abstract class GameConfig extends PlaceConfig
|
||||
*/
|
||||
public List<String> getDescription ()
|
||||
{
|
||||
return new ArrayList<String>(); // nothing by default
|
||||
return Lists.newArrayList(); // nothing by default
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -99,7 +99,7 @@ public class RatingRepository extends DepotRepository
|
||||
*/
|
||||
public List<RatingRecord> getRatings (int playerId, long since, int count)
|
||||
{
|
||||
ArrayList<QueryClause> clauses = new ArrayList<QueryClause>();
|
||||
ArrayList<QueryClause> clauses = Lists.newArrayList();
|
||||
if (since > 0L) {
|
||||
Timestamp when = new Timestamp(System.currentTimeMillis() - since);
|
||||
clauses.add(new Where(new And(new Equals(RatingRecord.PLAYER_ID, playerId),
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@@ -146,7 +147,7 @@ public class TourneyRepository extends JORARepository
|
||||
throws PersistenceException
|
||||
{
|
||||
ArrayList<TourneyRecord> recordList = loadAll(_ttable, "");
|
||||
ArrayList<TourneyConfig> configList = new ArrayList<TourneyConfig>(recordList.size());
|
||||
ArrayList<TourneyConfig> configList = Lists.newArrayListWithCapacity(recordList.size());
|
||||
for (TourneyRecord record : recordList) {
|
||||
configList.add(record.getTourneyConfig());
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ import javax.swing.Icon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.samskivert.swing.util.SwingUtil;
|
||||
|
||||
import com.threerings.util.Name;
|
||||
@@ -213,7 +215,7 @@ public class TurnDisplay extends JPanel
|
||||
protected TurnGameObject _turnObj;
|
||||
|
||||
/** A mapping of the labels currently associated with each player. */
|
||||
protected HashMap<Name,JLabel> _labels = new HashMap<Name,JLabel>();
|
||||
protected HashMap<Name,JLabel> _labels = Maps.newHashMap();
|
||||
|
||||
/** The game-specified player icons. */
|
||||
protected Icon[] _playerIcons;
|
||||
|
||||
@@ -21,11 +21,12 @@
|
||||
|
||||
package com.threerings.parlor.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.samskivert.util.CollectionUtil;
|
||||
import com.samskivert.util.Interval;
|
||||
import com.samskivert.util.RandomUtil;
|
||||
@@ -118,10 +119,10 @@ public class RobotPlayer extends Interval
|
||||
protected long _robotDelay = DEFAULT_ROBOT_DELAY;
|
||||
|
||||
/** The list of available key press action commands. */
|
||||
protected List<String> _press = new ArrayList<String>();
|
||||
protected List<String> _press = Lists.newArrayList();
|
||||
|
||||
/** The list of available key release action commands. */
|
||||
protected List<String> _release = new ArrayList<String>();
|
||||
protected List<String> _release = Lists.newArrayList();
|
||||
|
||||
/** The key translator that describes available keys and commands. */
|
||||
protected KeyTranslator _xlate;
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
package com.threerings.puzzle.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import java.awt.Color;
|
||||
@@ -31,6 +30,8 @@ import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.samskivert.swing.Label;
|
||||
@@ -375,10 +376,10 @@ public abstract class PuzzleBoardView extends VirtualMediaPanel
|
||||
protected Rectangle _bounds;
|
||||
|
||||
/** The action animations on the board. */
|
||||
protected List<Animation> _actionAnims = new ArrayList<Animation>();
|
||||
protected List<Animation> _actionAnims = Lists.newArrayList();
|
||||
|
||||
/** The action sprites on the board. */
|
||||
protected List<Sprite> _actionSprites = new ArrayList<Sprite>();
|
||||
protected List<Sprite> _actionSprites = Lists.newArrayList();
|
||||
|
||||
/** Prevents certain animations from overlapping others. */
|
||||
protected AnimationArranger _avoidArranger;
|
||||
|
||||
@@ -21,10 +21,11 @@
|
||||
|
||||
package com.threerings.stage.client;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.threerings.media.image.ColorPository;
|
||||
import com.threerings.media.image.Colorization;
|
||||
import com.threerings.media.tile.TileSet;
|
||||
@@ -145,5 +146,5 @@ public class SceneColorizer implements TileSet.Colorizer
|
||||
protected StageScene _scene;
|
||||
|
||||
/** Contains our colorization class information. */
|
||||
protected Map<String, int[]> _cids = new HashMap<String, int[]>();
|
||||
protected Map<String, int[]> _cids = Maps.newHashMap();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ package com.threerings.stage.data;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
|
||||
import com.threerings.miso.data.ObjectInfo;
|
||||
@@ -223,5 +225,5 @@ public class StageScene extends SceneImpl
|
||||
protected SpotSceneImpl _sdelegate;
|
||||
|
||||
/** A list of all interesting scene objects. */
|
||||
protected ArrayList<ObjectInfo> _objects = new ArrayList<ObjectInfo>();
|
||||
protected ArrayList<ObjectInfo> _objects = Lists.newArrayList();
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ import java.util.List;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import com.samskivert.util.HashIntMap;
|
||||
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
@@ -819,14 +822,14 @@ public class StageSceneManager extends SpotSceneManager
|
||||
|
||||
/** Rectangles describing the footprints (in tile coordinates) of all
|
||||
* of our scene objects. */
|
||||
protected ArrayList<Rectangle> _footprints = new ArrayList<Rectangle>();
|
||||
protected ArrayList<Rectangle> _footprints = Lists.newArrayList();
|
||||
|
||||
/** 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<Point> _plocs = new HashSet<Point>();
|
||||
protected HashSet<Point> _plocs = Sets.newHashSet();
|
||||
|
||||
/** The dimensions of a cluster with the specified number of
|
||||
* occupants. */
|
||||
|
||||
@@ -1167,7 +1167,7 @@ public class EditorScenePanel extends StageScenePanel
|
||||
protected SceneObject _pscobj;
|
||||
|
||||
/** A list of things that will do some extra painting for us. */
|
||||
protected ArrayList<ExtrasPainter> _extras = new ArrayList<ExtrasPainter>();
|
||||
protected ArrayList<ExtrasPainter> _extras = Lists.newArrayList();
|
||||
|
||||
/** The dialog providing portal edit functionality. */
|
||||
protected PortalDialog _dialogPortal;
|
||||
|
||||
@@ -38,6 +38,8 @@ import javax.swing.JTextField;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
import javax.swing.event.PopupMenuListener;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import com.samskivert.util.Collections;
|
||||
import com.samskivert.util.ComparableArrayList;
|
||||
|
||||
@@ -45,6 +47,7 @@ import com.samskivert.swing.GroupLayout;
|
||||
import com.samskivert.swing.HGroupLayout;
|
||||
|
||||
import com.threerings.media.image.ColorPository;
|
||||
import com.threerings.media.image.ColorPository.ColorRecord;
|
||||
import com.threerings.media.tile.NoSuchTileSetException;
|
||||
import com.threerings.media.tile.RecolorableTileSet;
|
||||
import com.threerings.media.tile.TileManager;
|
||||
@@ -170,7 +173,7 @@ public class SceneInfoPanel extends JPanel
|
||||
{
|
||||
// add all possible colorization names to the list
|
||||
final TileManager tilemgr = _ctx.getTileManager();
|
||||
final HashSet<String> set = new HashSet<String>();
|
||||
final HashSet<String> set = Sets.newHashSet();
|
||||
StageMisoSceneModel msmodel = StageMisoSceneModel.getSceneModel(
|
||||
_scene.getSceneModel());
|
||||
msmodel.visitObjects(new ObjectVisitor() {
|
||||
@@ -189,8 +192,8 @@ public class SceneInfoPanel extends JPanel
|
||||
return;
|
||||
}
|
||||
if (zations != null) {
|
||||
for (int ii=0; ii < zations.length; ii++) {
|
||||
set.add(zations[ii]);
|
||||
for (String zation : zations) {
|
||||
set.add(zation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,10 +237,10 @@ public class SceneInfoPanel extends JPanel
|
||||
|
||||
ColorPository.ColorRecord[] colors = cpos.enumerateColors(cclass);
|
||||
ComparableArrayList<String> list = new ComparableArrayList<String>();
|
||||
for (int ii=0; ii < colors.length; ii++) {
|
||||
list.insertSorted(colors[ii].name);
|
||||
if (colors[ii].colorId == pick) {
|
||||
choice = colors[ii].name;
|
||||
for (ColorRecord color : colors) {
|
||||
list.insertSorted(color.name);
|
||||
if (color.colorId == pick) {
|
||||
choice = color.name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,9 +271,9 @@ public class SceneInfoPanel extends JPanel
|
||||
Object selected = _colorIds.getSelectedItem();
|
||||
int pick = -1;
|
||||
|
||||
for (int ii=0; ii < colors.length; ii++) {
|
||||
if (colors[ii].name.equals(selected)) {
|
||||
pick = colors[ii].colorId;
|
||||
for (ColorRecord color : colors) {
|
||||
if (color.name.equals(selected)) {
|
||||
pick = color.colorId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
package com.threerings.stage.tools.editor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -34,6 +33,8 @@ import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.samskivert.util.HashIntMap;
|
||||
|
||||
import com.threerings.media.tile.ImageProvider;
|
||||
@@ -110,8 +111,8 @@ public class TestTileLoader implements TileSetIDBroker
|
||||
return f.isDirectory();
|
||||
}
|
||||
});
|
||||
for (int ii=0; ii < subdirs.length; ii++) {
|
||||
loadTestTilesFromDir(subdirs[ii], sets);
|
||||
for (File subdir : subdirs) {
|
||||
loadTestTilesFromDir(subdir, sets);
|
||||
}
|
||||
|
||||
// now look for the xml file
|
||||
@@ -121,10 +122,10 @@ public class TestTileLoader implements TileSetIDBroker
|
||||
}
|
||||
});
|
||||
|
||||
for (int ii=0; ii < xml.length; ii++) {
|
||||
File xmlfile = new File(directory, xml[ii]);
|
||||
for (String element : xml) {
|
||||
File xmlfile = new File(directory, element);
|
||||
|
||||
Map<String, TileSet> tiles = new HashMap<String, TileSet>();
|
||||
Map<String, TileSet> tiles = Maps.newHashMap();
|
||||
try {
|
||||
_parser.loadTileSets(xmlfile, tiles);
|
||||
} catch (IOException ioe) {
|
||||
@@ -179,7 +180,7 @@ public class TestTileLoader implements TileSetIDBroker
|
||||
protected int _fakeID = Short.MAX_VALUE;
|
||||
|
||||
/** A mapping of pathname -> tileset id. */
|
||||
protected Map<String, Integer> _idmap = new HashMap<String, Integer>();
|
||||
protected Map<String, Integer> _idmap = Maps.newHashMap();
|
||||
|
||||
/** Our xml parser. */
|
||||
protected XMLTileSetParser _parser;
|
||||
|
||||
@@ -56,6 +56,7 @@ import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.samskivert.util.HashIntMap;
|
||||
@@ -362,26 +363,24 @@ public class TileInfoPanel extends JSplitPane
|
||||
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
|
||||
root.removeAllChildren();
|
||||
|
||||
ArrayList<TreePath> expand = new ArrayList<TreePath>();
|
||||
ArrayList<TreePath> expand = Lists.newArrayList();
|
||||
|
||||
// add all the elements in the base layer
|
||||
DefaultMutableTreeNode base = new DefaultMutableTreeNode("Base Layer");
|
||||
root.add(base);
|
||||
addNodes(base, getSortedTileSets(EditorModel.BASE_LAYER),
|
||||
"", 0, expand);
|
||||
addNodes(base, getSortedTileSets(EditorModel.BASE_LAYER), "", 0, expand);
|
||||
|
||||
// add all the elements in the object layer
|
||||
DefaultMutableTreeNode obj = new DefaultMutableTreeNode("Object Layer");
|
||||
root.add(obj);
|
||||
addNodes(obj, getSortedTileSets(EditorModel.OBJECT_LAYER),
|
||||
"", 0, expand);
|
||||
addNodes(obj, getSortedTileSets(EditorModel.OBJECT_LAYER), "", 0, expand);
|
||||
|
||||
// notify the JTree that we've put some brand new branches on it.
|
||||
model.reload();
|
||||
|
||||
// expand our container categories
|
||||
for (Iterator<TreePath> iter = expand.iterator(); iter.hasNext(); ) {
|
||||
_tsettree.expandPath(iter.next());
|
||||
for (TreePath treePath : expand) {
|
||||
_tsettree.expandPath(treePath);
|
||||
}
|
||||
|
||||
// now select the previously selected item, or the first...
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
package com.threerings.stage.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.samskivert.util.ListUtil;
|
||||
|
||||
@@ -225,20 +225,20 @@ public class PlacementConstraints
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < removed.length; i++) {
|
||||
if (removed[i].tile.hasConstraint(ObjectTileSet.SURFACE) &&
|
||||
hasOnSurface(removed[i], added, removed)) {
|
||||
for (ObjectData element : removed) {
|
||||
if (element.tile.hasConstraint(ObjectTileSet.SURFACE) &&
|
||||
hasOnSurface(element, added, removed)) {
|
||||
return MessageBundle.qualify(STAGE_MESSAGE_BUNDLE,
|
||||
"m.has_on_surface");
|
||||
}
|
||||
|
||||
int dir = getConstraintDirection(removed[i], ObjectTileSet.WALL);
|
||||
int dir = getConstraintDirection(element, ObjectTileSet.WALL);
|
||||
if (dir != NONE) {
|
||||
if (hasOnWall(removed[i], added, removed, dir)) {
|
||||
if (hasOnWall(element, added, removed, dir)) {
|
||||
return MessageBundle.qualify(STAGE_MESSAGE_BUNDLE,
|
||||
"m.has_on_wall");
|
||||
|
||||
} else if (hasAttached(removed[i], added, removed, dir)) {
|
||||
} else if (hasAttached(element, added, removed, dir)) {
|
||||
return MessageBundle.qualify(STAGE_MESSAGE_BUNDLE,
|
||||
"m.has_attached");
|
||||
}
|
||||
@@ -457,14 +457,14 @@ public class PlacementConstraints
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < constraints.length; i++) {
|
||||
if (constraints[i].startsWith(prefix)) {
|
||||
for (String constraint : constraints) {
|
||||
if (constraint.startsWith(prefix)) {
|
||||
int fromidx = prefix.length(),
|
||||
toidx = constraints[i].indexOf('_', fromidx);
|
||||
toidx = constraint.indexOf('_', fromidx);
|
||||
dirheight.dir = DirectionUtil.fromShortString(toidx == -1 ?
|
||||
constraints[i].substring(fromidx) :
|
||||
constraints[i].substring(fromidx, toidx));
|
||||
dirheight.low = constraints[i].endsWith(ObjectTileSet.LOW);
|
||||
constraint.substring(fromidx) :
|
||||
constraint.substring(fromidx, toidx));
|
||||
dirheight.low = constraint.endsWith(ObjectTileSet.LOW);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -503,17 +503,16 @@ public class PlacementConstraints
|
||||
{
|
||||
List<ObjectData> list = Lists.newArrayList();
|
||||
|
||||
for (Iterator<ObjectData> it = _objectData.values().iterator(); it.hasNext(); ) {
|
||||
ObjectData data = it.next();
|
||||
for (ObjectData data : _objectData.values()) {
|
||||
if (rect.intersects(data.bounds) && !ListUtil.contains(removed,
|
||||
data)) {
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < added.length; i++) {
|
||||
if (rect.intersects(added[i].bounds)) {
|
||||
list.add(added[i]);
|
||||
for (ObjectData element : added) {
|
||||
if (rect.intersects(element.bounds)) {
|
||||
list.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -568,9 +567,8 @@ public class PlacementConstraints
|
||||
/** The Miso scene model. */
|
||||
protected StageMisoSceneModel _mmodel;
|
||||
|
||||
/** For all objects in the scene, maps {@link ObjectInfo}s to
|
||||
* {@link ObjectData}s. */
|
||||
protected HashMap<ObjectInfo,ObjectData> _objectData = new HashMap<ObjectInfo,ObjectData>();
|
||||
/** For all objects in the scene, maps {@link ObjectInfo}s to {@link ObjectData}s. */
|
||||
protected HashMap<ObjectInfo, ObjectData> _objectData = Maps.newHashMap();
|
||||
|
||||
/** One rectangle we'll re-use for all constraints ops. */
|
||||
protected static final Rectangle _constrainRect = new Rectangle();
|
||||
|
||||
@@ -21,13 +21,14 @@
|
||||
|
||||
package com.threerings.stage.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.samskivert.util.SortableArrayList;
|
||||
|
||||
import com.threerings.util.DirectionCodes;
|
||||
@@ -247,7 +248,7 @@ public class StageSceneUtil
|
||||
*/
|
||||
public static List<SceneLocation> getClusterLocs (Cluster cluster)
|
||||
{
|
||||
List<SceneLocation> list = new ArrayList<SceneLocation>();
|
||||
List<SceneLocation> list = Lists.newArrayList();
|
||||
|
||||
// convert our tile coordinates into a cartesian coordinate system
|
||||
// with units equal to one fine coordinate in size
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.Set;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -92,7 +93,7 @@ public class StatRepository extends DepotRepository
|
||||
*/
|
||||
public ArrayList<Stat> loadStats (int playerId)
|
||||
{
|
||||
ArrayList<Stat> stats = new ArrayList<Stat>();
|
||||
ArrayList<Stat> stats = Lists.newArrayList();
|
||||
Where where = new Where(StatRecord.PLAYER_ID, playerId);
|
||||
for (StatRecord record : findAll(StatRecord.class, where)) {
|
||||
Stat stat = decodeStat(record.statCode, record.statData, record.modCount);
|
||||
@@ -117,13 +118,13 @@ public class StatRepository extends DepotRepository
|
||||
*/
|
||||
public void writeModified (int playerId, Stat[] stats)
|
||||
{
|
||||
for (int ii = 0; ii < stats.length; ii++) {
|
||||
for (Stat stat : stats) {
|
||||
try {
|
||||
if (stats[ii].getType().isPersistent() && stats[ii].isModified()) {
|
||||
updateStat(playerId, stats[ii], true);
|
||||
if (stat.getType().isPersistent() && stat.isModified()) {
|
||||
updateStat(playerId, stat, true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warning("Error flushing modified stat", "stat", stats[ii], e);
|
||||
log.warning("Error flushing modified stat", "stat", stat, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.samskivert.io.PersistenceException;
|
||||
import com.samskivert.util.HashIntMap;
|
||||
|
||||
@@ -166,7 +168,7 @@ public class SceneUpdateMarshaller
|
||||
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 = Maps.newHashMap();
|
||||
|
||||
/** A counter used in assigning update types to classes. */
|
||||
protected int _nextType = 0;
|
||||
|
||||
@@ -24,6 +24,8 @@ package com.threerings.whirled.spot.server;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.samskivert.util.HashIntMap;
|
||||
|
||||
import com.threerings.util.Name;
|
||||
@@ -591,5 +593,5 @@ public class SpotSceneManager extends SceneManager
|
||||
protected HashIntMap<ClusterRecord> _clusters = new HashIntMap<ClusterRecord>();
|
||||
|
||||
/** A mapping of entering bodies to portal ids. */
|
||||
protected HashMap<Integer, Portal> _enterers = new HashMap<Integer, Portal>();
|
||||
protected HashMap<Integer, Portal> _enterers = Maps.newHashMap();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
package com.threerings.whirled.tools.xml;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import java.io.File;
|
||||
@@ -31,6 +30,7 @@ import java.io.IOException;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.megginson.sax.DataWriter;
|
||||
|
||||
import com.threerings.tools.xml.NestableWriter;
|
||||
@@ -108,8 +108,7 @@ public class SceneWriter
|
||||
throws SAXException
|
||||
{
|
||||
// write out our auxiliary scene models
|
||||
for (int ii = 0; ii < model.auxModels.length; ii++) {
|
||||
AuxModel amodel = model.auxModels[ii];
|
||||
for (AuxModel amodel : model.auxModels) {
|
||||
NestableWriter awriter = _auxers.get(amodel.getClass());
|
||||
if (awriter != null) {
|
||||
awriter.write(amodel, writer);
|
||||
@@ -120,5 +119,5 @@ public class SceneWriter
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<Class<?>, NestableWriter> _auxers = new HashMap<Class<?>, NestableWriter>();
|
||||
protected Map<Class<?>, NestableWriter> _auxers = Maps.newHashMap();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ package com.threerings.whirled.zone.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.samskivert.util.ResultListener;
|
||||
|
||||
import com.threerings.presents.client.BasicDirector;
|
||||
@@ -289,7 +291,7 @@ public class ZoneDirector extends BasicDirector
|
||||
protected ZoneSummary _summary;
|
||||
|
||||
/** Our zone observer list. */
|
||||
protected ArrayList<ZoneObserver> _observers = new ArrayList<ZoneObserver>();
|
||||
protected ArrayList<ZoneObserver> _observers = Lists.newArrayList();
|
||||
|
||||
/** Our previous zone id. */
|
||||
protected int _previousZoneId = -1;
|
||||
|
||||
Reference in New Issue
Block a user