|
|
|||||||||
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 jpicedt.graphic.model.PicSmoothPolygon
public class PicSmoothPolygon
A multicurve, either closed or not, the geometry of which is specified using a polygon, in such a way that
the curve snakes "smoothly" along the polygon. For each polygon point, a coefficient helps altering the
smoothness of the the path. Like the class it inherits from, this element has a variable number of
user-controlled points that can be added/inserted/deleted by the user.
Each polygon point is also an anchor point (e.g. for grid alignment).
Implementation notes : inherited pts
ArrayList acts as an array of specification
points for the multicurve (this behaviour being mostly inherited from superclass). Besides, there's an
ArrayList
of PicPoint
's, namely polygonPts
, which backs the geometry
of the polygon, and acts as a list of user-controlled points.
Moving a control-point thus updates specification points as appropriate.
[SR:todo:11/01/2003] add documentation about curve equation.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class jpicedt.graphic.model.AbstractCurve |
---|
AbstractCurve.CtrlPtSubsetAbstractCurve, AbstractCurve.CurveToSegment, AbstractCurve.EndSegment, AbstractCurve.LineToSegment, AbstractCurve.PointType, AbstractCurve.Segment |
Field Summary | |
---|---|
protected static int |
COEF_SLIDER_MAX
Max value of smoothness coefficient accessible to Jslider in the geometry editor |
protected static int |
COEF_SLIDER_MIN
Min value of smoothness coefficient accessible to JSlider in the geometry editor |
protected static double |
DEFAULT_SMOOTH_COEFF
The default value for the smoothness coefficient on startup. |
protected ArrayList<PicPoint> |
polygonPts
An array of PicPoint 's backing the geometry of the polygon. |
protected ArrayList<Double> |
smoothCoeff
The following array contains one Double per polygon point, specifying how close to polygon points the curve should go along. |
Fields inherited from class jpicedt.graphic.model.AbstractCurve |
---|
bezierPts, isClosed |
Fields inherited from class jpicedt.graphic.model.AbstractElement |
---|
attributeSet, name, parent, view |
Constructor Summary | |
---|---|
PicSmoothPolygon()
Create a new empty open smooth polygon, with a default attribute set. |
|
PicSmoothPolygon(boolean closed)
Create a new empty smooth polygon, open or closed, with a default attribute set bound to it. |
|
PicSmoothPolygon(boolean closed,
PicAttributeSet set)
Create a new empty smooth polygon with the given attribute set. |
|
PicSmoothPolygon(PicPoint[] polygonPts,
boolean closed,
double[] smoothCoeffs,
PicAttributeSet set)
Create a new smooth polygon initialized from the given array of PicPoint's, using the given array of smoothness values. |
|
PicSmoothPolygon(PicPoint[] polyPts,
boolean closed,
double smoothCoeff,
PicAttributeSet set)
Create a new smooth polygon initialized from the given array of PicPoint's. |
|
PicSmoothPolygon(PicPoint[] polygonPts,
boolean closed,
PicAttributeSet set)
Create a new smooth polygon initialized from the given array of PicPoint's, using the default smoothness value. |
|
PicSmoothPolygon(PicSmoothPolygon poly)
"cloning" constructor (to be used by clone()) |
Method Summary | |
---|---|
void |
addPoint(int ptIndex,
PicPoint pt)
Add the given polygon point at the given position, shifting ensuing point indices to the right. |
void |
addPoint(int ptIndex,
PicPoint pt,
double smoothCoeff)
Add the given polygon point at the given position, shifting ensuing point indices to the right. |
void |
addPoint(PicPoint pt)
Add the given point at the end of this PicSmoothPolygon . |
void |
addPoint(PicPoint pt,
double smoothCoeff)
Add the given point with the given smoothness-coefficient at the end of this PicSmoothPolygon . |
PicSmoothPolygon |
clone()
Overide Object.clone() method |
PicMultiCurve |
convertToMultiCurve()
Convert this PicSmoothPolygon to a PicMultiCurve , by simply relying on the
appropriate constructor in class PicMultiCurve . |
ArrayList<PEAction> |
createActions(ActionDispatcher actionDispatcher,
ActionLocalizer localizer,
HitInfo hi)
Create an array of Action's related to this object |
AbstractCustomizer |
createCustomizer()
Returns a Customizer for geometry editing |
Rectangle2D |
getBoundingBox(Rectangle2D r)
Returns the bounding box (ie the surrounding rectangle) in double precision This implementation compute the bb from the union of : the bb as computed by super-class and the smallest rectangle that encompasses all the polygon-points. |
PicPoint |
getCtrlPt(int numPoint,
PicPoint dest)
Return the user-controlled point (ie a polygon point, not a bezier point) having the given index. |
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
|
String |
getDefaultName()
|
int |
getFirstPointIndex()
Returns the index of the first user-controlled point that can be retrieved by getCtrlPt() . |
int |
getLastPointIndex()
Returns the index of the last user-controlled point that can be retrieved by getCtrlPt() . |
protected PicPoint |
getPolygonPt(int numPoint)
Return a reference to the polygon point with the given index. |
double |
getSmoothCoefficient(int index)
|
void |
mirror(PicPoint ptOrg,
PicVector normalVector)
Effectue une réflexion sur this relativement à l'axe
défini par ptOrg et normalVector . |
void |
removeLastPoint()
Remove the last point of this PicSmoothPolygon . |
void |
removePoint(int pos)
Remove a point at the given position from this PicSmoothPolygon, then fire a changed-update. |
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,
UserConfirmationCache ucc)
Scale this object by (sx,sy) using (ptOrgX,ptOrgY) as the origin. |
void |
setClosed(boolean state)
Set close path state, then fires a changed-update. |
void |
setCtrlPt(int index,
PicPoint pt,
EditPointConstraint constraint)
Set the user-controlled point with the given index to the given value. |
void |
setSmoothCoefficient(int index,
double c)
|
void |
shear(PicPoint ptOrg,
double shx,
double shy,
UserConfirmationCache ucc)
Shear this Element by the given params wrt to the given origin |
int |
splitSegment(int segIdx,
PicPoint pt)
Split the given polygon segment (starting from 0), by inserting a new polygon point at the appropriate position. |
int |
splitSegment(int segIdx,
PicPoint pt,
double smoothCoeff)
Split the given polygon segment (starting from 0), by inserting a new polygon point at the appropriate position. |
String |
toString()
Used for debugging purpose. |
void |
translate(double dx,
double dy)
Translate this Element by (dx,dy) ; this implementation translates the specification-points, then fires a changed-update event. |
Methods inherited from class jpicedt.graphic.model.AbstractElement |
---|
anchorPointsIterator, fireChangedUpdate, getAttribute, getAttributeSet, 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 |
---|
anchorPointsIterator, createShape, getAttribute, getAttributeSet, getDrawing, getName, getParent, getView, removeView, replaceBy, scale, scale, scale, setAttribute, setAttributeSet, setCtrlPt, setParent, setViewFromFactory, shear, syncArrowGeometry |
Field Detail |
---|
protected ArrayList<PicPoint> polygonPts
PicPoint
's backing the geometry of the polygon. Aka caching mechanism holding
a list of user-controlled points.
protected ArrayList<Double> smoothCoeff
protected static double DEFAULT_SMOOTH_COEFF
protected static int COEF_SLIDER_MIN
protected static int COEF_SLIDER_MAX
Constructor Detail |
---|
public PicSmoothPolygon()
public PicSmoothPolygon(boolean closed)
closed
- whether the generated multi-curve will be closed or notpublic PicSmoothPolygon(boolean closed, PicAttributeSet set)
set
- attribute set to be bound to this elementclosed
- whether the generated multi-curve will be closed or notpublic PicSmoothPolygon(PicPoint[] polyPts, boolean closed, double smoothCoeff, PicAttributeSet set)
polyPts
- array of PicPoint's specifying the polygon geometry.set
- attribute set to be bound to this elementclosed
- whether the generated multi-curve will be closed or notsmoothCoeff
- the default smoothness value for each polygon pointpublic PicSmoothPolygon(PicPoint[] polygonPts, boolean closed, double[] smoothCoeffs, PicAttributeSet set)
polygonPts
- array of PicPoint's specifying the polygon geometry.set
- attribute set to be bound to this elementclosed
- whether the generated multi-curve will be closed or notsmoothCoeffs
- array of smoothness values for each polygon pointpublic PicSmoothPolygon(PicPoint[] polygonPts, boolean closed, PicAttributeSet set)
polygonPts
- array of PicPoint's specifying the polygon geometry.set
- attribute set to be bound to this elementclosed
- whether the generated multi-curve will be closed or notpublic PicSmoothPolygon(PicSmoothPolygon poly)
poly
- PicSmoothPolygon to be clonedMethod Detail |
---|
public PicSmoothPolygon clone()
clone
in interface Element
clone
in class AbstractElement
public String getDefaultName()
getDefaultName
in class AbstractElement
public int getFirstPointIndex()
getCtrlPt()
.
This implementation returns 0.
getFirstPointIndex
in interface Element
public int getLastPointIndex()
getCtrlPt()
.
This default implementation returns the number of polygon-points minus one.
getLastPointIndex
in interface Element
public PicPoint getCtrlPt(int numPoint, PicPoint dest)
setCtrlPt
method.
getCtrlPt
in interface Element
numPoint
- the point index, should be greater or equal to the value returned by
getFirstPointIndex
, and lower or equal to getLastPointIndex
.
numPoint
;
if dest
is null, allocates a new PicPoint and return it,
otherwise directly modifies dest
and returns it as well for convenience.protected final PicPoint getPolygonPt(int numPoint)
getCtrlPt(int,PicPoint)
, except that a mere reference is returned.
public void setCtrlPt(int index, PicPoint pt, EditPointConstraint constraint)
setCtrlPt
in interface Element
setCtrlPt
in class AbstractCurve
constraint
- not used so farpublic void addPoint(PicPoint pt)
PicSmoothPolygon
.
addPoint
in class AbstractCurve
public void addPoint(PicPoint pt, double smoothCoeff)
PicSmoothPolygon
.
public void addPoint(int ptIndex, PicPoint pt)
public void addPoint(int ptIndex, PicPoint pt, double smoothCoeff)
public int splitSegment(int segIdx, PicPoint pt)
splitSegment
in class AbstractCurve
segIdx
- index of the polygon segment that must be split.pt
- the PicPoint to be added
public int splitSegment(int segIdx, PicPoint pt, double smoothCoeff)
segIdx
- index of the polygon segment that must be split.smoothCoeff
- the smoothness coefficient to be used for the new polygon point.pt
- the PicPoint to be addedpublic void removePoint(int pos)
Nothing is done if this polygon has only one point.
removePoint
in class AbstractCurve
pos
- index of point to be removedpublic void removeLastPoint()
PicSmoothPolygon
.
This is a convenience call to removePoint(polygonPts.size()-1)
public PicMultiCurve convertToMultiCurve()
PicSmoothPolygon
to a PicMultiCurve
, by simply relying on the
appropriate constructor in class PicMultiCurve
.
convertToMultiCurve
in interface PicMultiCurveConvertable
public double getSmoothCoefficient(int index)
index
- Description of the Parameter
public void setSmoothCoefficient(int index, double c)
index
- index of point whose smoothCoeff is to be adjustedc
- value of the smoothCoeffpublic void setClosed(boolean state)
setClosed
in class AbstractCurve
state
- The new closed valueAbstractCurve.isClosed()
public void translate(double dx, double dy)
translate
in interface Element
translate
in class AbstractCurve
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,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 eventually fires a changed-update event.
scale
in interface Element
scale
in class AbstractCurve
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
rotate
in class AbstractCurve
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
mirror
in class AbstractCurve
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)
shear
in interface Element
shear
in class AbstractCurve
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 CtrlPtSubset getCtrlPtSubset(ConvexZoneGroup csg, BitSet czExtension)
Element
csg
, et
czExtension
getCtrlPtSubset
in interface Element
getCtrlPtSubset
in class AbstractCurve
csg
- l'ensemble de zones convexes ConvexZoneGroup
auquel on teste l'appartenance des
points de contrôle.czExtension
- cet argument est ignoré
CtrlPtSubset
valuejpicedt.graphic.model
public Rectangle2D getBoundingBox(Rectangle2D r)
getBoundingBox
in interface Element
getBoundingBox
in class AbstractCurve
public String toString()
toString
in class AbstractCurve
public ArrayList<PEAction> createActions(ActionDispatcher actionDispatcher, ActionLocalizer localizer, HitInfo hi)
createActions
in interface ActionFactory
createActions
in class AbstractCurve
actionDispatcher
- dispatches events to the proper PECanvas
localizer
- 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()
AbstractCurve
createCustomizer
in interface CustomizerFactory
createCustomizer
in class AbstractCurve
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |