com.jfimagine.jfgraph.geom
Class RoundedRect

java.lang.Object
  |
  +--com.jfimagine.jfgraph.geom.Rect
        |
        +--com.jfimagine.jfgraph.geom.RoundedRect
All Implemented Interfaces:
java.lang.Cloneable

public class RoundedRect
extends Rect

RoundedRect class. A class used to represent a rounded rectangle in the plane with double coordinates. A rounded rectangle will always be a regular rectangle, but not parallelogram or trapezoid.

Attention: Here we used a clockwise quadrant system. And the first quadrant is under right bottom corner.

Version:
$Revision: 1.1 $
Author:
CookieMaker

Field Summary
protected  double m_radius
          radius of each rounded corner.
 
Fields inherited from class com.jfimagine.jfgraph.geom.Rect
m_leftBottom, m_leftTop, m_rightBottom, m_rightTop, SIDETYPE_BOTTOM, SIDETYPE_LEFT, SIDETYPE_RIGHT, SIDETYPE_TOP, VERTEXMOVETYPE_ISOSCELESTRAPEZOID, VERTEXMOVETYPE_PARALLEL, VERTEXMOVETYPE_RECTANGLE, VERTEXMOVETYPE_SCALE, VERTEXMOVETYPE_TRAPEZOID, VERTEXTYPE_LEFTBOTTOM, VERTEXTYPE_LEFTTOP, VERTEXTYPE_RIGHTBOTTOM, VERTEXTYPE_RIGHTTOP
 
Constructor Summary
RoundedRect()
          Constructor for RoundedRect.
RoundedRect(double x, double y, double w, double h, double r)
          Constructor for RoundedRect.
RoundedRect(RoundedRect rect)
          Constructor for RoundedRect.
 
Method Summary
 java.lang.Object clone()
          Creates a new object of the same class and with the same contents as this object.
 boolean equals(java.lang.Object obj)
          Determines whether or not two objects are equal.
 Arc getCornerArc(int vertex)
          get an rounded corner arc.
 JFPoint getCornerCenterPoint(int vertex)
          get an end point at the rounded corner curve.
 JFPoint getCornerEndPoint(int startVertex, int endVertex)
          get an end point at the rounded corner curve.
 void getCornerRect(int vertex, Rect rect)
          get an rounded corner rectangle(include the rounded corner).
 double getRadius()
          get the radius of current rounded rectangle.
 LineSeg getSide(int sideType)
          Get a side line of this rectangle.
 int hashCode()
          Returns the hashcode for this Object.
 LineSeg pickLine(double x, double y, double pickOffset)
          Pick a line segment of this rectangle by a point with a pickoffset.
 void setRadius(double radius)
          set the radius of current rounded rectangle.
 void setValue(double x, double y, double w, double h, double r)
          Set the bounds of current rectangle.
 void setValue(Rect rect)
          Set the value of current rectangle.
 java.lang.String toString()
          Convert this object to String
 
Methods inherited from class com.jfimagine.jfgraph.geom.Rect
canAddPort, contains, contains, flipBy, flipBy, getBounds, getCenter, getHeight, getVertex, getWidth, getX, getY, intersects, intersects, intersects, intersects, intersects, mirrorBy, mirrorBy, moveBy, moveVertex, newScaleCenter, rotateBy, rotateBy, rotateBy, scaleBy, scaleBy, setValue, setVertex, setVertex
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m_radius

protected double m_radius
radius of each rounded corner.

Constructor Detail

RoundedRect

public RoundedRect()
Constructor for RoundedRect.


RoundedRect

public RoundedRect(RoundedRect rect)
Constructor for RoundedRect.

Parameters:
rect - A rectangle object.

RoundedRect

public RoundedRect(double x,
                   double y,
                   double w,
                   double h,
                   double r)
Constructor for RoundedRect.

Parameters:
x - X coordiate.
y - Y coordiate.
w - Width of this rectangle.
h - Height of this rectangle.
r - Radius of each rounded corner.
Method Detail

setValue

public void setValue(double x,
                     double y,
                     double w,
                     double h,
                     double r)
Set the bounds of current rectangle.

Parameters:
x - X coordiate.
y - Y coordiate.
w - Width of this rectangle.
h - Height of this rectangle.
r - Radius of each rounded corner.

setValue

public void setValue(Rect rect)
Set the value of current rectangle.

Overrides:
setValue in class Rect
Parameters:
rect - A new rectangle.

getRadius

public double getRadius()
get the radius of current rounded rectangle.

Returns:
The radius.

setRadius

public void setRadius(double radius)
set the radius of current rounded rectangle.

Parameters:
radius - The radius.

getCornerEndPoint

public JFPoint getCornerEndPoint(int startVertex,
                                 int endVertex)
get an end point at the rounded corner curve.

Parameters:
startVertex - The type of start vertex type.
endVertex - The type of end vertex type.
Returns:
The end point.

getCornerCenterPoint

public JFPoint getCornerCenterPoint(int vertex)
get an end point at the rounded corner curve.

Parameters:
vertex - The type of the vertex type.
Returns:
The end point.

getCornerRect

public void getCornerRect(int vertex,
                          Rect rect)
get an rounded corner rectangle(include the rounded corner).

Parameters:
vertex - The type of the vertex type.
rect - The return corner rectangle. note: the lefttop vertex of return is the corner vertex, the rightTop vertex is the near point that under clockwise side of line from corner vertex to curve center, the rightBottom vertex is the center of corner curve, the leftBottom vertex is the near point that under counter-clockwise side of line from corner vertex to curve center.

getCornerArc

public Arc getCornerArc(int vertex)
get an rounded corner arc.

Parameters:
vertex - The type of the vertex type.
Returns:
The corner arc.

getSide

public LineSeg getSide(int sideType)
Get a side line of this rectangle. We we must consider each side will be shorten by two 'RADIUS' distances of the rounded corner.

Overrides:
getSide in class Rect
Returns:
A side line.

pickLine

public LineSeg pickLine(double x,
                        double y,
                        double pickOffset)
Pick a line segment of this rectangle by a point with a pickoffset.

Overrides:
pickLine in class Rect
Parameters:
x - X coordinate of this point.
y - Y coordinate of this point.
pickOffset - An analog pick offset that great equal than 0.
Returns:
A line segment picked.

toString

public java.lang.String toString()
Convert this object to String

Overrides:
toString in class Rect
Returns:
An string represents the content of the object

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a new object of the same class and with the same contents as this object.

Overrides:
clone in class Rect
Returns:
A clone of this instance.
java.lang.CloneNotSupportedException

hashCode

public int hashCode()
Returns the hashcode for this Object.

Overrides:
hashCode in class Rect
Returns:
hash code for this Point2D.

equals

public boolean equals(java.lang.Object obj)
Determines whether or not two objects are equal.

Overrides:
equals in class Rect
Parameters:
obj - an object to be compared with this object
Returns:
true if the object to be compared is an instance of Port and has the same values; false otherwise.


Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All Rights Reserved.