Class FieldPanelOverLayoutManager

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

    public class FieldPanelOverLayoutManager
    extends java.lang.Object
    implements java.awt.LayoutManager2
    A LayoutManager that can be applied to a FieldPanel, allowing Components to be placed over a given field location. To apply it, use Container.setLayout(LayoutManager) to install it. In this case, the Container must be a FieldPanel. Then, use Container.add(Component, Object), passing a FieldLocation as the constraint. Currently, you must call layoutContainer(Container) manually after you add or remove any components. When this layout manager is removed from the FieldPanel, you should call unregister() in order to dispose of internal resources.
    • Constructor Detail

      • FieldPanelOverLayoutManager

        public FieldPanelOverLayoutManager​(FieldPanel fieldpane)
    • Method Detail

      • unregister

        public void unregister()
        Remove my callbacks from the FieldPanel
      • addComponent

        protected void addComponent​(FieldLocation loc,
                                    java.awt.Component comp)
        Add a component to be position over the given location
        Parameters:
        loc - the location of the field to occlude
        comp - the component to be placed over the field
      • removeComponent

        protected boolean removeComponent​(FieldLocation loc)
        Remove a component by its field location
        Parameters:
        loc - the location of the field
        Returns:
        true if there was a component placed at the given location
      • removeComponent

        protected boolean removeComponent​(java.awt.Component comp)
        Remove a component
        Parameters:
        comp - the component to remove
        Returns:
        true if the component existed
      • trickMapComponents

        protected void trickMapComponents()
        Tickle the layout manager, so we get a callback to map the components onto the layout.
      • addLayoutListener

        public void addLayoutListener​(FieldPanelOverLayoutListener listener)
        Add a listener for overlay layout events
        Parameters:
        listener - the listener to add
      • removeLayoutListener

        public void removeLayoutListener​(FieldPanelOverLayoutListener listener)
        Remove a listener for overlay layout events
        Parameters:
        listener - the listener to remove
      • getLayoutListeners

        public FieldPanelOverLayoutListener[] getLayoutListeners()
        Get the list of register overlay layout event listeners
        Returns:
        the array
      • getListeners

        public <T> T[] getListeners​(java.lang.Class<T> listenerType)
      • fireLayoutListeners

        protected void fireLayoutListeners​(FieldPanelOverLayoutEvent ev)
        Fire the given overlay layout event to all registered listeners
        Parameters:
        ev -
      • addLayoutComponent

        public void addLayoutComponent​(java.lang.String name,
                                       java.awt.Component comp)
        Specified by:
        addLayoutComponent in interface java.awt.LayoutManager
      • addLayoutComponent

        public void addLayoutComponent​(java.awt.Component comp,
                                       java.lang.Object constraints)
        Specified by:
        addLayoutComponent in interface java.awt.LayoutManager2
      • removeLayoutComponent

        public void removeLayoutComponent​(java.awt.Component comp)
        Specified by:
        removeLayoutComponent in interface java.awt.LayoutManager
      • preferredLayoutSize

        public java.awt.Dimension preferredLayoutSize​(java.awt.Container parent)
        Specified by:
        preferredLayoutSize in interface java.awt.LayoutManager
      • minimumLayoutSize

        public java.awt.Dimension minimumLayoutSize​(java.awt.Container parent)
        Specified by:
        minimumLayoutSize in interface java.awt.LayoutManager
      • maximumLayoutSize

        public java.awt.Dimension maximumLayoutSize​(java.awt.Container target)
        Specified by:
        maximumLayoutSize in interface java.awt.LayoutManager2
      • layoutContainer

        public void layoutContainer​(java.awt.Container parent)
        Specified by:
        layoutContainer in interface java.awt.LayoutManager
      • getLayoutAlignmentX

        public float getLayoutAlignmentX​(java.awt.Container target)
        Specified by:
        getLayoutAlignmentX in interface java.awt.LayoutManager2
      • getLayoutAlignmentY

        public float getLayoutAlignmentY​(java.awt.Container target)
        Specified by:
        getLayoutAlignmentY in interface java.awt.LayoutManager2
      • invalidateLayout

        public void invalidateLayout​(java.awt.Container target)
        Specified by:
        invalidateLayout in interface java.awt.LayoutManager2