Class DefaultVisuals<T extends javax.swing.JComponent>
- java.lang.Object
-
- org.jdesktop.swingx.renderer.DefaultVisuals<T>
-
- All Implemented Interfaces:
java.io.Serializable
public class DefaultVisuals<T extends javax.swing.JComponent> extends java.lang.Object implements java.io.Serializable
Encapsulates the default visual configuration of renderering components, respecting the state of the passed-inCellContext
. It's basically re-usable across all types of renderees (JTable, JList, JTree).Guarantees to completely configure the default visual properties (listed below) of a given component. As a consequence, client code (f.i. in
Highlighter
s) can safely change them without long-lasting visual artefacts.- foreground and background, depending on selected and focused state
- border
- font
- Painter (if applicable)
- enabled
- componentOrientation
- toolTipText
- minimum-, maximum-, preferredSize
- name
PENDING: allow mutators for overruling the
CellContext
s defaults? Would prefer not to, as in the context of SwingX visual config on the renderer level is discouraged (the way to go areHighlighter
s.PENDING: not yet quite decided whether the toolTipText property belongs into the visual default config. Doing so gives client code the choice to set it either in a Highlighter or a custom ComponentProvider.
- Author:
- Jeanette Winzenburg
- See Also:
CellContext
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultVisuals()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
configureBorder(T renderingComponent, CellContext context)
Configures the rendering component's border from the given cell context.protected void
configureColors(T renderingComponent, CellContext context)
Configures colors of rendering component from the given cell context.protected void
configureFocusColors(T renderingComponent, CellContext context)
Configures focus-related colors form given cell context.protected void
configurePainter(T renderingComponent, CellContext context)
Configures the default Painter if applicable.protected void
configureSizes(T renderingComponent, CellContext context)
Configures min-, max, preferredSize properties of the renderingComponent.protected void
configureState(T renderingComponent, CellContext context)
Configure "divers" visual state of the rendering component from the given cell context.void
configureVisuals(T renderingComponent, CellContext context)
Configures all default visual state of the rendering component from the given cell context.protected java.awt.Color
getBackground(CellContext context)
Returns the unselected background to use for the rendering component.protected java.awt.Color
getForeground(CellContext context)
Returns the unselected foreground to use for the rendering component.void
setBackground(java.awt.Color c)
Sets the renderer's unselected-background color to the specified color.void
setForeground(java.awt.Color c)
Sets the renderer's unselected-foreground color to the specified color.
-
-
-
Method Detail
-
setForeground
public void setForeground(java.awt.Color c)
Sets the renderer's unselected-foreground color to the specified color. Ifnot null
this color will overrule the default color of the CellContext.- Parameters:
c
- set the foreground color to this value
-
setBackground
public void setBackground(java.awt.Color c)
Sets the renderer's unselected-background color to the specified color. Ifnot null
this color will overrule the default color of the CellContext.- Parameters:
c
- set the background color to this value
-
configureVisuals
public void configureVisuals(T renderingComponent, CellContext context)
Configures all default visual state of the rendering component from the given cell context.- Parameters:
renderingComponent
- the component to configure, must not be nullcontext
- the cell context to configure from, must not be null- Throws:
java.lang.NullPointerException
- if either renderingComponent or cellContext is null
-
configurePainter
protected void configurePainter(T renderingComponent, CellContext context)
Configures the default Painter if applicable. Here: set's to null.- Parameters:
renderingComponent
- the component to configure, must not be nullcontext
- the cell context to configure from, must not be null
-
configureState
protected void configureState(T renderingComponent, CellContext context)
Configure "divers" visual state of the rendering component from the given cell context.Here: synch
Font
,ComponentOrientation
andenabled
to context's component. Resets toolTipText to null. Calls configureSizes to reset xxSize if appropriate. Resets the component's name property.PENDING: not fully defined - "divers" means everything that's not
Color
s norBorder
norPainter
.- Parameters:
renderingComponent
- the component to configure, must not be nullcontext
- the cell context to configure from, must not be null
-
configureSizes
protected void configureSizes(T renderingComponent, CellContext context)
Configures min-, max, preferredSize properties of the renderingComponent. Here: set all to null.- Parameters:
renderingComponent
- the component to configure, must not be nullcontext
- the cell context to configure from, must not be null
-
configureColors
protected void configureColors(T renderingComponent, CellContext context)
Configures colors of rendering component from the given cell context.- Parameters:
renderingComponent
- the component to configure, must not be nullcontext
- the cell context to configure from, must not be null
-
configureFocusColors
protected void configureFocusColors(T renderingComponent, CellContext context)
Configures focus-related colors form given cell context.PENDING: move to context as well? - it's the only comp with focus specifics? Problem is the parameter type...
- Parameters:
renderingComponent
- the component to configure, must not be nullcontext
- the cell context to configure from, must not be null
-
configureBorder
protected void configureBorder(T renderingComponent, CellContext context)
Configures the rendering component's border from the given cell context.- Parameters:
renderingComponent
- the component to configure, must not be nullcontext
- the cell context to configure from, must not be null
-
getForeground
protected java.awt.Color getForeground(CellContext context)
Returns the unselected foreground to use for the rendering component.Here: returns this renderer's unselected foreground is not null, returns the foreground from the given context. In other words: the renderer's foreground takes precedence if set.
- Parameters:
context
- the cell context.- Returns:
- the unselected foreground.
-
getBackground
protected java.awt.Color getBackground(CellContext context)
Returns the unselected background to use for the rendering component.Here: returns this renderer's unselected background is not null, returns the background from the given context. In other words: the renderer's background takes precedence if set.
- Parameters:
context
- the cell context.- Returns:
- the unselected background.
-
-