de.cau.cs.kieler.synccharts.custom
Class NeighborAwareOpenRectangleFigure

java.lang.Object
  extended by org.eclipse.draw2d.Figure
      extended by org.eclipse.draw2d.Shape
          extended by de.cau.cs.kieler.synccharts.custom.OpenRectangleFigure
              extended by de.cau.cs.kieler.synccharts.custom.NeighborAwareOpenRectangleFigure
All Implemented Interfaces:
IFigure
Direct Known Subclasses:
CustomRegionFigure

public class NeighborAwareOpenRectangleFigure
extends OpenRectangleFigure

An OpenRectangleFigure that draws only its outline sides under certain conditions. It iterates its sibling figures and determines which are neighbors on which sides and how far they are away.

In general it draws only its east and south border. Even then only iff at the corresponding side there is a neighbor. If there is no neighbor (e.g. if the figure is at the lower bottom of its parent) then the side is not drawn.

If the neighbors are too far away, the corresponding site still gets drawn to get clear bounds if the children are laid out sparsely.

Rating proposed yellow
(2010-01-27) msp

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.draw2d.Figure
Figure.FigureIterator, Figure.IdentitySearch
 
Nested classes/interfaces inherited from interface org.eclipse.draw2d.IFigure
IFigure.NoInsets
 
Field Summary
 
Fields inherited from class org.eclipse.draw2d.Shape
lineStyle, lineWidth
 
Fields inherited from class org.eclipse.draw2d.Figure
bgColor, border, bounds, fgColor, flags, font, MAX_FLAG, maxSize, minSize, NO_MANAGER, prefSize, toolTip
 
Fields inherited from interface org.eclipse.draw2d.IFigure
MAX_DIMENSION, MIN_DIMENSION, NO_INSETS
 
Constructor Summary
NeighborAwareOpenRectangleFigure()
           
 
Method Summary
 void allCheck()
          Indicate that all sibling shall check for their neighbors.
 void checkNeighbors()
          Iterate your siblings and determine if they are neighbors and on what sides and how far away.
 void realRepaint()
          Overriding the realRepaint() method in order to trigger a check for neighborhood for all siblings whenever this figure is modified.
 void setNoDrawMargin(int themargin)
          Set the margin from either the border of the parent or siblings at which the corresponding sides shall be drawn no matter what.
 void setSiblingLevel(int level)
          Set the hierarchy level on which this figure searches for sibling neighbors.
 boolean shouldRepaint()
          Overriding shouldRepaint to test whether the sides must be checked again.
 
Methods inherited from class de.cau.cs.kieler.synccharts.custom.OpenRectangleFigure
fillShape, getPreBounds, getPreParentBounds, isEast, isNorth, isSouth, isWest, outlineShape, setDrawSides, setEast, setNorth, setPreBounds, setPreParentBounds, setSouth, setWest
 
Methods inherited from class org.eclipse.draw2d.Shape
getAlpha, getAntialias, getLineAttributes, getLineCap, getLineDash, getLineDashOffset, getLineJoin, getLineMiterLimit, getLineStyle, getLineWidth, getLineWidthFloat, paintFigure, setAlpha, setAlpha, setAntialias, setAntialias, setFill, setFillXOR, setLineAttributes, setLineCap, setLineDash, setLineDashOffset, setLineJoin, setLineMiterLimit, setLineStyle, setLineWidth, setLineWidthFloat, setOutline, setOutlineXOR, setXOR
 
Methods inherited from class org.eclipse.draw2d.Figure
add, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findDescendantAtExcluding, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, findMouseEventTargetInDescendantsAt, fireCoordinateSystemChanged, fireFigureMoved, fireMoved, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundColor, getBorder, getBounds, getChildren, getClientArea, getClientArea, getClippingStrategy, getCursor, getFlag, getFont, getForegroundColor, getInsets, getLayoutManager, getListeners, getLocalBackgroundColor, getLocalFont, getLocalForegroundColor, getLocation, getMaximumSize, getMinimumSize, getMinimumSize, getParent, getPreferredSize, getPreferredSize, getSize, getToolTip, getUpdateManager, handleFocusGained, handleFocusLost, handleKeyPressed, handleKeyReleased, handleMouseDoubleClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseHover, handleMouseMoved, handleMousePressed, handleMouseReleased, hasFocus, internalGetEventDispatcher, intersects, invalidate, invalidateTree, isCoordinateSystem, isEnabled, isFocusTraversable, isMirrored, isMouseEventTarget, isOpaque, isRequestFocusEnabled, isShowing, isValid, isValidationRoot, isVisible, layout, paint, paintBorder, paintChildren, paintClientArea, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBackgroundColor, setBorder, setBounds, setChildrenDirection, setChildrenEnabled, setChildrenOrientation, setClippingStrategy, setConstraint, setCursor, setEnabled, setFlag, setFocusTraversable, setFont, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, useLocalCoordinates, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NeighborAwareOpenRectangleFigure

public NeighborAwareOpenRectangleFigure()
Method Detail

checkNeighbors

public void checkNeighbors()
Iterate your siblings and determine if they are neighbors and on what sides and how far away. Configure your side drawing accordingly.


allCheck

public void allCheck()
Indicate that all sibling shall check for their neighbors. This is likely be called whenever this figure has been modified (e.g. moved) and all siblings have to be checked whether this is still a neighbor or not.


realRepaint

public void realRepaint()
Overriding the realRepaint() method in order to trigger a check for neighborhood for all siblings whenever this figure is modified.

Overrides:
realRepaint in class OpenRectangleFigure

shouldRepaint

public boolean shouldRepaint()
Overriding shouldRepaint to test whether the sides must be checked again. Will return true either if this bounds have changed or the bounds of the "real" parent.

Overrides:
shouldRepaint in class OpenRectangleFigure
Returns:
true if the figure should repaint

setSiblingLevel

public void setSiblingLevel(int level)
Set the hierarchy level on which this figure searches for sibling neighbors. In a complex context (e.g. in the Eclipse Graphical Editing Framework or Graphical Modeling Framework) the NeigborAwareOpenRectangleFigures might be nested in an additional parent. Like: Hence this siblingLevel tells the figure not only look into its parent, but the corresponding amount of levels up in the hierarchy and just then dive back into it. For simplicity this only covers the simple trees like shown above and not arbitrary trees.

Parameters:
level - the hierarchy level which shall be used to find sibling elements.

setNoDrawMargin

public void setNoDrawMargin(int themargin)
Set the margin from either the border of the parent or siblings at which the corresponding sides shall be drawn no matter what. This can help to clarify a nodes bounds if it is too far away from its neighbors or the parent bounds.

Parameters:
themargin - the desired margin.