Class LayoutDesc

java.lang.Object
org.proto4j.swing.core.desc.GenericDesc<Layout>
org.proto4j.swing.core.desc.LayoutDesc
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

    Fields inherited from class org.proto4j.swing.core.desc.GenericDesc

    INVALID_INT, UNDEFINED
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected LayoutDesc​(ComponentDesc parent)
    Creates a new LayoutDesc.
  • Method Summary

    Modifier and Type Method Description
    void applyTo​(java.awt.Component component)
    Applies the LayoutManager to the given component.
    void bind​(ComponentDesc component, java.awt.Container target)
    Tries to add the given Component to the parent Container object.
    abstract java.lang.Object createConstraints​(ComponentDesc child)
    Creates layout constraints if possible by using extra configuration variables by the parent ComponentDesc.
    abstract java.awt.LayoutManager createManager()
    Based on the configuration given by the annotations on each field, this descriptor tries to create the corresponding LayoutManager.
    protected ComponentDesc getParent()  
    abstract boolean isAbsolute()
    Indicates that the implemented LayoutDesc 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LayoutDesc

      protected LayoutDesc​(ComponentDesc parent)
      Creates a new LayoutDesc. 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 corresponding LayoutManager.

      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 implemented LayoutDesc will represent the absolute layout.
      Returns:
      true if the absolute layout should be used; false otherwise
    • createConstraints

      public abstract java.lang.Object createConstraints​(ComponentDesc child)
      Creates layout constraints if possible by using extra configuration variables by the parent ComponentDesc.

      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 defined
      java.lang.NullPointerException - if the given child component is null
    • bind

      public void bind​(ComponentDesc component, java.awt.Container target)
      Tries to add the given Component to the parent Container object.
      Parameters:
      component - the component that will be added to the container
      target - the Container where the Component should be added to
    • applyTo

      public void applyTo​(java.awt.Component component)
      Applies the LayoutManager to the given component.
      Specified by:
      applyTo in class GenericDesc<Layout>
      Parameters:
      component - the Component reference
    • getParent

      protected ComponentDesc 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)