jpicedt.graphic.model
Interface Element
- All Superinterfaces:
- PicObjectConstants
- All Known Implementing Classes:
- AbstractCurve, AbstractElement, BranchElement, DefaultLeafElement, DefaultSelectionHandler, Drawing.RootElement, PicCircleFrom3Points, PicEllipse, PicGroup, PicMultiCurve, PicNodeConnection, PicParallelogram, PicPsCurve, PicSmoothPolygon, PicText, TextEditable
public interface Element
- extends PicObjectConstants
This interface specifies the general contract for models of graphic elements that may be added to a Drawing.
A MODEL of graphic element basically comprises :
- A set of (possibly virtual, see implementation hints below) user-controlled points
that helps the "user" alter the geometry
of the element ; these points are made accessible by means of the various get/setPoint() methods,
using an index ranging from
getFirstPointIndex()
to getLastPointIndex()
inclusive.
These methods may be used e.g. by the UI machinery when processing mouse-events, or by parsers when
building a new Drawing from scratch.
- Amid this set, some points may serve as anchor-points for grid alignment (see
PointIterator
).
- An attribute set that allows binding the element's geometry to a set of colour, stroke, etc... attributes.
- A parent and possibly children once the element has been added to a tree defining a Drawing's model. This allows
us to let the root element only hold state about the tree while still maintaining the ability for
a child to retrieve this state at any time through a (possibly recursive) call to getParent.
- Besides, each Element may have a View attached to it (but this is not necessary as long as it has not
to be rendered), which is responsible for rendering the element to
a graphic context. View's are usually created by a ViewFactory that's suited for the kind of content the
model represents (e.g. PostScript, LaTeX, JPIC-XML, ...).
Implementation hints : under the hood, the geometry may be backed e.g. by an array of points
(in which case these may be the control-points as well),
by a java.awt.Shape
, or by any other kind of mechanism the developper thinks is appropriate
to the particular model she wants to implement.
- Since:
- PicEdt 1.0
- Author:
- Sylvain Reynal
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 |
Method Summary |
PointIndexIterator |
anchorPointsIterator()
Return an Iterator over user-controlled point indexes that can serve as anchor points for grid alignment. |
Object |
clone()
Return a deep copy of this element. |
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. |
Object |
getAttribute(PicAttributeName name)
|
PicAttributeSet |
getAttributeSet()
|
Rectangle2D |
getBoundingBox(Rectangle2D r)
|
Drawing |
getDrawing()
Retrieves the underlying drawing |
int |
getFirstPointIndex()
Return the index of the first user-controlled point that can be retrieved by getPoint() |
int |
getLastPointIndex()
Return the index of the last user-controlled point that can be retrieved by getPoint() |
String |
getName()
Return a non-localised string representing this element's name. |
Element |
getParent()
Gets the parent of the element. |
PicPoint |
getPoint(int index,
PicPoint src)
Return the user-controlled point having the given index. |
double |
getPointX(int index)
Same as getPoint() , yet return the x-coordinate only. |
double |
getPointY(int index)
Same as getPoint() , yet return the y-coordinate only. |
View |
getView()
|
void |
removeView()
remove the view that render this element ; this may be used to remove any reference to the view,
and render it eligible for garbage collection ; if no View, does nothing. |
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 origin
sx and sy can be negative. |
void |
scale(PicPoint ptOrg,
double sx,
double sy)
Scale this object by (sx,sy) using ptOrg as origin
sx and sy may be negative. |
void |
setAttribute(PicAttributeName name,
Object value)
set the given attribute name to the given value for this Element |
void |
setAttributeSet(PicAttributeSet attributeSet)
|
void |
setParent(Element p)
Sets the parent of the element. |
void |
setPoint(int index,
PicPoint pt)
Deprecated. Use setPoint(int, PicPoint, EditPointConstraint) |
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. |
void |
setViewFromFactory(ViewFactory f)
set the view for this Element from the given view factory |
void |
shear(PicPoint ptOrg,
double shx,
double shy)
Shear this Element by the given params wrt to the given origin |
void |
translate(double dx,
double dy)
Translate this object by (dx,dy) |
getName
String getName()
- Return a non-localised string representing this element's name. This may be used by a UI to display some
information related to this element, or by a localizer to fetch a i18n'd string.
clone
Object clone()
- Return a deep copy of this element.
getDrawing
Drawing getDrawing()
- Retrieves the underlying drawing
- Returns:
- the drawing ; null if this Element doesn't belong to any drawing yet.
getParent
Element getParent()
- Gets the parent of the element.
- Returns:
- the parent
setParent
void setParent(Element p)
- Sets the parent of the element.
getAllowsChildren
boolean getAllowsChildren()
- Returns true if the receiver allows children.
forwardChangedUpdate
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.
This gives a chance to the receiver to update its layout, then to propagate the change-event upward.
This method obviously makes sense only if this element allows children (else it will never be called anyway,
hence concrete implementation may do nothing here).
- Parameters:
eventType
- the event typechild
- the child that sent the change-event.
getPoint
PicPoint getPoint(int index,
PicPoint src)
- Return the user-controlled point having the given index. The general contract 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.
- Parameters:
index
- 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
index
;
if src
is null, concrete implementation of this method should
allocate a new PicPoint and return it,
otherwise directly modify src
and return it as well for convenience. - Since:
- PicEdt 1.0
[todo] change name to getControlPoint() or getUserPoint() or whatever seems more appropriate.
getPointX
double getPointX(int index)
- Same as
getPoint()
, yet return the x-coordinate only.
- 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:
- PicEdt 1.0
getPointY
double getPointY(int index)
- Same as
getPoint()
, yet return the y-coordinate only.
- 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:
- PicEdt 1.0
getFirstPointIndex
int getFirstPointIndex()
- Return the index of the first user-controlled point that can be retrieved by getPoint()
getLastPointIndex
int getLastPointIndex()
- Return the index of the last user-controlled point that can be retrieved by getPoint()
setPoint
void setPoint(int index,
PicPoint pt)
- Deprecated. Use setPoint(int, PicPoint, EditPointConstraint)
- Set the user-controlled point indexed by "index" to the given value.
This should be a convenience call to setPoint(index,pt,null), i.e. using no particular geometrical constraint.
setPoint
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.
Constraints depend on the particular concrete implementation, and may involve restricting movement along
a particular direction, moving several points at once to preserve parallelism,...
- Parameters:
constraint
- a geometry constraint, or null if no particular constraint is being imposed (aka default).
anchorPointsIterator
PointIndexIterator anchorPointsIterator()
- Return an Iterator over user-controlled point indexes that can serve as anchor points for grid alignment.
This is up to concrete implementations to decide what subset of user-controlled points
is most appropriate for grid alignment.
translate
void translate(double dx,
double dy)
- Translate this object by (dx,dy)
- Parameters:
dx
- The X coordinate of translation vectordy
- The Y coordinate of translation vector- Since:
- PicEdt 1.0
[todo] add an "apply(Transform t)" method as replacement to "translate()" and "scale()", where Transform
may possibly inherit from java.awt.geom.AffineTransform [syd : 5/8/2002]
scale
void scale(PicPoint ptOrg,
double sx,
double sy)
- Scale this object by (sx,sy) using ptOrg as origin
sx and sy may be negative. This can be implemented as a convenience call to
scale(double,double,double,double)
scale
void scale(double ptOrgX,
double ptOrgY,
double sx,
double sy)
- Scale this object by (sx,sy) using (ptOrgX,ptOrgY) as origin
sx and sy can be negative.
rotate
void rotate(PicPoint ptOrg,
double angle)
- Rotate this Element by the given angle along the given point
- Parameters:
angle
- rotation angle in radians
shear
void shear(PicPoint ptOrg,
double shx,
double shy)
- Shear this Element by the given params wrt to the given origin
getBoundingBox
Rectangle2D getBoundingBox(Rectangle2D r)
- Returns:
- the bounding box (i.e. the surrounding rectangle) in double precision
Used e.g. to determine the arguments of the \\begin{picture} command.
If r is null, allocate a new rectangle and returns it. Otherwise the source rectangle is
modified and returned for convenience.
[todo:reynal] this really need to be improved : this method would probably better be moved to the
attached view, since the latter knows exactly what the TRUE bounding box is.
- Since:
- PicEdt 1.0
getView
View getView()
- Returns:
- the View that's responsible for rendering this Element
setViewFromFactory
void setViewFromFactory(ViewFactory f)
- set the view for this Element from the given view factory
removeView
void removeView()
- remove the view that render this element ; this may be used to remove any reference to the view,
and render it eligible for garbage collection ; if no View, does nothing.
getAttributeSet
PicAttributeSet getAttributeSet()
- Returns:
- AttributeSet for this Element
setAttributeSet
void setAttributeSet(PicAttributeSet attributeSet)
- Parameters:
attributeSet
- a new AttributeSet for this Element ; this actually make a deep copy of the
given attribute set beforehands.
setAttribute
void setAttribute(PicAttributeName name,
Object value)
- set the given attribute name to the given value for this Element
getAttribute
Object getAttribute(PicAttributeName name)
- Returns:
- the value for the given attribute name
Submit a bug : syd@jpicedt.org