|
|
|||||||||
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.AbstractCurve
jpicedt.graphic.model.PicMultiCurve
public class PicMultiCurve
PicMultiCurve is basically an AbstractCurve where each subdivision point has
additionnal features regarding 2nd-order smoothness and symmetry. These
features, however, are dynamic in the sense that they may be enforced by passing
geometric constraints to the setPoint()
method instead of
having them tightly bound to the class. Besides,
setSmooth()
and setSymmetric()
methods may
be used to dynamically enforce these features w/o having to move control-points.
Field Summary | |
---|---|
static BasicEditPointConstraint |
FREELY
predefined constraint for setPoint() |
static BasicEditPointConstraint |
SMOOTHNESS
predefined constraint for setPoint() |
static BasicEditPointConstraint |
SYMMETRY
predefined constraint for setPoint() |
Fields inherited from class jpicedt.graphic.model.AbstractCurve |
---|
FIRST_CURVE_END_POINT, FIRST_SEGMENT_CONTROL_POINT, INVALID_POINT_INDEX, isClosed, LAST_CURVE_END_POINT, SECOND_SEGMENT_CONTROL_POINT, SUBDIVISION_POINT |
Fields inherited from class jpicedt.graphic.model.DefaultLeafElement |
---|
nodeConnections, nodeName, pts |
Fields inherited from class jpicedt.graphic.model.AbstractElement |
---|
attributeSet, parent, view |
Constructor Summary | |
---|---|
PicMultiCurve()
Create a new empty open multi curve, with a default attribute set. |
|
PicMultiCurve(boolean closed)
Create a new empty multi curve, with a default attribute set. |
|
PicMultiCurve(boolean closed,
PicAttributeSet set)
Create a new empty multi curve with the given set of attribute |
|
PicMultiCurve(PicMultiCurve curve)
"cloning" constructor (to be used by clone()) |
|
PicMultiCurve(PicPoint pt1)
Create a new open multi curve reduced to the given point, and a default attribute set. |
|
PicMultiCurve(PicPoint[] pts,
PicAttributeSet set)
Create a new multi-curve filled with the given array of PicPoint's, each segment being a curved Bezier segment. |
|
PicMultiCurve(PicPoint pt1,
PicAttributeSet set)
Create a new open multi curve reduced to the given point, and the given attribute set |
|
PicMultiCurve(PicPoint pt1,
PicPoint pt2)
Create a new line, i.e. |
|
PicMultiCurve(PicPoint pt1,
PicPoint pt2,
PicAttributeSet set)
Create a new straight open multi curve with the two given points, and the given attribute set. |
|
PicMultiCurve(PicPoint pt1,
PicPoint ctrl1,
PicPoint ctrl2,
PicPoint pt2)
Create an open single cubic bezier curve from the four given points, and a default attribute set |
|
PicMultiCurve(PicPsCurve curve)
constructor for conversion of pscurve into multiCurve |
|
PicMultiCurve(PicSmoothPolygon poly)
constructor for conversion of smoothPoly into multiCurve |
Method Summary | |
---|---|
void |
addPoint(PicPoint pt)
Adds a new subdivision point to the end of this curve. |
Object |
clone()
Override Object.clone() method |
PicMultiCurve |
convertToMultiCurve()
converts this ELement to a PicMultiCurve, i.e., itself (no copy). |
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 |
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, then fire a GEOMETRY_CHANGE event. If the curve is closed, you should use splitSegment instead, since this method does nothing
in this case ;-) |
double |
distance(PicMultiCurve other)
Returns the shortest distance b/w the end-points of this curve and those of the given one. |
PicMultiCurveConvertable |
fetchClosestCurve(Collection l)
Returns the curve in the given collection that is closest to this one in the sense of the distance() method. |
String |
getName()
Returns a non-localised string representing this object's name This default implementation returns the class name. |
void |
join(PicMultiCurveConvertable c)
Join this curve and the given Element after proper conversion of the latter to a PicMultiCurve, by appending the control points of the given curve to this one. |
void |
removePoint(int index)
Removes the point with the given index from this curve. |
void |
removeSubdivisionPoint(int subdivIndex)
Removes a subdivision point from this curve, together with its two neighbouring control points. |
void |
reverseIndexing()
Reverse the order in which points are stored in the protected pts array. |
void |
setClosed(boolean state)
close or open this curve, that is, remove or add an end-point. This methods fires a DrawingEvent of type GEOMETRY_CHANGE . |
void |
setPoint(int index,
PicPoint pt,
EditPointConstraint constraint)
Set the coordinates of a Bezier point having the given index to the given location, possibly moving other control-points according to the given constraint. |
void |
setSmooth()
changes the smoothness feature of all the subdivision points at once. |
void |
setSmooth(int subdivIndex)
Forces the smoothness feature of the given subdivision point by moving alternate control-points. If one neightbouring segment is straight, it imposes the location of the alternate control. If both segments are straight, this method can't do anything unfortunately. If both segments are curved, the resulting tangent is computed from the external bissector of both control vectors, yet retaining norm of control-vectors. This method fires a drawing-event of type GEOMETRY_CHANGE. |
void |
setStraight()
Straighten ALL segments (ie make this curve a polygon). |
void |
setStraight(int segIndex)
changes the straightness feature for the given segment by making its control- and end-points identical. |
void |
setSymmetric()
force the symmetry feature of all the subdivision points at once. |
void |
setSymmetric(int subdivIndex)
Force the SYMMETRY feature of the given subdivision point. |
int |
splitSegment(int seg_idx,
PicPoint pt)
Adds a new point to a (maybe curved) segment then fires a changed-update. |
String |
toString()
Return a string for debugging purpose. |
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 BasicEditPointConstraint SYMMETRY
public static final BasicEditPointConstraint SMOOTHNESS
public static final BasicEditPointConstraint FREELY
Constructor Detail |
---|
public PicMultiCurve()
public PicMultiCurve(boolean closed)
closed
- whether this curve is closed or notpublic PicMultiCurve(boolean closed, PicAttributeSet set)
closed
- whether this curve is closed or notset
- attribute set to be bound to this elementpublic PicMultiCurve(PicPoint pt1)
public PicMultiCurve(PicPoint pt1, PicAttributeSet set)
public PicMultiCurve(PicPoint pt1, PicPoint pt2)
public PicMultiCurve(PicPoint pt1, PicPoint pt2, PicAttributeSet set)
public PicMultiCurve(PicPoint pt1, PicPoint ctrl1, PicPoint ctrl2, PicPoint pt2)
public PicMultiCurve(PicPoint[] pts, PicAttributeSet set)
public PicMultiCurve(PicSmoothPolygon poly)
poly
- the smoothPoly to be convertedpublic PicMultiCurve(PicPsCurve curve)
poly
- the PsCurve to be convertedpublic PicMultiCurve(PicMultiCurve curve)
curve
- the curve to be clonedMethod Detail |
---|
public Object clone()
clone
in interface Element
clone
in class DefaultLeafElement
public String getName()
DefaultLeafElement
getName
in interface Element
getName
in class DefaultLeafElement
public PicMultiCurve convertToMultiCurve()
convertToMultiCurve
in interface PicMultiCurveConvertable
public double distance(PicMultiCurve other)
public PicMultiCurveConvertable fetchClosestCurve(Collection l)
l
- a list of PicMultiCurveConvertable's ; l may contain this curve, in which case it's simply skipped.
public void reverseIndexing()
public void join(PicMultiCurveConvertable c)
public void setPoint(int index, PicPoint pt, EditPointConstraint constraint)
setPoint
in interface Element
setPoint
in class AbstractCurve
constraint
- not used hereEditPointConstraintCollator
public void addPoint(PicPoint pt)
lineTo()
and curveTo()
methods.
addPoint
in class AbstractCurve
public void curveTo(PicPoint ptCtrl1, PicPoint ptCtrl2, PicPoint ptEnd)
splitSegment
instead, since this method does nothing
in this case ;-)
curveTo
in class AbstractCurve
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 int splitSegment(int seg_idx, PicPoint pt)
splitSegment
in class AbstractCurve
seg_idx
- index of the segment to be splitpt
- point at which segment is to be split
public void removeSubdivisionPoint(int subdivIndex)
This method fires a DrawingEvent of type GEOMETRY_CHANGE..
removeSubdivisionPoint
in class AbstractCurve
index
- index of the subdivision point to be removed with respect to the SUBDIVISION point numbering scheme,
e.g. 0 for the first subdivision point (= first curve end-point).public void removePoint(int index)
removeSubdivisionPoint
.
Else, this means removing a control point, and we just "straighten" the corresponding segment end-point
by moving the control-point to the location of the nearest subdivision-point (hence this has no effect on
straight segments).
removePoint
in class AbstractCurve
index
- any valid control- or subdivision- index to be removedpublic void setClosed(boolean state)
setClosed
in class AbstractCurve
state
- The new close valuepublic void setSmooth(int subdivIndex)
subdivIndex
- index of the subdivision point, e.g. 0,1,2... for the 1st,2nd,3rd,... subdivision point.public void setSmooth()
public void setSymmetric(int subdivIndex)
subdivIndex
- index of the subdivision point, e.g. 0,1,2... for the 1st,2nd,3rd,... subdivision point.public void setSymmetric()
public void setStraight(int segIndex)
public void setStraight()
public String toString()
toString
in class AbstractCurve
public PEAction[] createActions(ActionDispatcher actionDispatcher, ActionLocalizer localizer, HitInfo hi)
createActions
in interface ActionFactory
createActions
in class AbstractCurve
actionDispatcher
- dispatches events to the proper PECanvaslocalizer
- i18n localizer for PEAction'shi
- a HitInfo containing information related to the mouse-event which triggered the popup menu.public AbstractCustomizer createCustomizer()
createCustomizer
in interface CustomizerFactory
createCustomizer
in class AbstractCurve
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |