com.threerings.miso.client
Class SceneObjectTip

java.lang.Object
  extended by com.samskivert.swing.LabelSausage
      extended by com.threerings.miso.client.SceneObjectTip
All Implemented Interfaces:
SceneObjectIndicator

public class SceneObjectTip
extends LabelSausage
implements SceneObjectIndicator

A lightweight tooltip used by the MisoScenePanel. The tip foreground and background are controlled by the following UIManager properties:

 SceneObjectTip.background
 SceneObjectTip.foreground
 SceneObjectTip.font (falls back to Label.font)
 


Nested Class Summary
protected static class SceneObjectTip.DefaultLayout
          Our default tip layout algorithm which centers the tip in the bounds of the object in question.
protected static class SceneObjectTip.LayoutReg
          Used to store SceneObjectTip.TipLayout registrations.
static interface SceneObjectTip.TipLayout
          Used to position a scene tip in relation to the object with which it is associated.
 
Field Summary
protected static Color _background
          Colors to use when rendering the tip.
protected static Font _font
          The font to use when rendering the tip.
protected static Color _foreground
          Colors to use when rendering the tip.
protected static ComparableArrayList<SceneObjectTip.LayoutReg> _layouts
          Contains a sorted list of layout registrations.
protected static Composite ALPHA
          The alpha we use for our base.
 Rectangle bounds
          The bounding box of this tip, or null prior to layout().
protected static int EXTRA_PAD
          The number of pixels to pad between the icon and text.
protected static int ICON_PAD
          The number of pixels to pad around the icon.
 
Fields inherited from class com.samskivert.swing.LabelSausage
_dia, _icon, _label, _lxoff, _lyoff, _size, _xoff, _yoff
 
Constructor Summary
SceneObjectTip(String text, Icon icon)
          Construct a SceneObjectTip.
 
Method Summary
protected  void drawBase(Graphics2D gfx, int x, int y)
           
 Rectangle getBounds()
          Returns the bounds of the indicator when drawn.
 boolean isLaidOut()
          Returns whether the indicator has already been laid out (and thus doesn't need to be again)
 void layout(Graphics2D gfx, SceneObject tipFor, Rectangle boundary)
          Called to initialize the tip so that it can be painted.
 void paint(Graphics2D gfx)
          Paints the indicator in the scene.
static void registerTipLayout(String prefix, SceneObjectTip.TipLayout layout)
          It may be desirable to layout object tips specially depending on what sort of actions they represent, so we allow different tip layout algorithms to be registered for particular object prefixes.
 void removed()
          Called when the indicator is removed from the scene.
 String toString()
          Generates a string representation of this instance.
 void update(Icon icon, String tiptext)
          Updates the Icon and text for the indicator.
 
Methods inherited from class com.samskivert.swing.LabelSausage
drawBorder, drawExtras, drawIcon, drawLabel, layout, layout, paint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bounds

public Rectangle bounds
The bounding box of this tip, or null prior to layout().


ALPHA

protected static final Composite ALPHA
The alpha we use for our base.


_background

protected static Color _background
Colors to use when rendering the tip.


_foreground

protected static Color _foreground
Colors to use when rendering the tip.


_font

protected static Font _font
The font to use when rendering the tip.


_layouts

protected static ComparableArrayList<SceneObjectTip.LayoutReg> _layouts
Contains a sorted list of layout registrations.


ICON_PAD

protected static final int ICON_PAD
The number of pixels to pad around the icon.

See Also:
Constant Field Values

EXTRA_PAD

protected static final int EXTRA_PAD
The number of pixels to pad between the icon and text.

See Also:
Constant Field Values
Constructor Detail

SceneObjectTip

public SceneObjectTip(String text,
                      Icon icon)
Construct a SceneObjectTip.

Method Detail

isLaidOut

public boolean isLaidOut()
Description copied from interface: SceneObjectIndicator
Returns whether the indicator has already been laid out (and thus doesn't need to be again)

Specified by:
isLaidOut in interface SceneObjectIndicator

layout

public void layout(Graphics2D gfx,
                   SceneObject tipFor,
                   Rectangle boundary)
Called to initialize the tip so that it can be painted.

Specified by:
layout in interface SceneObjectIndicator
Parameters:
tipFor - the scene object that we're a tip for.
boundary - the boundary of all displayable space.

paint

public void paint(Graphics2D gfx)
Description copied from interface: SceneObjectIndicator
Paints the indicator in the scene. Always called after SceneObjectIndicator.layout(Graphics2D, SceneObject, Rectangle)

Specified by:
paint in interface SceneObjectIndicator

getBounds

public Rectangle getBounds()
Description copied from interface: SceneObjectIndicator
Returns the bounds of the indicator when drawn.

Specified by:
getBounds in interface SceneObjectIndicator

removed

public void removed()
Description copied from interface: SceneObjectIndicator
Called when the indicator is removed from the scene.

Specified by:
removed in interface SceneObjectIndicator

update

public void update(Icon icon,
                   String tiptext)
Description copied from interface: SceneObjectIndicator
Updates the Icon and text for the indicator.

Specified by:
update in interface SceneObjectIndicator

toString

public String toString()
Generates a string representation of this instance.

Overrides:
toString in class Object

registerTipLayout

public static void registerTipLayout(String prefix,
                                     SceneObjectTip.TipLayout layout)
It may be desirable to layout object tips specially depending on what sort of actions they represent, so we allow different tip layout algorithms to be registered for particular object prefixes. The registration is simply a list searched from longest string to shortest string for the first match to an object's action.


drawBase

protected void drawBase(Graphics2D gfx,
                        int x,
                        int y)
Overrides:
drawBase in class LabelSausage