Allow label sausages to override icon painting.

Allow RadialMenuItems to add an additional icon to the sausage.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1627 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray
2005-03-22 23:14:54 +00:00
parent be560ac666
commit 07e65fca52
3 changed files with 36 additions and 3 deletions
@@ -111,9 +111,7 @@ public abstract class LabelSausage
drawBase(gfx, x, y);
// render our icon if we've got one
if (_icon != null) {
_icon.paintIcon(null, gfx, x + _xoff, y + _yoff);
}
drawIcon(gfx, x, y, cliData);
drawLabel(gfx, x, y);
drawBorder(gfx, x, y);
@@ -134,6 +132,16 @@ public abstract class LabelSausage
x, y, _size.width - 1, _size.height - 1, _dia, _dia);
}
/**
* Draws the icon, if applicable.
*/
protected void drawIcon (Graphics2D gfx, int x, int y, Object cliData)
{
if (_icon != null) {
_icon.paintIcon(null, gfx, x + _xoff, y + _yoff);
}
}
/**
* Draws the label.
*/
@@ -93,6 +93,18 @@ public class RadialMenu
public boolean isEnabled (RadialMenu menu, RadialMenuItem item);
}
/**
* An additional interface that can be implemented by the predicate
* to display extra status.
*/
public static interface IconPredicate extends Predicate
{
/**
* Return an additional predicate that should be drawn.
*/
public Icon getIcon (RadialMenu menu, RadialMenuItem item);
}
/**
* Constructs a radial menu.
*/
@@ -105,4 +105,17 @@ public class RadialMenuItem extends RadialLabelSausage
{
paint(gfx, x, y, menu);
}
// documentation inherited
protected void drawIcon (Graphics2D gfx, int x, int y, Object cliData)
{
super.drawIcon(gfx, x, y, cliData);
if (predicate instanceof RadialMenu.IconPredicate) {
Icon icon = ((RadialMenu.IconPredicate) predicate).getIcon(
(RadialMenu) cliData, this);
if (icon != null) {
icon.paintIcon(null, gfx, x + _xoff, y + _yoff);
}
}
}
}