http://www.jpicedt.org

jpicedt.graphic.model
Class AbstractElement

java.lang.Object
  extended by jpicedt.graphic.model.AbstractElement
All Implemented Interfaces:
Element, ActionFactory
Direct Known Subclasses:
AbstractCurve, BranchElement, PicNodeConnection, PicParallelogram, TextEditable

public abstract class AbstractElement
extends Object
implements Element, ActionFactory

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
protected  PicAttributeSet attributeSet
          the attribute set
protected  String name
          the name of this element, if set by the user
protected  BranchElement parent
          the parent of this element
protected  View view
          the view that render this element
 
Constructor Summary
AbstractElement()
          construct an AbstractElement with no parent and a default PicAttributeSet
AbstractElement(AbstractElement obj)
          cloning constructor ; attribute set is deeply copied.
AbstractElement(PicAttributeSet attributeSet)
          construct an AbstractElement with no parent and the given PicAttributeSet.
 
Method Summary
 PointIndexIterator anchorPointsIterator()
          Create an Iterator over points that can serve as anchor points for grid alignment.
abstract  AbstractElement clone()
          Returns a clone of this Element
 ArrayList<PEAction> createActions(ActionDispatcher actionDispatcher, ActionLocalizer localizer, HitInfo hi)
          Creates an array of Action's related to this object
 Shape createShape()
          Creates a Shape that reflects the geometry of this model.
protected  void fireChangedUpdate(DrawingEvent.EventType eventType)
          Must be called each time this AbstractElement changes.
<T> T
getAttribute(PicAttributeName<T> name)
          Returns the value for the given attribute name
 PicAttributeSet getAttributeSet()
          Returns the AttributeSet bound to this AbstractElement.
 CtrlPtSubset getCtrlPtSubset(ConvexZoneGroup csg, BitSet czExtension)
          Renvoie un la partie des points de contrôle qui satisfont à l'un des deux critères suivants: ceux compris dans l'ensemble de zones convexes csg, et ceux en relation avec les points de contrôle satisfaisant au première critère selon une relation définies par czExtension
protected abstract  String getDefaultName()
           
 Drawing getDrawing()
          Retrieves the underlying drawing
 String getName()
          Return a non-localised string representing this element's name.
 BranchElement getParent()
          Gets the parent of the element.
 View getView()
          Returns the View that's responsible for rendering this AbstractElement
 boolean pullOutOfGroup()
          If this element's parent is a PicGroup, pull it out this PicGroup, and add it to its grand-parent as a sibling of this PicGroup.
 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 replaceBy(Element by, boolean replaceInSelection)
          Une implantation de Element.replaceBy(Element by, boolean replaceInSelection).
 void scale(double ptOrgX, double ptOrgY, double sx, double sy)
          Dilate cet élément par (sx,sy) en utilisant (ptOrgX, ptOrgY) comme origine ; sx ou sy peuvent être négatifs.
 void scale(PicPoint ptOrg, double sx, double sy)
          Dilate cet élément par (sx,sy) en utilisant ptOrg comme origine ; sx ou sy peuvent être négatifs.
 void scale(PicPoint ptOrg, double sx, double sy, UserConfirmationCache ucc)
          Dilate cet élément par (sx,sy) en utilisant ptOrg comme origine ; sx ou sy peuvent être négatifs.
<T> void
setAttribute(PicAttributeName<T> name, T value)
          Set the given attribute name to the given value for this AbstractElement
 void setAttributeSet(PicAttributeSet attributeSet)
          Bind the given attributes set to this Element.
 void setCtrlPt(int index, PicPoint pt)
          convenience call to setCtrlPt(int, PicPoint, null)
 void setName(String name)
          Sets the name of this object.
 void setParent(BranchElement p)
          Sets the parent of this element to be the given element.
 void setViewFromFactory(ViewFactory f)
          Set the view for this AbstractElement from the given view factory or remove the view if f is null.
 void shear(PicPoint ptOrg, double shx, double shy)
          Cisaille cet élément par (shx,shy) en utilisant ptOrg comme origine.
 void syncArrowGeometry(ArrowView v, ArrowView.Direction d)
          Helper for the associated View.
 String toString()
          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
getBoundingBox, getCtrlPt, getFirstPointIndex, getLastPointIndex, mirror, rotate, scale, setCtrlPt, shear, translate
 

Field Detail

name

protected String name
the name of this element, if set by the user


parent

protected BranchElement 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 AbstractElement clone()
Returns a clone of this Element

Specified by:
clone in interface Element
Overrides:
clone in class Object

getName

public String getName()
Description copied from interface: Element
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.

Specified by:
getName in interface Element
Returns:
a localised string that represents this object's name

setName

public void setName(String name)
Sets the name of this object.

Parameters:
name - if null, reverts to the default name.

getDefaultName

protected abstract String getDefaultName()

getDrawing

public Drawing getDrawing()
Retrieves the underlying drawing

Specified by:
getDrawing in interface Element
Returns:
the drawing ; null if this AbstractElement doesn't belong to any drawing yet.

getParent

public BranchElement getParent()
Gets the parent of the element.

Specified by:
getParent in interface Element
Returns:
the parent

replaceBy

public void replaceBy(Element by,
                      boolean replaceInSelection)
Une implantation de Element.replaceBy(Element by, boolean replaceInSelection).

Specified by:
replaceBy in interface Element
Parameters:
by - l'Element servant de remplacement.
replaceInSelection - indique que this est également à remplacer dans la selection.

setParent

public void setParent(BranchElement p)
Sets the parent of this element to be the given element.

Specified by:
setParent in interface Element
Parameters:
p - The parent to be set for this element.

pullOutOfGroup

public boolean pullOutOfGroup()
If this element's parent is a PicGroup, pull it out this PicGroup, and add it to its grand-parent as a sibling of this PicGroup.

Returns:
whether the operation succeeded or not
Since:
jpicedt 1.5

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 calling forwardChangedUpdate(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 call super.fireChangeUpdate.

Parameters:
eventType - the event type

setCtrlPt

public void setCtrlPt(int index,
                      PicPoint pt)
convenience call to setCtrlPt(int, PicPoint, null)

Specified by:
setCtrlPt in interface Element

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:
anchorPointsIterator in interface Element

scale

public void scale(PicPoint ptOrg,
                  double sx,
                  double sy,
                  UserConfirmationCache ucc)
Dilate cet élément par (sx,sy) en utilisant ptOrg comme origine ; sx ou sy peuvent être négatifs. Ceci est une commodité d'appel de scale(ptOrg.x, ptOrg.y, sx, sy,ucc).

Specified by:
scale in interface Element

scale

public void scale(PicPoint ptOrg,
                  double sx,
                  double sy)
Dilate cet élément par (sx,sy) en utilisant ptOrg comme origine ; sx ou sy peuvent être négatifs. Ceci est une commodité d'appel de scale(ptOrg.x, ptOrg.y, sx, sy,UserConfirmationCache.DEFAULT).

Specified by:
scale in interface Element

scale

public void scale(double ptOrgX,
                  double ptOrgY,
                  double sx,
                  double sy)
Dilate cet élément par (sx,sy) en utilisant (ptOrgX, ptOrgY) comme origine ; sx ou sy peuvent être négatifs. Ceci est une commodité d'appel de scale(ptOrgX, ptOrgY, sx, sy,UserConfirmationCache.DEFAULT).

Specified by:
scale in interface Element

shear

public void shear(PicPoint ptOrg,
                  double shx,
                  double shy)
Cisaille cet élément par (shx,shy) en utilisant ptOrg comme origine. Ceci est une commodité d'appel de shear(ptOrg, shx, shy,UserConfirmationCache.DEFAULT).

Specified by:
shear in interface Element

getView

public View getView()
Returns the View that's responsible for rendering this AbstractElement

Specified by:
getView in interface Element
Returns:
the View that's responsible for rendering this Element

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:
setViewFromFactory in interface Element

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:
removeView in interface Element

createShape

public Shape createShape()
Creates a Shape that reflects the geometry of this model. This implementation returns null [underway].

Specified by:
createShape in interface Element

syncArrowGeometry

public void syncArrowGeometry(ArrowView v,
                              ArrowView.Direction d)
Helper for the associated View. This implementation does nothing by default.

Specified by:
syncArrowGeometry in interface Element

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:
getAttributeSet in interface 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:
setAttributeSet in interface Element

setAttribute

public <T> void setAttribute(PicAttributeName<T> name,
                             T value)
Set the given attribute name to the given value for this AbstractElement

Specified by:
setAttribute in interface Element

getAttribute

public <T> T getAttribute(PicAttributeName<T> name)
Returns the value for the given attribute name

Specified by:
getAttribute in interface Element

toString

public String toString()
Returns a String representation of the attribute set for this AbstractElement

Overrides:
toString in class Object

getCtrlPtSubset

public CtrlPtSubset getCtrlPtSubset(ConvexZoneGroup csg,
                                    BitSet czExtension)
Description copied from interface: Element
Renvoie un la partie des points de contrôle qui satisfont à l'un des deux critères suivants:
  1. ceux compris dans l'ensemble de zones convexes csg, et
  2. ceux en relation avec les points de contrôle satisfaisant au première critère selon une relation définies par czExtension

Specified by:
getCtrlPtSubset in interface Element
Parameters:
csg - un ensemble de zones convexes
czExtension - un BitSet permettant d'étendre l'ensemble des points de contrôle compris dans l'ensemble de zones convexes csg. La signification des bit est selon l'énuméré CtrlPtSubset.CZExtension.
Returns:
null
Since:
jPicEdt 1.6
See Also:
jpicedt.graphic.model

createActions

public ArrayList<PEAction> createActions(ActionDispatcher actionDispatcher,
                                         ActionLocalizer localizer,
                                         HitInfo hi)
Creates an array of Action's related to this object

Specified by:
createActions in interface ActionFactory
Parameters:
actionDispatcher - répartiteur utilisé pour créer unePEAction
localizer - utilisé pour localiser les paramètre des actions
hi - une HitInfo contenant les informations relatives à l'évènement-souris qui a déclencher le menu contextuel.

http://www.jpicedt.org

Submit a bug : syd@jpicedt.org