com.guiseframework.component.layout
Class AbstractLayout<T extends Constraints>

java.lang.Object
  extended by com.globalmentor.beans.BoundPropertyObject
      extended by com.guiseframework.event.GuiseBoundPropertyObject
          extended by com.guiseframework.component.layout.AbstractLayout<T>
Type Parameters:
T - The type of layout constraints associated with each component. This class and subclasses represent layout definitions, not layout implementations.
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, Layout<T>
Direct Known Subclasses:
AbstractFlowLayout, AbstractValueLayout, ReferenceLayout, RegionLayout

public abstract class AbstractLayout<T extends Constraints>
extends GuiseBoundPropertyObject
implements Layout<T>

Abstract implementation of layout information for a layout component.

Author:
Garret Wilson

Nested Class Summary
protected  class AbstractLayout.ConstraintsPropertyChangeListener
          A property change listener that listens for changes in a constraint object's properties and fires a layout constraints property change event in response.
 
Field Summary
 
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
 
Constructor Summary
AbstractLayout()
           
 
Method Summary
 void addComponent(Component component)
          Adds a component to the layout.
protected  void componentConstraintsChanged(Component component, Constraints oldConstraints, Constraints newConstraints)
          Indicates that the constraints for a component have changed.
protected
<V> void
fireConstraintsPropertyChange(Component component, T constraints, java.lang.String propertyName, V oldValue, V newValue)
          Reports that the bound property of a component's constraints has changed.
protected  com.globalmentor.beans.GenericPropertyChangeListener<Constraints> getComponentConstraintsChangeListener()
           
 T getConstraints(Component component)
          Retreives layout constraints associated with a component.
protected  AbstractLayout.ConstraintsPropertyChangeListener getConstraintsPropertyChangeListener()
           
 LayoutComponent getOwner()
           
 void removeComponent(Component component)
          Removes a component from the layout.
 void setOwner(LayoutComponent newOwner)
          Sets the layout component that owns this layout This method is managed by layout components, and normally should not be called by applications.
 
Methods inherited from class com.guiseframework.event.GuiseBoundPropertyObject
getSession
 
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.guiseframework.component.layout.Layout
createDefaultConstraints, getConstraintsClass, getSession
 
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

AbstractLayout

public AbstractLayout()
Method Detail

getConstraintsPropertyChangeListener

protected AbstractLayout.ConstraintsPropertyChangeListener getConstraintsPropertyChangeListener()
Returns:
The lazily-created listener of constraint property changes.

getComponentConstraintsChangeListener

protected com.globalmentor.beans.GenericPropertyChangeListener<Constraints> getComponentConstraintsChangeListener()
Returns:
The lazily-created listener of component constraints changes.

componentConstraintsChanged

protected void componentConstraintsChanged(Component component,
                                           Constraints oldConstraints,
                                           Constraints newConstraints)
Indicates that the constraints for a component have changed. This method is also called when the component is first added to the layout. This version removes and installs property change listeners to and from the constraints objects as appropriate.

Parameters:
component - The component for which constraints have changed.
oldConstraints - The old component constraints, or null if there were no constraints previously.
newConstraints - The new component constraints, or null if the component now has no constraints.

getOwner

public LayoutComponent getOwner()
Specified by:
getOwner in interface Layout<T extends Constraints>
Returns:
The layout component that owns this layout, or null if this layout has not been installed into a layout component.

setOwner

public void setOwner(LayoutComponent newOwner)
Sets the layout component that owns this layout This method is managed by layout components, and normally should not be called by applications. //TODO del A layout cannot be given a layout component if it is already installed in another layout component. Once a layout is installed in a layout component, it cannot be uninstalled. A layout cannot be given a layout component if it is already installed in another layout component. A layout cannot be given a layout component unless that layout component already recognizes this layout as its layout. If a layout is given the same layout component it already has, no action occurs.

Specified by:
setOwner in interface Layout<T extends Constraints>
Parameters:
newOwner - The new layout component for this layout. //TODO del @exception NullPointerException if the given layout component is null.
Throws:
java.lang.IllegalStateException - if a different layout component is provided and this layout already has a layout component.
java.lang.IllegalArgumentException - if a different layout component is provided and the given layout component does not already recognize this layout as its layout.

addComponent

public void addComponent(Component component)
Adds a component to the layout. Called immediately after a component is added to the associated layout component. This method is called by the associated layout component, and should not be called directly by application code.

Specified by:
addComponent in interface Layout<T extends Constraints>
Parameters:
component - The component to add to the layout.
Throws:
java.lang.IllegalStateException - if this layout has not yet been installed into a layout component.

removeComponent

public void removeComponent(Component component)
Removes a component from the layout. Called immediately before a component is removed from the associated layout component. This method is called by the associated layout component, and should not be called directly by application code.

Specified by:
removeComponent in interface Layout<T extends Constraints>
Parameters:
component - The component to remove from the layout.

getConstraints

public T getConstraints(Component component)
Retreives layout constraints associated with a component. If the constraints currently associated with the component are not compatible with this layout, or if no constraints are associated with the given component, default constraints are created and associated with the component.

Specified by:
getConstraints in interface Layout<T extends Constraints>
Parameters:
component - The component for which layout metadata is being requested.
Returns:
The constraints associated with the component.
Throws:
java.lang.IllegalStateException - if this layout has not yet been installed into a layout component.
java.lang.IllegalStateException - if no constraints are associated with the given component and this layout does not support default constraints.
See Also:
Layout.getConstraintsClass(), Component.getConstraints(), Component.setConstraints(Constraints)

fireConstraintsPropertyChange

protected <V> void fireConstraintsPropertyChange(Component component,
                                                 T constraints,
                                                 java.lang.String propertyName,
                                                 V oldValue,
                                                 V newValue)
Reports that the bound property of a component's constraints has changed. No event is fired if old and new are both null or are both non-null and equal according to the Object.equals(java.lang.Object) method. No event is fired if no listeners are registered for the given property. This method delegates actual firing of the event to BoundPropertyObject.firePropertyChange(PropertyChangeEvent).

Parameters:
component - The component for which a constraint value changed.
constraints - The constraints for which a value changed.
propertyName - The name of the property being changed.
oldValue - The old property value.
newValue - The new property value.
See Also:
LayoutConstraintsPropertyChangeEvent


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.