java.lang.Object
- Direct Known Subclasses:
AbsoluteLayoutDesc,BorderLayoutDesc,BoxLayoutDesc,CardLayoutDesc,FlowLayoutDesc,GridLayoutDesc,SpringLayoutDesc
public abstract class LayoutDesc extends GenericDesc<Layout>
The base class for all
LayoutDesc inheritors. This abstract
layer is used to provide the general requirements on this class.
There will be only one LayoutDesc at a definition on a
ComponentDesc instance.
- Since:
- 1.0
- See Also:
GenericDesc
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protectedLayoutDesc(ComponentDesc parent)Creates a newLayoutDesc. -
Method Summary
Modifier and Type Method Description voidapplyTo(java.awt.Component component)Applies theLayoutManagerto the given component.voidbind(ComponentDesc component, java.awt.Container target)Tries to add the givenComponentto the parentContainerobject.abstract java.lang.ObjectcreateConstraints(ComponentDesc child)Creates layout constraints if possible by using extra configuration variables by the parentComponentDesc.abstract java.awt.LayoutManagercreateManager()Based on the configuration given by the annotations on each field, this descriptor tries to create the correspondingLayoutManager.protected ComponentDescgetParent()abstract booleanisAbsolute()Indicates that the implementedLayoutDescwill represent the absolute layout.protected <T> voidsetConstraint(java.lang.String name, java.util.Properties options, java.lang.Class<T> cls, java.util.function.Consumer<? super T> consumer)Methods inherited from class org.proto4j.swing.core.desc.GenericDesc
annotationType, get, getDefinedOptions, getOption, hasOption, keys, put, read, read
-
Constructor Details
-
LayoutDesc
Creates a newLayoutDesc. This constructor is protected so only inheritors can call it.
-
-
Method Details
-
createManager
public abstract java.awt.LayoutManager createManager()Based on the configuration given by the annotations on each field, this descriptor tries to create the correspondingLayoutManager.Implementations of this method should return
nullof failure instead of throwing an exception.- Returns:
- the qualified LayoutManager
-
isAbsolute
public abstract boolean isAbsolute()Indicates that the implementedLayoutDescwill represent the absolute layout.- Returns:
trueif the absolute layout should be used; false otherwise
-
createConstraints
Creates layout constraints if possible by using extra configuration variables by the parentComponentDesc.This method may return
nullif no constraints are defined or can be used. Another way is to throw an exception in order to show the user a misconfiguration.- Returns:
- the layout constraints for the given child component
- Throws:
DescInitializationException- if the options are not definedjava.lang.NullPointerException- if the given child component isnull
-
bind
Tries to add the givenComponentto the parentContainerobject.- Parameters:
component- the component that will be added to the containertarget- theContainerwhere theComponentshould be added to
-
applyTo
public void applyTo(java.awt.Component component)Applies theLayoutManagerto the given component.- Specified by:
applyToin classGenericDesc<Layout>- Parameters:
component- theComponentreference
-
getParent
-
setConstraint
protected <T> void setConstraint(java.lang.String name, java.util.Properties options, java.lang.Class<T> cls, java.util.function.Consumer<? super T> consumer)
-