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

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

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

The class provides an object that refers to the settings of a node in a Tree. 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 NodeSettings 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:
1.5 9/15/01
Author:
Corey Sanders

Field Summary
static java.lang.String ANIMATION_SCHEME_1
          Default Animating color scheme for the animator.
static java.lang.String ANIMATION_SCHEME_2
          Animating color scheme 2.
static java.lang.String ANIMATION_SCHEME_3
          Animating color scheme 3.
static java.lang.String ANIMATION_SCHEME_4
          Animating color scheme 4.
static java.lang.String ANIMATION_SCHEME_5
          Animating color scheme 5.
static java.lang.String ANIMATOR_SCHEME_1
          Animator color scheme 1.
static java.lang.String ANIMATOR_SCHEME_2
          Animator color scheme 2.
static java.lang.String ANIMATOR_SCHEME_3
          Animator color scheme 3.
static java.lang.String ANIMATOR_SCHEME_4
          Animator color scheme 4.
static java.lang.String ANIMATOR_SCHEME_5
          Animator color scheme 5.
static java.lang.String BLACK_SCHEME
          Black color scheme.
static java.lang.String CHRISTMAS_SCHEME
          Christmas 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.lang.String GHOST_SCHEME
          Ghost color scheme.
static java.lang.String HALLOWEEN_SCHEME
          Halloween color scheme.
static float linkAlphaAnimateDefault
          Default AlphaComposite alpha for link animating (0.6).
static float linkAlphaDefault
          Default AlphaComposite alpha for link drawing (0.8).
static java.awt.AlphaComposite linkCompositeAnimateDefault
          Default Composite for link animating (AlphaComposite(linkRuleDefault, linkAlphaAnimateDefault)).
static java.awt.AlphaComposite linkCompositeDefault
          Default Composite for link drawing (AlphaComposite(linkRuleDefault, linkAlphaDefault)).
static java.awt.Color linkDefaultColor
          Default Paint for link drawing (PaintSettings.lightWhite)
static java.awt.BasicStroke linkDefaultStroke
          Default Stroke for link drawing (BasicStroke(1)).
static int linkRuleDefault
          Default AlphaComposite rule for link drawing (SRC_IN).
static float nodeAlphaAnimateDefault
          Default AlphaComposite alpha for node animating (0.8).
static float nodeAlphaDefault
          Default AlphaComposite alpha for node drawing (1.0).
static java.awt.AlphaComposite nodeCompositeAnimateDefault
          Default Composite for node animating (AlphaComposite(nodeRuleDefault, nodeAlphaAnimateDefault)).
static java.awt.AlphaComposite nodeCompositeDefault
          Default Composite for node drawing (AlphaComposite(nodeRuleDefault, nodeAlphaDefault)).
static java.awt.Color nodeDefaultFillColor
          Default Paint for node drawing (PaintSettings.darkBlue)
static NodeShape nodeDefaultShape
          Default NodeShape for node drawing (Ellipse2DNode)
static java.awt.Color nodeOutlineDefaultColor
          Default Paint for node outline drawing (PaintSettings.darkBlue)
static java.awt.BasicStroke nodeOutlineDefaultStroke
          Default Stroke for node drawing (BasicStroke(1.5)).
static int nodeRuleDefault
          Default AlphaComposite rule for node drawing (SRC_OVER).
static java.lang.String original
          String used in getSettingName to define an undefined settings.
static java.lang.String PRINCETON_SCHEME
          Princeton color scheme.
static java.awt.BasicStroke redLinkDefaultStroke
           
static java.lang.String ROTATION_SCHEME_1
          Rotation Scheme 1.
static java.lang.String ROTATION_SCHEME_2
          Rotation Scheme 2.
static java.lang.String ROTATION_SCHEME_3
          Rotation Scheme 3.
static java.lang.String ROTATION_SCHEME_4
          Rotation Scheme 4.
static java.lang.String TREE_SCHEME
          Tree color scheme.
static java.lang.String WHITE_SCHEME
          White color scheme.
 
Constructor Summary
NodeSettings()
          Constructor, contructs a default defined NodeSettings.
NodeSettings(java.lang.String scheme)
          Constructor, contructs a defined NodeSettings with the given scheme.
 
Method Summary
 java.lang.Object clone()
          Returns a copy of this NodeSettings object.
 java.awt.Composite getLeftLinkComposite()
          Gets the left link composite.
 java.awt.Paint getLeftLinkPaint()
          Gets the left link paint.
 java.awt.Stroke getLeftLinkStroke()
          Gets the left link stroke.
 float getLeftLinkStrokeWidth()
          Gets the left link stroke width.
static java.lang.String[] getList()
          Gets an array of String elements representing every NodeSettings choice available.
 java.awt.Composite getNodeComposite()
          Gets the node composite.
 java.awt.Paint getNodeFillPaint()
          Gets the node fill paint.
 java.awt.Paint getNodeOutlinePaint()
          Gets the node outline paint.
 java.awt.Stroke getNodeOutlineStroke()
          Gets the outline stroke of the node.
 float getNodeOutlineStrokeWidth()
          Gets the outline stroke width of the node.
 NodeShape getNodeShape()
          Gets the NodeShape of the settings.
 java.awt.Composite getRightLinkComposite()
          Gets the right link composite.
 java.awt.Paint getRightLinkPaint()
          Gets the right link paint.
 java.awt.Stroke getRightLinkStroke()
          Gets the right link stroke.
 float getRightLinkStrokeWidth()
          Gets the right link stroke width.
static NodeSettings getScheme(java.lang.String s)
          Gets a NodeSettings that defines the given int scheme.
static NodeSettings getScheme(java.lang.String s, java.awt.Color background)
          Gets a NodeSettings that defines the given int scheme.
 java.lang.String getSettingName()
          Gets the string name for the current settings.
 void setAllSettings(NodeSettings s)
          Sets the settings of just the node of the NodeSettings, using the NodeSettings passed.
 void setLeftLinkComposite(java.awt.Composite c)
          Sets the left composite.
 void setLeftLinkPaint(java.awt.Paint p)
          Sets the left link paint.
 void setLeftLinkStroke(java.awt.Stroke s)
          Sets the left link stroke.
 void setLeftLinkStroke(java.awt.Stroke s, float w)
          Sets the left link stroke.
 void setLeftSettings(NodeSettings s)
          Sets the left settings of the NodeSettings, using the NodeSettings passed.
 void setNodeComposite(java.awt.Composite c)
          Sets the node composite.
 void setNodeFillPaint(java.awt.Paint p)
          Sets the paint for filling the node.
 void setNodeOutlinePaint(java.awt.Paint p)
          Sets the paint for the outline of the node.
 void setNodeOutlineStroke(java.awt.BasicStroke s)
          Sets the node stroke.
 void setNodeOutlineStroke(java.awt.Stroke s, float w)
          Sets the stroke for the node.
 void setNodeSettings(NodeSettings s)
          Sets the settings of just the node of the NodeSettings, using the NodeSettings passed.
 void setNodeShape(NodeShape s)
          Sets the NodeShape for the settings.
 void setRightLinkComposite(java.awt.Composite c)
          Sets the right composite.
 void setRightLinkPaint(java.awt.Paint p)
          Sets the right link paint.
 void setRightLinkStroke(java.awt.Stroke s)
          Sets the right link stroke.
 void setRightLinkStroke(java.awt.Stroke s, float w)
          Sets the right link stroke.
 void setRightSettings(NodeSettings s)
          Sets the right settings of the NodeSettings, using the NodeSettings passed.
 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

nodeRuleDefault

public static final int nodeRuleDefault
Default AlphaComposite rule for node drawing (SRC_OVER).

See Also:
Constant Field Values

linkRuleDefault

public static final int linkRuleDefault
Default AlphaComposite rule for link drawing (SRC_IN).

See Also:
Constant Field Values

nodeAlphaDefault

public static final float nodeAlphaDefault
Default AlphaComposite alpha for node drawing (1.0).

See Also:
Constant Field Values

nodeAlphaAnimateDefault

public static final float nodeAlphaAnimateDefault
Default AlphaComposite alpha for node animating (0.8).

See Also:
Constant Field Values

linkAlphaDefault

public static final float linkAlphaDefault
Default AlphaComposite alpha for link drawing (0.8).

See Also:
Constant Field Values

linkAlphaAnimateDefault

public static final float linkAlphaAnimateDefault
Default AlphaComposite alpha for link animating (0.6).

See Also:
Constant Field Values

linkDefaultStroke

public static final java.awt.BasicStroke linkDefaultStroke
Default Stroke for link drawing (BasicStroke(1)).


redLinkDefaultStroke

public static final java.awt.BasicStroke redLinkDefaultStroke

linkDefaultColor

public static final java.awt.Color linkDefaultColor
Default Paint for link drawing (PaintSettings.lightWhite)


nodeDefaultShape

public static final NodeShape nodeDefaultShape
Default NodeShape for node drawing (Ellipse2DNode)


nodeDefaultFillColor

public static final java.awt.Color nodeDefaultFillColor
Default Paint for node drawing (PaintSettings.darkBlue)


nodeOutlineDefaultStroke

public static final java.awt.BasicStroke nodeOutlineDefaultStroke
Default Stroke for node drawing (BasicStroke(1.5)).


nodeOutlineDefaultColor

public static final java.awt.Color nodeOutlineDefaultColor
Default Paint for node outline drawing (PaintSettings.darkBlue)


nodeCompositeDefault

public static final java.awt.AlphaComposite nodeCompositeDefault
Default Composite for node drawing (AlphaComposite(nodeRuleDefault, nodeAlphaDefault)).


nodeCompositeAnimateDefault

public static final java.awt.AlphaComposite nodeCompositeAnimateDefault
Default Composite for node animating (AlphaComposite(nodeRuleDefault, nodeAlphaAnimateDefault)).


linkCompositeDefault

public static final java.awt.AlphaComposite linkCompositeDefault
Default Composite for link drawing (AlphaComposite(linkRuleDefault, linkAlphaDefault)).


linkCompositeAnimateDefault

public static final java.awt.AlphaComposite linkCompositeAnimateDefault
Default Composite for link animating (AlphaComposite(linkRuleDefault, linkAlphaAnimateDefault)).


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

ERASE

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

See Also:
Constant Field Values

PRINCETON_SCHEME

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

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
Christmas color scheme.

See Also:
Constant Field Values

TREE_SCHEME

public static final java.lang.String TREE_SCHEME
Tree color scheme.

See Also:
Constant Field Values

HALLOWEEN_SCHEME

public static final java.lang.String HALLOWEEN_SCHEME
Halloween color scheme.

See Also:
Constant Field Values

ANIMATION_SCHEME_1

public static final java.lang.String ANIMATION_SCHEME_1
Default Animating color scheme for the animator. (Uses the animation defaults of above).

See Also:
Constant Field Values

ANIMATION_SCHEME_2

public static final java.lang.String ANIMATION_SCHEME_2
Animating color scheme 2.

See Also:
Constant Field Values

ANIMATION_SCHEME_3

public static final java.lang.String ANIMATION_SCHEME_3
Animating color scheme 3.

See Also:
Constant Field Values

ANIMATION_SCHEME_4

public static final java.lang.String ANIMATION_SCHEME_4
Animating color scheme 4.

See Also:
Constant Field Values

ANIMATION_SCHEME_5

public static final java.lang.String ANIMATION_SCHEME_5
Animating color scheme 5.

See Also:
Constant Field Values

ANIMATOR_SCHEME_1

public static final java.lang.String ANIMATOR_SCHEME_1
Animator color scheme 1.

See Also:
Constant Field Values

ANIMATOR_SCHEME_2

public static final java.lang.String ANIMATOR_SCHEME_2
Animator color scheme 2.

See Also:
Constant Field Values

ANIMATOR_SCHEME_3

public static final java.lang.String ANIMATOR_SCHEME_3
Animator color scheme 3.

See Also:
Constant Field Values

ANIMATOR_SCHEME_4

public static final java.lang.String ANIMATOR_SCHEME_4
Animator color scheme 4.

See Also:
Constant Field Values

ANIMATOR_SCHEME_5

public static final java.lang.String ANIMATOR_SCHEME_5
Animator color scheme 5.

See Also:
Constant Field Values

ROTATION_SCHEME_1

public static final java.lang.String ROTATION_SCHEME_1
Rotation Scheme 1.

See Also:
Constant Field Values

ROTATION_SCHEME_2

public static final java.lang.String ROTATION_SCHEME_2
Rotation Scheme 2.

See Also:
Constant Field Values

ROTATION_SCHEME_3

public static final java.lang.String ROTATION_SCHEME_3
Rotation Scheme 3.

See Also:
Constant Field Values

ROTATION_SCHEME_4

public static final java.lang.String ROTATION_SCHEME_4
Rotation 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

NodeSettings

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


NodeSettings

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

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

getScheme

public static NodeSettings getScheme(java.lang.String s)
Gets a NodeSettings 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:
NodeSettings that defines the given color scheme or default if no color scheme exists.

getScheme

public static NodeSettings getScheme(java.lang.String s,
                                     java.awt.Color background)
Gets a NodeSettings 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.
background - background color if needed.
Returns:
NodeSettings 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.

setLeftSettings

public void setLeftSettings(NodeSettings s)
Sets the left settings of the NodeSettings, using the NodeSettings passed. The right settings remain untouched. Only affects the links.

Parameters:
s - NodeSettings to which the left settings are set, using the left settings.

setRightSettings

public void setRightSettings(NodeSettings s)
Sets the right settings of the NodeSettings, using the NodeSettings passed. The left settings remain untouched. Only affects the links.

Parameters:
s - NodeSettings to which the right settings are set, using the right settings.

setNodeSettings

public void setNodeSettings(NodeSettings s)
Sets the settings of just the node of the NodeSettings, using the NodeSettings passed. The link settings remain untouched. Only affects the node.

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

setAllSettings

public void setAllSettings(NodeSettings s)
Sets the settings of just the node of the NodeSettings, using the NodeSettings passed. The link settings remain untouched. Only affects the node.

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

clone

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

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

setRightLinkStroke

public void setRightLinkStroke(java.awt.Stroke s,
                               float w)
Sets the right link stroke.

Parameters:
s - Stroke that sets the right link.
w - Width of the Stroke for drawing corrections.

setRightLinkStroke

public void setRightLinkStroke(java.awt.Stroke s)
Sets the right link stroke. No width is necessary, becuase BasicStroke defines a getLineWidth method.

Parameters:
s - BasicStroke that sets the right link.

setRightLinkPaint

public void setRightLinkPaint(java.awt.Paint p)
Sets the right link paint.

Parameters:
p - Paint for the right link.

setRightLinkComposite

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

Parameters:
c - Composite for drawing the right link.

setLeftLinkStroke

public void setLeftLinkStroke(java.awt.Stroke s,
                              float w)
Sets the left link stroke.

Parameters:
s - Stroke that sets the left link.
w - Width of the Stroke for drawing corrections.

setLeftLinkStroke

public void setLeftLinkStroke(java.awt.Stroke s)
Sets the left link stroke. No width is necessary, becuase BasicStroke defines a getLineWidth method.

Parameters:
s - BasicStroke that sets the left link.

setLeftLinkPaint

public void setLeftLinkPaint(java.awt.Paint p)
Sets the left link paint.

Parameters:
p - Paint for the left link.

setLeftLinkComposite

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

Parameters:
c - Composite for drawing the left link.

setNodeShape

public void setNodeShape(NodeShape s)
Sets the NodeShape for the settings.

Parameters:
s - NodeShape for drawing the node.

setNodeFillPaint

public void setNodeFillPaint(java.awt.Paint p)
Sets the paint for filling the node.

Parameters:
p - Paint for filling the node.

setNodeOutlineStroke

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

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

setNodeOutlineStroke

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

Parameters:
s - BasicStroke for drawing the key.

setNodeOutlinePaint

public void setNodeOutlinePaint(java.awt.Paint p)
Sets the paint for the outline of the node.

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

setNodeComposite

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

Parameters:
c - Composite for drawing the node.

getLeftLinkStroke

public java.awt.Stroke getLeftLinkStroke()
Gets the left link stroke.

Returns:
Stroke of the left link.

getLeftLinkStrokeWidth

public float getLeftLinkStrokeWidth()
Gets the left link stroke width.

Returns:
double width of the left link.

getLeftLinkPaint

public java.awt.Paint getLeftLinkPaint()
Gets the left link paint.

Returns:
Paint of the left link.

getLeftLinkComposite

public java.awt.Composite getLeftLinkComposite()
Gets the left link composite.

Returns:
Composite of the left link.

getRightLinkStroke

public java.awt.Stroke getRightLinkStroke()
Gets the right link stroke.

Returns:
Stroke of the right link.

getRightLinkStrokeWidth

public float getRightLinkStrokeWidth()
Gets the right link stroke width.

Returns:
double width of the right link.

getRightLinkPaint

public java.awt.Paint getRightLinkPaint()
Gets the right link paint.

Returns:
Paint of the right link.

getRightLinkComposite

public java.awt.Composite getRightLinkComposite()
Gets the right link composite.

Returns:
Composite of the right link.

getNodeShape

public NodeShape getNodeShape()
Gets the NodeShape of the settings.

Returns:
NodeShape for the node.

getNodeFillPaint

public java.awt.Paint getNodeFillPaint()
Gets the node fill paint.

Returns:
fill Paint of the node.

getNodeOutlineStroke

public java.awt.Stroke getNodeOutlineStroke()
Gets the outline stroke of the node.

Returns:
Stroke outline of the node.

getNodeOutlineStrokeWidth

public float getNodeOutlineStrokeWidth()
Gets the outline stroke width of the node.

Returns:
double width of the outline of the node.

getNodeOutlinePaint

public java.awt.Paint getNodeOutlinePaint()
Gets the node outline paint.

Returns:
outline Paint of the node.

getNodeComposite

public java.awt.Composite getNodeComposite()
Gets the node composite.

Returns:
Composite of the node.