|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jpicedt.graphic.model.AbstractElement jpicedt.graphic.model.AbstractCurve
public abstract class AbstractCurve
A curve made up of a concatenation of cubic bezier curves and straight lines, hereafter globally denoted as "segments". Straight lines are actually just bezier curves with control-points and their respective subdivision-points being at the same location. This curve may be either closed or not, and has a variable number of points. Segments may be added/inserted/deleted.
There are two sort of points in this curve:
bezierPts
ArrayList with the following indexing scheme :
Arrays of specification-point coordinates are managed in a distinct way if the curve is open or close :
Nested Class Summary | |
---|---|
class |
AbstractCurve.CtrlPtSubsetAbstractCurve
|
class |
AbstractCurve.CurveToSegment
|
class |
AbstractCurve.EndSegment
Dernier Segment rendu par getMiminalSegmentList() . |
class |
AbstractCurve.LineToSegment
|
static class |
AbstractCurve.PointType
constant field for getPointType() |
class |
AbstractCurve.Segment
|
Field Summary | |
---|---|
protected ArrayList<PicPoint> |
bezierPts
list of specification points |
protected boolean |
isClosed
tells whether this curve is closed of not |
Fields inherited from class jpicedt.graphic.model.AbstractElement |
---|
attributeSet, name, parent, view |
Constructor Summary | |
---|---|
AbstractCurve()
Creates a new empty open Abstract curve |
|
AbstractCurve(AbstractCurve curve)
"cloning" constructor (to be used by clone()) |
|
AbstractCurve(boolean closed)
Creates a new empty Abstract curve |
|
AbstractCurve(boolean closed,
PicAttributeSet set)
Creates a new empty Abstract curve with the given set of attributes |
|
AbstractCurve(int nbSegments,
boolean closed)
Creates a new Abstract curve and allocates as many points as needed by the given number of segments. |
|
AbstractCurve(int nbSegments,
boolean closed,
PicAttributeSet set)
Creates a new Abstract curve with the given number of segments, and attaches the given attribute set to it. |
Method Summary | |
---|---|
abstract void |
addPoint(PicPoint pt)
Adds the given point to the end of this curve. |
ArrayList<PEAction> |
createActions(ActionDispatcher actionDispatcher,
ActionLocalizer localizer,
HitInfo hi)
Creates an array of Action's related to this object |
AbstractCustomizer |
createCustomizer()
Returns a Customizer for geometry editing |
Shape |
createShape()
Create a Shape for the geometry of this model. |
void |
curveTo(PicPoint ptCtrl1,
PicPoint ptCtrl2,
PicPoint ptEnd)
If this curve if OPEN and NON-EMPTY, adds the given points (2 control points and an endpoint) to the end of the curve. |
void |
diff1CurveTo(PicVector dP0,
PicVector dP1,
PicPoint p1)
Utilisable pour approcher une courbe paramétrée P(t) par la chaîne de courbe de Bézier this lorqu'on dispose des dérivées d'ordre 1 de P(t). |
void |
diff2CurveTo(PicVector d2P0,
PicVector d2P1,
PicVector dP0,
PicVector dP1,
PicPoint p1)
Utilisable pour approcher une courbe paramétrée P(t) par la chaîne de courbe de Bézier this lorqu'on dispose des dérivées d'ordre 1 et 2 de P(t). |
int |
getAlternateControlPoint(int ctrlPtIdx)
Returns the bezier-index of the alternate control-point of the given control-point. |
protected PicPoint |
getBezierPt(int index)
Returns a reference on the Bezier point with the given index. |
PicPoint |
getBezierPt(int index,
PicPoint dest)
If the curve is closed, any index is a valid index thx to the use of Periodic Boundary Conditions. |
int |
getBezierPtsCount()
Return the number of specification points backing the geometry of this element. |
double |
getBezierPtX(int index)
|
double |
getBezierPtY(int index)
|
Rectangle2D |
getBoundingBox(Rectangle2D r)
Returns the bounding box (i.e. the surrounding rectangle) in double precision Used e.g. to determine the arguments of a \\begin{picture} command. |
CtrlPtSubset |
getCtrlPtSubset(ConvexZoneGroup csg,
BitSet czExtension)
Renvoie un la partie des points de contrôle qui satisfont à l'un des deux critères suivants: ceux compris dans l'ensemble de zones convexes csg , et
ceux en relation avec les points de contrôle satisfaisant au première critère selon une relation
définies par czExtension
|
PicVector |
getIncomingTangent(int subdivIndex)
Return a non-normalized vector tangent to the incoming segment (i.e., wrt the control-point that comes before the given subdivision point) |
ArrayList<AbstractCurve.Segment> |
getMiminalSegmentList()
Cette fonction est destiné à faciliter le formattage du code LaTeX. |
int |
getNearestSubdivisionPoint(int ctrlPtIdx)
Returns the bezier-index of the nearest subdivision-point of the given control-point. |
int |
getNumberOfSubdivisionPoints()
Returns the number of subdivision points (including endpoints if the curve is open) |
PicVector |
getOutgoingTangent(int subdivIndex)
Return a non-normalized vector tangent to the outcoming segment (i.e., wrt the control-point that comes after the given subdivision point) |
int |
getPBCBezierIndex(int bezierPtIdx)
Convenience method for Periodic Boundary Condition (PBC) management when curve is CLOSED. |
int |
getPBCSegmentIndex(int segmentIdx)
Convenience method for Periodic Boundary Condition (PBC) management when curve is CLOSED. |
AbstractCurve.PointType |
getPointType(int index)
Returns whether the given point index relates to a curve's end-point, a subdivision point, a control point (in which case this method returns the rank of the control point inside the segment to which it belongs), or (if the curve is open) is an invalid point index. |
int |
getSegmentCount()
Returns the number of segments that make up this curve. |
Rectangle2D |
getShapeBounds2D(Rectangle2D r)
Returns the the smallest rectangle enclosing the shape of this curve, as opposed to getBoundingBox
which is defined as the smallest rectangle encompassing ALL
Bezier points. |
protected boolean |
hasValidSize()
Return whether the current nb of specification points is valid, i.e. there is no incomplete segment. |
boolean |
isClosed()
Returns true if this curve is closed. |
boolean |
isControlPoint(int index)
Return whether the bezier-point with the given index is a control-point. |
boolean |
isPolygon()
Return true if this curve is a polygon, ie has only straight segments |
boolean |
isSmooth(int subdivIndex)
Check whether the two control points around the given subdivision point satisfy (up to 5%) the 2nd order smoothness criterion. |
boolean |
isStraight(int segIndex)
Returns whether the given segment is straight. |
boolean |
isSymmetric(int subdivIndex)
Check whether the control points around the given subdivision point satisfy (up to 5%) the symmetry criterion. |
boolean |
isValidBezierIndex(int pointIndex)
Returns true iff the given bezier point index is a valid point index. |
boolean |
isValidSegmentIndex(int segIdx)
Returns true iff the given segment index is a valid segment index. |
void |
lineTo(PicPoint pt)
Adds a STRAIGHT segment to the end of this curve, i.e. control-points and subdivision-points are identical at each segment's end. |
void |
mirror(PicPoint ptOrg,
PicVector normalVector)
Effectue une réflexion sur this relativement à l'axe
défini par ptOrg et normalVector . |
int |
pointToSegmentIndex(int pointIndex)
Returns the index of the segment the given point belongs to. |
void |
removeLastSubdivisionPoint()
Removes the last subdivision point. |
abstract void |
removePoint(int index)
Remove the point with the given index from this curve |
void |
removeSubdivisionPoint(int subdivIndex)
Remove a subdivision point from this curve, together with the two neighbouring control points. |
void |
rotate(PicPoint ptOrg,
double angle)
Rotate this Element by the given angle along the given point This method does not fire any change event. |
void |
scale(double ptOrgX,
double ptOrgY,
double sx,
double sy,
UserConfirmationCache ucc)
Scale this object by (sx,sy) using (ptOrgX,ptOrgY) as the origin. |
int |
segmentToPointIndex(int segmentIndex,
AbstractCurve.PointType pointType)
Returns the index of the bezier-point belonging to the given segment, and having the given pointType. |
protected void |
setBezierPt(int index,
PicPoint pt)
Set the coordinates of the Bezier point with the given index |
void |
setClosed(boolean state)
close or open this curve, either by opening the last segment if curve is closed, or by adding two control-points after the last segment if it is open. |
void |
setCtrlPt(int index,
PicPoint pt,
EditPointConstraint c)
Set the coordinates of the Bezier point with the given index to the given location, but doesn't fire any DrawingEvent. |
void |
shear(PicPoint ptOrg,
double shx,
double shy,
UserConfirmationCache ucc)
Shear this Element by the given params wrt to the given origin
This method does not fire any change event. |
abstract int |
splitSegment(int index,
PicPoint pt)
Split the segment having the given index. |
int |
splitSegment(int seg,
PicPoint ptleft,
PicPoint pt,
PicPoint ptright)
Split a segment (either straight or curved) at a given point using two additionnal control points given as parameters. |
void |
syncArrowGeometry(ArrowView v,
ArrowView.Direction d)
Helper for the associated View. |
String |
toString()
Returns a string for debugging purpose. |
void |
translate(double dx,
double dy)
Translate this Element by (dx,dy) ; this implementation translates the bezier points. |
Methods inherited from class jpicedt.graphic.model.AbstractElement |
---|
anchorPointsIterator, clone, fireChangedUpdate, getAttribute, getAttributeSet, getDefaultName, getDrawing, getName, getParent, getView, pullOutOfGroup, removeView, replaceBy, scale, scale, scale, setAttribute, setAttributeSet, setCtrlPt, setName, setParent, setViewFromFactory, shear |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface jpicedt.graphic.model.Element |
---|
getCtrlPt, getFirstPointIndex, getLastPointIndex |
Field Detail |
---|
protected ArrayList<PicPoint> bezierPts
protected boolean isClosed
Constructor Detail |
---|
public AbstractCurve()
public AbstractCurve(boolean closed)
closed
- whether the generated multi-curve will be closed or notpublic AbstractCurve(boolean closed, PicAttributeSet set)
closed
- whether the generated multi-curve will be closed or notset
- attribute set to be bound to this curvepublic AbstractCurve(int nbSegments, boolean closed)
nbSegments
- nb of elementary lines or cubic Bezier curves ; if 0, this curve is reduced to a single pointclosed
- whether this curve is closed or not
IllegalArgumentException
- if nbSegments is negativepublic AbstractCurve(int nbSegments, boolean closed, PicAttributeSet set)
nbSegments
- nb of elementary lines or cubic Bezier curvesset
- attribute set to be bound to this elementpublic AbstractCurve(AbstractCurve curve)
Method Detail |
---|
public AbstractCurve.PointType getPointType(int index)
public int getPBCBezierIndex(int bezierPtIdx)
If curve is CLOSED, returns the given index modulo the number of bezier points, i.e. an index
guaranteed to lie b/w 0 and the number of bezier points minus one.
Otherwise leaves unchanged.
bezierPtIdx
- any integer, positive or not, greater than the number of bezier points or not, etc...
public int getPBCSegmentIndex(int segmentIdx)
If curve is CLOSED, returns the given index modulo the number of segment, i.e. an index
guaranteed to lie b/w 0 and the number of segments minus one.
Otherwise leaves unchanged.
segmentIdx
- any integer, positive or not, greater than the number of bezier points or not, etc...
public int getNearestSubdivisionPoint(int ctrlPtIdx)
public int getAlternateControlPoint(int ctrlPtIdx)
public boolean isControlPoint(int index)
public int pointToSegmentIndex(int pointIndex)
public int segmentToPointIndex(int segmentIndex, AbstractCurve.PointType pointType)
pointType
- one of SUBDIVISION_POINT, FIRST_SEGMENT_CONTROL_POINT or SECOND_SEGMENT_CONTROL_POINT.
Other qualifiers are meaningless here, and act as the SUBDIVISION_POINT qualifier.public boolean isValidBezierIndex(int pointIndex)
getPointType(int)
public boolean isValidSegmentIndex(int segIdx)
protected final boolean hasValidSize()
public int getBezierPtsCount()
protected PicPoint getBezierPt(int index)
public PicPoint getBezierPt(int index, PicPoint dest)
index
- index of point of which a copy is to be returned.dest
- if null, it is instanciated on-the-fly and returned for
convenience, otherwise used to store the returned point
protected void setBezierPt(int index, PicPoint pt)
public double getBezierPtX(int index)
public double getBezierPtY(int index)
public void setCtrlPt(int index, PicPoint pt, EditPointConstraint c)
setCtrlPt
in interface Element
c
- not used herepublic abstract void addPoint(PicPoint pt)
public abstract int splitSegment(int index, PicPoint pt)
public abstract void removePoint(int index)
public void curveTo(PicPoint ptCtrl1, PicPoint ptCtrl2, PicPoint ptEnd)
splitSegment
instead.
ptCtrl1
- first control point of the new Bezier segmentptCtrl2
- second control point of the new Bezier segmentptEnd
- second end-point of the new Bezier segmentpublic void diff1CurveTo(PicVector dP0, PicVector dP1, PicPoint p1)
for(int i = 0; i <= N;++i)
{
t = (a*i + b*(N-i))/N;
p1 = P(t);
dP1 = dP/dt(t);
if(i == 0)
curve.addPoint(p1);
else
curve.diff1CurveTo(dP0,dP1,p1);
dP0 = dP1;
}
dP0
- valeur de dP(t)/dt en t=t0dP1
- valeur de dP(t)/dt en t=t1p1
- valeur de P(t) en t=t1public void diff2CurveTo(PicVector d2P0, PicVector d2P1, PicVector dP0, PicVector dP1, PicPoint p1)
for(int i = 0; i <= N;++i)
{
t = (a*i + b*(N-i))/N;
p1 = P(t);
dP1 = dP/dt(t);
d2P1 = d2P/d2t(t);
if(i == 0)
curve.addPoint(p1);
else
curve.diff2CurveTo(d2P0,d2P1,dP0,dP1,p1);
dP0 = dP1;
d2P0 = d2P1;
}
d2P0
- valeur de d2P(t)/d2t en t=t0+d2P1
- valeur de d2P(t)/d2t en t=t1-dP0
- valeur de dP(t)/dt en t=t0+dP1
- valeur de dP(t)/dt en t=t1-p1
- valeur de P(t) en t=t1public ArrayList<AbstractCurve.Segment> getMiminalSegmentList()
Segment
non redondant. C'est à dire que les points de contrôle double n'apportant pas
d'information sont supprimés.
Segment
non redondante qui forme la courbe.public void lineTo(PicPoint pt)
curveTo
.
Note that this method does NOT fire any DrawingEvent.
This method does nothing if the curve is EMPTY or CLOSED.
pt
- The second end-point of the line to be addedpublic int splitSegment(int seg, PicPoint ptleft, PicPoint pt, PicPoint ptright)
Implementation works as follow : parameters ptLeft and ptRight act as new control points, the original segment - labelled as [a,b,c,d] - being split up into two new segments, i.e. [a,b,ptleft,pt] and [pt,ptright,c,d]. These two segments inherit their straightness attribute from the original segment. This works for closed as well as open curves.
Note that this method does NOT fire any DrawingEvent.
seg
- index of segment to be split, i.e. 0,1,2,... for the 1st, 2nd, 3rd,... segment.ptleft
- first new control-pointpt
- the point at which segment must be split (= new subdivision point)ptright
- second new control-point
public void removeSubdivisionPoint(int subdivIndex)
This method does NOT fire any DrawingEvent.
subdivIndex
- index of the subdivision point to be removed with respect to SUBDIVISION point numbering scheme,
e.g. 0 for the first subdivision point (= first curve end-point), 1 for the second one (= bezier point
with index "3"), etc... This is similar to the SEGMENT numbering scheme incidentally.
an
- IllegalArgumentException if the given index is not a valid subdivision point index, i.e.
is greater than the nb of segments.public void removeLastSubdivisionPoint()
removeSubdivisionPoint
.
public int getSegmentCount()
public int getNumberOfSubdivisionPoints()
public PicVector getIncomingTangent(int subdivIndex)
public PicVector getOutgoingTangent(int subdivIndex)
public boolean isStraight(int segIndex)
segIndex
- segment index with respect to the segment numbering scheme, that is, 0 for the first segment, etc...public boolean isPolygon()
public boolean isSmooth(int subdivIndex)
subdivIndex
relates
to a curve's end-point, return true. If one of the neighbouring segment is straight, end-points are
used instead of control-points.
subdivIndex
- subdivision-point index, with respect to subdivision-point (SP) numbering scheme, i.e.
0,1,2,... for the 1st, 2nd, 3rd... subdivision point.public boolean isSymmetric(int subdivIndex)
subdivIndex
- subdivision-point index (with respect to subdivision-point numbering scheme), that is,
0,1,2,... for the 1st, 2nd, 3rd,... subdivision point.public void setClosed(boolean state)
state
- The new closeness valueisClosed()
public boolean isClosed()
setClosed(boolean)
public CtrlPtSubset getCtrlPtSubset(ConvexZoneGroup csg, BitSet czExtension)
Element
csg
, et
czExtension
getCtrlPtSubset
in interface Element
getCtrlPtSubset
in class AbstractElement
csg
- un ensemble de zones convexesczExtension
- un BitSet
permettant d'étendre l'ensemble des points de contrôle
compris dans l'ensemble de zones convexes csg
. La signification des bit est selon
l'énuméré CtrlPtSubset.CZExtension
.
null
jpicedt.graphic.model
public Shape createShape()
createShape
in interface Element
createShape
in class AbstractElement
public void syncArrowGeometry(ArrowView v, ArrowView.Direction d)
syncArrowGeometry
in interface Element
syncArrowGeometry
in class AbstractElement
public Rectangle2D getShapeBounds2D(Rectangle2D r)
getBoundingBox
which is defined as the smallest rectangle encompassing ALL
Bezier points.
r
- if null, gets allocated and returned for convenienceShape.getBounds2D()
public String toString()
toString
in class AbstractElement
public void translate(double dx, double dy)
translate
in interface Element
dx
- The X coordinate of translation vectordy
- The Y coordinate of translation vectorpublic void scale(double ptOrgX, double ptOrgY, double sx, double sy, UserConfirmationCache ucc)
sx
and sy
may be negative.
This method does not fire any change event.
scale
in interface Element
ucc
- une valeur UserConfirmationCache
permettant de demander à l'utilisateur
confirmation, de se souvenir de la dernière confirmation qu'il a donné, ou de ses préférences.public void rotate(PicPoint ptOrg, double angle)
rotate
in interface Element
angle
- rotation angle in radianspublic void mirror(PicPoint ptOrg, PicVector normalVector)
this
relativement à l'axe
défini par ptOrg
et normalVector
.
mirror
in interface Element
ptOrg
- le PicPoint
par lequel passe l'axe de réflexion.normalVector
- le PicVector
normal à l'axe de réflexion.public void shear(PicPoint ptOrg, double shx, double shy, UserConfirmationCache ucc)
Element
by the given params wrt to the given origin
This method does not fire any change event.
shear
in interface Element
ucc
- une valeur UserConfirmationCache
permettant de demander à l'utilisateur
confirmation, de se souvenir de la dernière confirmation qu'il a donné, ou de ses préférences.public Rectangle2D getBoundingBox(Rectangle2D r)
This implementation compute the bb from the smallest rectangle that encompasses all specification-points.
getBoundingBox
in interface Element
public ArrayList<PEAction> createActions(ActionDispatcher actionDispatcher, ActionLocalizer localizer, HitInfo hi)
createActions
in interface ActionFactory
createActions
in class AbstractElement
actionDispatcher
- dispatches events to the proper PECanvaslocalizer
- i18n localizer for PEAction'shi
- une HitInfo
contenant les informations relatives à l'évènement-souris qui a
déclencher le menu contextuel.public AbstractCustomizer createCustomizer()
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |