Cleaned up; don't attempt to edit classes with no components; no need to

use the FrameManager and MediaPanel for displaying sprites since we're not
doing things properly anyway (properly meaning using a sprite manager and
all the associated business).


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1497 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-06-19 23:24:04 +00:00
parent a3196fbad3
commit 5a98d450a1
3 changed files with 29 additions and 33 deletions
@@ -1,13 +1,11 @@
//
// $Id: BuilderPanel.java,v 1.6 2002/04/23 01:17:28 mdb Exp $
// $Id: BuilderPanel.java,v 1.7 2002/06/19 23:24:04 mdb Exp $
package com.threerings.cast.builder;
import javax.swing.*;
import com.samskivert.swing.*;
import com.threerings.media.FrameManager;
import com.threerings.cast.CharacterManager;
import com.threerings.cast.ComponentRepository;
@@ -21,8 +19,8 @@ public class BuilderPanel extends JPanel
/**
* Constructs the builder panel.
*/
public BuilderPanel (FrameManager framemgr, CharacterManager charmgr,
ComponentRepository crepo)
public BuilderPanel (CharacterManager charmgr,
ComponentRepository crepo, String cprefix)
{
setLayout(new VGroupLayout());
@@ -37,8 +35,8 @@ public class BuilderPanel extends JPanel
// create the component selection and sprite display panels
JPanel sub = new JPanel(gl);
sub.add(new ComponentPanel(model));
sub.add(new SpritePanel(framemgr, charmgr, model));
sub.add(new ComponentPanel(model, cprefix));
sub.add(new SpritePanel(charmgr, model));
add(sub);
}
}
@@ -1,5 +1,5 @@
//
// $Id: ComponentPanel.java,v 1.6 2001/11/27 08:09:35 mdb Exp $
// $Id: ComponentPanel.java,v 1.7 2002/06/19 23:24:04 mdb Exp $
package com.threerings.cast.builder;
@@ -24,27 +24,35 @@ public class ComponentPanel extends JPanel
/**
* Constructs the component panel.
*/
public ComponentPanel (BuilderModel model)
public ComponentPanel (BuilderModel model, String cprefix)
{
setLayout(new VGroupLayout(GroupLayout.STRETCH));
// set up a border
setBorder(BorderFactory.createEtchedBorder());
// add the component editors to the panel
addClassEditors(model);
addClassEditors(model, cprefix);
}
/**
* Adds editor user interface elements for each component class to
* allow the user to select the desired component.
*/
protected void addClassEditors (BuilderModel model)
protected void addClassEditors (BuilderModel model, String cprefix)
{
List classes = model.getComponentClasses();
int size = classes.size();
for (int ii = 0; ii < size; ii++) {
ComponentClass cclass = (ComponentClass)classes.get(ii);
if (!cclass.name.startsWith(cprefix)) {
continue;
}
List ccomps = model.getComponents(cclass);
add(new ClassEditor(model, cclass, ccomps));
if (ccomps.size() > 0) {
add(new ClassEditor(model, cclass, ccomps));
} else {
Log.info("Not creating editor for empty class " +
"[class=" + cclass + "].");
}
}
}
}
@@ -1,5 +1,5 @@
//
// $Id: SpritePanel.java,v 1.13 2002/04/23 01:17:28 mdb Exp $
// $Id: SpritePanel.java,v 1.14 2002/06/19 23:24:04 mdb Exp $
package com.threerings.cast.builder;
@@ -9,10 +9,9 @@ import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.util.List;
import javax.swing.JPanel;
import com.threerings.media.FrameManager;
import com.threerings.media.MediaPanel;
import java.util.List;
import com.threerings.util.DirectionCodes;
@@ -26,17 +25,14 @@ import com.threerings.cast.StandardActions;
* The sprite panel displays a character sprite centered in the panel
* suitable for user perusal.
*/
public class SpritePanel extends MediaPanel
public class SpritePanel extends JPanel
implements DirectionCodes, BuilderModelListener
{
/**
* Constructs the sprite panel.
*/
public SpritePanel (FrameManager framemgr, CharacterManager charmgr,
BuilderModel model)
public SpritePanel (CharacterManager charmgr, BuilderModel model)
{
super(framemgr);
// save off references
_charmgr = charmgr;
_model = model;
@@ -47,17 +43,10 @@ public class SpritePanel extends MediaPanel
}
// documentation inherited
protected void paintMiddle (Graphics2D gfx, List invalidRects)
public void paintComponent (Graphics g)
{
// clear the background
gfx.setColor(Color.lightGray);
Dimension d = getSize();
gfx.fillRect(0, 0, d.width - 1, d.height - 1);
if (_sprite == null) {
// create the sprite if it's not yet extant
generateSprite();
}
super.paintComponent(g);
Graphics2D gfx = (Graphics2D)g;
if (_sprite != null) {
// render the sprite
@@ -66,9 +55,10 @@ public class SpritePanel extends MediaPanel
}
// documentation inherited
public void setBounds (Rectangle r)
public void doLayout ()
{
super.setBounds(r);
super.doLayout();
generateSprite();
centerSprite();
}