drvgraph.j2d
Class ClassBox

java.lang.Object
  extended by java.awt.geom.RectangularShape
      extended by java.awt.geom.Rectangle2D
          extended by java.awt.Rectangle
              extended by drvgraph.j2d.ClassBox
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public class ClassBox
extends java.awt.Rectangle
implements java.lang.Comparable

Represents the class box. Class boxes are simply containers that are populated with one or more class patterns.
Class boxes have a name (the corresponding class name) and a number of class patterns, which are stored in a vector.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D
java.awt.geom.Rectangle2D.Double, java.awt.geom.Rectangle2D.Float
 
Field Summary
 
Fields inherited from class java.awt.Rectangle
height, width, x, y
 
Fields inherited from class java.awt.geom.Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
 
Constructor Summary
ClassBox()
          Creates a class box with no name and an empty vector of class patterns.
ClassBox(java.lang.String cn, java.util.Vector<ClassPattern> cp)
          Creates a class box with a defined class name and a given vector of class patterns.
 
Method Summary
 void addClassPattern(ClassPattern cp)
          Adds the specified class pattern to the end of the class pattern vector, increasing its size by one.
 int compareTo(java.lang.Object anotherCb)
          Compares this class box with a given class box.
 java.lang.String getClassName()
          Returns a string that represents the class name.
 java.util.Vector<ClassPattern> getClassPatterns()
          Returns the vector, containing the class patterns included in the class box.
 boolean isSelected()
          Checks if the class box is selected.
 void paint(java.awt.Graphics g)
          Draws the class box.
 void removeClassPattern(ClassPattern cp)
          Removes the specified class pattern from the class pattern vector, reducing its size by one.
 void setClassName(java.lang.String className)
          Sets the class name.
 void setClassPatterns(java.util.Vector<ClassPattern> classPatterns)
          Sets the class pattern vector of the specific class box.
 void setSelected(boolean b)
          Sets the "selected" status of the class box.
 
Methods inherited from class java.awt.Rectangle
add, add, add, contains, contains, contains, contains, createIntersection, createUnion, equals, getBounds, getBounds2D, getHeight, getLocation, getSize, getWidth, getX, getY, grow, inside, intersection, intersects, isEmpty, move, outcode, reshape, resize, setBounds, setBounds, setLocation, setLocation, setRect, setSize, setSize, toString, translate, union
 
Methods inherited from class java.awt.geom.Rectangle2D
add, add, add, contains, contains, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, setRect, union
 
Methods inherited from class java.awt.geom.RectangularShape
clone, contains, contains, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.Shape
contains, contains, contains, contains, getPathIterator, getPathIterator, intersects, intersects
 

Constructor Detail

ClassBox

public ClassBox()
Creates a class box with no name and an empty vector of class patterns.


ClassBox

public ClassBox(java.lang.String cn,
                java.util.Vector<ClassPattern> cp)
Creates a class box with a defined class name and a given vector of class patterns.

Parameters:
cn - the class name string
cp - the initial vector of class patterns
See Also:
ClassPattern
Method Detail

getClassName

public java.lang.String getClassName()
Returns a string that represents the class name.

Returns:
the class name string

setClassName

public void setClassName(java.lang.String className)
Sets the class name.

Parameters:
className - the string used as the class name

getClassPatterns

public java.util.Vector<ClassPattern> getClassPatterns()
Returns the vector, containing the class patterns included in the class box.

Returns:
the class pattern vector
See Also:
ClassPattern

setClassPatterns

public void setClassPatterns(java.util.Vector<ClassPattern> classPatterns)
Sets the class pattern vector of the specific class box.

Parameters:
classPatterns - the class pattern vector
See Also:
ClassPattern

addClassPattern

public void addClassPattern(ClassPattern cp)
Adds the specified class pattern to the end of the class pattern vector, increasing its size by one.

Parameters:
cp - the class pattern to be added
See Also:
ClassPattern

removeClassPattern

public void removeClassPattern(ClassPattern cp)
Removes the specified class pattern from the class pattern vector, reducing its size by one. If the class pattern is not included in the vector, then no changes take place.

Parameters:
cp - the class pattern to be removed
See Also:
ClassPattern

setSelected

public void setSelected(boolean b)
Sets the "selected" status of the class box. Its value can either be "true" or "false".

Parameters:
b - the "selected" status flag (true|false)

isSelected

public boolean isSelected()
Checks if the class box is selected.

Returns:
the class box "selected" status

paint

public void paint(java.awt.Graphics g)
Draws the class box. Even empty class boxes (i.e. class boxes that contain no class patterns) are drawn. The number and size of the included class patterns determines the final size of the class box.

Parameters:
g - the Graphics component that draws the class box
See Also:
Graphics, ClassPattern

compareTo

public int compareTo(java.lang.Object anotherCb)
              throws java.lang.ClassCastException
Compares this class box with a given class box.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
anotherCb - the class box to compare this class box to
Returns:
the comparison outcome: 0 if the two class boxes are identical, -1 otherwise
Throws:
java.lang.ClassCastException - A ClassCastException is thrown if the Object to compare this object to belongs to a different class.