/*
* @(#)Ellipse2DNode.java
*
* Last Modified: 9/15/01
*/
import java.awt.*;
import java.awt.geom.*;
/**
* Ellipse2DNode
class implements NodeShape for it is an Ellipse NodeShape
* that can be used as a node in a tree.
* * Because it is simply a Shape that also implements getInscribedRectangle, it therefore can * use all methods defined within Ellipse2DNode.
*
* @see java.awt.geom.Ellipse2D
* @see NodeShape
*
* @author Corey Sanders
* @version 1.2 9/15/01
*/
public class Ellipse2DNode extends Ellipse2D.Double implements NodeShape {
/**
* Constructs a new Ellipse2D
, initialized to
* location (0, 0) and size (0, 0).
*/
public Ellipse2DNode() {
super();
}
/**
* Constructs and initializes an Ellipse2D
from the
* specified coordinates.
* @param x, y the coordinates of the bounding rectangle
* @param w the width of the rectangle
* @param h the height of the rectangle
*/
public Ellipse2DNode(double x, double y, double w, double h) {
super(x,y,w,h);
}
/**
* Get the Inscribed Rectangle of the current Ellipse2DNode
according to the
* specifications of the NodeShape
Interface.
*
* @return Rectangle2D that represents the inscribedRectangle of the Ellipse2DNode
.
*/
public Rectangle2D getInscribedRectangle() {
// x and y start at 1/4 the width in.
double x = getX() + getWidth()/4.0;
double y = getY() + getHeight()/4.0;
// Width and Height are half of the node.
double width = getWidth()/2.0;
double height = getHeight()/2.0;
return new Rectangle2D.Double(x,y,width,height);
}
}