public class

DefaultSynthStyle

extends SynthStyle
implements Cloneable
java.lang.Object
   ↳ javax.swing.plaf.synth.SynthStyle
     ↳ sun.swing.plaf.synth.DefaultSynthStyle

Class Overview

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.

Summary

Nested Classes
class DefaultSynthStyle.StateInfo StateInfo represents Style information specific to the state of a component. 
Public Constructors
DefaultSynthStyle()
Nullary constructor, intended for subclassers.
DefaultSynthStyle(DefaultSynthStyle style)
Creates a new DefaultSynthStyle that is a copy of the passed in style.
DefaultSynthStyle(Insets insets, boolean opaque, StateInfo[] states, Map data)
Creates a new DefaultSynthStyle.
Public Methods
DefaultSynthStyle addTo(DefaultSynthStyle style)
Merges the contents of this Style with that of the passed in Style, returning the resulting merged syle.
Object clone()
Creates a clone of this style.
Object get(SynthContext state, Object key)
Getter for a region specific style property.
Color getColor(JComponent c, Region id, int state, ColorType type)
Color getColor(SynthContext context, ColorType type)
Returns the color for the specified state.
Map getData()
Returns the style specific data.
Object getDefaultValue(SynthContext context, Object key)
Returns the default value for a particular property.
Font getFont(JComponent c, Region id, int state)
Font getFont(SynthContext state)
Returns the Font for the specified state.
SynthGraphicsUtils getGraphicsUtils(SynthContext context)
Returns a SynthGraphicsUtils.
Insets getInsets(SynthContext state, Insets to)
Returns the Insets.
SynthPainter getPainter(SynthContext ss)
Returns the Painter for the passed in Component.
DefaultSynthStyle.StateInfo getStateInfo(int state)
Returns the best matching StateInfo for a particular state.
StateInfo[] getStateInfo()
Returns the array of StateInfo's that that are used to specify properties specific to a particular style.
boolean isOpaque(SynthContext ss)
Returns the value to initialize the opacity property of the Component to.
void setData(Map data)
Sets style specific values.
void setFont(Font font)
Sets the font that is used if there is no matching StateInfo, or it does not define a font.
void setGraphicsUtils(SynthGraphicsUtils graphics)
Sets the SynthGraphicsUtils that will be used for rendering.
void setInsets(Insets insets)
Sets the insets.
void setOpaque(boolean opaque)
Sets whether or not the JComponent should be opaque.
void setPainter(SynthPainter painter)
Sets the Painter to use for the border.
void setStateInfo(StateInfo[] states)
Sets the array of StateInfo's which are used to specify properties specific to a particular style.
String toString()
Returns a string representation of the object.
Protected Methods
Color getColorForState(JComponent c, Region id, int state, ColorType type)
Returns the color for the specified state.
Color getColorForState(SynthContext context, ColorType type)
Returns the color for the specified state.
Font getFontForState(SynthContext context)
Returns the font for the specified state.
Font getFontForState(JComponent c, Region id, int state)
Returns the font for the specified state.
[Expand]
Inherited Methods
From class javax.swing.plaf.synth.SynthStyle
From class java.lang.Object

Public Constructors

public DefaultSynthStyle ()

Nullary constructor, intended for subclassers.

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 clonsed as well.

Parameters
style Style to duplicate

public DefaultSynthStyle (Insets insets, boolean opaque, StateInfo[] states, Map data)

Creates a new DefaultSynthStyle.

Parameters
insets Insets for the Style
opaque Whether or not the background is completely painted in an opaque color
states StateInfos describing properties per state
data Style specific data.

Public Methods

public DefaultSynthStyle addTo (DefaultSynthStyle style)

Merges the contents of this Style with that of the passed in Style, returning the resulting merged syle. 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 Style to add our styles to
Returns
  • Merged style.

public Object clone ()

Creates a clone of this style.

Returns
  • Clone of this style

public Object get (SynthContext state, Object key)

Getter for a region specific style property.

Parameters
state SynthContext indentifying requestor
key Property being requested.
Returns
  • Value of the named property

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

public Color getColor (SynthContext context, ColorType type)

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(SynthContext, ColorType).

Parameters
context SynthContext identifying requester
type Type of color being requested.
Returns
  • Color

public Map getData ()

Returns the style specific data.

Returns
  • Style specific data.

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
key Property being requested.
Returns
  • Value of the named property

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

public Font getFont (SynthContext state)

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(SynthContext) is invoked.

Parameters
state SynthContext identifying requester
Returns
  • Font to render with

public SynthGraphicsUtils getGraphicsUtils (SynthContext context)

Returns a SynthGraphicsUtils.

Parameters
context SynthContext indentifying requestor
Returns
  • SynthGraphicsUtils

public Insets getInsets (SynthContext state, Insets to)

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 identifying requester
to Where to place Insets
Returns
  • Insets.

public SynthPainter getPainter (SynthContext ss)

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

Parameters
ss SynthContext indentifying requestor
Returns
  • Painter for the border

public DefaultSynthStyle.StateInfo getStateInfo (int state)

Returns the best matching StateInfo for a particular state.

Parameters
state Component state.
Returns
  • Best matching StateInfo, or null

public StateInfo[] getStateInfo ()

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

Returns
  • Array of StateInfos.

public boolean isOpaque (SynthContext ss)

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 indentifying requestor
Returns
  • opaque Whether or not the JComponent is opaque.

public void setData (Map data)

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

Parameters
data Style specific values

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 to use for rendering

public void setGraphicsUtils (SynthGraphicsUtils graphics)

Sets the SynthGraphicsUtils that will be used for rendering.

Parameters
graphics SynthGraphics

public void setInsets (Insets insets)

Sets the insets.

public void setOpaque (boolean opaque)

Sets whether or not the JComponent should be opaque.

Parameters
opaque Whether or not the JComponent should be opaque.

public void setPainter (SynthPainter painter)

Sets the Painter to use for the border.

Parameters
painter Painter for the Border.

public void setStateInfo (StateInfo[] states)

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

Parameters
states StateInfos

public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
  • a string representation of the object.

Protected Methods

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

Returns the color for the specified state.

Parameters
c JComponent the style is associated with
id Region identifier
state State of the region.
type Type of color being requested.
Returns
  • Color to render with

protected Color getColorForState (SynthContext context, ColorType type)

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

Parameters
context SynthContext identifying requester
type Type of color being requested.
Returns
  • Color to render with

protected Font getFontForState (SynthContext context)

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

Parameters
context SynthContext identifying requester
Returns
  • Font to render with

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 the style is associated with
id Region identifier
state State of the region.
Returns
  • Font to render with