de.uni_paderborn.fujaba.fsa.swing
Class GrabManager

java.lang.Object
  extended byjava.awt.event.ComponentAdapter
      extended byde.uni_paderborn.fujaba.fsa.swing.GrabManager
All Implemented Interfaces:
java.awt.event.ComponentListener, java.util.EventListener, java.awt.event.HierarchyBoundsListener, java.awt.event.HierarchyListener, java.beans.PropertyChangeListener

public class GrabManager
extends java.awt.event.ComponentAdapter
implements java.beans.PropertyChangeListener, java.awt.event.HierarchyListener, java.awt.event.HierarchyBoundsListener

The GrabManager associates a number of Grabs to a target JComponent, manages events of the target and calls the GrabLayouter to relayout the Grabs when necessary.

The association to the JComponent is implemented using the clientProperty-Methods of the JComponent. This means that the association to the JComponent is implemented with the traditional access methods, but the backward association is implemented as the client property with name

GrabManager.TARGET_PROPERTY
of the target component. It is accessible via:

    (GrabManager)targetComponent.getClientProperty(GrabManager.TARGET_PROPERTY)
 

Associations

              0..1                      N
 GrabManager ----------------------------- JGrab
              manager               grabs
              0..1                                 N
 GrabManager ---------------------------------------- JComponent
              getClientProperty               target
 

Version:
$Revision: 1.28 $
Author:
$Author: schneider $
See Also:
JComponent.getClientProperty(java.lang.Object), JComponent.putClientProperty(java.lang.Object, java.lang.Object), JGrab, GrabLayouter

Field Summary
private  java.awt.Container commonAncestorOfGrabs
          No comment provided by developer, please add a comment to improve documentation.
private  de.upb.tools.fca.FHashSet grabs
           0..1 N GrabManager ----------------------------- JGrab manager grabs
private static java.util.HashSet postPonedManagers
          No comment provided by developer, please add a comment to improve documentation.
private static boolean postPoneing
          No comment provided by developer, please add a comment to improve documentation.
private static int recursionDepth
          No comment provided by developer, please add a comment to improve documentation.
private  boolean revalidating
          No comment provided by developer, please add a comment to improve documentation.
private  javax.swing.JComponent target
           0..1 N GrabManager ---------------------------------------- JComponent getClientProperty target (GrabManager.TARGET_PROPERTY)
static java.lang.String TARGET_PROPERTY
          No comment provided by developer, please add a comment to improve documentation.
 
Constructor Summary
GrabManager()
          Constructor for class GrabManager
GrabManager(javax.swing.JComponent target)
          Constructor for class GrabManager
 
Method Summary
 boolean addToGrabs(JGrab value)
          Add a Grab to the list of Grabs that are managed by this Object.
 void ancestorMoved(java.awt.event.HierarchyEvent e)
          Listen for changes to ancestors of the target.
 void ancestorResized(java.awt.event.HierarchyEvent e)
          No comment provided by developer, please add a comment to improve documentation.
 void componentMoved(java.awt.event.ComponentEvent e)
           
 void componentResized(java.awt.event.ComponentEvent e)
           
static void doPostPonedGrabLayout()
          No comment provided by developer, please add a comment to improve documentation.
 javax.swing.JComponent getTarget()
           
 boolean hasInGrabs(JGrab value)
           
 void hierarchyChanged(java.awt.event.HierarchyEvent e)
           
 java.util.Iterator iteratorOfGrabs()
          No comment provided by developer, please add a comment to improve documentation.
static void postPoneGrabLayout()
          No comment provided by developer, please add a comment to improve documentation.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Listens for changes to Position or size of the target to revalidate the grabs and for changes to the parents of the Grabs to update the common ancestor
private  void registerGrab(JGrab grab)
          No comment provided by developer, please add a comment to improve documentation.
private  void registerGrabs()
          No comment provided by developer, please add a comment to improve documentation.
private  void registerTarget()
          No comment provided by developer, please add a comment to improve documentation.
 void removeAllFromGrabs()
          No comment provided by developer, please add a comment to improve documentation.
 boolean removeFromGrabs(JGrab value)
          Removes the Grab value from the list of Grabs and updates the common ancestor of all grabs
 void revalidate()
          Checks the Target if a specific GrabLayouter is set as client property with name GrabLayouter.TARGET_PROPERTY.
 void revalidate(int depthIncrease)
          Checks the Target if a specific GrabLayouter is set as client property with name GrabLayouter.TARGET_PROPERTY.
 boolean setTarget(javax.swing.JComponent value)
          Set the target of this Manager (and all of its Grabs) to value.
 int sizeOfGrabs()
          No comment provided by developer, please add a comment to improve documentation.
private  void unregisterGrab(JGrab grab)
          No comment provided by developer, please add a comment to improve documentation.
private  void unregisterGrabs()
          No comment provided by developer, please add a comment to improve documentation.
private  void unregisterTarget()
          No comment provided by developer, please add a comment to improve documentation.
private  void updateCommonAncestorOfGrabs(java.awt.Container hint)
          recalculate common ancestor from scratch by iterating over all grabs
private  void updateCommonAncestorOfGrabs(java.awt.Container parent, boolean removed)
          Update the common ancestor of all grabs by checking the parent value and comparing it to the current value.
 
Methods inherited from class java.awt.event.ComponentAdapter
componentHidden, componentShown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TARGET_PROPERTY

public static final java.lang.String TARGET_PROPERTY
No comment provided by developer, please add a comment to improve documentation.

See Also:
Constant Field Values

recursionDepth

private static int recursionDepth
No comment provided by developer, please add a comment to improve documentation.


postPoneing

private static boolean postPoneing
No comment provided by developer, please add a comment to improve documentation.


postPonedManagers

private static java.util.HashSet postPonedManagers
No comment provided by developer, please add a comment to improve documentation.


target

private javax.swing.JComponent target
              0..1                                 N
 GrabManager ---------------------------------------- JComponent
              getClientProperty               target
              (GrabManager.TARGET_PROPERTY)
 


grabs

private de.upb.tools.fca.FHashSet grabs
              0..1                      N
 GrabManager ----------------------------- JGrab
              manager               grabs
 


commonAncestorOfGrabs

private java.awt.Container commonAncestorOfGrabs
No comment provided by developer, please add a comment to improve documentation.


revalidating

private boolean revalidating
No comment provided by developer, please add a comment to improve documentation.

Constructor Detail

GrabManager

public GrabManager()
Constructor for class GrabManager


GrabManager

public GrabManager(javax.swing.JComponent target)
Constructor for class GrabManager

Parameters:
target - No description provided
Method Detail

postPoneGrabLayout

public static void postPoneGrabLayout()
No comment provided by developer, please add a comment to improve documentation.


doPostPonedGrabLayout

public static void doPostPonedGrabLayout()
No comment provided by developer, please add a comment to improve documentation.


setTarget

public boolean setTarget(javax.swing.JComponent value)
Set the target of this Manager (and all of its Grabs) to value.

Reverse Link is

    (GrabManager)value.getClientProperty(GrabManager.TARGET_PROPERTY)
 

Parameters:
value - The new target
Returns:
true if target was changed, false otherwise
See Also:
getTarget()

unregisterTarget

private void unregisterTarget()
No comment provided by developer, please add a comment to improve documentation.


registerTarget

private void registerTarget()
No comment provided by developer, please add a comment to improve documentation.


registerGrabs

private void registerGrabs()
No comment provided by developer, please add a comment to improve documentation.


unregisterGrabs

private void unregisterGrabs()
No comment provided by developer, please add a comment to improve documentation.


registerGrab

private void registerGrab(JGrab grab)
No comment provided by developer, please add a comment to improve documentation.

Parameters:
grab - No description provided

unregisterGrab

private void unregisterGrab(JGrab grab)
No comment provided by developer, please add a comment to improve documentation.

Parameters:
grab - No description provided

getTarget

public javax.swing.JComponent getTarget()
Returns:
the JComponent this GrabManager is connected to

addToGrabs

public boolean addToGrabs(JGrab value)
Add a Grab to the list of Grabs that are managed by this Object. Update the common ancestor of all Grabs accordingly

Parameters:
value - the Grab to add
Returns:
true if the Grab was added, false otherwise
See Also:
updateCommonAncestorOfGrabs(java.awt.Container, boolean)

hasInGrabs

public boolean hasInGrabs(JGrab value)
Parameters:
value -
Returns:
No description provided

iteratorOfGrabs

public java.util.Iterator iteratorOfGrabs()
No comment provided by developer, please add a comment to improve documentation.

Returns:
No description provided

sizeOfGrabs

public int sizeOfGrabs()
No comment provided by developer, please add a comment to improve documentation.

Returns:
No description provided

removeFromGrabs

public boolean removeFromGrabs(JGrab value)
Removes the Grab value from the list of Grabs and updates the common ancestor of all grabs

Parameters:
value - the grab in question
Returns:
true if the list was changed
See Also:
updateCommonAncestorOfGrabs(java.awt.Container, boolean)

removeAllFromGrabs

public void removeAllFromGrabs()
No comment provided by developer, please add a comment to improve documentation.


updateCommonAncestorOfGrabs

private void updateCommonAncestorOfGrabs(java.awt.Container hint)
recalculate common ancestor from scratch by iterating over all grabs

Parameters:
hint - No description provided
See Also:
updateCommonAncestorOfGrabs(java.awt.Container, boolean)

updateCommonAncestorOfGrabs

private void updateCommonAncestorOfGrabs(java.awt.Container parent,
                                         boolean removed)
Update the common ancestor of all grabs by checking the parent value and comparing it to the current value.

The commonAncestorOfGrabs is needed to decrease the work that is to be done when an AncestorEvent occurs on the JComponent. If the ancestor in question is an ancestor of commonAncestorOfGrabs nothing is to be done. Otherwise a revalidate() is necessary

Parameters:
parent -
removed -
See Also:
updateCommonAncestorOfGrabs(Container)

revalidate

public void revalidate()
Checks the Target if a specific GrabLayouter is set as client property with name GrabLayouter.TARGET_PROPERTY. If none is found the default Layouter is the result of GrabLayouter.get().

Then the layout-Method of the Layouter is called to reposition the grabs around the target JComponent

See Also:
GrabLayouter, GrabLayouter.getDefaultLayouter(), GrabLayouter.layout(de.uni_paderborn.fujaba.fsa.swing.GrabManager)

revalidate

public void revalidate(int depthIncrease)
Checks the Target if a specific GrabLayouter is set as client property with name GrabLayouter.TARGET_PROPERTY. If none is found the default Layouter is the result of GrabLayouter.get().

Then the layout-Method of the Layouter is called to reposition the grabs around the target JComponent

Parameters:
depthIncrease - recursion is limitted to 2.
depthIncrease 0 layouts with full recursion
depthIncrease 1 layouts this frame and its direct neighbors
depthIncrease 2 or greater layouts only this frame
See Also:
GrabLayouter, GrabLayouter.getDefaultLayouter(), GrabLayouter.layout(de.uni_paderborn.fujaba.fsa.swing.GrabManager)

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Listens for changes to Position or size of the target to revalidate the grabs and for changes to the parents of the Grabs to update the common ancestor

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
e - the event
See Also:
revalidate(), updateCommonAncestorOfGrabs(java.awt.Container, boolean)

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Specified by:
componentMoved in interface java.awt.event.ComponentListener
Parameters:
e - the event

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Specified by:
componentResized in interface java.awt.event.ComponentListener
Parameters:
e - the event

hierarchyChanged

public void hierarchyChanged(java.awt.event.HierarchyEvent e)
Specified by:
hierarchyChanged in interface java.awt.event.HierarchyListener
Parameters:
e - the event

ancestorMoved

public void ancestorMoved(java.awt.event.HierarchyEvent e)
Listen for changes to ancestors of the target.

If a parent of the common ancestor of grabs is changed there is nothing to do, because the changes affect the grabs, too. Otherwise the grabs have to be relayouted

Specified by:
ancestorMoved in interface java.awt.event.HierarchyBoundsListener
Parameters:
e - The event
See Also:
revalidate(), updateCommonAncestorOfGrabs(Container)

ancestorResized

public void ancestorResized(java.awt.event.HierarchyEvent e)
No comment provided by developer, please add a comment to improve documentation.

Specified by:
ancestorResized in interface java.awt.event.HierarchyBoundsListener
Parameters:
e - No description provided