public abstract class AbstractComponentDecoration extends Object implements com.google.code.validationframework.api.common.Disposable
Concrete implementations will just need to provide the size and do the painting on the already-computed location.
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractComponentDecoration.DecorationPainter
Entity responsible of calling the
paint(Graphics) method. |
| Modifier and Type | Field and Description |
|---|---|
protected AbstractComponentDecoration.DecorationPainter |
decorationPainter
Decoration painter component.
|
| Constructor and Description |
|---|
AbstractComponentDecoration(JComponent decoratedComponent,
Anchor decoratedComponentAnchor,
Anchor decorationAnchor)
Constructor specifying the component to be decorated and the two anchors composing the anchor link between the
decorated component and its decoration.
|
AbstractComponentDecoration(JComponent decoratedComponent,
AnchorLink anchorLink)
Constructor specifying the component to be decorated and the anchor link between the decorated component and its
decoration.
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispose() |
void |
followAndRepaint()
Triggers a repaint of the component decoration.
|
protected void |
followDecoratedComponent()
Updates the decoration painter with respect to the decorated component.
|
AnchorLink |
getAnchorLink()
Gets the anchor link between the decorated component and its decoration.
|
JComponent |
getClippingAncestor()
Gets the custom clipping ancestor component that will be used to clip the decoration.
|
JComponent |
getDecoratedComponent()
Gets the decorated component to which the decoration is attached.
|
protected abstract int |
getHeight()
Returns the height of the decoration.
|
boolean |
getPaintWhenDisabled()
States whether the decoration is painted (shown) even when the decorated component is disabled.
|
protected abstract int |
getWidth()
Returns the width of the decoration.
|
boolean |
isVisible()
States whether the decoration is visible or not.
|
abstract void |
paint(Graphics g)
Paints the decoration in the specified graphics.
|
void |
setAnchorLink(AnchorLink anchorLink)
Sets the anchor link between the component and its decoration.
|
void |
setClippingAncestor(JComponent decorationClippingAncestor)
Sets the custom clipping ancestor component that will be used to clip the decoration.
|
void |
setPaintWhenDisabled(boolean paintWhenDisabled)
States whether the decoration is to be painted (shown) even when the decorated component is disabled.
|
void |
setVisible(boolean visible)
Sets the visibility of the decoration.
|
protected final AbstractComponentDecoration.DecorationPainter decorationPainter
It is merely a hook into the Swing painting mechanism.
This is the component that is actually added to the layered pane.
public AbstractComponentDecoration(JComponent decoratedComponent, AnchorLink anchorLink)
decoratedComponent - Component to be decorated.anchorLink - Anchor link between the decorated component and its decoration.public AbstractComponentDecoration(JComponent decoratedComponent, Anchor decoratedComponentAnchor, Anchor decorationAnchor)
decoratedComponent - Component to be decorated.decoratedComponentAnchor - Anchor on the decorated component.decorationAnchor - Anchor on the decoration.AbstractComponentDecoration(JComponent, AnchorLink)public JComponent getDecoratedComponent()
public JComponent getClippingAncestor()
If null is returned, the parent container of the decorated component is used.
public void setClippingAncestor(JComponent decorationClippingAncestor)
If set to null, the parent container of the decorated component will be used.
Note that the specified clipping component shall be an ancestor of the decorated component, or the component itself.
decorationClippingAncestor - Clipping ancestor or null topublic AnchorLink getAnchorLink()
public void setAnchorLink(AnchorLink anchorLink)
anchorLink - Anchor link between the component and its decoration.public boolean isVisible()
public void setVisible(boolean visible)
visible - True to make the decoration visible, false to make it invisible.public boolean getPaintWhenDisabled()
public void setPaintWhenDisabled(boolean paintWhenDisabled)
paintWhenDisabled - True if decoration is to be painted (shown) even when the decorated component is
disabled, false otherwise.protected void followDecoratedComponent()
This method is to be called whenever changes on the decorated component have an impact on the decoration (for instance, its size, location, etc.).
This method has been made protected so that it can be easily called from the implementing sub-classes.
public void dispose()
dispose in interface com.google.code.validationframework.api.common.DisposableDisposablepublic void followAndRepaint()
Note that this will also make the decoration follow the component.
followDecoratedComponent()protected abstract int getWidth()
protected abstract int getHeight()
public abstract void paint(Graphics g)
g - Graphics to paint the decoration to.Copyright © 2020. All rights reserved.