Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| http://www.jpicedt.org
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jpicedt.graphic.model
Class PicPsCurve

    java.lang.Object
      jpicedt.graphic.model.AbstractElement
          jpicedt.graphic.model.DefaultLeafElement
              jpicedt.graphic.model.AbstractCurve
                  jpicedt.graphic.model.PicPsCurve

All Implemented Interfaces:
  ActionFactory, CustomizerFactory, Element, PicMultiCurveConvertable, PicObjectConstants

public class PicPsCurve
extends AbstractCurve
implements ActionFactory, CustomizerFactory, PicMultiCurveConvertable

A multicurve, either closed or not, going through a set of control points. This is the implementation of the (somewhat obscure) pstricks \pscurve function. There are three coefficients a,b,c altering the curvature.

Since:
  jpicedt 1.4pre5
Version:
  $Id: PicPsCurve.java,v 1.2.2.1 2007/09/02 11:56:27 reynal Exp $
Author:
  Vincent Guirardel

Field Summary
`protected static int` | `A_SLIDER_MAX` Max value of curvature coefficient accessible to Jslider in the geometry editor
`protected static int` | `A_SLIDER_MIN` Min value of curvature coefficient accessible to JSlider in the geometry editor
`protected static int` | `B_SLIDER_MAX`
`protected static int` | `B_SLIDER_MIN`
`protected static int` | `C_SLIDER_MAX`
`protected static int` | `C_SLIDER_MIN`
`protected double` | `curvatureA` Curvature parameters a,b,c of pscurve.
`protected double` | `curvatureB`
`protected double` | `curvatureC`
`protected static double` | `DEFAULT_CURVATURE_A` default values for the curvature parameters
`protected static double` | `DEFAULT_CURVATURE_B`
`protected static double` | `DEFAULT_CURVATURE_C`
`protected ArrayList` | `polygonPts` An array of PicPoint's backing the geometry of the polygon.

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`

Fields inherited from interface jpicedt.graphic.model.PicObjectConstants
`ARROW_GLOBAL_SCALE_LENGTH, ARROW_GLOBAL_SCALE_WIDTH, ARROW_INSET_SCALE, ARROW_LENGTH_SCALE, ARROW_WIDTH_LINEWIDTH_SCALE, ARROW_WIDTH_MINIMUM_MM, BRACKET_LENGTH_SCALE, CROSSHATCH, CROSSHATCH_FILLED, DASH_OPAQUE, DASH_TRANSPARENT, DASH1, DASH2, DASH3, DASHED, DIMEN, DOT_SEP, DOT_SEP1, DOT_SEP2, DOT_SEP3, DOTTED, DOUBLE_COLOR, DOUBLE_LINE, DOUBLE_SEP, FILL_COLOR, FILL_STYLE, HATCH_ANGLE, HATCH_COLOR, HATCH_SEP, HATCH_WIDTH, HLINES, HLINES_FILLED, INNER, LEFT_ARROW, LINE_COLOR, LINE_STYLE, LINE_WIDTH, MIDDLE, NONE, OUTER, OVER_STRIKE, OVER_STRIKE_COLOR, OVER_STRIKE_WIDTH, POLYDOTS_ANGLE, POLYDOTS_CIRCLE, POLYDOTS_DISK, POLYDOTS_PENTAGON, POLYDOTS_PENTAGON_FILLED, POLYDOTS_PLUS, POLYDOTS_SCALE_H, POLYDOTS_SCALE_V, POLYDOTS_SIZE_LINEWIDTH_SCALE, POLYDOTS_SIZE_MINIMUM_MM, POLYDOTS_SQUARE, POLYDOTS_SQUARE_FILLED, POLYDOTS_STYLE, POLYDOTS_SUPERIMPOSE, POLYDOTS_TRIANGLE, POLYDOTS_TRIANGLE_FILLED, PS_POINT, PST_CUSTOM, RBRACKET_LENGTH_SCALE, RIGHT_ARROW, SHADOW, SHADOW_ANGLE, SHADOW_COLOR, SHADOW_SIZE, SOLID, TBAR_WIDTH_LINEWIDTH_SCALE, TBAR_WIDTH_MINIMUM_MM, TEXT_BOX_CIRCLE, TEXT_BOX_NO_FRAME, TEXT_BOX_OVAL, TEXT_BOX_RECTANGLE, TEXT_FRAME, TEXT_HALIGN_CENTER, TEXT_HALIGN_LEFT, TEXT_HALIGN_RIGHT, TEXT_HOR_ALIGN, TEXT_ROTATION, TEXT_VALIGN_BASELINE, TEXT_VALIGN_BOTTOM, TEXT_VALIGN_CENTER, TEXT_VALIGN_TOP, TEXT_VERT_ALIGN, VLINES, VLINES_FILLED`

Constructor Summary
`PicPsCurve()` Create a new empty open pscurve, with a default attribute set.
`PicPsCurve(boolean closed)` Create a new empty pscurve, open or closed, with a default attribute set bound to it.
`PicPsCurve(boolean closed, PicAttributeSet set)` Create a new empty pscurve with the given attribute set.
`PicPsCurve(PicPoint[] polyPts, boolean closed, double a, double b, double c, PicAttributeSet set)` Create a new pscurve initialized from the given array of PicPoint's.
`PicPsCurve(PicPoint[] polygonPts, boolean closed, PicAttributeSet set)` Create a new pscurve initialized from the given array of PicPoint's, using the default curvature values.
`PicPsCurve(PicPsCurve poly)` "cloning" constructor (to be used by clone())

Method Summary
`void` | `addPoint(int ptIndex, PicPoint pt)` Inserts the specified point at the specified index.
`void` | `addPoint(PicPoint pt)` adds the given point at the end of this pscurve.
`Object` | `clone()` Overide Object.clone() method
`PicMultiCurve` | `convertToMultiCurve()` converts this PicPsCurve to a PicMultiCurve, by simply relying on the appropriate constructor in class `PicMultiCurve`.
`PEAction[]` | `createActions(ActionDispatcher actionDispatcher, ActionLocalizer localizer, HitInfo hi)` Create an array of Action's related to this object
`AbstractCustomizer` | `createCustomizer()` Returns a customizer (Swing) component
`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.
`double[]` | `getCurvatures()` Return an array containing the three curvature coefficients in an array, namely [a b c].
`PicPoint[]` | `getFinalControlCurve()` Returns the 4 Bezier points of the final prolongation of the PsCurve.
`int` | `getFirstPointIndex()` Returns the index of the first user-controlled point that can be retrieved by `getPoint()`.
`PicPoint[]` | `getInitialControlCurve()` Returns the 4 Bezier points of the initial prolongation of the PsCurve.
`int` | `getLastPointIndex()` Returns the index of the last user-controlled point that can be retrieved by `getPoint()`.
`String` | `getName()` Returns a non-localised string representing this object's name This default implementation returns the class name.
`PicPoint` | `getPoint(int numPoint, PicPoint src)` Return the user-controlled point (ie a polygon point, not a bezier point) having the given index.
`double` | `getPointX(int index)` This implementation returns the X-coord of the polygon-point with the same index.
`double` | `getPointY(int index)` This implementation returns the Y-coord of the polygon-point with the same index.
`protected PicPoint` | `getPolygonPoint(int numPoint)` Return a reference on the polygon point with the given index.
`void` | `removeLastPoint()` removes the last point of this PicPsCurve.
`void` | `removePoint(int pos)` Remove a point at the given position from this PicPsCurve, 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)` 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` | `setPoint(int index, PicPoint pt, EditPointConstraint constraint)` Set the user-controlled point with the given index to the given value.
`void` | `shear(PicPoint ptOrg, double shx, double shy)` 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.
`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.AbstractCurve
`curveTo, getAlternateControlPoint, getIncomingTangent, getNearestSubdivisionPoint, getNumberOfSegments, getNumberOfSubdivisionPoints, getOutgoingTangent, getPBCBezierIndex, getPBCSegmentIndex, getPointType, getShapeBounds2D, getSpecificationPoint, hasValidSize, isClosed, isControlPoint, isPolygon, isSmooth, isStraight, isSymmetric, isValidBezierIndex, isValidSegmentIndex, lineTo, pointToSegmentIndex, removeLastSubdivisionPoint, removeSubdivisionPoint, segmentToPointIndex, splitSegment`

Methods inherited from class jpicedt.graphic.model.DefaultLeafElement
`addConnection, fireChangedUpdate, forwardChangedUpdate, getAllowsChildren, getNodeName, getNumberOfSpecificationPoints, getPoint, getSpecificationPoint, getSpecificationPointX, getSpecificationPointY, isNode, isNodeable, iterator, nodeConnectionOrigin, nodeReferencePoint, nodeReferencePointX, nodeReferencePointY, removeAllConnections, removeConnection, setNodeName, setPoint, setSpecificationPoint`

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

### polygonPts

    protected ArrayList polygonPts

  An array of PicPoint's backing the geometry of the polygon. Aka caching mechanism holding a list of user-controlled points.

### curvatureA

    protected double curvatureA

  Curvature parameters a,b,c of pscurve.

### curvatureB

    protected double curvatureB

### curvatureC

    protected double curvatureC

### DEFAULT_CURVATURE_A

    protected static double DEFAULT_CURVATURE_A

  default values for the curvature parameters

### DEFAULT_CURVATURE_B

    protected static double DEFAULT_CURVATURE_B

### DEFAULT_CURVATURE_C

    protected static double DEFAULT_CURVATURE_C

### A_SLIDER_MIN

    protected static int A_SLIDER_MIN

  Min value of curvature coefficient accessible to JSlider in the geometry editor

### B_SLIDER_MIN

    protected static int B_SLIDER_MIN

### C_SLIDER_MIN

    protected static int C_SLIDER_MIN

### A_SLIDER_MAX

    protected static int A_SLIDER_MAX

  Max value of curvature coefficient accessible to Jslider in the geometry editor

### B_SLIDER_MAX

    protected static int B_SLIDER_MAX

### C_SLIDER_MAX

    protected static int C_SLIDER_MAX

Constructor Detail

### PicPsCurve

    public PicPsCurve()

  Create a new empty open pscurve, with a default attribute set.

### PicPsCurve

    public PicPsCurve(boolean closed)

  Create a new empty pscurve, open or closed, with a default attribute set bound to it.

Parameters:
  `closed` - whether the pscurve will be closed or not

### PicPsCurve

    public PicPsCurve(boolean closed,
                      PicAttributeSet set)

  Create a new empty pscurve with the given attribute set.

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

### PicPsCurve

    public PicPsCurve(PicPoint[] polyPts,
                      boolean closed,
                      double a,
                      double b,
                      double c,
                      PicAttributeSet set)

  Create a new pscurve initialized from the given array of PicPoint's.

Parameters:
  `polyPts` - array of PicPoint's specifying the pscurve geometry.
  `set` - attribute set to be bound to this element
  `closed` - whether the generated multi-curve will be closed or not
  `a` - the a-curvature value
  `b` - the b-curvature value
  `c` - the c-curvature value
Since:
  jpicedt 1.4pre5

### PicPsCurve

    public PicPsCurve(PicPoint[] polygonPts,
                      boolean closed,
                      PicAttributeSet set)

  Create a new pscurve initialized from the given array of PicPoint's, using the default curvature values.

Parameters:
  `polygonPts` - array of PicPoint's specifying the polygon geometry.
  `set` - attribute set to be bound to this element
  `closed` - whether the generated multi-curve will be closed or not
Since:
  jpicedt 1.4pre5

### PicPsCurve

    public PicPsCurve(PicPsCurve poly)

  "cloning" constructor (to be used by clone())

Parameters:
  `poly` - PicPsCurve to be cloned
Since:
  jpicedt 1.4pre5

Method Detail

### clone

    public Object clone()

  Overide Object.clone() method

  Specified by:
    `clone` in interface `Element`
  Overrides:
    `clone` in class `DefaultLeafElement`
  Since:
    jpicedt 1.4pre5

### getName

    public String getName()

  Description copied from class: `DefaultLeafElement`
  Returns a non-localised string representing this object's name This default implementation returns the class name.

  Specified by:
    `getName` in interface `Element`
  Overrides:
    `getName` in class `DefaultLeafElement`
  Returns:
    a localised string that represents this object's name

### getFirstPointIndex

    public int getFirstPointIndex()

  Returns the index of the first user-controlled point that can be retrieved by `getPoint()`. This implementation returns 0.

  Specified by:
    `getFirstPointIndex` in interface `Element`
  Overrides:
    `getFirstPointIndex` in class `DefaultLeafElement`

### getLastPointIndex

    public int getLastPointIndex()

  Returns the index of the last user-controlled point that can be retrieved by `getPoint()`. This default implementation returns the number of polygon-points minus one.

  Specified by:
    `getLastPointIndex` in interface `Element`
  Overrides:
    `getLastPointIndex` in class `DefaultLeafElement`

### getPoint

    public PicPoint getPoint(int numPoint,
                             PicPoint src)

  Return the user-controlled point (ie a polygon point, not a bezier point) having the given index. The general contract in Element is to return an IMMUTABLE instance of PicPoint, so that the only way to alter the geometry of this element is by calling the `setPoint` method.
  Overriden so as to return a "polygon" point instead of a bezier-point (which act as specification-point here).

  Specified by:
    `getPoint` in interface `Element`
  Overrides:
    `getPoint` in class `DefaultLeafElement`
  Parameters:
    `numPoint` - the point index, should be greater or equal to the value returned by `getFirstPointIndex`, and lower or equal to `getLastPointIndex`.
  Returns:
    the point indexed by `numPoint` ; if `src` is null, allocates a new PicPoint and return it, otherwise directly modifies `src` and returns it as well for convenience.

### getPolygonPoint

    protected final PicPoint getPolygonPoint(int numPoint)

  Return a reference on the polygon point with the given index. This is equivalent to calling getPoint(int,PicPoint), except that a mere reference is returned.

### getPointX

    public double getPointX(int index)

  This implementation returns the X-coord of the polygon-point with the same index.

  Specified by:
    `getPointX` in interface `Element`
  Overrides:
    `getPointX` in class `DefaultLeafElement`
  Parameters:
    `index` - the point index, should be greater or equal to the value returned by `getFirstPointIndex`, and lower or equal to `getLastPointIndex`.
  Returns:
    the X-coord of the point indexed by `index`.
  Since:
    jpicedt 1.4pre5

### getPointY

    public double getPointY(int index)

  This implementation returns the Y-coord of the polygon-point with the same index.

  Specified by:
    `getPointY` in interface `Element`
  Overrides:
    `getPointY` in class `DefaultLeafElement`
  Parameters:
    `index` - the point index, should be greater or equal to the value returned by `getFirstPointIndex`, and lower or equal to `getLastPointIndex`.
  Returns:
    the Y-coord of the point indexed by `index`.
  Since:
    jpicedt 1.4pre5

### translate

    public void translate(double dx,
                          double dy)

  Translate this Element by (dx,dy) ; this implementation translates the specification-points, then fires a changed-update event.

  Specified by:
    `translate` in interface `Element`
  Overrides:
    `translate` in class `DefaultLeafElement`
  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)

  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 eventually fires a changed-update event.

  Specified by:
    `scale` in interface `Element`
  Overrides:
    `scale` in class `DefaultLeafElement`

### rotate

    public void rotate(PicPoint ptOrg,
                       double angle)

  Rotate this Element by the given angle along the given point

  Specified by:
    `rotate` in interface `Element`
  Overrides:
    `rotate` in class `DefaultLeafElement`
  Parameters:
    `angle` - rotation angle in radians

### shear

    public void shear(PicPoint ptOrg,
                      double shx,
                      double shy)

  Shear this Element by the given params wrt to the given origin

  Specified by:
    `shear` in interface `Element`
  Overrides:
    `shear` in class `DefaultLeafElement`

### setPoint

    public void setPoint(int index,
                         PicPoint pt,
                         EditPointConstraint constraint)

  Set the user-controlled point with the given index to the given value. This implementation sets the value of the polygon-point having the same index, then update the associated Bezier curve, and fires a changed-update event.

  Specified by:
    `setPoint` in interface `Element`
  Overrides:
    `setPoint` in class `AbstractCurve`
  Parameters:
    `constraint` - not used so far

### addPoint

    public void addPoint(PicPoint pt)

  adds the given point at the end of this pscurve.

  Specified by:
    `addPoint` in class `AbstractCurve`

### addPoint

    public void addPoint(int ptIndex,
                         PicPoint pt)

  Inserts the specified point at the specified index. Shifts the point currently at that position (if any) and any subsequent points to the right.

### splitSegment

    public int splitSegment(int segIdx,
                            PicPoint pt)

  Split the given polygon segment (starting from 0), by inserting a new polygon point at the appropriate position. then fires a changed-update. For instance, spliting segment "2" yields the following polygon points : 0, 1, 2, insertion pt, 3, 4, etc...

  Specified by:
    `splitSegment` in class `AbstractCurve`
  Parameters:
    `segIdx` - index of the polygon segment that must be split.
    `pt` - the PicPoint to be added
  Returns:
    the index of the user-controlled point which got inserted, according to the indexing scheme of set/getPoint(). This may for instance allow a receiver to control the "new" segment shape by calling setPoint() 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 void removePoint(int pos)

  Remove a point at the given position from this PicPsCurve, then fire a changed-update. This shifts any subsequent points to the left.

  Nothing is done if this polygon has only one point.

  Specified by:
    `removePoint` in class `AbstractCurve`
  Parameters:
    `pos` - index of point to be removed

### removeLastPoint

    public void removeLastPoint()

  removes the last point of this PicPsCurve. This is a convenience call to `removePoint(polygonPts.size()-1)`

### convertToMultiCurve

    public PicMultiCurve convertToMultiCurve()

  converts this PicPsCurve to a PicMultiCurve, by simply relying on the appropriate constructor in class `PicMultiCurve`.

  Specified by:
    `convertToMultiCurve` in interface `PicMultiCurveConvertable`

### getInitialControlCurve

    public PicPoint[] getInitialControlCurve()

  Returns the 4 Bezier points of the initial prolongation of the PsCurve. Used to draw the dotted control line when highlighted.

### getFinalControlCurve

    public PicPoint[] getFinalControlCurve()

  Returns the 4 Bezier points of the final prolongation of the PsCurve. Used to draw the dotted control line when highlighted.

### setClosed

    public void setClosed(boolean state)

  set close path state, then fires a changed-update.

  Overrides:
    `setClosed` in class `AbstractCurve`
  Parameters:
    `state` - The new closed value

### getCurvatures

    public double[] getCurvatures()

  Return an array containing the three curvature coefficients in an array, namely [a b c].

### getBoundingBox

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

  Specified by:
    `getBoundingBox` in interface `Element`
  Overrides:
    `getBoundingBox` in class `DefaultLeafElement`
  Since:
    jpicedt 1.4pre5

### toString

    public String toString()

  Used for debugging purpose.

  Overrides:
    `toString` in class `AbstractCurve`

### createActions

    public PEAction[] createActions(ActionDispatcher actionDispatcher,
                                    ActionLocalizer localizer,
                                    HitInfo hi)

  Create an array of Action's related to this object

  Specified by:
    `createActions` in interface `ActionFactory`
  Overrides:
    `createActions` in class `AbstractCurve`
  Parameters:
    `actionDispatcher` - dispatches events to the proper PECanvas
    `localizer` - i18n localizer for PEAction's

### createCustomizer

    public AbstractCustomizer createCustomizer()

  Description copied from interface: `CustomizerFactory`
  Returns a customizer (Swing) component

  Specified by:
    `createCustomizer` in interface `CustomizerFactory`
  Overrides:
    `createCustomizer` in class `AbstractCurve`
  Returns:
    a Customizer for geometry editing

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| http://www.jpicedt.org
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug : syd@jpicedt.org