|
|
||||||||||
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
This is a default implementation of AbstractElement targetting leaf Element's, i.e. Element's that
can NOT have children.
The element's geometry is backed by an array of coordinates (labelled specification points)
containing the minimum number of pair of
coordinates required to fully specify the shape of the element. For convenience, this array
has been made accessible by means of the getSpecificationPointX/Y()
methods : this may be used
e.g. by an associated View to create the appropriate java.awt.Shape if required.
Even if, as of this implementation, specification points act as user-controlled point, there may be more control points however (e.g. for a rectangle, there are two "specification" points, yet five control points, including the center).
Field Summary | |
protected ArrayList |
nodeConnections
a list of node-connection this element is attached to |
protected String |
nodeName
name of node for pstricks export |
protected ArrayList |
pts
an ArrayList containing PicPoint's representing the geometry of this element (specification points) |
Fields inherited from class jpicedt.graphic.model.AbstractElement |
attributeSet, parent, view |
Constructor Summary | |
DefaultLeafElement()
construct an Element with no parent and a default PicAttributeSet, and no specification points. |
|
DefaultLeafElement(DefaultLeafElement obj)
cloning constructor ; specification points and attribute set are deeply copied. |
|
DefaultLeafElement(int nPts)
construct a Element with no parent and a default PicAttributeSet, and the given number of specification points. |
|
DefaultLeafElement(int nPts,
PicAttributeSet attributeSet)
construct a DefaultElement with no parent and the given PicAttributeSet, and the given number of specification points. |
Method Summary | |
void |
addConnection(PicNodeConnection edge)
|
Object |
clone()
Returns a clone of this element |
protected void |
fireChangedUpdate(DrawingEvent.EventType eventType)
Overriden in order to support forwarding to node connections. |
void |
forwardChangedUpdate(Element child,
DrawingEvent.EventType eventType)
Called by a child of this element to inform its parent of some change that occured to it or one of its children. |
boolean |
getAllowsChildren()
Returns true if the receiver allows children. |
Rectangle2D |
getBoundingBox(Rectangle2D r)
Returns the bounding box (i.e. |
int |
getFirstPointIndex()
Returns the index of the first user-controlled point that can be retrieved by getPoint() . |
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. |
String |
getNodeName()
gets node name. |
int |
getNumberOfSpecificationPoints()
Return the number of specification points backing the geometry of this element. |
PicPoint |
getPoint(int numPoint)
Convenience call to getPoint(numPoint,null), i.e., a new Point is allocated on the fly. |
PicPoint |
getPoint(int numPoint,
PicPoint src)
Return the user-controlled point having the given index. |
double |
getPointX(int index)
This default implementation returns the X-coord of the specification-point with the same index. |
double |
getPointY(int index)
This default implementation returns the Y-coord of the specification-point with the same index. |
protected PicPoint |
getSpecificationPoint(int index)
Return a reference on the specification point with the given index. |
PicPoint |
getSpecificationPoint(int index,
PicPoint src)
Return the specification-point having the given index. |
double |
getSpecificationPointX(int index)
Return the X-coordinate of the specification point with the given index, by calling {@link #getSpecificationPoint(int). |
double |
getSpecificationPointY(int index)
Return the Y-coordinate of the specification point with the given index, by calling {@link #getSpecificationPoint(int). |
boolean |
isNode()
Are we a Node ?(ie do we have connections ?) |
boolean |
isNodeable()
Can we be made into a node ? to be overriden by subclass |
Iterator |
iterator()
Returns an iterator over all the node connections |
PicPoint |
nodeConnectionOrigin(double dx,
double dy)
|
PicPoint |
nodeReferencePoint()
|
double |
nodeReferencePointX()
|
double |
nodeReferencePointY()
|
void |
removeAllConnections()
|
void |
removeConnection(PicNodeConnection edge)
|
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 |
setNodeName(String name)
sets node name. |
void |
setPoint(int index,
PicPoint pt)
Deprecated. use setPoint(index,pt,constraint) instead |
void |
setPoint(int index,
PicPoint pt,
EditPointConstraint constraint)
Set the user-controlled point indexed by "index" to the given value, using the specified geometrical constraint. |
protected void |
setSpecificationPoint(int index,
PicPoint pt)
set the specification point with the given index to the given location. |
void |
shear(PicPoint ptOrg,
double shx,
double shy)
Shear this Element by the given params wrt to the given origin |
String |
toString()
Returns a String representation of this DefaultElement |
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, 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 |
protected ArrayList pts
protected String nodeName
protected ArrayList nodeConnections
Constructor Detail |
public DefaultLeafElement()
public DefaultLeafElement(int nPts)
public DefaultLeafElement(int nPts, PicAttributeSet attributeSet)
public DefaultLeafElement(DefaultLeafElement obj)
Method Detail |
public String getName()
public Object clone()
clone
in interface Element
clone
in class AbstractElement
public Iterator iterator()
public boolean isNode()
public void setNodeName(String name)
name
is null, create a new name.
public String getNodeName()
public boolean isNodeable()
public void addConnection(PicNodeConnection edge)
public void removeConnection(PicNodeConnection edge)
public void removeAllConnections()
public PicPoint nodeReferencePoint()
public double nodeReferencePointX()
public double nodeReferencePointY()
public PicPoint nodeConnectionOrigin(double dx, double dy)
public boolean getAllowsChildren()
public void forwardChangedUpdate(Element child, DrawingEvent.EventType eventType)
This implementation does nothing, since this method can never be called.
eventType
- the event typechild
- the child that sent the change-event.protected void fireChangedUpdate(DrawingEvent.EventType eventType)
fireChangedUpdate
in class AbstractElement
public double getSpecificationPointX(int index)
getSpecificationPoint(index)
.
index
- the point index, should be greater or equal to zero, and lower or equal
to the index returned by getNumberOfSpecificationPoints()
.public double getSpecificationPointY(int index)
getSpecificationPoint(index)
.
index
- the point index, should be greater or equal to zero, and lower or equal
to the index returned by getNumberOfSpecificationPoints()
.public PicPoint getSpecificationPoint(int index, PicPoint src)
getPoint()
in interface Element, and simply clones a PicPoint obtained by a call to
getSpecificationPoint(index)
.
index
- the point index, should be greater or equal to zero, and lower or equal
to the index returned by getNumberOfSpecificationPoints()
.
index
;
if src
is null, allocates a new PicPoint and return it,
otherwise directly modifies src
and returns it as well for convenience.protected PicPoint getSpecificationPoint(int index)
It is enough to override this method if one wants to change the behaviour of all other getSpecificationPoint() methods at once (typical applications include : carrying out security checks on the given index, applying a geometric transformation on the PicPoint to be returned, creating index aliases, ...).
[developpers] protecting access is MAN-DA-TO-RY ! I don't trust ourselves enough to let us play with references from outta-hood ;-)
public int getNumberOfSpecificationPoints()
public int getFirstPointIndex()
getPoint()
.
This default implementation returns 0.
public int getLastPointIndex()
getPoint()
.
This default implementation returns the number of specification points minus one.
public PicPoint getPoint(int numPoint, PicPoint src)
setPoint
method.
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 PicPoint getPoint(int numPoint)
public double getPointX(int index)
index
- 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 index)
index
- the point index, should be greater or equal to the value returned by
getFirstPointIndex
, and lower or equal to getLastPointIndex
.
index
.public void setPoint(int index, PicPoint pt)
public void setPoint(int index, PicPoint pt, EditPointConstraint constraint)
constraint
- a geometry constraint, or null if no particular constraint is being imposed (aka default).protected void setSpecificationPoint(int index, PicPoint pt)
public void translate(double dx, double dy)
dx
- The X coordinate of translation vectordy
- The Y coordinate of translation vectorpublic void scale(double ptOrgX, double ptOrgY, double sx, double sy)
sx
and sy
may be negative.
This method eventually fires a changed-update event.
public void rotate(PicPoint ptOrg, double angle)
angle
- rotation angle in radianspublic void shear(PicPoint ptOrg, double shx, double shy)
public Rectangle2D getBoundingBox(Rectangle2D r)
This implementation compute the bb from the smallest rectangle that encompasses all specification-points.
public String toString()
toString
in class AbstractElement
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |