java.lang.Object
furbelow.AbstractComponentDecorator
- Direct Known Subclasses:
GhostedDragImage,ListAnimator,TreeAnimator,WaitIndicator
Provide a method for consistently augmenting the appearance of a given
component by painting something on it after the component itself
gets painted. If not explicitly removed via
dispose(), an instance
of this object will live as long as its target component.
By default, the decorator matches the location and size of the decorated
component, but the bounds can be adjusted by overriding
getDecorationBounds(). The synch() method should be
called whenever the bounds returned by getDecorationBounds() would
change.
The decoration is clipped to the bounds set on the decoration, which does not necessarily need to be the same as the decorated component's bounds. The decoration may extend beyond the decorated component bounds, or it may be reduced to a smaller region.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classUsed to hook into the Swing painting architecture. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a decorator for the given component.AbstractComponentDecorator(JComponent c, int layerOffset) Create a decorator for the given component, indicating the layer offset from the target component.AbstractComponentDecorator(JComponent c, int layerOffset, int position) Create a decorator with the given position within its layer. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidattach()protected RectangleclipDecorationBounds(Rectangle decorated) Adjust the painting offsets and size of the decoration to account for ancestor clipping.voiddispose()Stop decorating.protected JComponentReturns the decorated component.protected RectangleReturn the bounds, relative to the decorated component, of the decoration.protected JComponentReturns the component used to paint the decoration and optionally track events.Return the currently set default tooltip text.Provide for different tool tips depending on the actual location over the decoration.booleanIndicate whether the decoration is visible.abstract voidDefine the decoration's appearance.voidrepaint()Force a refresh of the underlying component and its decoration.voidSet the cursor to appear anywhere over the decoration bounds.voidsetDecorationBounds(int x, int y, int w, int h) Change the bounds of the decoration, relative to the decorated component.voidsetDecorationBounds(Rectangle bounds) Change the bounds of the decoration, relative to the decorated component.protected voidsetPainterBounds(int x, int y, int w, int h) voidsetToolTipText(String text) Set the text to be displayed when the mouse is over the decoration.voidsetVisible(boolean visible) Use this to change the visibility of the decoration.protected voidsynch()Ensure the size of the decorator matches the current decoration bounds with appropriate clipping to viewports.toString()
-
Field Details
-
DEFAULT_BOUNDS
-
TOP
public static final int TOP- See Also:
-
-
Constructor Details
-
AbstractComponentDecorator
Create a decorator for the given component. -
AbstractComponentDecorator
Create a decorator for the given component, indicating the layer offset from the target component. Negative values mean the decoration is painted before the target component is painted. -
AbstractComponentDecorator
Create a decorator with the given position within its layer. UseTOPto cover other decorations, orBOTTOMto be covered by other decorations.WARNING: BOTTOM doesn't currently work, probably a JLayeredPane bug in either the code or documentation.
- See Also:
-
-
Method Details
-
setToolTipText
Set the text to be displayed when the mouse is over the decoration.- See Also:
-
getToolTipText
Return the currently set default tooltip text.- See Also:
-
getToolTipText
Provide for different tool tips depending on the actual location over the decoration. Note that if you only override this method, you must also invokesetToolTipText(String)with a non-null argument.- See Also:
-
isVisible
public boolean isVisible()Indicate whether the decoration is visible. The decoration may be clipped by ancestor scroll panes or by being moved outside if the visible region of its parent window. -
setVisible
public void setVisible(boolean visible) Use this to change the visibility of the decoration. -
attach
protected void attach() -
synch
protected void synch()Ensure the size of the decorator matches the current decoration bounds with appropriate clipping to viewports. -
clipDecorationBounds
Adjust the painting offsets and size of the decoration to account for ancestor clipping. This might be due to scroll panes or having the decoration lie outside the parent layered pane. -
getDecorationBounds
Return the bounds, relative to the decorated component, of the decoration. The default covers the entire component. Note that this method will be called from the constructor, so be careful when overriding and referencing derived class state. -
setDecorationBounds
Change the bounds of the decoration, relative to the decorated component. The special valueDEFAULT_BOUNDSmeans the bounds will track the component bounds. -
setDecorationBounds
public void setDecorationBounds(int x, int y, int w, int h) Change the bounds of the decoration, relative to the decorated component. -
setPainterBounds
protected void setPainterBounds(int x, int y, int w, int h) -
getComponent
Returns the decorated component. -
getPainter
Returns the component used to paint the decoration and optionally track events. -
setCursor
Set the cursor to appear anywhere over the decoration bounds. If null, the cursor of the decorated component will be used. -
repaint
public void repaint()Force a refresh of the underlying component and its decoration. -
dispose
public void dispose()Stop decorating. -
paint
Define the decoration's appearance. The point (0,0) represents the upper left corner of the decorated component. The default clip mask will be the extents of the decoration bounds, as indicated bygetDecorationBounds(), which defaults to the decorated component bounds. -
toString
-