Class AbstractLayout<T extends Constraints>
java.lang.Object
com.globalmentor.beans.BoundPropertyObject
io.guise.framework.event.GuiseBoundPropertyObject
io.guise.framework.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
Modifier and TypeClassDescriptionprotected class
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addComponent
(Component component) Lays out the associated layout component.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, String propertyName, V oldValue, V newValue) Reports that the bound property of a component's constraints has changed.protected com.globalmentor.beans.GenericPropertyChangeListener<Constraints>
getConstraints
(Component component) Retrieves layout constraints associated with a component.protected AbstractLayout<T>.ConstraintsPropertyChangeListener
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 io.guise.framework.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 io.guise.framework.component.layout.Layout
createDefaultConstraints, getConstraintsClass, getSession
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Constructor Details
-
AbstractLayout
public AbstractLayout()
-
-
Method Details
-
getConstraintsPropertyChangeListener
protected AbstractLayout<T>.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, ornull
if there were no constraints previously.newConstraints
- The new component constraints, ornull
if the component now has no constraints.
-
getOwner
- Specified by:
getOwner
in interfaceLayout<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
Description copied from interface:Layout
Sets the layout component that owns this layout This method is managed by layout components, and normally should not be called by applications. 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 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 interfaceLayout<T extends Constraints>
- Parameters:
newOwner
- The new layout component for this layout.
-
addComponent
Lays out the associated layout component. This version does nothing.- Specified by:
addComponent
in interfaceLayout<T extends Constraints>
- Parameters:
component
- The component to add to the layout.- Throws:
IllegalStateException
- if this layout has not yet been installed into a layout component.
-
removeComponent
Description copied from interface:Layout
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 interfaceLayout<T extends Constraints>
- Parameters:
component
- The component to remove from the layout.
-
getConstraints
Description copied from interface:Layout
Retrieves 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 interfaceLayout<T extends Constraints>
- Parameters:
component
- The component for which layout metadata is being requested.- Returns:
- The constraints associated with the component.
- See Also:
-
fireConstraintsPropertyChange
protected <V> void fireConstraintsPropertyChange(Component component, T constraints, 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 bothnull
or are both non-null
and equal according to theObject.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 toBoundPropertyObject.firePropertyChange(PropertyChangeEvent)
.- Type Parameters:
V
- The type of the values.- 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:
-