APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.swing.plaf.synth

public Class DefaultSynthStyle

extends SynthStyle
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
javax.swing.plaf.synth.ParsedSynthStyle
Imports
javax.swing.plaf.synth.*, java.awt.*, java.util.*, javax.swing.*, javax.swing.plaf.*

Default implementation of SynthStyle. Has setters for the various SynthStyle methods. Many of the properties can be specified for all states, using SynthStyle directly, or a specific state using one of the StateInfo methods.

Beyond the constructor a subclass should override the addTo and clone methods, these are used when the Styles are being merged into a resulting style.

Author
Scott Violet

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
DefaultSynthStyle.StateInfo

StateInfo represents Style information specific to the state of a component.

Field Summary

Modifier and TypeField and Description
private Map<Object, Object>
data

User specific data.

private Font
font

Font to use if there is no matching StateInfo, or the StateInfo doesn't define one.

private Insets
insets

Insets.

private boolean
opaque

Should the component be opaque?

private SynthPainter
painter

Painter to use if the StateInfo doesn't have one.

private static final Object
private DefaultSynthStyle.StateInfo[]
states

Information specific to ComponentState.

private SynthGraphicsUtils
synthGraphics

SynthGraphics, may be null.

Constructor Summary

AccessConstructor and Description
public
DefaultSynthStyle()

Nullary constructor, intended for subclassers.

public
DefaultSynthStyle(DefaultSynthStyle
Style to duplicate
style
)

Creates a new DefaultSynthStyle that is a copy of the passed in style.

public
DefaultSynthStyle(Insets
Insets for the Style
insets
,
boolean
Whether or not the background is completely painted in an opaque color
opaque
,
DefaultSynthStyle.StateInfo[]
StateInfos describing properties per state
states
,
Map<Object, Object>
Style specific data.
data
)

Creates a new DefaultSynthStyle.

Method Summary

Modifier and TypeMethod and Description
public DefaultSynthStyle

Returns:

Merged style.
addTo
(DefaultSynthStyle
Style to add our styles to
style
)

Merges the contents of this Style with that of the passed in Style, returning the resulting merged style.

public Object

Returns:

Clone of this style
clone
()

Overrides java.lang.Object.clone.

Creates a clone of this style.

public Object

Returns:

Value of the named property
get
(SynthContext
SynthContext identifying requestor
state
,
Object
Property being requested.
key
)

Overrides javax.swing.plaf.synth.SynthStyle.get.

Getter for a region specific style property.

public Color
getColor(SynthContext context, ColorType type)

Overrides javax.swing.plaf.synth.SynthStyle.getColor.

Returns the color for the specified state.

public Color
getColor(JComponent c, Region id, int state, ColorType type)

protected Color
getColorForState(SynthContext context, ColorType type)

Implements abstract javax.swing.plaf.synth.SynthStyle.getColorForState.

Returns the color for the specified state.

protected Color

Returns:

Color to render with
getColorForState
(JComponent
JComponent the style is associated with
c
,
Region
Region identifier
id
,
int
State of the region.
state
,
ColorType
Type of color being requested.
type
)

Returns the color for the specified state.

public Map<Object, Object>

Returns:

Style specific data.
getData
()

Returns the style specific data.

public Object

Returns:

Value of the named property
getDefaultValue
(SynthContext
SynthContext identifying requestor
context
,
Object
Property being requested.
key
)

Returns the default value for a particular property.

public Font
getFont(SynthContext state)

Overrides javax.swing.plaf.synth.SynthStyle.getFont.

Returns the Font for the specified state.

public Font
getFont(JComponent c, Region id, int state)

protected Font

Returns:

Font to render with
getFontForState
(JComponent
JComponent the style is associated with
c
,
Region
Region identifier
id
,
int
State of the region.
state
)

Returns the font for the specified state.

protected Font
getFontForState(SynthContext context)

Implements abstract javax.swing.plaf.synth.SynthStyle.getFontForState.

Returns the font for the specified state.

public SynthGraphicsUtils

Returns:

SynthGraphicsUtils
getGraphicsUtils
(SynthContext
SynthContext identifying requestor
context
)

Overrides javax.swing.plaf.synth.SynthStyle.getGraphicsUtils.

Returns a SynthGraphicsUtils.

public Insets

Returns:

Insets.
getInsets
(SynthContext
SynthContext identifying requestor
state
,
Insets
Where to place Insets
to
)

Overrides javax.swing.plaf.synth.SynthStyle.getInsets.

Returns the Insets.

private Object
public SynthPainter

Returns:

Painter for the border
getPainter
(SynthContext
SynthContext identifying requestor
ss
)

Overrides javax.swing.plaf.synth.SynthStyle.getPainter.

Returns the Painter for the passed in Component.

public DefaultSynthStyle.StateInfo[]

Returns:

Array of StateInfos.
getStateInfo
()

Returns the array of StateInfo's that that are used to specify properties specific to a particular style.

public DefaultSynthStyle.StateInfo

Returns:

Best matching StateInfo, or null
getStateInfo
(int
Component state.
state
)

Returns the best matching StateInfo for a particular state.

public boolean

Returns:

opaque Whether or not the JComponent is opaque.
isOpaque
(SynthContext
SynthContext identifying requestor
ss
)

Overrides javax.swing.plaf.synth.SynthStyle.isOpaque.

Returns the value to initialize the opacity property of the Component to.

public void
setData(Map<Object, Object>
Style specific values
data
)

Sets style specific values.

public void
setFont(Font
Font to use for rendering
font
)

Sets the font that is used if there is no matching StateInfo, or it does not define a font.

public void
setGraphicsUtils(SynthGraphicsUtils
SynthGraphics
graphics
)

Sets the SynthGraphicsUtils that will be used for rendering.

public void
setInsets(Insets
the new insets.
insets
)

Sets the insets.

public void
setOpaque(boolean
Whether or not the JComponent should be opaque.
opaque
)

Sets whether or not the JComponent should be opaque.

public void
setPainter(SynthPainter
Painter for the Border.
painter
)

Sets the Painter to use for the border.

public void
setStateInfo(DefaultSynthStyle.StateInfo[]
StateInfos
states
)

Sets the array of StateInfo's which are used to specify properties specific to a particular style.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from javax.swing.plaf.synth.SynthStyle:
getBooleangetIcongetIntgetStringinstallDefaultsuninstallDefaults

Field Detail

databack to summary
private Map<Object, Object> data

User specific data.

fontback to summary
private Font font

Font to use if there is no matching StateInfo, or the StateInfo doesn't define one.

insetsback to summary
private Insets insets

Insets.

opaqueback to summary
private boolean opaque

Should the component be opaque?

painterback to summary
private SynthPainter painter

Painter to use if the StateInfo doesn't have one.

PENDINGback to summary
private static final Object PENDING
statesback to summary
private DefaultSynthStyle.StateInfo[] states

Information specific to ComponentState.

synthGraphicsback to summary
private SynthGraphicsUtils synthGraphics

SynthGraphics, may be null.

Constructor Detail

DefaultSynthStyleback to summary
public DefaultSynthStyle()

Nullary constructor, intended for subclassers.

DefaultSynthStyleback to summary
public DefaultSynthStyle(DefaultSynthStyle style)

Creates a new DefaultSynthStyle that is a copy of the passed in style. Any StateInfo's of the passed in style are cloned as well.

Parameters
style:DefaultSynthStyle

Style to duplicate

DefaultSynthStyleback to summary
public DefaultSynthStyle(Insets insets, boolean opaque, DefaultSynthStyle.StateInfo[] states, Map<Object, Object> data)

Creates a new DefaultSynthStyle.

Parameters
insets:Insets

Insets for the Style

opaque:boolean

Whether or not the background is completely painted in an opaque color

states:DefaultSynthStyle.StateInfo[]

StateInfos describing properties per state

data:Map<Object, Object>

Style specific data.

Method Detail

addToback to summary
public DefaultSynthStyle addTo(DefaultSynthStyle style)

Merges the contents of this Style with that of the passed in Style, returning the resulting merged style. Properties of this DefaultSynthStyle will take precedence over those of the passed in DefaultSynthStyle. For example, if this style specifics a non-null font, the returned style will have its font so to that regardless of the style's font.

Parameters
style:DefaultSynthStyle

Style to add our styles to

Returns:DefaultSynthStyle

Merged style.

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Creates a clone of this style.

Returns:Object

Clone of this style

getback to summary
public Object get(SynthContext state, Object key)

Overrides javax.swing.plaf.synth.SynthStyle.get.

Getter for a region specific style property.

Parameters
state:SynthContext

SynthContext identifying requestor

key:Object

Property being requested.

Returns:Object

Value of the named property

getColorback to summary
public Color getColor(SynthContext context, ColorType type)

Overrides javax.swing.plaf.synth.SynthStyle.getColor.

Doc from javax.swing.plaf.synth.SynthStyle.getColor.

Returns the color for the specified state. This gives precedence to foreground and background of the JComponent. If the Color from the JComponent is not appropriate, or not used, this will invoke getColorForState. Subclasses should generally not have to override this, instead override getColorForState.

getColorback to summary
public Color getColor(JComponent c, Region id, int state, ColorType type)
getColorForStateback to summary
protected Color getColorForState(SynthContext context, ColorType type)

Implements abstract javax.swing.plaf.synth.SynthStyle.getColorForState.

Doc from javax.swing.plaf.synth.SynthStyle.getColorForState.

Returns the color for the specified state. This should NOT call any methods on the JComponent.

getColorForStateback to summary
protected Color getColorForState(JComponent c, Region id, int state, ColorType type)

Returns the color for the specified state.

Parameters
c:JComponent

JComponent the style is associated with

id:Region

Region identifier

state:int

State of the region.

type:ColorType

Type of color being requested.

Returns:Color

Color to render with

getDataback to summary
public Map<Object, Object> getData()

Returns the style specific data.

Returns:Map<Object, Object>

Style specific data.

getDefaultValueback to summary
public Object getDefaultValue(SynthContext context, Object key)

Returns the default value for a particular property. This is only invoked if this style doesn't define a property for key.

Parameters
context:SynthContext

SynthContext identifying requestor

key:Object

Property being requested.

Returns:Object

Value of the named property

getFontback to summary
public Font getFont(SynthContext state)

Overrides javax.swing.plaf.synth.SynthStyle.getFont.

Doc from javax.swing.plaf.synth.SynthStyle.getFont.

Returns the Font for the specified state. This redirects to the JComponent from the context as necessary. If this does not redirect to the JComponent getFontForState is invoked.

getFontback to summary
public Font getFont(JComponent c, Region id, int state)
getFontForStateback to summary
protected Font getFontForState(JComponent c, Region id, int state)

Returns the font for the specified state. This should NOT callback to the JComponent.

Parameters
c:JComponent

JComponent the style is associated with

id:Region

Region identifier

state:int

State of the region.

Returns:Font

Font to render with

getFontForStateback to summary
protected Font getFontForState(SynthContext context)

Implements abstract javax.swing.plaf.synth.SynthStyle.getFontForState.

Doc from javax.swing.plaf.synth.SynthStyle.getFontForState.

Returns the font for the specified state. This should NOT call any method on the JComponent.

getGraphicsUtilsback to summary
public SynthGraphicsUtils getGraphicsUtils(SynthContext context)

Overrides javax.swing.plaf.synth.SynthStyle.getGraphicsUtils.

Returns a SynthGraphicsUtils.

Parameters
context:SynthContext

SynthContext identifying requestor

Returns:SynthGraphicsUtils

SynthGraphicsUtils

getInsetsback to summary
public Insets getInsets(SynthContext state, Insets to)

Overrides javax.swing.plaf.synth.SynthStyle.getInsets.

Returns the Insets. If to is non-null the resulting insets will be placed in it, otherwise a new Insets object will be created and returned.

Parameters
state:SynthContext

SynthContext identifying requestor

to:Insets

Where to place Insets

Returns:Insets

Insets.

getKeyFromDataback to summary
private Object getKeyFromData(Map<Object, Object> stateData, Object key)
getPainterback to summary
public SynthPainter getPainter(SynthContext ss)

Overrides javax.swing.plaf.synth.SynthStyle.getPainter.

Returns the Painter for the passed in Component. This may return null.

Parameters
ss:SynthContext

SynthContext identifying requestor

Returns:SynthPainter

Painter for the border

getStateInfoback to summary
public DefaultSynthStyle.StateInfo[] getStateInfo()

Returns the array of StateInfo's that that are used to specify properties specific to a particular style.

Returns:DefaultSynthStyle.StateInfo[]

Array of StateInfos.

getStateInfoback to summary
public DefaultSynthStyle.StateInfo getStateInfo(int state)

Returns the best matching StateInfo for a particular state.

Parameters
state:int

Component state.

Returns:DefaultSynthStyle.StateInfo

Best matching StateInfo, or null

isOpaqueback to summary
public boolean isOpaque(SynthContext ss)

Overrides javax.swing.plaf.synth.SynthStyle.isOpaque.

Returns the value to initialize the opacity property of the Component to. A Style should NOT assume the opacity will remain this value, the developer may reset it or override it.

Parameters
ss:SynthContext

SynthContext identifying requestor

Returns:boolean

opaque Whether or not the JComponent is opaque.

setDataback to summary
public void setData(Map<Object, Object> data)

Sets style specific values. This does NOT copy the data, it assigns it directly to this Style.

Parameters
data:Map<Object, Object>

Style specific values

setFontback to summary
public void setFont(Font font)

Sets the font that is used if there is no matching StateInfo, or it does not define a font.

Parameters
font:Font

Font to use for rendering

setGraphicsUtilsback to summary
public void setGraphicsUtils(SynthGraphicsUtils graphics)

Sets the SynthGraphicsUtils that will be used for rendering.

Parameters
graphics:SynthGraphicsUtils

SynthGraphics

setInsetsback to summary
public void setInsets(Insets insets)

Sets the insets.

Parameters
insets:Insets

the new insets.

setOpaqueback to summary
public void setOpaque(boolean opaque)

Sets whether or not the JComponent should be opaque.

Parameters
opaque:boolean

Whether or not the JComponent should be opaque.

setPainterback to summary
public void setPainter(SynthPainter painter)

Sets the Painter to use for the border.

Parameters
painter:SynthPainter

Painter for the Border.

setStateInfoback to summary
public void setStateInfo(DefaultSynthStyle.StateInfo[] states)

Sets the array of StateInfo's which are used to specify properties specific to a particular style.

Parameters
states:DefaultSynthStyle.StateInfo[]

StateInfos

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

sun.swing.plaf.synth back to summary

public Class DefaultSynthStyle.StateInfo

extends Object
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.synth.ParsedSynthStyle.StateInfo

StateInfo represents Style information specific to the state of a component.

Field Summary

Modifier and TypeField and Description
private Color[]
private Map<Object, Object>
private Font
private int

Constructor Summary

AccessConstructor and Description
public
StateInfo()

Creates a new StateInfo.

public
StateInfo(int
Component state(s) that this StateInfo should be used for
state
,
Font
Font for this state
font
,
Color[]
Colors for this state
colors
)

Creates a new StateInfo with the specified properties

public
StateInfo(DefaultSynthStyle.StateInfo
StateInfo to copy.
info
)

Creates a new StateInfo that is a copy of the passed in StateInfo.

Method Summary

Modifier and TypeMethod and Description
public DefaultSynthStyle.StateInfo

Returns:

Merged StateInfo.
addTo
(DefaultSynthStyle.StateInfo
StateInfo to add our styles to
info
)

Merges the contents of this StateInfo with that of the passed in StateInfo, returning the resulting merged StateInfo.

public Object

Returns:

Copy of this StateInfo.
clone
()

Overrides java.lang.Object.clone.

Creates and returns a copy of this StateInfo.

public Color

Returns:

Color.
getColor
(ColorType type)

Returns the Color to used for the specified ColorType.

public Color[]

Returns:

Array of colors
getColors
()

Returns the array of colors to use for rendering this state.

public int

Returns:

state info.
getComponentState
()

Returns the state this StateInfo corresponds to.

public Map<Object, Object>
public Font

Returns:

Returns the font to use for rendering this state
getFont
()

Returns the font for this state.

public void
setColors(Color[]
Array of colors
colors
)

Sets the array of colors to use for rendering this state.

public void
setComponentState(int
info.
state
)

Sets the state this StateInfo corresponds to.

public void
public void
setFont(Font
Font to use for rendering
font
)

Sets the font for this state.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

colorsback to summary
private Color[] colors
databack to summary
private Map<Object, Object> data
fontback to summary
private Font font
stateback to summary
private int state

Constructor Detail

StateInfoback to summary
public StateInfo()

Creates a new StateInfo.

StateInfoback to summary
public StateInfo(int state, Font font, Color[] colors)

Creates a new StateInfo with the specified properties

Parameters
state:int

Component state(s) that this StateInfo should be used for

font:Font

Font for this state

colors:Color[]

Colors for this state

StateInfoback to summary
public StateInfo(DefaultSynthStyle.StateInfo info)

Creates a new StateInfo that is a copy of the passed in StateInfo.

Parameters
info:DefaultSynthStyle.StateInfo

StateInfo to copy.

Method Detail

addToback to summary
public DefaultSynthStyle.StateInfo addTo(DefaultSynthStyle.StateInfo info)

Merges the contents of this StateInfo with that of the passed in StateInfo, returning the resulting merged StateInfo. Properties of this StateInfo will take precedence over those of the passed in StateInfo. For example, if this StateInfo specifics a non-null font, the returned StateInfo will have its font so to that regardless of the StateInfo's font.

Parameters
info:DefaultSynthStyle.StateInfo

StateInfo to add our styles to

Returns:DefaultSynthStyle.StateInfo

Merged StateInfo.

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this StateInfo.

Returns:Object

Copy of this StateInfo.

getColorback to summary
public Color getColor(ColorType type)

Returns the Color to used for the specified ColorType.

Returns:Color

Color.

getColorsback to summary
public Color[] getColors()

Returns the array of colors to use for rendering this state. This is indexed by ColorType.getID().

Returns:Color[]

Array of colors

getComponentStateback to summary
public int getComponentState()

Returns the state this StateInfo corresponds to.

Returns:int

state info.

See Also
SynthConstants
getDataback to summary
public Map<Object, Object> getData()
getFontback to summary
public Font getFont()

Returns the font for this state.

Returns:Font

Returns the font to use for rendering this state

setColorsback to summary
public void setColors(Color[] colors)

Sets the array of colors to use for rendering this state. This is indexed by ColorType.getID().

Parameters
colors:Color[]

Array of colors

setComponentStateback to summary
public void setComponentState(int state)

Sets the state this StateInfo corresponds to.

Parameters
state:int

info.

See Also
SynthConstants
setDataback to summary
public void setData(Map<Object, Object> data)
setFontback to summary
public void setFont(Font font)

Sets the font for this state.

Parameters
font:Font

Font to use for rendering

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.