Class ObjectCardLayout

  • All Implemented Interfaces:
    java.awt.LayoutManager, java.awt.LayoutManager2

    public class ObjectCardLayout
    extends java.lang.Object
    implements java.awt.LayoutManager2
    A ObjectCardLayout is an object based cardlayout.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.Object,​java.awt.Component> components
      The components.
      protected java.lang.Object curkey
      The key of the current component (if any).
      protected java.awt.Component current
      The current component (if any).
      static java.lang.String DEFAULT_COMPONENT
      The default component (used when no other component is shown).
      protected int hgap
      The horizontal gap.
      protected int vgap
      The vertical gap.
    • Constructor Summary

      Constructors 
      Constructor Description
      ObjectCardLayout()
      Construct a new layout.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addLayoutComponent​(java.awt.Component component, java.lang.Object constraints)
      Will be called from the container, when a new component with constraint object was added.
      void addLayoutComponent​(java.lang.String name, java.awt.Component comp)
      A component was added to the container.
      java.awt.Component getComponent​(java.lang.Object object)
      Get a component for the given identifier.
      java.lang.Object getCurrentKey()
      Get the key of the currently shown component (if any).
      float getLayoutAlignmentX​(java.awt.Container target)
      Get the component interest where to be aligned.
      float getLayoutAlignmentY​(java.awt.Container target)
      Get the component interest where to be aligned.
      void invalidateLayout​(java.awt.Container target)
      When called, all values are recalculated.
      boolean isAvailable​(java.lang.Object object)
      Test if there is a panel for a object available.
      void layoutContainer​(java.awt.Container parent)
      Set the components bounds in the parent.
      java.awt.Dimension maximumLayoutSize​(java.awt.Container target)
      Compute the maximum layout size.
      java.awt.Dimension minimumLayoutSize​(java.awt.Container parent)
      Compute the minimum layout size.
      java.awt.Dimension preferredLayoutSize​(java.awt.Container parent)
      Compute the preferred layout size.
      void removeLayoutComponent​(java.awt.Component comp)
      Will be called from the container, when a component was removed.
      void show​(java.lang.Object object)
      Shows the component in the parent.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DEFAULT_COMPONENT

        public static final java.lang.String DEFAULT_COMPONENT
        The default component (used when no other component is shown).
        See Also:
        Constant Field Values
      • hgap

        protected int hgap
        The horizontal gap.
      • vgap

        protected int vgap
        The vertical gap.
      • components

        protected java.util.Map<java.lang.Object,​java.awt.Component> components
        The components.
      • current

        protected java.awt.Component current
        The current component (if any).
      • curkey

        protected java.lang.Object curkey
        The key of the current component (if any).
    • Constructor Detail

      • ObjectCardLayout

        public ObjectCardLayout()
        Construct a new layout.
    • Method Detail

      • show

        public void show​(java.lang.Object object)
        Shows the component in the parent.
        Parameters:
        object - The object.
        parent - The parent.
      • isAvailable

        public boolean isAvailable​(java.lang.Object object)
        Test if there is a panel for a object available.
        Parameters:
        object - The object.
        Returns:
        True, if it exists a panel.
      • getComponent

        public java.awt.Component getComponent​(java.lang.Object object)
        Get a component for the given identifier.
      • getCurrentKey

        public java.lang.Object getCurrentKey()
        Get the key of the currently shown component (if any).
      • addLayoutComponent

        public void addLayoutComponent​(java.lang.String name,
                                       java.awt.Component comp)
        A component was added to the container.
        Specified by:
        addLayoutComponent in interface java.awt.LayoutManager
        Parameters:
        name - The constraint in a string.
        comp - The component.
      • layoutContainer

        public void layoutContainer​(java.awt.Container parent)
        Set the components bounds in the parent.
        Specified by:
        layoutContainer in interface java.awt.LayoutManager
        Parameters:
        parent - The container.
      • minimumLayoutSize

        public java.awt.Dimension minimumLayoutSize​(java.awt.Container parent)
        Compute the minimum layout size.
        Specified by:
        minimumLayoutSize in interface java.awt.LayoutManager
        Parameters:
        parent - The container.
        Returns:
        The minimum layout size.
      • preferredLayoutSize

        public java.awt.Dimension preferredLayoutSize​(java.awt.Container parent)
        Compute the preferred layout size.
        Specified by:
        preferredLayoutSize in interface java.awt.LayoutManager
        Parameters:
        parent - The container.
        Returns:
        The preferred layout size.
      • removeLayoutComponent

        public void removeLayoutComponent​(java.awt.Component comp)
        Will be called from the container, when a component was removed.
        Specified by:
        removeLayoutComponent in interface java.awt.LayoutManager
        Parameters:
        comp - The component.
      • addLayoutComponent

        public void addLayoutComponent​(java.awt.Component component,
                                       java.lang.Object constraints)
        Will be called from the container, when a new component with constraint object was added.
        Specified by:
        addLayoutComponent in interface java.awt.LayoutManager2
        Parameters:
        component - The component.
        constraints - The constraints.
      • getLayoutAlignmentX

        public float getLayoutAlignmentX​(java.awt.Container target)
        Get the component interest where to be aligned. (not used).
        Specified by:
        getLayoutAlignmentX in interface java.awt.LayoutManager2
        Parameters:
        target - The container.
        Returns:
        Always 0.5 (centered).
      • getLayoutAlignmentY

        public float getLayoutAlignmentY​(java.awt.Container target)
        Get the component interest where to be aligned. (not used).
        Specified by:
        getLayoutAlignmentY in interface java.awt.LayoutManager2
        Parameters:
        target - The container.
        Returns:
        Always 0.5 (centered).
      • invalidateLayout

        public void invalidateLayout​(java.awt.Container target)
        When called, all values are recalculated.
        Specified by:
        invalidateLayout in interface java.awt.LayoutManager2
        Parameters:
        target - The container.
      • maximumLayoutSize

        public java.awt.Dimension maximumLayoutSize​(java.awt.Container target)
        Compute the maximum layout size.
        Specified by:
        maximumLayoutSize in interface java.awt.LayoutManager2
        Parameters:
        target - The container.
        Returns:
        The maximum layout size.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object