Package jpicedt.graphic.model
Class AbstractElement
- java.lang.Object
-
- jpicedt.graphic.model.AbstractElement
-
- All Implemented Interfaces:
Element,PicObjectConstants
- Direct Known Subclasses:
BranchElement,DefaultLeafElement,PicNodeConnection
public abstract class AbstractElement extends java.lang.Object implements Element
An abstract class that can serve as the basis class for elements of a Drawing.This implementation provides some useful behaviour where the integration of Element's in a tree-model is concerned.
- Since:
- PicEdt 1.0
- Author:
- Sylvain Reynal
-
-
Field Summary
Fields Modifier and Type Field Description protected PicAttributeSetattributeSetthe attribute setprotected Elementparentthe parent of this elementprotected Viewviewthe view that render this element-
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
Constructors Constructor Description AbstractElement()construct an AbstractElement with no parent and a default PicAttributeSetAbstractElement(AbstractElement obj)cloning constructor ; attribute set is deeply copied.AbstractElement(PicAttributeSet attributeSet)construct an AbstractElement with no parent and the given PicAttributeSet.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description PointIndexIteratoranchorPointsIterator()Create an Iterator over points that can serve as anchor points for grid alignment.abstract java.lang.Objectclone()Returns a clone of this Elementprotected voidfireChangedUpdate(DrawingEvent.EventType eventType)Must be called each time this AbstractElement changes.java.lang.ObjectgetAttribute(PicAttributeName name)Returns the value for the given attribute namePicAttributeSetgetAttributeSet()Returns the AttributeSet bound to this AbstractElement.DrawinggetDrawing()Retrieves the underlying drawingElementgetParent()Gets the parent of the element.ViewgetView()Returns the View that's responsible for rendering this AbstractElementvoidremoveView()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.voidscale(PicPoint ptOrg, double sx, double sy)Scale this object by (sx,sy) using ptOrg as origin sx and sy can be negative.voidsetAttribute(PicAttributeName name, java.lang.Object value)Set the given attribute name to the given value for this AbstractElementvoidsetAttributeSet(PicAttributeSet attributeSet)Bind the given attributes set to this Element.voidsetParent(Element p)Sets the parent of this element to be the given element.voidsetViewFromFactory(ViewFactory f)set the view for this AbstractElement from the given view factory or remove the view if f is null.java.lang.StringtoString()Returns a String representation of the attribute set for this AbstractElement-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jpicedt.graphic.model.Element
forwardChangedUpdate, getAllowsChildren, getBoundingBox, getFirstPointIndex, getLastPointIndex, getName, getPoint, getPointX, getPointY, rotate, scale, setPoint, setPoint, shear, translate
-
-
-
-
Field Detail
-
parent
protected Element parent
the parent of this element
-
attributeSet
protected PicAttributeSet attributeSet
the attribute set
-
view
protected View view
the view that render this element
-
-
Constructor Detail
-
AbstractElement
public AbstractElement()
construct an AbstractElement with no parent and a default PicAttributeSet
-
AbstractElement
public AbstractElement(PicAttributeSet attributeSet)
construct an AbstractElement with no parent and the given PicAttributeSet.
-
AbstractElement
public AbstractElement(AbstractElement obj)
cloning constructor ; attribute set is deeply copied. The parent and the view are set to null.
-
-
Method Detail
-
clone
public abstract java.lang.Object clone()
Returns a clone of this Element
-
getDrawing
public Drawing getDrawing()
Retrieves the underlying drawing- Specified by:
getDrawingin interfaceElement- Returns:
- the drawing ; null if this AbstractElement doesn't belong to any drawing yet.
-
getParent
public Element getParent()
Gets the parent of the element.
-
setParent
public void setParent(Element p)
Sets the parent of this element to be the given element.
-
fireChangedUpdate
protected void fireChangedUpdate(DrawingEvent.EventType eventType)
Must be called each time this AbstractElement changes. This default implementation updates the associated View if any, then propagates upward along the tree by callingforwardChangedUpdate(this)on the Element's parent, if any.
Tree's root-element should override so as to fire the change to the hosting drawing.
If subclasser are willing to override this method, they should callsuper.fireChangeUpdate.- Parameters:
type- the event type
-
anchorPointsIterator
public PointIndexIterator anchorPointsIterator()
Create an Iterator over points that can serve as anchor points for grid alignment. This implementation returns a DefaultPointIndexIterator which simply iterates through all user-controlled points in ascending order.- Specified by:
anchorPointsIteratorin interfaceElement
-
scale
public void scale(PicPoint ptOrg, double sx, double sy)
Scale this object by (sx,sy) using ptOrg as origin sx and sy can be negative. This is a convenience call toscale(double,double,double,double).
-
getView
public View getView()
Returns the View that's responsible for rendering this AbstractElement
-
setViewFromFactory
public void setViewFromFactory(ViewFactory f)
set the view for this AbstractElement from the given view factory or remove the view if f is null.- Specified by:
setViewFromFactoryin interfaceElement
-
removeView
public 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.- Specified by:
removeViewin interfaceElement
-
getAttributeSet
public PicAttributeSet getAttributeSet()
Returns the AttributeSet bound to this AbstractElement.Be careful that modifying attributes using this method does not fire any DrawingEvent's, hence does not keep the view synchronized with the state of the model.
- Specified by:
getAttributeSetin interfaceElement- Returns:
- AttributeSet for this Element
-
setAttributeSet
public void setAttributeSet(PicAttributeSet attributeSet)
Bind the given attributes set to this Element. This implementation actually makes a deep copy of the given set beforehands.- Specified by:
setAttributeSetin interfaceElement- Parameters:
attributeSet- a new AttributeSet for this Element ; this actually make a deep copy of the given attribute set beforehands.
-
setAttribute
public void setAttribute(PicAttributeName name, java.lang.Object value)
Set the given attribute name to the given value for this AbstractElement- Specified by:
setAttributein interfaceElement
-
getAttribute
public java.lang.Object getAttribute(PicAttributeName name)
Returns the value for the given attribute name- Specified by:
getAttributein interfaceElement- Returns:
- the value for the given attribute name
-
toString
public java.lang.String toString()
Returns a String representation of the attribute set for this AbstractElement- Overrides:
toStringin classjava.lang.Object
-
-