|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.geom.Area
ca.utoronto.cs.prefuseextensions.geom.Sector2D
public class Sector2D
Sector2D is the class for all objects that store a 2D sector defined by a outer bounding rectangle, width, start angle, and angular extent (length of the arc). The bounding rectangle defines the outer boundary of the full ellipse of which the outer arc is a partial section. The width defines the width of the sector between the inner arc and outer arc. The width is used to calculate an inner bounding rectangle which defines the outer boundary of the full ellipse of which the inner arc is a partial section. The angles are specified relative to the non-square extents of the bounding rectangles such that 45 degrees always falls on the line from the center of the ellipses to the upper right corner of the bounding rectangles. As a result, if the bounding rectangles are noticeably longer along one axis than the other, the angles to the start and end of the arc segment will be skewed farther along the longer axis of the bounds. Because of the use of radians by prefuse layouts, input angles are in radians. Angles are converted to degrees (and returned in degree) for use by java2d.awt.geom.Arc2D which forms the inner and outer arcs of the Sector2D The actual storage representation of the coordinates is maintained by the Area superclass and 2 Arc2D objects. This code is not an extension of prefuse, see license-rsf-tree.txt.
Field Summary | |
---|---|
static int |
CONSTANT_SECTOR_WIDTH
Maintain sector width as constant when drawing elliptical sectors. |
static int |
PROPORTIONAL_SECTOR_WIDTH
Alter sector width to be proportional between height and width of framing rectangle when drawing elliptical sectors. |
Constructor Summary | |
---|---|
Sector2D()
Creates an empty sector2D. |
|
Sector2D(java.awt.geom.Arc2D innerArc,
java.awt.geom.Arc2D outerArc)
Creates a Sector2D with the given inner and outer arcs as the bounds. |
|
Sector2D(double centerX,
double centerY,
double innerRadius,
double outerRadius,
double startAngle,
double angleExtent)
Creates a Sector2D centered at the given coordinates and with the specified inner and outer radii and angular span. |
|
Sector2D(double x,
double y,
double w,
double h,
double startAngle,
double angleExtent,
double width)
Creates a Sector2D within the given rectangular bounds, start angle, angle extents, and width. |
|
Sector2D(java.awt.geom.Rectangle2D ellipseBounds,
double startAngle,
double angleExtent,
double width)
Creates a Sector2D within the given rectangular bounds, start angle, angle extents, and width. |
|
Sector2D(Sector2D sector)
Creates a Sector2D with dimensions the same as a given Sector2D. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Create a copy of this Sector2D. |
double |
getAngleExtent()
Returns the angular extent of this sector. |
double |
getAngleStart()
Returns the angular start of this sector. |
double |
getCenterX()
Returns the x-coordinate of the center of the framing rectangle of the sector in double precision. |
double |
getCenterY()
Returns the y-coordinate of the center of the framing rectangle of the sector in double precision. |
int |
getEllipseMethod()
Gets the current method of drawing elliptical sectors. |
java.awt.geom.Rectangle2D |
getFrame()
Returns the framing Rectangle2D that defines the overall shape of this object. |
double |
getHeight()
Returns the height of the framing rectangle in double precision. |
java.awt.geom.Arc2D |
getInnerArc()
Get the Arc2D (PIE shaped) which forms the inner arc of this Sector2D. |
double |
getInnerRadius()
Get the radius of the ellipse for which the inner arc is a part. |
double |
getMaxX()
Returns the maximum x value (the right corner) of the bounding box which contains the ellipse which the outer arc of this sector is part. |
double |
getMaxY()
Returns the maximum y value (the lower corner) of the bounding box which contains the ellipse which the outer arc of this sector is part. |
java.awt.geom.Arc2D |
getOuterArc()
Get the Arc2D (PIE shaped) which forms the outer arc of this Sector2D |
double |
getOuterRadius()
Get the radius of the ellipse for which the outer arc is a part. |
double |
getSectorWidth()
Returns the difference in radius between the outer and inner arcs forming this sector. |
double |
getWidth()
Returns the width of the framing rectangle in double precision. |
double |
getX()
Returns the X coordinate of the upper left corner of the framing rectangle in double precision. |
double |
getY()
Returns the Y coordinate of the upper left corner of the framing rectangle in double precision. |
void |
scale(double scaleAmount)
Scales the bounding frame up or down by the absolute value scaleAmount . |
void |
scale(double scaleAmount,
double newSectorWidth)
Scales the bounding frame up or down by the absolute value scaleAmount . |
void |
setAngleExtent(double angleExtent)
Sets this sectors angular span to the given value. |
void |
setAngleStart(double startAngle)
Sets the angle start to the given value. |
void |
setEllipseMethod(int ellipseMethod)
Sets the ellipse drawing method. |
void |
setFrame(double x,
double y,
double w,
double h)
Sets the location and size of the outer bounds of this Sector2D to the specified rectangular values. |
void |
setInnerArc(java.awt.geom.Arc2D innerArc)
Sets the inner arc of this Sector2D to the dimensions of the given arc. |
void |
setInnerRadius(double innerRadius)
Sets the inner radius this Sector2D to the given value. |
void |
setOuterArc(java.awt.geom.Arc2D outerArc)
Sets the outer arc of this Sector2D to the dimensions of the given arc. |
void |
setOuterRadius(double outerRadius)
Sets the outer radius this Sector2D to the given radius. |
void |
setRadii(double innerRadius,
double outerRadius)
Sets the inner and outer radii this Sector2D to the given values. |
void |
setSector(double x,
double y,
double w,
double h,
double startAngle,
double angleExtent,
double width)
Sets the dimensions of this sector as given. |
void |
setSector(Sector2D sector)
Sets this Sector to be the same as the specified Sector. |
void |
setSectorByCenter(double centerX,
double centerY,
double innerRadius,
double outerRadius,
double startAngle,
double angleExtent)
Set this sector centered at the given coordinates and with the specified inner and outer radii and angular span. |
void |
setSectorWidth(double width)
Set the width of this sector as specified. |
Methods inherited from class java.awt.geom.Area |
---|
add, contains, contains, contains, contains, createTransformedArea, equals, exclusiveOr, getBounds, getBounds2D, getPathIterator, getPathIterator, intersect, intersects, intersects, isEmpty, isPolygonal, isRectangular, isSingular, reset, subtract, transform |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.awt.Shape |
---|
contains, contains, contains, contains, getBounds, getBounds2D, getPathIterator, getPathIterator, intersects, intersects |
Field Detail |
---|
public static final int CONSTANT_SECTOR_WIDTH
setEllipseMethod(int)
,
Constant Field Valuespublic static final int PROPORTIONAL_SECTOR_WIDTH
setEllipseMethod(int)
,
Constant Field ValuesConstructor Detail |
---|
public Sector2D()
public Sector2D(Sector2D sector)
sector
- the Sector2D whose dimensions will be copiedpublic Sector2D(java.awt.geom.Arc2D innerArc, java.awt.geom.Arc2D outerArc) throws java.lang.IllegalArgumentException
innerArc
- the inner arc which specifies the inner radius and angles of
the sectorouterArc
- the outer arc which specifies the outer radius and angles of
the sector
java.lang.IllegalArgumentException
- if the arcs do not span the same angles or if the innerArc
radius is not less than or equal to outerArc radius.public Sector2D(java.awt.geom.Rectangle2D ellipseBounds, double startAngle, double angleExtent, double width) throws java.lang.IllegalArgumentException
ellipseBounds
- the bounded rectangle for the outer arc of this sector2DstartAngle
- the angle to start this Sector2DangleExtent
- the angular width of this Sector2Dwidth
- the width of the Sector2D, extending inward from the outer arc
java.lang.IllegalArgumentException
- if the width
exceeds the radius of the outer
arc (half the width of the ellipseBounds
public Sector2D(double x, double y, double w, double h, double startAngle, double angleExtent, double width) throws java.lang.IllegalArgumentException
x
- the x-coordinate of the upper-left corner of the bounding
rectangley
- the y-coordinate of the upper-left corner of the bounding
rectanglew
- the width of the bounding rectangleh
- the height of the bounding rectanglestartAngle
- the angle to start this Sector2DangleExtent
- the angular width of this Sector2Dwidth
- the width of this Sector2D, extending inward from the outer
arc
java.lang.IllegalArgumentException
- if the width
exceeds the radius of the outer
arc (half the rectangle width w
public Sector2D(double centerX, double centerY, double innerRadius, double outerRadius, double startAngle, double angleExtent) throws java.lang.IllegalArgumentException
centerX
- the x-coordinate of the centre of bounding box of this
Sector2DcenterY
- the y-coordinate of the centre of bounding box of this
Sector2DinnerRadius
- the radius of the inner arc of this Sector2DouterRadius
- the radius of the outer arc of this Sector2DstartAngle
- the angle to start this Sector2D in radiansangleExtent
- the angular width of this Sector2D in radians
java.lang.IllegalArgumentException
- if the innerRadius
is greater than the
outerRadius
Method Detail |
---|
public java.lang.Object clone()
clone
in class java.awt.geom.Area
public void setInnerArc(java.awt.geom.Arc2D innerArc) throws java.lang.IllegalArgumentException
innerArc
- the new arc to set this inner arc to match
java.lang.IllegalArgumentException
- if innerArc
is not a PIE arc of angles the same as the
outer arc and bounding box within that of the outer arc.public java.awt.geom.Arc2D getInnerArc()
public void setOuterArc(java.awt.geom.Arc2D outerArc) throws java.lang.IllegalArgumentException
outerArc
.
outerArc
- the new arc to set this outer arc to match
java.lang.IllegalArgumentException
- if outerArc
is not a PIE arc with a bounding box which
contains that of the inner arc.public java.awt.geom.Arc2D getOuterArc()
public void setOuterRadius(double outerRadius) throws java.lang.IllegalArgumentException
outerRadius
- the new value for the outer radius of this Sector2D
java.lang.IllegalArgumentException
- if outerRadius
is not greater than or equal to the current inner radiuspublic double getOuterRadius()
public void setRadii(double innerRadius, double outerRadius) throws java.lang.IllegalArgumentException
innerRadius
- the new value for the inner radius of this Sector2DouterRadius
- the new value for the outer radius of this Sector2D
java.lang.IllegalArgumentException
- if the given outer radius is not greater than or equal to the given inner radiuspublic void setInnerRadius(double innerRadius) throws java.lang.IllegalArgumentException
innerRadius
- the new value for the inner radius of this Sector2D
java.lang.IllegalArgumentException
- if innerRadius
is greater than the current outer radiuspublic double getInnerRadius()
java.lang.IllegalStateException
- if the x and y radii are different (sector is elliptical).public void scale(double scaleAmount)
scaleAmount
. The sector center
is unchanged.
scaleAmount
- the amount to grow or shrink the width and height of the bounding framepublic void scale(double scaleAmount, double newSectorWidth)
scaleAmount
. The sector center
is unchanged. The sector width is simultaneously reset to newSectorWidth
.
scaleAmount
- the amount to grow or shrink the width and height of the bounding framenewSectorWidth
- the sector width for the scaled sectorpublic void setSector(double x, double y, double w, double h, double startAngle, double angleExtent, double width) throws java.lang.IllegalArgumentException
x
- the x-coordinate of the upper-left corner of the bounding
rectangley
- the y-coordinate of the upper-left corner of the bounding
rectanglew
- the width of the bounding rectangleh
- the height of the bounding rectanglestartAngle
- the angle to start this Sector2D in radiansangleExtent
- the angular width of this Sector2D in radianswidth
- the width of this Sector2D, extending inward from the outer
arc
java.lang.IllegalArgumentException
- if double (sector) width
would exceed outer bounding box or if
width
is less than zero.Arc2D.setArc(double, double, double, double, double,
double, int)
public void setSectorByCenter(double centerX, double centerY, double innerRadius, double outerRadius, double startAngle, double angleExtent) throws java.lang.IllegalArgumentException
centerX
- the x-coordinate of the centre of bounding box of this
Sector2DcenterY
- the y-coordinate of the centre of bounding box of this
Sector2DinnerRadius
- the radius of the inner arc of this Sector2D in radiansouterRadius
- the radius of the outer arc of this Sector2D in radiansstartAngle
- the angle to start this Sector2DangleExtent
- the angular width of this Sector2D
java.lang.IllegalArgumentException
- if the innerRadius
is greater than the
outerRadius
Arc2D.setArc(double, double, double, double, double,
double, int)
public void setAngleStart(double startAngle)
startAngle
- the new starting angle in radiansArc2D.setAngleStart(double)
public void setAngleExtent(double angleExtent)
angleExtent
- the new angular span for this sector in radiansArc2D.setAngleExtent(double)
public void setSectorWidth(double width) throws java.lang.IllegalArgumentException
width
- the width (inward from outer radius) to make this sector
java.lang.IllegalArgumentException
- if double sector width would exceed outer bounding box and bounding box width is > 0public void setFrame(double x, double y, double w, double h) throws java.lang.IllegalArgumentException
x
- the coordinates to which to set the location of the upper left corner of the outer bounds of this Rectangle2Dy
- the coordinates to which to set the location of the upper left corner of the outer bounds of this Rectangle2Dw
- the width to set the outer bounding box of this Sector2Dh
- the height to set the outer bounding box of this Sector2D
java.lang.IllegalArgumentException
- if w
is less than twice the sector widthpublic void setSector(Sector2D sector)
sector
- the sector to copypublic double getAngleExtent()
public double getAngleStart()
public double getX()
public double getY()
public double getWidth()
public double getHeight()
public double getMaxX()
public double getMaxY()
public double getCenterX()
double
precision.
public double getCenterY()
double
precision.
public java.awt.geom.Rectangle2D getFrame()
Rectangle2D
that defines the overall shape of this object.
Rectangle2D
, specified in double coordinatespublic double getSectorWidth()
public void setEllipseMethod(int ellipseMethod)
Arcs forming Sectors contained in (non-square) rectangles are parts of ellipses.
Inner arc can be designated to maintain constant sector width (inner and outer angles
will not match because w/h proportions will differ) or proportional (changing) sector
width (default). This behaviour is managed by the value of ellipseMethod
and
(@link #setSectorWidth(double)).
ellipseMethod
- Can be either CONSTANT_SECTOR_WIDTH
or PROPORTIONAL_SECTOR_WIDTH
java.lang.IllegalArgumentException
- if ellipseMethod
is not one of CONSTANT_SECTOR_WIDTH
or PROPORTIONAL_SECTOR_WIDTH
public int getEllipseMethod()
CONSTANT_SECTOR_WIDTH
or PROPORTIONAL_SECTOR_WIDTH
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |