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 protected
LayoutDesc(ComponentDesc parent)
Creates a newLayoutDesc
. -
Method Summary
Modifier and Type Method Description void
applyTo(java.awt.Component component)
Applies theLayoutManager
to the given component.void
bind(ComponentDesc component, java.awt.Container target)
Tries to add the givenComponent
to the parentContainer
object.abstract java.lang.Object
createConstraints(ComponentDesc child)
Creates layout constraints if possible by using extra configuration variables by the parentComponentDesc
.abstract java.awt.LayoutManager
createManager()
Based on the configuration given by the annotations on each field, this descriptor tries to create the correspondingLayoutManager
.protected ComponentDesc
getParent()
abstract boolean
isAbsolute()
Indicates that the implementedLayoutDesc
will represent the absolute layout.protected <T> void
setConstraint(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
null
of failure instead of throwing an exception.- Returns:
- the qualified LayoutManager
-
isAbsolute
public abstract boolean isAbsolute()Indicates that the implementedLayoutDesc
will represent the absolute layout.- Returns:
true
if 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
null
if 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 givenComponent
to the parentContainer
object.- Parameters:
component
- the component that will be added to the containertarget
- theContainer
where theComponent
should be added to
-
applyTo
public void applyTo(java.awt.Component component)Applies theLayoutManager
to the given component.- Specified by:
applyTo
in classGenericDesc<Layout>
- Parameters:
component
- theComponent
reference
-
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)
-