|
|
|||||||||
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.PicParallelogram
public class PicParallelogram
A class implementing a parallelogram. Geometry is fully specified by three corner points
(namely, the bottom-left, bottom-right and top-right corners), which thus
act as specification-points (see DefaultLeafElement for details), and can be retrieved using
getSpecificationPointX/Y
. These are obviously stored in the pts
ArrayList, as defined in DefaultLeafElement.
[SR:TODO] add rounded-corners feature.
Field Summary | |
---|---|
protected PicVector |
b2tVec
see documentation for l2rVec |
static BasicEditPointConstraint |
CENTER_FIXED
predefined constraint for setPoint() |
static BasicEditPointConstraint |
DEFAULT
predefined constraint for setPoint() |
static int |
FIRST_PT
Index of first control-point |
protected PicVector |
l2rVec
"l2rVec" is a vector pointing from P_BL to P_BR (or equally, from P_TL to P_TR) "b2tVec" is a vector pointing from P_BR to P_TR (or equally, from P_BL to P_TL) These two vectors simply define a convenient parallelogram's basis, and are updated by a call to updateParalleloBasis(). |
static int |
LAST_PT
Index of last control-point |
static int |
P_BL
Bottom-Left corner (also first specification point) |
static int |
P_BR
Bottom-Right corner (also second specification point) |
static int |
P_CENTER
Parallelogram's centre |
static int |
P_SPEC_BL
1st specification point : Bottom-Left corner |
static int |
P_SPEC_BR
2nd specification point : Bottom-Right corner |
static int |
P_SPEC_TR
3rd specification point : Top-Right corner |
static int |
P_TL
Top-Left corner |
static int |
P_TR
Top-Right corner (also third specification point) |
static int |
SIDE_B
Bottom side mid-point |
static int |
SIDE_L
Left side mid-pint |
static int |
SIDE_R
Right side mid-point |
static int |
SIDE_T
Top side mid-point |
static BasicEditPointConstraint |
SQUARE
predefined constraint for setPoint() |
Fields inherited from class jpicedt.graphic.model.DefaultLeafElement |
---|
nodeConnections, nodeName, pts |
Fields inherited from class jpicedt.graphic.model.AbstractElement |
---|
attributeSet, parent, view |
Constructor Summary | |
---|---|
PicParallelogram()
Creates a new PicParallelogram reduced to (0,0) |
|
PicParallelogram(PicAttributeSet set)
Creates a new PicParallelogram reduced to (0,0), with the given attribute set |
|
PicParallelogram(PicParallelogram parallelo)
"cloning" constructor (to be used by clone()) |
|
PicParallelogram(PicPoint pt,
PicAttributeSet set)
Create a new PicParallelogram reduced to a point located at the given position |
|
PicParallelogram(PicPoint pt1,
PicPoint pt3)
Create a new rectangle with axes parallel to X- and Y-axes, using the 2 given points to build the diagonal, and a default attribute set. |
|
PicParallelogram(PicPoint pt1,
PicPoint pt2,
PicPoint pt3)
Create a new PicParallelogram object using the 3 given points as 3 consecutive points of the parallelogram, and a default attribute set. |
|
PicParallelogram(PicPoint pt1,
PicPoint pt2,
PicPoint pt3,
PicAttributeSet set)
Create a new PicParallelogram object using the 3 given points as 3 consecutive points of the parallelogram. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Overrides Object.clone() method |
PicMultiCurve |
convertToMultiCurve()
Return a polygon created from the sides of this parallelogram. |
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 |
java.awt.geom.Rectangle2D |
getBoundingBox(java.awt.geom.Rectangle2D r)
Returns the bounding box (ie the surrounding rectangle) in double precision Used for instance to determine the arguments of a \\begin{picture} command. |
PicPoint |
getCenter(PicPoint src)
Return the parallelogram's centre |
double |
getCenterX()
Return the X-coord of the parallelogram's center |
double |
getCenterY()
Return the Y-coord of the parallelogram's center |
int |
getFirstPointIndex()
Return the index of the first point that can be retrieved by getPoint |
int |
getLastPointIndex()
Return the index of the last point that can be retrieved by getPoint |
java.lang.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 having the given index. |
double |
getPointX(int numPoint)
Return the X-coord of the control-point indexed by numPoint . |
double |
getPointY(int numPoint)
Return the Y-coord of the control-point indexed by numPoint . |
boolean |
isRectangle()
Returns true if this parallelogram is a rectangle |
void |
rotate(PicPoint ptOrg,
double angle)
Rotate this Element by the given angle along the given point |
void |
setPoint(int numPoint,
PicPoint pt,
EditPointConstraint constraint)
Set the coordinate of the control-point indexed by "numPoint" to the given value. |
void |
shear(PicPoint ptOrg,
double shx,
double shy)
Shear this Element by the given params wrt to the given origin |
protected PicVector |
toParalleloBasisCoordinates(PicPoint ptOrg,
PicPoint ptSrc,
PicVector ptDest)
Compute the contravariant coordinate of the given point "ptSrc" along the "l2r" and "b2t" vectors of the parallelogram's basis, the origin of the basis being set at "ptOrg" This simply reduces to a contravariant change of coordinates from the cartesian basis to the (non-orthonormalized) parallelogram basis. To wind up : denoting OM = vec(ptOrg -> ptSrc), (e1,e2) the cartesian basis (ie std model-coordinates), and (x',y') the new coords in the (l2r,b2t) basis, yields : OM = x e1 + y e2 = x' l2r + y' b2t. |
java.lang.String |
toString()
Implementation of the Object.toString() method, used for debugging purpose |
protected void |
updateParalleloBasis()
Compute the "l2r" and "b2t" vectors of the parallelogram basis from the location of the three specification-points of this parallelogram. |
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 int P_BL
public static final int P_BR
public static final int P_TR
public static final int P_TL
public static final int SIDE_B
public static final int SIDE_R
public static final int SIDE_T
public static final int SIDE_L
public static final int P_CENTER
public static final int FIRST_PT
public static final int LAST_PT
public static final BasicEditPointConstraint SQUARE
public static final BasicEditPointConstraint DEFAULT
public static final BasicEditPointConstraint CENTER_FIXED
public static final int P_SPEC_BL
public static final int P_SPEC_BR
public static final int P_SPEC_TR
protected PicVector l2rVec
An essential function of these vectors is to "retain" the initial parallelogram basis even if the element becomes flat at some point during an edit operation.
protected PicVector b2tVec
l2rVec
Constructor Detail |
---|
public PicParallelogram()
public PicParallelogram(PicAttributeSet set)
public PicParallelogram(PicPoint pt1, PicPoint pt2, PicPoint pt3)
public PicParallelogram(PicPoint pt1, PicPoint pt2, PicPoint pt3, PicAttributeSet set)
public PicParallelogram(PicPoint pt1, PicPoint pt3)
public PicParallelogram(PicPoint pt, PicAttributeSet set)
public PicParallelogram(PicParallelogram parallelo)
The
- PicParallelogram object to cloneMethod Detail |
---|
public java.lang.Object clone()
clone
in interface Element
clone
in class DefaultLeafElement
public java.lang.String getName()
DefaultLeafElement
getName
in interface Element
getName
in class DefaultLeafElement
public double getPointX(int numPoint)
numPoint
.
getPointX
in interface Element
getPointX
in class DefaultLeafElement
numPoint
- the point index, should be greater or equal to the value returned by
getFirstPointIndex
, and lower or equal to getLastPointIndex
.
index
.public double getPointY(int numPoint)
numPoint
.
getPointY
in interface Element
getPointY
in class DefaultLeafElement
numPoint
- the point index, should be greater or equal to the value returned by
getFirstPointIndex
, and lower or equal to getLastPointIndex
.
index
.public PicPoint getPoint(int numPoint, PicPoint src)
setPoint
method.
getPoint
in interface Element
getPoint
in class DefaultLeafElement
numPoint
- the point index, should be greater or equal to the value returned by
getFirstPointIndex
, and lower or equal to getLastPointIndex
.
numPoint
;
if src
is null, allocates a new PicPoint and return it,
otherwise directly modifies src
and returns it as well for convenience.public int getFirstPointIndex()
getFirstPointIndex
in interface Element
getFirstPointIndex
in class DefaultLeafElement
public int getLastPointIndex()
getLastPointIndex
in interface Element
getLastPointIndex
in class DefaultLeafElement
protected void updateParalleloBasis()
protected PicVector toParalleloBasisCoordinates(PicPoint ptOrg, PicPoint ptSrc, PicVector ptDest)
Note that updateParalleloBasis
must be called beforehands for this method to return
a valid results [SR:pending] need to be cleaned up.
ptOrg
- origin of parallelogram's basisptSrc
- source point, coordinates of which have to be convertedptDest
- if null, gets allocated and returned for convenience ; besides, it is perfectly safe to call
this method with ptDest and one of ptOrg and ptSrc referencing the same PicPoint.
public void setPoint(int numPoint, PicPoint pt, EditPointConstraint constraint)
The SQUARE constraint imposes that the parallelogram be a square. The square diagonal is computed from the current control-point and its opposite corner. Other spec' points are set accordingly.
The CENTER_FIXED constraint imposes that the parallelogram center be kept fixed. Spec' points are set accordingly.
setPoint
in interface Element
setPoint
in class DefaultLeafElement
numPoint
- one of P_TL, P_TR, P_BL, P_BR, SIDE_T, SIDE_B, SIDE_L, SIDE_R or P_CENTER.constraint
- either null, DEFAULT, CENTER_FIXED or SQUAREpublic double getCenterX()
public double getCenterY()
public PicPoint getCenter(PicPoint src)
src
is null, allocates a new PicPoint and return it,
otherwise directly modifies src
and returns it as well for convenience.public void rotate(PicPoint ptOrg, double angle)
rotate
in interface Element
rotate
in class DefaultLeafElement
angle
- rotation angle in radianspublic void shear(PicPoint ptOrg, double shx, double shy)
shear
in interface Element
shear
in class DefaultLeafElement
public PicMultiCurve convertToMultiCurve()
convertToMultiCurve
in interface PicMultiCurveConvertable
public java.awt.geom.Rectangle2D getBoundingBox(java.awt.geom.Rectangle2D r)
This implementation compute the bounding-box from the smallest rectangle that encompasses all the specification-points.
getBoundingBox
in interface Element
getBoundingBox
in class DefaultLeafElement
public boolean isRectangle()
public java.lang.String toString()
toString
in class DefaultLeafElement
public PEAction[] createActions(ActionDispatcher actionDispatcher, ActionLocalizer localizer, HitInfo hi)
createActions
in interface ActionFactory
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()
CustomizerFactory
createCustomizer
in interface CustomizerFactory
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |