Whitespace

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@1031 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Dave Hoover
2010-10-15 20:16:01 +00:00
parent b443c0e48c
commit 082bd4399b
28 changed files with 233 additions and 324 deletions
@@ -30,7 +30,7 @@ public class TestFrame extends JFrame
{
public TestFrame ()
{
super("Character Builder");
super("Character Builder");
setResizable(false);
setDefaultCloseOperation(EXIT_ON_CLOSE);
@@ -35,8 +35,7 @@ import com.threerings.media.MediaPanel;
import com.threerings.media.sprite.Sprite;
/**
* A test app that is useful for visualizing paths during their
* development.
* A test app that is useful for visualizing paths during their development.
*/
public class PathViz extends MediaPanel
{
@@ -87,8 +86,7 @@ public class PathViz extends MediaPanel
protected static class HappySprite extends Sprite
{
public HappySprite ()
{
public HappySprite () {
_bounds.width = 32;
_bounds.height = 32;
_oxoff = 16;
@@ -96,16 +94,14 @@ public class PathViz extends MediaPanel
}
@Override
public void paint (Graphics2D gfx)
{
public void paint (Graphics2D gfx) {
gfx.setColor(Color.blue);
int hx = _bounds.x + _bounds.width/2;
int hy = _bounds.y + _bounds.height/2;
gfx.drawLine(hx, _bounds.y, hx, _bounds.y + _bounds.height-1);
gfx.drawLine(_bounds.x, hy, _bounds.x+_bounds.width-1, hy);
gfx.setColor(Color.black);
gfx.drawRect(_bounds.x, _bounds.y,
_bounds.width-1, _bounds.height-1);
gfx.drawRect(_bounds.x, _bounds.y, _bounds.width-1, _bounds.height-1);
}
}
@@ -43,7 +43,7 @@ public class ScrollingFrame extends ManagedJFrame
*/
public ScrollingFrame (GraphicsConfiguration gc)
{
super(gc);
super(gc);
// set up the frame options
setTitle("Scene scrolling test");
@@ -64,8 +64,8 @@ public class ScrollingFrame extends ManagedJFrame
vgl = new VGroupLayout(VGroupLayout.NONE);
vgl.setOffAxisPolicy(VGroupLayout.STRETCH);
JPanel stuff = new JPanel(vgl);
for (int i = 0; i < 10; i++) {
stuff.add(new JButton("Button " + i));
for (int ii = 0; ii < 10; ii++) {
stuff.add(new JButton("Button " + ii));
}
getContentPane().add(new SafeScrollPane(stuff));
}
@@ -82,7 +82,7 @@ public class ScrollingFrame extends ManagedJFrame
// now add the new one
_panel = panel;
getContentPane().add(_panel, 0);
getContentPane().add(_panel, 0);
}
protected Component _panel;
@@ -67,47 +67,40 @@ public class ScrollingTestApp
throws IOException
{
// get the graphics environment
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
// get the target graphics device
GraphicsDevice gd = env.getDefaultScreenDevice();
log.info("Graphics device [dev=" + gd +
", mem=" + gd.getAvailableAcceleratedMemory() +
", displayChange=" + gd.isDisplayChangeSupported() +
", fullScreen=" + gd.isFullScreenSupported() + "].");
log.info("Graphics device", "dev", gd, "mem", gd.getAvailableAcceleratedMemory(),
"displayChange", gd.isDisplayChangeSupported(), "fullScreen", gd.isFullScreenSupported());
// get the graphics configuration and display mode information
GraphicsConfiguration gc = gd.getDefaultConfiguration();
DisplayMode dm = gd.getDisplayMode();
log.info("Display mode [bits=" + dm.getBitDepth() +
", wid=" + dm.getWidth() + ", hei=" + dm.getHeight() +
", refresh=" + dm.getRefreshRate() + "].");
log.info("Display mode", "bits", dm.getBitDepth(), "wid", dm.getWidth(),
"hei", dm.getHeight(), "refresh", dm.getRefreshRate());
// create the window
_frame = new ScrollingFrame(gc);
_frame = new ScrollingFrame(gc);
// set up our frame manager
_framemgr = FrameManager.newInstance(_frame);
// we don't need to configure anything
ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles(
null, "config/resource/manager.properties", null);
rmgr.initBundles(null, "config/resource/manager.properties", null);
ClientImageManager imgr = new ClientImageManager(rmgr, _frame);
_tilemgr = new MisoTileManager(rmgr, imgr);
_tilemgr.setTileSetRepository(
new BundledTileSetRepository(rmgr, imgr, "tilesets"));
_tilemgr = new MisoTileManager(rmgr, imgr);
_tilemgr.setTileSetRepository(new BundledTileSetRepository(rmgr, imgr, "tilesets"));
// hack in some different MisoProperties
MisoConfig.config = new Config("rsrc/config/miso/scrolling");
// create the context object
MisoContext ctx = new ContextImpl();
// create the context object
MisoContext ctx = new ContextImpl();
// create the various managers
BundledComponentRepository crepo =
new BundledComponentRepository(rmgr, imgr, "components");
BundledComponentRepository crepo = new BundledComponentRepository(rmgr, imgr, "components");
CharacterManager charmgr = new CharacterManager(imgr, crepo);
// create our scene view panel
@@ -132,8 +125,7 @@ public class ScrollingTestApp
}
} catch (NoSuchComponentException nsce) {
log.warning("Can't locate ship component [class=" + scclass +
", name=" + scname + "].");
log.warning("Can't locate ship component", "class", scclass, "name", scname);
}
_ship.addSpriteObserver(new PathAdapter() {
@@ -157,8 +149,7 @@ public class ScrollingTestApp
int x = _ship.getX(), y = _ship.getY();
_ship.move(new LinePath(x, y, x, y + 1000, 3000l));
// size and position the window, entering full-screen exclusive
// mode if available
// size and position the window, entering full-screen exclusive mode if available
if (gd.isFullScreenSupported()) {
log.info("Entering full-screen exclusive mode.");
gd.setFullScreenWindow(_frame);
@@ -179,18 +170,18 @@ public class ScrollingTestApp
}
/**
* The implementation of the MisoContext interface that provides
* handles to the manager objects that offer commonly used services.
* The implementation of the MisoContext interface that provides handles to the manager
* objects that offer commonly used services.
*/
protected class ContextImpl implements MisoContext
{
public MisoTileManager getTileManager () {
return _tilemgr;
}
public MisoTileManager getTileManager () {
return _tilemgr;
}
public FrameManager getFrameManager () {
return _framemgr;
}
public FrameManager getFrameManager () {
return _framemgr;
}
}
/**
@@ -47,8 +47,8 @@ import com.threerings.cast.bundle.BundledComponentRepository;
import static com.threerings.miso.Log.log;
/**
* The ViewerApp is a scene viewing application that allows for trying
* out game scenes in a pseudo-runtime environment.
* The ViewerApp is a scene viewing application that allows for trying out game scenes in a
* pseudo-runtime environment.
*/
public class ViewerApp
{
@@ -64,38 +64,33 @@ public class ViewerApp
}
// get the graphics environment
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
// get the target graphics device
GraphicsDevice gd = env.getDefaultScreenDevice();
log.info("Graphics device [dev=" + gd +
", mem=" + gd.getAvailableAcceleratedMemory() +
", displayChange=" + gd.isDisplayChangeSupported() +
", fullScreen=" + gd.isFullScreenSupported() + "].");
log.info("Graphics device", "dev", gd, "mem", gd.getAvailableAcceleratedMemory(),
"displayChange", gd.isDisplayChangeSupported(),
"fullScreen", gd.isFullScreenSupported());
// get the graphics configuration and display mode information
GraphicsConfiguration gc = gd.getDefaultConfiguration();
DisplayMode dm = gd.getDisplayMode();
log.info("Display mode [bits=" + dm.getBitDepth() +
", wid=" + dm.getWidth() + ", hei=" + dm.getHeight() +
", refresh=" + dm.getRefreshRate() + "].");
log.info("Display mode", "bits", dm.getBitDepth(), "wid", dm.getWidth(),
"hei", dm.getHeight(), "refresh", dm.getRefreshRate());
// create the window
_frame = new ViewerFrame(gc);
_frame = new ViewerFrame(gc);
_framemgr = FrameManager.newInstance(_frame);
// we don't need to configure anything
ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles(
null, "config/resource/manager.properties", null);
rmgr.initBundles(null, "config/resource/manager.properties", null);
ClientImageManager imgr = new ClientImageManager(rmgr, _frame);
_tilemgr = new MisoTileManager(rmgr, imgr);
_tilemgr.setTileSetRepository(
new BundledTileSetRepository(rmgr, imgr, "tilesets"));
_tilemgr = new MisoTileManager(rmgr, imgr);
_tilemgr.setTileSetRepository(new BundledTileSetRepository(rmgr, imgr, "tilesets"));
// create the context object
MisoContext ctx = new ContextImpl();
// create the context object
MisoContext ctx = new ContextImpl();
// create the various managers
BundledComponentRepository crepo =
@@ -111,14 +106,13 @@ public class ViewerApp
SimpleMisoSceneParser parser = new SimpleMisoSceneParser("");
SimpleMisoSceneModel model = parser.parseScene(args[0]);
if (model == null) {
log.warning("No miso scene found in scene file " +
"[path=" + args[0] + "].");
log.warning("No miso scene found in scene file", "path", args[0]);
System.exit(-1);
}
_panel.setSceneModel(model);
} catch (Exception e) {
log.warning("Unable to parse scene [path=" + args[0] + "].", e);
log.warning("Unable to parse scene", "path", args[0], e);
System.exit(-1);
}
@@ -143,13 +137,11 @@ public class ViewerApp
*/
protected class ContextImpl implements MisoContext
{
public MisoTileManager getTileManager ()
{
return _tilemgr;
}
public MisoTileManager getTileManager () {
return _tilemgr;
}
public FrameManager getFrameManager ()
{
public FrameManager getFrameManager () {
return _framemgr;
}
}
@@ -44,7 +44,7 @@ public class ViewerFrame extends ManagedJFrame
*/
public ViewerFrame (GraphicsConfiguration gc)
{
super(gc);
super(gc);
// set up the frame options
setTitle("Scene Viewer");
@@ -57,8 +57,7 @@ public class ViewerFrame extends ManagedJFrame
// create the "Settings" menu
JMenu menuSettings = new JMenu("Settings");
MenuUtil.addMenuItem(
menuSettings, "Preferences", this, "handlePreferences");
MenuUtil.addMenuItem(menuSettings, "Preferences", this, "handlePreferences");
// create the menu bar
JMenuBar bar = new JMenuBar();
@@ -80,7 +79,7 @@ public class ViewerFrame extends ManagedJFrame
// now add the new one
_panel = panel;
getContentPane().add(_panel, BorderLayout.CENTER);
getContentPane().add(_panel, BorderLayout.CENTER);
}
/**
@@ -58,7 +58,7 @@ public class ViewerSceneViewPanel extends MisoScenePanel
CharacterManager charmgr,
ComponentRepository crepo)
{
super(ctx, MisoConfig.getSceneMetrics());
super(ctx, MisoConfig.getSceneMetrics());
// create the character descriptors
_descUser = CastUtil.getRandomDescriptor("female", crepo);
@@ -71,7 +71,7 @@ public class ViewerSceneViewPanel extends MisoScenePanel
// create the decoy sprites
createDecoys(_spritemgr, charmgr);
PerformanceMonitor.register(this, "paint", 1000);
PerformanceMonitor.register(this, "paint", 1000);
}
@Override
@@ -137,8 +137,8 @@ public class ViewerSceneViewPanel extends MisoScenePanel
@Override
public void paint (Graphics g)
{
super.paint(g);
PerformanceMonitor.tick(this, "paint");
super.paint(g);
PerformanceMonitor.tick(this, "paint");
}
// documentation inherited
@@ -177,14 +177,14 @@ public class ViewerSceneViewPanel extends MisoScenePanel
{
// get the path from here to there
LineSegmentPath path = (LineSegmentPath)getPath(s, x, y, true);
if (path == null) {
s.cancelMove();
return false;
}
if (path == null) {
s.cancelMove();
return false;
}
// start the sprite moving along the path
path.setVelocity(100f/1000f);
s.move(path);
path.setVelocity(100f/1000f);
s.move(path);
return true;
}