Created base SceneViewPanel that the editor and viewer apps extend.

Added fringe layer to scenes.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@176 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-08-04 01:41:02 +00:00
parent e52ab9a739
commit 42967815e1
6 changed files with 104 additions and 60 deletions
@@ -1,5 +1,5 @@
//
// $Id: ViewerFrame.java,v 1.6 2001/08/02 21:02:57 shaper Exp $
// $Id: ViewerFrame.java,v 1.7 2001/08/04 01:41:02 shaper Exp $
package com.threerings.miso.viewer;
@@ -25,7 +25,6 @@ class ViewerFrame extends JFrame implements WindowListener
public ViewerFrame ()
{
super("Scene Viewer");
addWindowListener(this);
}
@@ -45,8 +44,16 @@ class ViewerFrame extends JFrame implements WindowListener
new AmbulatorySprite(spritemgr, 300, 300, tilemgr, TSID_CHAR);
spritemgr.addSprite(sprite);
// create a top-level panel to manage everything
JPanel top = new JPanel();
GroupLayout gl = new HGroupLayout(GroupLayout.STRETCH);
gl.setOffAxisPolicy(GroupLayout.STRETCH);
top.setLayout(gl);
// set up the scene view panel with a default scene
SceneViewPanel svpanel = new SceneViewPanel(_ctx, spritemgr, sprite);
ViewerSceneViewPanel svpanel =
new ViewerSceneViewPanel(_ctx, spritemgr, sprite);
top.add(svpanel, GroupLayout.FIXED);
// add the scene view panel
getContentPane().add(svpanel, BorderLayout.CENTER);
@@ -69,7 +76,7 @@ class ViewerFrame extends JFrame implements WindowListener
protected static final int TSID_CHAR = 1003;
/** The panel displaying the scene. */
SceneViewPanel _svpanel;
ViewerSceneViewPanel _svpanel;
/** The context object. */
protected ViewerContext _ctx;
@@ -1,5 +1,5 @@
//
// $Id: SceneViewPanel.java,v 1.8 2001/08/02 23:12:19 shaper Exp $
// $Id: ViewerSceneViewPanel.java,v 1.1 2001/08/04 01:41:02 shaper Exp $
package com.threerings.miso.viewer;
@@ -14,38 +14,25 @@ import com.threerings.miso.viewer.util.ViewerContext;
import com.threerings.miso.scene.*;
import com.threerings.miso.scene.xml.XMLFileSceneRepository;
import com.threerings.miso.sprite.*;
import com.threerings.miso.util.PerformanceMonitor;
import com.threerings.miso.util.PerformanceObserver;
import com.threerings.miso.util.*;
/**
* The <code>SceneViewPanel</code> class is responsible for managing a
* <code>SceneView</code>, rendering it to the screen, and handling
* view-related UI events.
*/
public class SceneViewPanel extends JPanel
public class ViewerSceneViewPanel extends SceneViewPanel
implements MouseListener, MouseMotionListener, PerformanceObserver
{
/**
* Construct the panel and initialize it with a context.
*/
public SceneViewPanel (ViewerContext ctx, SpriteManager spritemgr,
Sprite sprite)
public ViewerSceneViewPanel (
ViewerContext ctx, SpriteManager spritemgr, Sprite sprite)
{
super(ctx.getTileManager(), spritemgr);
_ctx = ctx;
_sprite = sprite;
// construct the view object
IsoSceneModel smodel = new IsoSceneModel();
smodel.setTileDimensions(64, 48);
smodel.setBounds((10 * 64), (12 * 48));
smodel.setOrigin(320, -(5 * 48));
_view = new IsoSceneView(_ctx.getTileManager(), spritemgr, smodel);
// create an animation manager for this panel
AnimationManager animmgr =
new AnimationManager(spritemgr, this, _view);
new AnimationManager(spritemgr, this, _view);
// listen to the desired events
addMouseListener(this);
@@ -54,9 +41,6 @@ public class SceneViewPanel extends JPanel
// load up the initial scene
prepareStartingScene();
setDoubleBuffered(false);
setOpaque(true);
PerformanceMonitor.register(this, "paint", 1000);
}
@@ -82,29 +66,6 @@ public class SceneViewPanel extends JPanel
}
}
/**
* Set the scene managed by the panel.
*/
public void setScene (Scene scene)
{
_view.setScene(scene);
}
/**
* Render the panel and the scene view to the given graphics object.
*/
public void paintComponent (Graphics g)
{
Rectangle bounds = getBounds();
// Log.info("SceneViewPanel: paint [width=" + bounds.width +
// ", height=" + bounds.height + "].");
_view.paint(g);
PerformanceMonitor.tick(this, "paint");
}
public void checkpoint (String name, int ticks)
{
Log.info(name + " [ticks=" + ticks + "].");
@@ -148,7 +109,4 @@ public class SceneViewPanel extends JPanel
/** The context object. */
protected ViewerContext _ctx;
/** The scene view we're managing. */
protected SceneView _view;
}