ecologylab.xml.library.geom
Class Rectangle2DDoubleState

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.xml.ElementState
          extended by ecologylab.xml.library.geom.RectangularShape
              extended by ecologylab.xml.library.geom.Rectangle2DDoubleState
All Implemented Interfaces:
OptimizationTypes, XMLTranslationExceptionTypes, java.awt.Shape

public class Rectangle2DDoubleState
extends RectangularShape

Encapsulates a Rectangle2D.Double for use in translating to/from XML. ***WARNING!!!*** Performing transformations (such as setFrame()) on the result of getRect() will cause this object to become out of synch with its underlying Rectangle2D. DO NOT DO THIS! If other transformation methods are required, either notify me, or implement them yourself. :D Accessor methods (such as contains()) on the result of getRect() are fine.

Author:
Zachary O. Toups (toupsz@cs.tamu.edu)

Nested Class Summary
 
Nested classes/interfaces inherited from class ecologylab.xml.ElementState
ElementState.ClassToCollectionMap, ElementState.DeclarationStyle, ElementState.xml_attribute, ElementState.xml_class, ElementState.xml_classes, ElementState.xml_collection, ElementState.xml_leaf, ElementState.xml_map, ElementState.xml_nested, ElementState.xml_tag
 
Field Summary
 
Fields inherited from class ecologylab.xml.library.geom.RectangularShape
h, w, x, y
 
Fields inherited from class ecologylab.xml.ElementState
CDATA, ESTIMATE_CHARS_PER_FIELD, FLOATING_PRECISION_OFF, MARSHALLING_PARAMS, NORMAL, UTF16, UTF16_LE, UTF8, XML_FILE_HEADER
 
Fields inherited from interface ecologylab.xml.OptimizationTypes
BAD_FIELD, COLLECTION_ELEMENT, COLLECTION_SCALAR, IGNORED_ATTRIBUTE, IGNORED_ELEMENT, LEAF_NODE_VALUE, MAP_ELEMENT, MAP_SCALAR, NAME_SPACE_ATTRIBUTE, NAME_SPACE_LEAF_NODE, NAME_SPACE_MASK, NAME_SPACE_NESTED_ELEMENT, NAMESPACE_IGNORED_ELEMENT, NAMESPACE_TRIAL_ELEMENT, OTHER_NESTED_ELEMENT, REGULAR_ATTRIBUTE, REGULAR_NESTED_ELEMENT, ROOT, UNSET_TYPE, XMLNS_ATTRIBUTE, XMLNS_IGNORED
 
Fields inherited from interface ecologylab.xml.XMLTranslationExceptionTypes
FILE_NOT_FOUND, IO_EXCEPTION, NULL_PURL, UNKNOWN
 
Constructor Summary
Rectangle2DDoubleState()
           
Rectangle2DDoubleState(double x, double y, double width, double height)
           
 
Method Summary
 boolean contains(double x, double y)
           
 boolean contains(double x, double y, double w, double h)
           
 boolean contains(java.awt.geom.Point2D p)
           
 boolean contains(java.awt.geom.Rectangle2D r)
           
 java.awt.Rectangle getBounds()
           
 java.awt.geom.Rectangle2D getBounds2D()
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at, double flatness)
           
static Vector2d[] getSurfaceNormals()
          Determines the surface normals for each of the sides of the rectangular object.
 boolean intersects(double x, double y, double w, double h)
           
 boolean intersects(java.awt.geom.Rectangle2D r)
           
 java.awt.geom.Rectangle2D.Double shape()
          Returns an Rectangle2D object represented by this.
 
Methods inherited from class ecologylab.xml.library.geom.RectangularShape
getHeight, getWidth, getX, getY, setFrame
 
Methods inherited from class ecologylab.xml.ElementState
addNestedElement, addNestedElement, appendTextNodeString, buildDOM, buildDOM, buildDOM, buildDOM, buildDOM, buildDOMFromXMLCharSequence, buildDOMFromXMLString, checkAnnotation, convertNameStyles, createChildHook, fieldToXMLOptimizations, floatingPrecision, getCollection, getElementStateById, getMap, getNestedNameSpace, getTextNodeString, leafElementFieldNames, lookupNestedNameSpace, optimizations, parent, postTranslationProcessingHook, preTranslationProcessingHook, recycle, setDeclarationStyle, setFieldUsingTypeRegistry, setFloatingPrecision, setParent, setUseDOMForTranslateTo, translateFromXML, translateFromXML, translateFromXML, translateFromXML, translateFromXML, translateFromXMLCharSequence, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOMCharSequence, translateFromXMLDOMCharSequence, translateFromXMLRootNode, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateToDOM, translateToXML, translateToXML, translateToXML, translateToXML, writePrettyXML, writePrettyXML, writePrettyXML
 
Methods inherited from class ecologylab.generic.Debug
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, toString, warning, warning, weird, weird
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rectangle2DDoubleState

public Rectangle2DDoubleState()

Rectangle2DDoubleState

public Rectangle2DDoubleState(double x,
                              double y,
                              double width,
                              double height)
Method Detail

shape

public java.awt.geom.Rectangle2D.Double shape()
Returns an Rectangle2D object represented by this.

Specified by:
shape in class RectangularShape

contains

public boolean contains(java.awt.geom.Point2D p)

contains

public boolean contains(java.awt.geom.Rectangle2D r)

contains

public boolean contains(double x,
                        double y)

contains

public boolean contains(double x,
                        double y,
                        double w,
                        double h)

getBounds

public java.awt.Rectangle getBounds()

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at,
                                                  double flatness)

intersects

public boolean intersects(java.awt.geom.Rectangle2D r)

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)

getSurfaceNormals

public static Vector2d[] getSurfaceNormals()
Determines the surface normals for each of the sides of the rectangular object. These are stored in an array, with entry 0 indicating the top (-y) normal, and the others progressing clockwise from there. The normals are assumed to lie in the X-Y plane.

Returns:
a Vector2d array with each entry corresponding to the surface normal of one of the sides.