diva.canvas.interactor
Class CircleGeometry

java.lang.Object
  extended by diva.canvas.interactor.CircleGeometry
All Implemented Interfaces:
Geometry

public class CircleGeometry
extends java.lang.Object
implements Geometry

A class that provides support for manipulating the bounds of a figure. Because this geometry only provides one site at the bounds of the figure, and transforms the bounds equally in all directions, it makes sense to only use this Geometry type for figures containing circular shapes or otherwise highly-symmetric shapes.

Version:
$Id: CircleGeometry.java 47877 2008-01-24 00:35:12Z cxh $
Author:
Nick Zamora

Nested Class Summary
 class CircleGeometry.CircleSite
          CircleSite is the local class that implements an editable site of Rectangle objects.
 
Field Summary
private  double _minSize
          The minimum size of the circle
private  Figure _parentFigure
          The figure to which the sites are attached
private  java.awt.geom.Rectangle2D _rect
          The defining rectangle
private static int _siteCount
          The number of sites in the sites array.
private  CircleGeometry.CircleSite[] _sites
          The sites that exist so far
 
Constructor Summary
CircleGeometry(Figure figure, java.awt.geom.Rectangle2D bounds)
          Create a new geometry object on the given figure and with the given initial bounds.
 
Method Summary
 java.awt.geom.Rectangle2D getBounds()
          Get the current rectangle that defines this geometry.
 Figure getFigure()
          Get the figure to which this geometry object is attached.
 double getMinimumSize()
          Get the minimum size of the rectangle.
 Site getN()
          Get the north site (only site).
 java.awt.Shape getShape()
          Get the current shape that defines this geometry
 Site getSite(int id)
          Get the single site with the given ID.
 void setBounds(java.awt.geom.Rectangle2D rect)
          Set the rectangle that defines this geometry object.
 void setMinimumSize(double minimumSize)
          Set the minimum size of the rectangle.
 void setShape(java.awt.Shape shape)
          Set the shape that defines this geometry object.
 java.util.Iterator sites()
          Return an iteration over the sites in this geometry object.
 void translate(double x, double y)
          Translate the geometry object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_parentFigure

private Figure _parentFigure
The figure to which the sites are attached


_minSize

private double _minSize
The minimum size of the circle


_rect

private java.awt.geom.Rectangle2D _rect
The defining rectangle


_siteCount

private static int _siteCount
The number of sites in the sites array. Note: SwingConstants start at 1!


_sites

private CircleGeometry.CircleSite[] _sites
The sites that exist so far

Constructor Detail

CircleGeometry

public CircleGeometry(Figure figure,
                      java.awt.geom.Rectangle2D bounds)
Create a new geometry object on the given figure and with the given initial bounds.

Method Detail

getSite

public Site getSite(int id)
Get the single site with the given ID.


getMinimumSize

public double getMinimumSize()
Get the minimum size of the rectangle.


getN

public Site getN()
Get the north site (only site).


getFigure

public Figure getFigure()
Get the figure to which this geometry object is attached. Returns null if there isn't one.

Specified by:
getFigure in interface Geometry

getShape

public java.awt.Shape getShape()
Get the current shape that defines this geometry

Specified by:
getShape in interface Geometry

getBounds

public java.awt.geom.Rectangle2D getBounds()
Get the current rectangle that defines this geometry. This returns the same shape as getShape(), but as a Rectangle2D type.


setMinimumSize

public void setMinimumSize(double minimumSize)
Set the minimum size of the rectangle. The default is 1.0.


setShape

public void setShape(java.awt.Shape shape)
Set the shape that defines this geometry object. The shape must be a Rectangle2D, or an exception will be thrown.

Specified by:
setShape in interface Geometry

setBounds

public void setBounds(java.awt.geom.Rectangle2D rect)
Set the rectangle that defines this geometry object. This is the same as setShape(), but does not need to perform the type check.


sites

public java.util.Iterator sites()
Return an iteration over the sites in this geometry object.


translate

public void translate(double x,
                      double y)
Translate the geometry object

Specified by:
translate in interface Geometry