|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjpicedt.graphic.model.AbstractElement
jpicedt.graphic.model.DefaultLeafElement
jpicedt.graphic.model.PicParallelogram
jpicedt.graphic.model.PicEllipse
public class PicEllipse
Ellipse or arc, based on parallelogram
The geometrical model of this ellipse (or its arc counterpart) is based on a parallelogram, yet
is equivalent to an ellipse rotated around its center.
In the following code documentation, we will be using two coordinate-systems, namely :
l2rVec
and b2tVec
inherited from superclass.
skew
refers to the parallelogram basis, whereas rotated
denotes
angles measured in the ellipse basis.
Since ellipse axes are generally not parallel to parallelogram sides, except in the event this parallelogram is
a rectangle, both sets of angle DO obviously differ.
In the parallelogram basis, arc is modelled by the following parametrized curve :
Center + cos(t)*U+sin(t)*V,
for t ranging from skewAngleStart
to skewAngleEnd
.
Rotated angles are computed so that the arc of ellipse is obtained simply by rotating by "rotationAngle" (CCW) the arc of ellipse whose parametrization is Center+greatAxis*cos(t)*I+smallAxis*sin(t)*J where I,J is the ellipse canonical basis, and t varies between "rotatedAngleStart" and "rotatedAngleEnd". Note that this means that when small axis is negative, this parametrization goes CW and not CCW.
[TODO] changes ALL internal angles to radian, and move conversion to setters/getters is user may want to enter degrees. [TODO] add a picture (in GIF or PNG format) to this documentation (as in AbstractCurve) to help end-users understand all these tricky things !
Field Summary | |
---|---|
static int |
CHORD
prefined closure type for arcs |
protected int |
closure
closure type |
protected double |
greatAxis
Lengths of the great axis of the ellipse. |
static int |
LAST_PT
|
static int |
OPEN
prefined closure type for arcs |
static int |
P_ANGLE_END
point marking end-of-arc |
static int |
P_ANGLE_START
point marking start-of-arc |
static int |
PIE
prefined closure type for arcs |
protected double |
rotatedAngleEnd
Arc angles in degrees, as measured in the ellipse basis. |
protected double |
rotatedAngleStart
Arc angles in degrees, as measured in the ellipse basis. |
protected double |
rotationAngle
Angle in radians (CCW) between the great axis of the ellipse and the horizontal axis. |
protected double |
skewAngleEnd
|
protected double |
skewAngleStart
Arc start- and end- angles in degrees as measured with respect to parallolegram's basis (see toParalleloBasisCoordinates() for
details on how this basis is defined). |
protected double |
smallAxis
Length of the small axis of the ellipse. |
Fields inherited from class jpicedt.graphic.model.PicParallelogram |
---|
b2tVec, CENTER_FIXED, DEFAULT, FIRST_PT, l2rVec, P_BL, P_BR, P_CENTER, P_SPEC_BL, P_SPEC_BR, P_SPEC_TR, P_TL, P_TR, SIDE_B, SIDE_L, SIDE_R, SIDE_T, SQUARE |
Fields inherited from class jpicedt.graphic.model.DefaultLeafElement |
---|
nodeConnections, nodeName, pts |
Fields inherited from class jpicedt.graphic.model.AbstractElement |
---|
attributeSet, parent, view |
Constructor Summary | |
---|---|
PicEllipse()
Create a new PicEllipse, centered at (0,0), with a null radius. |
|
PicEllipse(int closure)
Create a new PicEllipse, centered at (0,0), with a null radius, the given closure type. |
|
PicEllipse(int closure,
PicAttributeSet set)
Create a new PicEllipse, centered at (0,0), with a null radius, the given closure type, and the given attribute set. |
|
PicEllipse(PicAttributeSet set)
Create a new PicEllipse, centered at (0,0), with a null radius, and the given attribute set. |
|
PicEllipse(PicEllipse ellipse)
"cloning" constructor (to be used by clone()) |
|
PicEllipse(PicPoint p1,
PicPoint p2,
PicPoint p3,
int closure)
Create a new PicEllipse object using the 3 given points as 3 consecutive points of the surrounding parallelogram, and a default attribute set. |
|
PicEllipse(PicPoint p1,
PicPoint p2,
PicPoint p3,
int closure,
PicAttributeSet set)
Create a new PicEllipse object using the 3 given points as 3 consecutive points of the surrounding parallelogram, and the given attribute set. |
Method Summary | |
---|---|
protected void |
_updateAxis()
Compute the axes of the ellipse (smallAxis, greatAxis), and the rotated angles in terms of the skew angles. |
java.lang.Object |
clone()
Overload Object.clone() method |
PicMultiCurve |
convertToMultiCurve()
Return a Bezier curve created from this ellipse |
AbstractCustomizer |
createCustomizer()
Returns a customizer (Swing) component |
double |
getAngleEnd()
Returns skewAngleEnd , ie angle end of the arc in degrees,
measured in the frame defined by the parallelogram. |
double |
getAngleExtent()
Returns the extent of the arc in degrees (CCW) as measured in the parallelogram basis. |
double |
getAngleStart()
Returns skewAngleStart , ie the starting angle of the arc in degrees,
measured in the frame defined by the parallelogram. |
int |
getArcType()
Returns the closure type, ie one of CHORD, PIE or OPEN predefined constant fields. |
java.lang.String |
getArcTypeAsString()
Returns the closure type as a String, ie one of "chord", "pie" or "open" |
double |
getGreatAxisLength()
Return the length of the great-axis of this ellipse/arc. |
int |
getLastPointIndex()
Return the index of the last point that can be retrieved by getPoint . |
java.lang.String |
getName()
Return a localised string that represents this object's name |
PicPoint |
getPoint(int numPoint,
PicPoint src)
Return the user-controlled point having the given index. |
double |
getRotatedAngleEnd()
Returns rotatedAngleEnd , ie the angle end of the arc in degrees
as measured in the frame defined by the axes of the ellipse. |
double |
getRotatedAngleExtent()
Returns the angle extent of the arc in degrees as measured in the frame defined by the axes of the ellipse. |
double |
getRotatedAngleStart()
Return rotatedAngleStart , ie the angle start of the arc in degrees (CCW),
as measured in the frame defined by the axes of the ellipse. |
double |
getRotationAngle()
Return the rotation angle, ie the angle between the great axis of the ellipse and the horizontal axis. |
double |
getSmallAxisLength()
Return the length of the small-axis of this ellipse/arc. |
PicPoint |
getTangentAtAngleEnd(PicVector pt)
Utility for computing arrow direction. |
PicPoint |
getTangentAtAngleStart(PicVector pt)
Utility for computing arrow direction. |
boolean |
isArc()
Returns true if this PicEllipse is an arc, ie if angle extent does not equl 360 |
boolean |
isCircle()
Deprecated. use isCircular() instead |
boolean |
isCircular()
Returns TRUE if this ellipse is circular, ie if smallAxis==greatAxis. |
boolean |
isClosed()
Returns whether this arc or ellipse is closed or not. |
boolean |
isFlat()
Return true if this ellipse is flat. |
boolean |
isPlain()
Return true if this PicEllipse is a plain ellipse, ie if angle extent equals 360. |
boolean |
isRotated()
Return true if this PicEllipse has a null rotation angle along the x-axis |
void |
rotate(PicPoint ptOrg,
double angle)
Rotate this Element by the given angle along the given point |
void |
scale(double ptOrgX,
double ptOrgY,
double sx,
double sy)
Scale this object by (sx,sy) using (ptOrgX,ptOrgY) as the origin. |
void |
setAngleEnd(double angleEnd)
Set the angle end, then fire a changed-update. |
void |
setAngleExtent(double angleExtent)
Sets the angle extent, keeping the angle start fixed, then fire a changed update. |
void |
setAngleStart(double angleStart)
Set the angle start, as measured in the parallelogram basis, then fire a changed-update. |
void |
setArcType(int closure)
Sets the closure type to one of CHORD, PIE or OPEN. |
void |
setPlain()
Set angle parameters so that this ellipse is a plain ellipse. |
void |
setPoint(int numPoint,
PicPoint pt,
EditPointConstraint constraint)
Set the coordinate of the point indexed by "numPoint" to the given value. |
void |
shear(PicPoint ptOrg,
double shx,
double shy)
Shear this Element by the given params wrt to the given origin |
java.lang.String |
toString()
Implementation of the Object.toString() method, used for debugging purpose |
protected void |
updateAxis()
Compute the axes of the ellipse (smallAxis, greatAxis), and the rotated angles in terms of the skew angles. |
protected void |
updateRotatedAngles()
Updates values of rotatedAngleStart and rotatedAngleEnd. |
Methods inherited from class jpicedt.graphic.model.PicParallelogram |
---|
createActions, getBoundingBox, getCenter, getCenterX, getCenterY, getFirstPointIndex, getPointX, getPointY, isRectangle, toParalleloBasisCoordinates, updateParalleloBasis |
Methods inherited from class jpicedt.graphic.model.AbstractElement |
---|
anchorPointsIterator, getAttribute, getAttributeSet, getDrawing, getParent, getView, removeView, scale, setAttribute, setAttributeSet, setParent, setViewFromFactory |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int P_ANGLE_START
public static final int P_ANGLE_END
public static final int LAST_PT
public static final int CHORD
public static final int OPEN
public static final int PIE
protected double skewAngleStart
toParalleloBasisCoordinates()
for
details on how this basis is defined).
To wind up shortly, let U and V denote unit-vectors defined by the sides of the parallelogram
(these are actually given by "l2rVec" and "b2tVec" protected fields, yet immediately after
computeParalleloBasis
has been called),
then the starting point of the arc is located at :
Center+cos(skewAngleStart)*U+sin(skewAngleStart)*V.
This value is closer to the user than rotatedAngleStart. [SR:je ne comprend pas cette phrase !!!]
Moreover, arc is modelled by the following parametrized curve :
Center + cos(t)*U+sin(t)*V,
for t ranging from skewAngleStart to skewAngleEnd.
We set skewAngleStart in (-180,180], and skewAngleEnd in (skewAngleStart,skewAngleStart+360].
This means that if one makes a mirror symmetry of the parallelogram and keeps the values of these "skew" angles unchanged,
then we get the mirror image of the arc.
We use degrees because user may enter a value.
[SR:pending] On peut faire la conversion dans les setters correspondants (setAngleXXX).
L'ideal est qd meme d'avoir la meme unite partout (en interne) pour ne pas s'emmeler les pedales.
PicParallelogram.l2rVec
,
PicParallelogram.b2tVec
protected double skewAngleEnd
skewAngleStart
protected double rotationAngle
protected double smallAxis
protected double greatAxis
protected double rotatedAngleStart
updateRotatedAngles
, and are obviously identical with them
if surrounding parallelogram is a rectangle.
These angles may be used to build an appropriate Shape
for this Element,
by first creating an Arc2D
from these angles, then rotating this shape
by rotationAngle
.
We restrict values of rotatedAngleStart to (-180,180], and those of rotatedAngleEnd to (rotatedAngleStart,rotatedAngleStart+360].
protected double rotatedAngleEnd
updateRotatedAngles
, and are obviously identical with them
if surrounding parallelogram is a rectangle.
These angles may be used to build an appropriate Shape
for this Element,
by first creating an Arc2D
from these angles, then rotating this shape
by rotationAngle
.
We restrict values of rotatedAngleStart to (-180,180], and those of rotatedAngleEnd to (rotatedAngleStart,rotatedAngleStart+360].
protected int closure
Constructor Detail |
---|
public PicEllipse()
public PicEllipse(PicAttributeSet set)
public PicEllipse(int closure)
closure
- one of CHORD, PIE or OPEN.public PicEllipse(int closure, PicAttributeSet set)
closure
- one of CHORD, PIE or OPEN.public PicEllipse(PicPoint p1, PicPoint p2, PicPoint p3, int closure, PicAttributeSet set)
closure
- one of CHORD, PIE or OPEN.public PicEllipse(PicPoint p1, PicPoint p2, PicPoint p3, int closure)
closure
- one of CHORD, PIE or OPEN.public PicEllipse(PicEllipse ellipse)
The
- PicEllipse object to cloneMethod Detail |
---|
public java.lang.Object clone()
clone
in interface Element
clone
in class PicParallelogram
public java.lang.String getName()
getName
in interface Element
getName
in class PicParallelogram
public void setPoint(int numPoint, PicPoint pt, EditPointConstraint constraint)
setPoint
in interface Element
setPoint
in class PicParallelogram
numPoint
- one of P_TL, P_TR, P_BL, P_BR, SIDE_T, SIDE_B, SIDE_L, SIDE_R or P_CENTER.constraint
- either null, DEFAULT, CENTER_FIXED or SQUAREpublic PicPoint getPoint(int numPoint, PicPoint src)
setPoint
method.
getPoint
in interface Element
getPoint
in class PicParallelogram
numPoint
- the point index, should be greater or equal to the value returned by
getFirstPointIndex
, and lower or equal to getLastPointIndex
.
numPoint
;
if src
is null, allocates a new PicPoint and return it,
otherwise directly modifies src
and returns it as well for convenience.public void scale(double ptOrgX, double ptOrgY, double sx, double sy)
sx
and sy
may be negative.
This method eventually fires a changed-update event.
scale
in interface Element
scale
in class DefaultLeafElement
public void rotate(PicPoint ptOrg, double angle)
rotate
in interface Element
rotate
in class PicParallelogram
angle
- rotation angle in radianspublic void shear(PicPoint ptOrg, double shx, double shy)
shear
in interface Element
shear
in class PicParallelogram
public PicMultiCurve convertToMultiCurve()
convertToMultiCurve
in interface PicMultiCurveConvertable
convertToMultiCurve
in class PicParallelogram
public double getRotationAngle()
rotationAngle
public double getGreatAxisLength()
public double getSmallAxisLength()
public void setAngleStart(double angleStart)
The
- starting angle of the arc, in degrees,
counted COUNTERCLOCKWISE (aka trigonometric),
and measured in the parallelogram basis, ie skewAngleStart
.public double getAngleStart()
skewAngleStart
, ie the starting angle of the arc in degrees,
measured in the frame defined by the parallelogram.
public void setAngleEnd(double angleEnd)
The
- angle end of the arc, in degrees,
measured in the frame defined by the parallelogram, ie skewAngleEnd
.public double getAngleEnd()
skewAngleEnd
, ie angle end of the arc in degrees,
measured in the frame defined by the parallelogram. (value of skewAngleStart)
public void setAngleExtent(double angleExtent)
Angular
- extent of the arc, in degrees, counted COUNTERCLOCKWISE
as measured in parallelogram basis.public double getAngleExtent()
public double getRotatedAngleStart()
rotatedAngleStart
, ie the angle start of the arc in degrees (CCW),
as measured in the frame defined by the axes of the ellipse.
public double getRotatedAngleEnd()
rotatedAngleEnd
, ie the angle end of the arc in degrees
as measured in the frame defined by the axes of the ellipse.
public double getRotatedAngleExtent()
public int getArcType()
public java.lang.String getArcTypeAsString()
public void setArcType(int closure)
public int getLastPointIndex()
getPoint
.
getLastPointIndex
in interface Element
getLastPointIndex
in class PicParallelogram
public boolean isFlat()
public boolean isCircular()
getSmallAxisLength()
,
#getGreateAxisLength.
public boolean isCircle()
public boolean isPlain()
public boolean isArc()
public boolean isRotated()
public void setPlain()
public boolean isClosed()
protected void _updateAxis()
protected void updateAxis()
protected void updateRotatedAngles()
public PicPoint getTangentAtAngleStart(PicVector pt)
pt
- a preallocated PicPoint that get filled with the result ; a new one is allocated if pt==null
public PicPoint getTangentAtAngleEnd(PicVector pt)
pt
- a preallocated PicPoint that get filled with the result ; a new one is allocated if pt==null
public java.lang.String toString()
toString
in class PicParallelogram
public AbstractCustomizer createCustomizer()
CustomizerFactory
createCustomizer
in interface CustomizerFactory
createCustomizer
in class PicParallelogram
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |