Package 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()togetLastPointIndex()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, ...).
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
-
-
Field Summary
-
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
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description PointIndexIteratoranchorPointsIterator()Return an Iterator over user-controlled point indexes that can serve as anchor points for grid alignment.java.lang.Objectclone()Return a deep copy of this element.voidforwardChangedUpdate(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.booleangetAllowsChildren()Returns true if the receiver allows children.java.lang.ObjectgetAttribute(PicAttributeName name)PicAttributeSetgetAttributeSet()java.awt.geom.Rectangle2DgetBoundingBox(java.awt.geom.Rectangle2D r)DrawinggetDrawing()Retrieves the underlying drawingintgetFirstPointIndex()Return the index of the first user-controlled point that can be retrieved by getPoint()intgetLastPointIndex()Return the index of the last user-controlled point that can be retrieved by getPoint()java.lang.StringgetName()Return a non-localised string representing this element's name.ElementgetParent()Gets the parent of the element.PicPointgetPoint(int index, PicPoint src)Return the user-controlled point having the given index.doublegetPointX(int index)Same asgetPoint(), yet return the x-coordinate only.doublegetPointY(int index)Same asgetPoint(), yet return the y-coordinate only.ViewgetView()voidremoveView()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.voidrotate(PicPoint ptOrg, double angle)Rotate this Element by the given angle along the given pointvoidscale(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.voidscale(PicPoint ptOrg, double sx, double sy)Scale this object by (sx,sy) using ptOrg as origin sx and sy may be negative.voidsetAttribute(PicAttributeName name, java.lang.Object value)set the given attribute name to the given value for this ElementvoidsetAttributeSet(PicAttributeSet attributeSet)voidsetParent(Element p)Sets the parent of the element.voidsetPoint(int index, PicPoint pt)Deprecated.Use setPoint(int, PicPoint, EditPointConstraint)voidsetPoint(int index, PicPoint pt, EditPointConstraint constraint)Set the user-controlled point indexed by "index" to the given value, using the specified geometrical constraint.voidsetViewFromFactory(ViewFactory f)set the view for this Element from the given view factoryvoidshear(PicPoint ptOrg, double shx, double shy)Shear this Element by the given params wrt to the given originvoidtranslate(double dx, double dy)Translate this object by (dx,dy)
-
-
-
Method Detail
-
getName
java.lang.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
java.lang.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 thesetPointmethod.- Parameters:
index- the point index, should be greater or equal to the value returned bygetFirstPointIndex, and lower or equal togetLastPointIndex.- Returns:
- the point indexed by
index; ifsrcis null, concrete implementation of this method should allocate a new PicPoint and return it, otherwise directly modifysrcand 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 asgetPoint(), yet return the x-coordinate only.- Parameters:
index- the point index, should be greater or equal to the value returned bygetFirstPointIndex, and lower or equal togetLastPointIndex.- Returns:
- the X-coord of the point indexed by
index. - Since:
- PicEdt 1.0
-
getPointY
double getPointY(int index)
Same asgetPoint(), yet return the y-coordinate only.- Parameters:
index- the point index, should be greater or equal to the value returned bygetFirstPointIndex, and lower or equal togetLastPointIndex.- 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
java.awt.geom.Rectangle2D getBoundingBox(java.awt.geom.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, java.lang.Object value)
set the given attribute name to the given value for this Element
-
getAttribute
java.lang.Object getAttribute(PicAttributeName name)
- Returns:
- the value for the given attribute name
-
-