att.grappa
Class GrappaBox

java.lang.Object
  extended by java.awt.geom.RectangularShape
      extended by java.awt.geom.Rectangle2D
          extended by java.awt.geom.Rectangle2D.Double
              extended by att.grappa.GrappaBox
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, java.lang.Cloneable

public class GrappaBox
extends java.awt.geom.Rectangle2D.Double

This class extends java.awt.geom.Rectangle2D.Double and provides built-in string-to-Rectangle2D and Rectangle2D-to-string conversions suitable for Grappa.

Version:
1.2, 21 Aug 2005; Copyright 1996 - 2005 by AT&T Corp.
Author:
John Mocenigo, Research @ AT&T Labs
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
private  boolean dimensioned
           
private static long serialVersionUID
           
 
Fields inherited from class java.awt.geom.Rectangle2D.Double
height, width, x, y
 
Fields inherited from class java.awt.geom.Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
 
Constructor Summary
GrappaBox()
          Constructs and initializes a GrappaBox with upper-left coordinates (0, 0) and zero width and height.
GrappaBox(double x, double y, double width, double height)
          Constructs and initializes a GrappaBox with the specified coordinates.
GrappaBox(java.awt.geom.Rectangle2D r)
          Constructs and initializes a GrappaBox from a Rectangle2D
GrappaBox(java.lang.String coordString)
          Constructs and initializes a GrappaBox with the coordinates derived from the specified String representation.
GrappaBox(java.lang.String coordString, boolean dimensioned)
          Constructs and initializes a GrappaBox with the coordinates derived from the specified String representation.
 
Method Summary
 boolean isDimensioned()
          Returns true if the String format will be "x1,x2,width,height" or false if the format will be "x1,y1,x2,y2".
 java.lang.String toAttributeString()
          Provides a string representation of this object consistent with Grappa attributes.
 java.lang.String toFormattedString(java.lang.String format)
          Provides a formatted string representation of this object.
 java.lang.String toString()
          Provides a generic string representation of this object.
 
Methods inherited from class java.awt.geom.Rectangle2D.Double
createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, setRect, setRect
 
Methods inherited from class java.awt.geom.Rectangle2D
add, add, add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, union
 
Methods inherited from class java.awt.geom.RectangularShape
clone, contains, contains, getBounds, 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
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

dimensioned

private boolean dimensioned
Constructor Detail

GrappaBox

public GrappaBox()
Constructs and initializes a GrappaBox with upper-left coordinates (0, 0) and zero width and height.


GrappaBox

public GrappaBox(java.awt.geom.Rectangle2D r)
Constructs and initializes a GrappaBox from a Rectangle2D

Parameters:
r - the rectangle defining the box (1-to-1 correspondence)

GrappaBox

public GrappaBox(double x,
                 double y,
                 double width,
                 double height)
Constructs and initializes a GrappaBox with the specified coordinates.

Parameters:
x, y - the upper-left position coordinates of the box
width, height - the size of the box

GrappaBox

public GrappaBox(java.lang.String coordString,
                 boolean dimensioned)
Constructs and initializes a GrappaBox with the coordinates derived from the specified String representation. When the dimensioned parameter is true, then the String format should be: "x-coord,y-coord,width,height" otherwise it should be: "x1-coord,y1-coord,x2-coord,y2-coord"

Parameters:
coordString - String representing the coordinates to which to set the newly constructed GrappaBox
dimensioned - a boolean indicating the format of the string

GrappaBox

public GrappaBox(java.lang.String coordString)
Constructs and initializes a GrappaBox with the coordinates derived from the specified String representation. The String format should be: "x-coord,y-coord,width,height""

Parameters:
coordString - String representing the coordinates to which to set the newly constructed GrappaBox
Method Detail

toAttributeString

public java.lang.String toAttributeString()
Provides a string representation of this object consistent with Grappa attributes.

Returns:
attribute-suitable string representation of this GrappaBox.

toFormattedString

public java.lang.String toFormattedString(java.lang.String format)
Provides a formatted string representation of this object.

Parameters:
format - the format used to build the string (%b is the base directive for a GrappaBox).
Returns:
a string representation of this GrappaBox.

toString

public java.lang.String toString()
Provides a generic string representation of this object.

Overrides:
toString in class java.awt.geom.Rectangle2D.Double
Returns:
a generic string representation of this GrappaBox.

isDimensioned

public boolean isDimensioned()
Returns true if the String format will be "x1,x2,width,height" or false if the format will be "x1,y1,x2,y2". The value is determined at creation time.

Returns:
a boolean indicating the format of this Object's string representation