Broke menu bounds computation out into its own method for use by subclasses.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3588 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Andrzej Kapolka
2005-06-07 16:43:59 +00:00
parent 62cacd152e
commit b9be0dcea7
@@ -470,17 +470,8 @@ public class MisoScenePanel extends VirtualMediaPanel
}
// make the menu surround the clicked object, but with consistent size
Rectangle mbounds = new Rectangle(scobj.bounds);
Dimension radbox = getObjectRadialSize();
if (mbounds.width != radbox.width) {
mbounds.x += (mbounds.width-radbox.width)/2;
mbounds.width = radbox.width;
}
if (mbounds.height != radbox.height) {
mbounds.y += (mbounds.height-radbox.height)/2;
mbounds.height = radbox.height;
}
Rectangle mbounds = getRadialMenuBounds(scobj);
_activeMenu = menu;
_activeMenu.addActionListener(new ActionListener() {
public void actionPerformed (ActionEvent e) {
@@ -497,6 +488,26 @@ public class MisoScenePanel extends VirtualMediaPanel
_activeMenu.activate(this, mbounds, scobj);
}
/**
* Returns an appropriate set of menu bounds for the specified object.
* Returns a rectangle of the size specified by
* {@link #getObjectRadialSize} centered around the object.
*/
protected Rectangle getRadialMenuBounds (SceneObject scobj)
{
Rectangle mbounds = new Rectangle(scobj.bounds);
Dimension radbox = getObjectRadialSize();
if (mbounds.width != radbox.width) {
mbounds.x += (mbounds.width-radbox.width)/2;
mbounds.width = radbox.width;
}
if (mbounds.height != radbox.height) {
mbounds.y += (mbounds.height-radbox.height)/2;
mbounds.height = radbox.height;
}
return mbounds;
}
/**
* Returns the size of the rectangle around which we create an
* object's radial menu. The default is a sensible size, but derived