http://www.jpicedt.org

jpicedt.graphic.model
Class AbstractCurve

java.lang.Object
  extended by jpicedt.graphic.model.AbstractElement
      extended by jpicedt.graphic.model.AbstractCurve
All Implemented Interfaces:
Element, ActionFactory
Direct Known Subclasses:
PicMultiCurve, PicPsCurve, PicSmoothPolygon

public abstract class AbstractCurve
extends AbstractElement
implements ActionFactory

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:

These are globally denoted as "Bezier points" and act as specification-points (cf bezierPts ArrayList)

Specification (or Bezier) points

They are stored in a protected bezierPts ArrayList with the following indexing scheme : These indices are globally referred to as "Bezier indices" throughout the code documentation.

Arrays of specification-point coordinates are managed in a distinct way if the curve is open or close :

Subdivision-point vs. segment numbering scheme

When used throughout the code documentation, the former expression means that 0,1,2 … indices relate to the first, second, third,… subdivision point. This is indicated by SP(i) on picture above. Conversely, each segment is made up of three points (with the exception of the last curve's end-point if the curve is open, which comprises a single segment), amongst which there is a single subdivision point. Hence segment numbering ranges from 0 to getSegmentCount()-1 following the same numbering scheme as subdivision-points. Methods pointToSegmentIndex() and segmentToPointIndex() translates between segment and bezier-point numbering schemes.

Adding/removing points

Methods splitSegment(), removeSubdivisionPoint(), lineTo() and curveTo() provide means to add/remove points to this curve. Abstract methods addPoint(),removePoint() and single-argument splitSegment(), whose implementation depends on the geometric "meaning" of user-controlled points, is left to subclassers.

DrawingEvent's dispatching

As a rule of thumb, any concrete subclass should post DrawingEvent's itself, where it thinks it has to, since none of the methods implemented here does it (this is aimed at reducing the burden for registered listeners which otherwise might -now and often- receive events twice).

[SR:TODO] split curve into several pieces (aka old PicPolygon.convertToLines() method) ;
[SR:TODO] join curves ;
[SR:TODO] add resample() method allowing to delete m point out of n (useful for polygons generated from data files) [SR:BUG] setSmooth()/setSymmetric() ↠ bug when neighbouring control-points are identical.

Since:
jpicedt 1.3.3
Version:
$Id: AbstractCurve.java,v 1.46 2013/03/27 07:20:51 vincentb1 Exp $
Author:
Vincent Guirardel, Sylvain Reynal.

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

bezierPts

protected ArrayList<PicPoint> bezierPts
list of specification points


isClosed

protected boolean isClosed
tells whether this curve is closed of not

Constructor Detail

AbstractCurve

public AbstractCurve()
Creates a new empty open Abstract curve


AbstractCurve

public AbstractCurve(boolean closed)
Creates a new empty Abstract curve

Parameters:
closed - whether the generated multi-curve will be closed or not

AbstractCurve

public AbstractCurve(boolean closed,
                     PicAttributeSet set)
Creates a new empty Abstract curve with the given set of attributes

Parameters:
closed - whether the generated multi-curve will be closed or not
set - attribute set to be bound to this curve

AbstractCurve

public AbstractCurve(int nbSegments,
                     boolean closed)
Creates a new Abstract curve and allocates as many points as needed by the given number of segments. Each segment comprises three Bezier points (i.e. one end-point, and two control-points), yet if the curve is open, there is one more Bezier point, namely the last curve end-point.

Parameters:
nbSegments - nb of elementary lines or cubic Bezier curves ; if 0, this curve is reduced to a single point
closed - whether this curve is closed or not
Throws:
IllegalArgumentException - if nbSegments is negative

AbstractCurve

public 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.

Parameters:
nbSegments - nb of elementary lines or cubic Bezier curves
set - attribute set to be bound to this element

AbstractCurve

public AbstractCurve(AbstractCurve curve)
"cloning" constructor (to be used by clone())

Method Detail

getPointType

public 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.
Note that if this curve is CLOSED, this method never returns FIRST_CURVE_END_POINT nor LAST_CURVE_END_POINT for that matter.
author: Sylvain Reynal [18/01/2003]

Returns:
a constant field, i.e. either SUBDIVISION_POINT, FIRST_SEGMENT_CONTROL_POINT, SECOND_SEGMENT_CONTROL_POINT, FIRST_CURVE_END_POINT, LAST_CURVE_END_POINT or INVALID_POINT_INDEX.

getPBCBezierIndex

public int getPBCBezierIndex(int bezierPtIdx)
Convenience method for Periodic Boundary Condition (PBC) management when curve is CLOSED.

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.

Parameters:
bezierPtIdx - any integer, positive or not, greater than the number of bezier points or not, etc...
Returns:
a bezier-point index guaranteed to lie between 0 and the number of bezier points minus one.

getPBCSegmentIndex

public int getPBCSegmentIndex(int segmentIdx)
Convenience method for Periodic Boundary Condition (PBC) management when curve is CLOSED.

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.

Parameters:
segmentIdx - any integer, positive or not, greater than the number of bezier points or not, etc...
Returns:
a segment index guaranteed to lie between 0 and the number of segments minus one.

getNearestSubdivisionPoint

public int getNearestSubdivisionPoint(int ctrlPtIdx)
Returns the bezier-index of the nearest subdivision-point of the given control-point. The policy is to return the same index if the given point is NOT a control-point.


getAlternateControlPoint

public int getAlternateControlPoint(int ctrlPtIdx)
Returns the bezier-index of the alternate control-point of the given control-point. The policy is to return the same index if the given point is NOT a control-point. Also note that the returned index is not guaranteed to be a valid index (there's no convincing way to test it here).


isControlPoint

public boolean isControlPoint(int index)
Return whether the bezier-point with the given index is a control-point.


pointToSegmentIndex

public int pointToSegmentIndex(int pointIndex)
Returns the index of the segment the given point belongs to.


segmentToPointIndex

public int segmentToPointIndex(int segmentIndex,
                               AbstractCurve.PointType pointType)
Returns the index of the bezier-point belonging to the given segment, and having the given pointType.

Parameters:
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.

isValidBezierIndex

public boolean isValidBezierIndex(int pointIndex)
Returns true iff the given bezier point index is a valid point index.

See Also:
getPointType(int)

isValidSegmentIndex

public boolean isValidSegmentIndex(int segIdx)
Returns true iff the given segment index is a valid segment index. This is always true for closed curves.


hasValidSize

protected final boolean hasValidSize()
Return whether the current nb of specification points is valid, i.e. there is no incomplete segment. This may be used in conjunction with the "assert" keyword (as of JDK1.4) for debugging purpose.


getBezierPtsCount

public int getBezierPtsCount()
Return the number of specification points backing the geometry of this element.


getBezierPt

protected PicPoint getBezierPt(int index)
Returns a reference on the Bezier point with the given index. If the curve is closed, any index is a valid index thx to the use of Periodic Boundary Conditions.


getBezierPt

public 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.

Parameters:
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
Returns:
a copy of the Bezier point with the given index.

setBezierPt

protected void setBezierPt(int index,
                           PicPoint pt)
Set the coordinates of the Bezier point with the given index


getBezierPtX

public double getBezierPtX(int index)

getBezierPtY

public double getBezierPtY(int index)

setCtrlPt

public 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. If the curve is CLOSED, this methods arranges for any index to be a valid index by means of PBC's.

Specified by:
setCtrlPt in interface Element
Parameters:
c - not used here

addPoint

public abstract void addPoint(PicPoint pt)
Adds the given point to the end of this curve.


splitSegment

public abstract int splitSegment(int index,
                                 PicPoint pt)
Split the segment having the given index.

Returns:
the index of the user-controlled point which got inserted, according to the indexing scheme of set/getCtrlPt(). This may for instance allow a receiver to control the "new" segment shape by calling setCtrlPt() with this index as a parameter w/o the burden of computing an exact point index (a thing that may depend on the particular implementation of this method).

removePoint

public abstract void removePoint(int index)
Remove the point with the given index from this curve


curveTo

public 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.
If the curve is closed, use splitSegment instead.

Parameters:
ptCtrl1 - first control point of the new Bezier segment
ptCtrl2 - second control point of the new Bezier segment
ptEnd - second end-point of the new Bezier segment

diff1CurveTo

public 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).
Si la courbe this n'est ni OPEN, ni non vide, alors l'appel à cette méthode est ignoré.
Sinon, en supposant que le dernier point de la courbe paramétrée ajouté à this est P(t0), ajoute une courbe de Bézier pour la section P(t0) à P(t1) en assurant que la courbe de Bézier ajouté est tangent à la courbe paramétrée P(t) en t=t0+ et t=t1-.
Pour approcher P(t) par N courbes de Bézier pour t sur l'intervalle [a b] on peut utiliser le code suivant:
 
 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;
 }
 
 

Parameters:
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=t1
Since:
jPicEdt 1.6

diff2CurveTo

public 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).
Attention cette méthode comprend un algorithme d'optimisation itératif qui la rend assez lente
Utilisable pour approcher une courbe paramétrée P(t) par la chaîne de courbe de Bézier this. Si la courbe this n'est ni OPEN, ni non vide, alors l'appel à cette méthode est ignoré.
Sinon, en supposant que le dernier point de la courbe paramétrée ajouté à this est P(t0), ajoute une courbe de Bézier pour la section P(t0) à P(t1) en assurant que la courbe de Bézier ajouté est tangente à la courbe paramétrée P(t) en t=t0+ et t=t1-, et en assurant que la courbe de Bézier ajoutée à sensiblement le même rayon de courbure que la coubre paramétrée P(t) en t=t0+ et t=t1-.
Pour approcher P(t) par N courbes de Bézier pour t sur l'intervalle [a b] on peut utiliser le code suivant: 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; }

Parameters:
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=t1
Since:
jPicEdt 1.6

getMiminalSegmentList

public ArrayList<AbstractCurve.Segment> getMiminalSegmentList()
Cette fonction est destiné à faciliter le formattage du code LaTeX. Elle renvoie une liste de Segment non redondant. C'est à dire que les points de contrôle double n'apportant pas d'information sont supprimés.

Returns:
La liste de Segment non redondante qui forme la courbe.

lineTo

public 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. This is a convenient call to curveTo.

Note that this method does NOT fire any DrawingEvent.
This method does nothing if the curve is EMPTY or CLOSED.

Parameters:
pt - The second end-point of the line to be added

splitSegment

public 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.

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.

Parameters:
seg - index of segment to be split, i.e. 0,1,2,... for the 1st, 2nd, 3rd,... segment.
ptleft - first new control-point
pt - the point at which segment must be split (= new subdivision point)
ptright - second new control-point
Returns:
the index of the subdivision-point which got inserted (see splitSegment(int,PicPoint) for details)

removeSubdivisionPoint

public void removeSubdivisionPoint(int subdivIndex)
Remove a subdivision point from this curve, together with the two neighbouring control points. This shifts any ensuing points to the "left", i.e. reduces indices by one.
Nothing is done if this curve has only one point. If both neighbouring segments had the same straightness value, it is inherited by the new segment. Otherwise, we set it to false.

This method does NOT fire any DrawingEvent.

Parameters:
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.
Throws:
an - IllegalArgumentException if the given index is not a valid subdivision point index, i.e. is greater than the nb of segments.

removeLastSubdivisionPoint

public void removeLastSubdivisionPoint()
Removes the last subdivision point. This is a convenience call to removeSubdivisionPoint.


getSegmentCount

public int getSegmentCount()
Returns the number of segments that make up this curve.


getNumberOfSubdivisionPoints

public int getNumberOfSubdivisionPoints()
Returns the number of subdivision points (including endpoints if the curve is open)


getIncomingTangent

public 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)

Returns:
a non-normalized vector, or null if the given subdivision point has no incoming tangent because it's the first point of an open curve

getOutgoingTangent

public 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)

Returns:
a non-normalized vector, or null if the given subdivision point has no outcoming tangent because it's the last point of an open curve

isStraight

public boolean isStraight(int segIndex)
Returns whether the given segment is straight. This is carried out by checking whether control-points and subdivision-points are identical at each end of the given segment. Return false if this segment is reduced to a point.

Parameters:
segIndex - segment index with respect to the segment numbering scheme, that is, 0 for the first segment, etc...

isPolygon

public boolean isPolygon()
Return true if this curve is a polygon, ie has only straight segments


isSmooth

public boolean isSmooth(int subdivIndex)
Check whether the two control points around the given subdivision point satisfy (up to 5%) the 2nd order smoothness criterion. If this curve is open, and 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.

Parameters:
subdivIndex - subdivision-point index, with respect to subdivision-point (SP) numbering scheme, i.e. 0,1,2,... for the 1st, 2nd, 3rd... subdivision point.

isSymmetric

public boolean isSymmetric(int subdivIndex)
Check whether the control points around the given subdivision point satisfy (up to 5%) the symmetry criterion.

Parameters:
subdivIndex - subdivision-point index (with respect to subdivision-point numbering scheme), that is, 0,1,2,... for the 1st, 2nd, 3rd,... subdivision point.

setClosed

public 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.
This methods doesn't fire any DrawingEvent.

Parameters:
state - The new closeness value
See Also:
isClosed()

isClosed

public boolean isClosed()
Returns true if this curve is closed.

See Also:
setClosed(boolean)

getCtrlPtSubset

public CtrlPtSubset getCtrlPtSubset(ConvexZoneGroup csg,
                                    BitSet czExtension)
Description copied from interface: Element
Renvoie un la partie des points de contrôle qui satisfont à l'un des deux critères suivants:
  1. ceux compris dans l'ensemble de zones convexes csg, et
  2. ceux en relation avec les points de contrôle satisfaisant au première critère selon une relation définies par czExtension

Specified by:
getCtrlPtSubset in interface Element
Overrides:
getCtrlPtSubset in class AbstractElement
Parameters:
csg - un ensemble de zones convexes
czExtension - 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.
Returns:
null
Since:
jPicEdt 1.6
See Also:
jpicedt.graphic.model

createShape

public Shape createShape()
Create a Shape for the geometry of this model.

Specified by:
createShape in interface Element
Overrides:
createShape in class AbstractElement

syncArrowGeometry

public void syncArrowGeometry(ArrowView v,
                              ArrowView.Direction d)
Helper for the associated View. This implementation updates the geometry of the given ArrowView only if isArc()==true.

Specified by:
syncArrowGeometry in interface Element
Overrides:
syncArrowGeometry in class AbstractElement

getShapeBounds2D

public 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.

Parameters:
r - if null, gets allocated and returned for convenience
See Also:
Shape.getBounds2D()

toString

public String toString()
Returns a string for debugging purpose.

Overrides:
toString in class AbstractElement

translate

public void translate(double dx,
                      double dy)
Translate this Element by (dx,dy) ; this implementation translates the bezier points. but does not fire any change event.

Specified by:
translate in interface Element
Parameters:
dx - The X coordinate of translation vector
dy - The Y coordinate of translation vector
Since:
PicEdt 1.0

scale

public void scale(double ptOrgX,
                  double ptOrgY,
                  double sx,
                  double sy,
                  UserConfirmationCache ucc)
Scale this object by (sx,sy) using (ptOrgX,ptOrgY) as the origin. This implementation simply apply a scaling transform to all specification-points. Note that sx and sy may be negative. This method does not fire any change event.

Specified by:
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.

rotate

public 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.

Specified by:
rotate in interface Element
Parameters:
angle - rotation angle in radians

mirror

public void mirror(PicPoint ptOrg,
                   PicVector normalVector)
Effectue une réflexion sur this relativement à l'axe défini par ptOrg et normalVector.

Specified by:
mirror in interface Element
Parameters:
ptOrg - le PicPoint par lequel passe l'axe de réflexion.
normalVector - le PicVector normal à l'axe de réflexion.

shear

public 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.

Specified by:
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.

getBoundingBox

public 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.

This implementation compute the bb from the smallest rectangle that encompasses all specification-points.

Specified by:
getBoundingBox in interface Element
Returns:
the bounding box (i.e. the surrounding rectangle) in double precision Used e.g. to determine the arguments of the \\begin{picture} command. If r is null, allocate a new rectangle and returns it. Otherwise the source rectangle is modified and returned for convenience. [todo:reynal] this really need to be improved : this method would probably better be moved to the attached view, since the latter knows exactly what the TRUE bounding box is.
Since:
PicEdt 1.0

createActions

public ArrayList<PEAction> createActions(ActionDispatcher actionDispatcher,
                                         ActionLocalizer localizer,
                                         HitInfo hi)
Creates an array of Action's related to this object

Specified by:
createActions in interface ActionFactory
Overrides:
createActions in class AbstractElement
Parameters:
actionDispatcher - dispatches events to the proper PECanvas
localizer - i18n localizer for PEAction's
hi - une HitInfo contenant les informations relatives à l'évènement-souris qui a déclencher le menu contextuel.

createCustomizer

public AbstractCustomizer createCustomizer()
Returns a Customizer for geometry editing


http://www.jpicedt.org

Submit a bug : syd@jpicedt.org