edu.princeton.cs.algs4.growingtree.framework
Class KeySettings

java.lang.Object
  extended by edu.princeton.cs.algs4.growingtree.framework.KeySettings
All Implemented Interfaces:
java.lang.Cloneable

public class KeySettings
extends java.lang.Object
implements java.lang.Cloneable

The class provides an object that refers to the settings of a DrawableKey. Many static variables are available for use as defaults and different settings. Additionally, a static method getScheme becomes very useful in acquiring the object with a given color scheme.

The class implements cloneable, making copies of the object possible. The copies are shallow copies which means changes to the specific elements could be dangerous when numerous instances refer to the same elements. For example, modifying the rule of the given AlphaComposite, modifies the rule for all KeySettings that refer to that AlphaComposite. Therefore, it is suggested that no modifications to the specific elements be made. Instead, simply use a different element.

Version:
3.0 9/01/02
Author:
Corey Sanders
See Also:
DrawableKey, NodeSettings

Field Summary
static java.lang.String ANIMATOR_SCHEME_1
          Default animating color scheme.
static java.lang.String ANIMATOR_SCHEME_2
          Animator Scheme 2.
static java.lang.String ANIMATOR_SCHEME_3
          Animator Scheme 3.
static java.lang.String ANIMATOR_SCHEME_4
          Animator Scheme 4.
static java.lang.String BLACK_SCHEME
          Black color scheme.
static java.lang.String CHRISTMAS_SCHEME
          Princeton color scheme.
static java.lang.String DEFAULT_SCHEME
          Default color scheme.
static java.lang.String DEFAULT_SCHEME_2
          Old Default color scheme.
static java.lang.String ERASE
          Erasing color scheme.
static java.awt.Font fontDefault
          Default Font for Key Drawing (Serif, Font.PLAIN).
static java.lang.String GHOST_SCHEME
          Ghost color scheme.
static float keyAlphaAnimateDefault
          Default alpha for Key Animating (.8).
static float keyAlphaDefault
          Default alpha for Key Drawing (1.0).
static java.awt.AlphaComposite keyCompositeAnimateDefault
          Default Composite for key animating (AlphaComposite(keyRuleDefault, keyAlphaAnimateDefault)).
static java.awt.AlphaComposite keyCompositeDefault
          Default Composite for key drawing (AlphaComposite(keyRuleDefault, keyAlphaDefault)).
static java.awt.Color keyDefaultColor
          Default Paint for Key Fill (PaintSettings.lightWhite).
static java.awt.BasicStroke keyDefaultStroke
          Default Stroke for Key Drawing (BasicStroke(.05)).
static java.awt.Color keyOutlineDefaultColor
          Default Paint for Key Stroke (Color.black).
static int keyRuleDefault
          Default AlphaComposite rule for Key Drawing (SRC_OVER).
static java.lang.String original
          String used in getSettingName to define an undefined settings.
static java.lang.String SUBTREE_COUNT_SCHEME
           
static java.lang.String WHITE_SCHEME
          White color scheme.
 
Constructor Summary
KeySettings()
          Constructor, contructs a default defined KeySettings.
KeySettings(java.lang.String scheme)
          Constructor, contructs a defined KeySettings with the given scheme.
 
Method Summary
 java.lang.Object clone()
          Returns a copy of this AffineTransform object.
 java.awt.Font getFont()
          Gets the Font used for drawing the key.
 java.awt.Composite getKeyComposite()
          Gets the key composite.
 java.awt.Paint getKeyFillPaint()
          Gets the key fill paint.
 java.awt.Paint getKeyOutlinePaint()
          Gets the key outline paint.
 java.awt.Stroke getKeyOutlineStroke()
          Gets the outline stroke of the key.
 float getKeyOutlineStrokeWidth()
          Gets the outline stroke width of the key.
static java.lang.String[] getList()
          Gets an array of String elements representing every NodeSettings choice available.
static KeySettings getScheme(java.lang.String s)
          Gets a KeySettings that defines the given int scheme.
 java.lang.String getSettingName()
          Gets the string name for the current settings.
 void setAllSettings(KeySettings s)
          Sets the settings of just the key of the KeySettings, using the KeySettings passed.
 void setFont(java.awt.Font f)
          Sets the Font used for drawing the key.
 void setKeyComposite(java.awt.Composite c)
          Sets the key composite.
 void setKeyFillPaint(java.awt.Paint p)
          Sets the paint for filling the key.
 void setKeyOutlinePaint(java.awt.Paint p)
          Sets the paint for the outline of the key.
 void setKeyOutlineStroke(java.awt.BasicStroke s)
          Sets the key stroke.
 void setKeyOutlineStroke(java.awt.Stroke s, float w)
          Sets the stroke for the key.
 void setScheme(java.lang.String s)
          Sets the scheme of the settings, using Color.white as the default background color, if the background color is indeed needed.
 void setScheme(java.lang.String s, java.awt.Color background)
          Sets the scheme of the settings, using the background color if needed.
 void setSettingName(java.lang.String settingName)
          Sets the string name for the current settings.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keyDefaultStroke

public static final java.awt.BasicStroke keyDefaultStroke
Default Stroke for Key Drawing (BasicStroke(.05)).


keyOutlineDefaultColor

public static final java.awt.Color keyOutlineDefaultColor
Default Paint for Key Stroke (Color.black).


keyDefaultColor

public static final java.awt.Color keyDefaultColor
Default Paint for Key Fill (PaintSettings.lightWhite).


keyRuleDefault

public static final int keyRuleDefault
Default AlphaComposite rule for Key Drawing (SRC_OVER).

See Also:
Constant Field Values

keyAlphaDefault

public static final float keyAlphaDefault
Default alpha for Key Drawing (1.0).

See Also:
Constant Field Values

keyAlphaAnimateDefault

public static final float keyAlphaAnimateDefault
Default alpha for Key Animating (.8).

See Also:
Constant Field Values

fontDefault

public static final java.awt.Font fontDefault
Default Font for Key Drawing (Serif, Font.PLAIN).


keyCompositeDefault

public static final java.awt.AlphaComposite keyCompositeDefault
Default Composite for key drawing (AlphaComposite(keyRuleDefault, keyAlphaDefault)).


keyCompositeAnimateDefault

public static final java.awt.AlphaComposite keyCompositeAnimateDefault
Default Composite for key animating (AlphaComposite(keyRuleDefault, keyAlphaAnimateDefault)).


DEFAULT_SCHEME

public static final java.lang.String DEFAULT_SCHEME
Default color scheme. (Uses the defaults of above).

See Also:
Constant Field Values

DEFAULT_SCHEME_2

public static final java.lang.String DEFAULT_SCHEME_2
Old Default color scheme.

See Also:
Constant Field Values

SUBTREE_COUNT_SCHEME

public static final java.lang.String SUBTREE_COUNT_SCHEME
See Also:
Constant Field Values

ERASE

public static final java.lang.String ERASE
Erasing color scheme. (Background color and larger stroke widths).

See Also:
Constant Field Values

BLACK_SCHEME

public static final java.lang.String BLACK_SCHEME
Black color scheme.

See Also:
Constant Field Values

GHOST_SCHEME

public static final java.lang.String GHOST_SCHEME
Ghost color scheme.

See Also:
Constant Field Values

WHITE_SCHEME

public static final java.lang.String WHITE_SCHEME
White color scheme.

See Also:
Constant Field Values

CHRISTMAS_SCHEME

public static final java.lang.String CHRISTMAS_SCHEME
Princeton color scheme.

See Also:
Constant Field Values

ANIMATOR_SCHEME_1

public static final java.lang.String ANIMATOR_SCHEME_1
Default animating color scheme. (Uses the defaults of above).

See Also:
Constant Field Values

ANIMATOR_SCHEME_2

public static final java.lang.String ANIMATOR_SCHEME_2
Animator Scheme 2.

See Also:
Constant Field Values

ANIMATOR_SCHEME_3

public static final java.lang.String ANIMATOR_SCHEME_3
Animator Scheme 3.

See Also:
Constant Field Values

ANIMATOR_SCHEME_4

public static final java.lang.String ANIMATOR_SCHEME_4
Animator Scheme 4.

See Also:
Constant Field Values

original

public static final java.lang.String original
String used in getSettingName to define an undefined settings.

See Also:
Constant Field Values
Constructor Detail

KeySettings

public KeySettings()
Constructor, contructs a default defined KeySettings.


KeySettings

public KeySettings(java.lang.String scheme)
Constructor, contructs a defined KeySettings with the given scheme.

Parameters:
int - scheme, defining the scheme of this KeySettings.
Method Detail

getScheme

public static KeySettings getScheme(java.lang.String s)
Gets a KeySettings that defines the given int scheme. The scheme must be one defined within the class, otherwise the default scheme is returned.

Parameters:
s - defined color scheme within the class.
Returns:
KeySettings that defines the given color scheme or default if no color scheme exists.

getList

public static java.lang.String[] getList()
Gets an array of String elements representing every NodeSettings choice available.


getSettingName

public java.lang.String getSettingName()
Gets the string name for the current settings.

Returns:
String defining the settings name.

setSettingName

public void setSettingName(java.lang.String settingName)
Sets the string name for the current settings.

Parameters:
settingName - String defining the settings name.

setScheme

public void setScheme(java.lang.String s)
Sets the scheme of the settings, using Color.white as the default background color, if the background color is indeed needed.

Parameters:
s - defined color scheme within the class.

setScheme

public void setScheme(java.lang.String s,
                      java.awt.Color background)
Sets the scheme of the settings, using the background color if needed.

Parameters:
s - defined color scheme within the class.
background - background color if needed.

clone

public java.lang.Object clone()
Returns a copy of this AffineTransform object.

Overrides:
clone in class java.lang.Object
Returns:
an Object that is a copy of this AffineTransform object.

setAllSettings

public void setAllSettings(KeySettings s)
Sets the settings of just the key of the KeySettings, using the KeySettings passed.

Parameters:
s - KeySettings to which the node settings are set.

setFont

public void setFont(java.awt.Font f)
Sets the Font used for drawing the key.

Parameters:
f - Font used for drawing.

setKeyFillPaint

public void setKeyFillPaint(java.awt.Paint p)
Sets the paint for filling the key.

Parameters:
p - Paint for filling the key.

setKeyOutlineStroke

public void setKeyOutlineStroke(java.awt.Stroke s,
                                float w)
Sets the stroke for the key.

Parameters:
s - Stroke that sets the key stroke.
w - Width of the Stroke for drawing corrections.

setKeyOutlineStroke

public void setKeyOutlineStroke(java.awt.BasicStroke s)
Sets the key stroke. No width is necessary, becuase BasicStroke defines a getLineWidth method.

Parameters:
s - BasicStroke for drawing the key.

setKeyOutlinePaint

public void setKeyOutlinePaint(java.awt.Paint p)
Sets the paint for the outline of the key.

Parameters:
p - Paint for drawing the outline of the key.

setKeyComposite

public void setKeyComposite(java.awt.Composite c)
Sets the key composite. Generally an AlphaComposite is used.

Parameters:
c - Composite for drawing the key.

getFont

public java.awt.Font getFont()
Gets the Font used for drawing the key.

Returns:
Font used for drawing.

getKeyFillPaint

public java.awt.Paint getKeyFillPaint()
Gets the key fill paint.

Returns:
fill Paint of the key.

getKeyOutlineStroke

public java.awt.Stroke getKeyOutlineStroke()
Gets the outline stroke of the key.

Returns:
Stroke outline of the key.

getKeyOutlineStrokeWidth

public float getKeyOutlineStrokeWidth()
Gets the outline stroke width of the key.

Returns:
width of the outline of the key.

getKeyOutlinePaint

public java.awt.Paint getKeyOutlinePaint()
Gets the key outline paint.

Returns:
outline Paint of the key.

getKeyComposite

public java.awt.Composite getKeyComposite()
Gets the key composite.

Returns:
Composite of the key.