com.rolemodelsoft.drawlet.examples.graphnode
Class GraphNode

java.lang.Object
  |
  +--com.rolemodelsoft.drawlet.basics.AbstractPaintable
        |
        +--com.rolemodelsoft.drawlet.basics.AbstractFigure
              |
              +--com.rolemodelsoft.drawlet.shapes.AbstractShape
                    |
                    +--com.rolemodelsoft.drawlet.shapes.FilledShape
                          |
                          +--com.rolemodelsoft.drawlet.shapes.AbstractRectangleShape
                                |
                                +--com.rolemodelsoft.drawlet.shapes.rectangles.RectangleShape
                                      |
                                      +--com.rolemodelsoft.drawlet.examples.graphnode.GraphNode
Direct Known Subclasses:
ArrowGraphNode

public class GraphNode
extends RectangleShape
implements LabelHolder

Here is a simple example of a graph node figure.

See Also:
Serialized Form

Field Summary
protected  StringRenderer renderer
          the renderer responsible for drawing the label.
protected  java.lang.String string
          the label associated with this graphnode.
protected  java.awt.Color textColor
          the color of the text in the graphnode.
 
Fields inherited from class com.rolemodelsoft.drawlet.shapes.AbstractRectangleShape
height, width, x, y
 
Fields inherited from class com.rolemodelsoft.drawlet.shapes.FilledShape
fillColor, lineColor
 
Fields inherited from class com.rolemodelsoft.drawlet.basics.AbstractFigure
listeners, locationListeners
 
Constructor Summary
GraphNode()
           
 
Method Summary
protected  ConnectedLineCreationHandle basicNewLineCreationHandle()
          Answer a new line creation handle
protected  void changedShape(java.awt.Rectangle rect)
          Denote that the shape changed.
protected  void changedSize(java.awt.Dimension dimension)
          Denote that size changed.
protected  int defaultHeight()
          Answer the default/initial value for height
protected  java.lang.String defaultString()
          Answer the default/initial value for string
protected  java.awt.Color defaultTextColor()
          Answer the default/initial value for textColor
protected  int defaultWidth()
          Answer the default/initial value for width
 Handle editTool(int x, int y)
          Answers a Handle that will provide editing capabilities on the receiver.
 Handle[] getHandles()
          Answer the handles associated with the receiver.
 java.awt.Rectangle getLabelBounds()
          Returns the current bounds of the label.
protected  StringRenderer getRenderer()
          Answer the renderer to paint the label.
 java.lang.String getString()
          Answer the string the figure paints.
 DrawingStyle getStyle()
          Answer the style which defines how to paint the figure.
 java.awt.Color getTextColor()
          Answer the Color to use when drawing text.
 void paint(java.awt.Graphics g)
          Paints the figure.
 void paintText(java.awt.Graphics original)
          Paints the text.
 Locator requestConnection(Figure requestor, int x, int y)
          Answers a Locator corresponding to a significant point on the receiver that will serve as a connection to the other figure.
protected  void resetSizeCache()
          Flush caches with respect to determining size.
 void setString(java.lang.String newString)
          Set the string the figure paints.
 void setStyle(DrawingStyle style)
          Set the style defining how to paint the figure.
 void setTextColor(java.awt.Color color)
          Set the Color to use when drawing text.
 
Methods inherited from class com.rolemodelsoft.drawlet.shapes.rectangles.RectangleShape
paintFilled, paintStrokes
 
Methods inherited from class com.rolemodelsoft.drawlet.shapes.AbstractRectangleShape
basicMove, basicReshape, basicResize, basicTranslate, defaultX, defaultY, getBounds, getSize
 
Methods inherited from class com.rolemodelsoft.drawlet.shapes.FilledShape
defaultFillColor, defaultLineColor, getFillColor, getLineColor, isOpaque, isStroked, setFillColor, setLineColor
 
Methods inherited from class com.rolemodelsoft.drawlet.shapes.AbstractShape
resetBoundsCache, reshapedPolygon, reshapedPolygon, setBounds, setSize
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractFigure
addPropertyChangeListener, addRelatedLocationListener, changedLocation, contains, contains, contains, deleteLocationListeners, disconnect, duplicate, duplicateIn, estimatedDuplicateSize, figureFromLocator, fireLocationChange, firePropertyChange, firePropertyChange, fireRelationChange, fireShapeChange, fireSizeChange, getLocation, getLocator, intersects, intersects, isObsolete, isWithin, isWithin, locatorAt, move, move, postDuplicate, relatedLocationListeners, removePropertyChangeListener, removeRelatedLocationListener, resetLocationCache, setSize, translate
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractPaintable
getBottom, getHeight, getLeft, getRight, getTop, getWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

string

protected java.lang.String string
the label associated with this graphnode.

textColor

protected java.awt.Color textColor
the color of the text in the graphnode.

renderer

protected transient StringRenderer renderer
the renderer responsible for drawing the label.
Constructor Detail

GraphNode

public GraphNode()
Method Detail

basicNewLineCreationHandle

protected ConnectedLineCreationHandle basicNewLineCreationHandle()
Answer a new line creation handle

changedShape

protected void changedShape(java.awt.Rectangle rect)
Denote that the shape changed.
Overrides:
changedShape in class AbstractRectangleShape
Parameters:
rect - the old bounds.

changedSize

protected void changedSize(java.awt.Dimension dimension)
Denote that size changed.
Overrides:
changedSize in class AbstractFigure
Parameters:
dimension - the old dimensions.

defaultHeight

protected int defaultHeight()
Answer the default/initial value for height
Overrides:
defaultHeight in class AbstractRectangleShape
Returns:
an integer representing the default/initial value for height

defaultString

protected java.lang.String defaultString()
Answer the default/initial value for string
Returns:
a String representing the default/inital value for string

defaultTextColor

protected java.awt.Color defaultTextColor()
Answer the default/initial value for textColor
Returns:
a Color representing the default/initial value for textColor

defaultWidth

protected int defaultWidth()
Answer the default/initial value for width
Overrides:
defaultWidth in class AbstractRectangleShape
Returns:
an integer representing the default/initial value for width

editTool

public Handle editTool(int x,
                       int y)
Answers a Handle that will provide editing capabilities on the receiver.
Overrides:
editTool in class AbstractFigure
Parameters:
x - the x coordinate to potentially begin editing
y - the y coordinate to potentially begin editing
Returns:
a Handle that will provide editing capabilities on the receiver

getHandles

public Handle[] getHandles()
Answer the handles associated with the receiver.
Overrides:
getHandles in class AbstractShape
Returns:
an array of the Handles associated with the receiver

getLabelBounds

public java.awt.Rectangle getLabelBounds()
Returns the current bounds of the label.
Specified by:
getLabelBounds in interface LabelHolder
Returns:
a Rectangle representing the current bounds of the label

getRenderer

protected StringRenderer getRenderer()
Answer the renderer to paint the label.
Returns:
the StringRender to paint the label

getString

public java.lang.String getString()
Answer the string the figure paints.
Returns:
the String the figure paints

getStyle

public DrawingStyle getStyle()
Answer the style which defines how to paint the figure.
Overrides:
getStyle in class FilledShape
Returns:
the DrawingStyle which defines how to paint the figure

getTextColor

public java.awt.Color getTextColor()
Answer the Color to use when drawing text.
Returns:
the Color to use when drawing text

paint

public void paint(java.awt.Graphics g)
Paints the figure.
Overrides:
paint in class FilledShape
Parameters:
g - the specified Graphics window

paintText

public void paintText(java.awt.Graphics original)
Paints the text.
Parameters:
g - the specified Graphics window

requestConnection

public Locator requestConnection(Figure requestor,
                                 int x,
                                 int y)
Answers a Locator corresponding to a significant point on the receiver that will serve as a connection to the other figure. By default, make it the middle of the receiver. Subclasses may wish to do something more meaningful.
Overrides:
requestConnection in class AbstractFigure
Parameters:
x - the x coordinate of the requested locator
y - the y coordinate of the requested locator

resetSizeCache

protected void resetSizeCache()
Flush caches with respect to determining size. This is a hook method. Subclasses may wish to override.
Overrides:
resetSizeCache in class AbstractShape

setString

public void setString(java.lang.String newString)
Set the string the figure paints.
Parameters:
newString - the string to paint

setStyle

public void setStyle(DrawingStyle style)
Set the style defining how to paint the figure.
Overrides:
setStyle in class FilledShape
Parameters:
style - the specified DrawingStyle

setTextColor

public void setTextColor(java.awt.Color color)
Set the Color to use when drawing text.
Parameters:
color - the color