Class PercentLayout

java.lang.Object
se.datadosen.component.buttonbar.PercentLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2

public class PercentLayout extends Object implements LayoutManager2
PercentLayout.
Constraint based layout which allow the space to be splitted using percentages. The following are allowed when adding components to container:
  • container.add(component);
    in this case, the component will be sized to its preferred size
  • container.add(component, "100");
    in this case, the component will have a width (or height) of 100
  • container.add(component, "25%");
    in this case, the component will have a width (or height) of 25 % of the container width (or height)
  • container.add(component, "*");
    in this case, the component will take the remaining space. if several components use the "*" constraint the space will be divided among the components.
  • Field Details

    • HORIZONTAL

      public static final int HORIZONTAL
      Useful constant to layout the components horizontally (from top to bottom).
      See Also:
    • VERTICAL

      public static final int VERTICAL
      Useful constant to layout the components vertically (from left to right).
      See Also:
  • Constructor Details

    • PercentLayout

      public PercentLayout()
      Creates a new HORIZONTAL PercentLayout with a gap of 0.
    • PercentLayout

      public PercentLayout(int orientation, int gap)
  • Method Details

    • setGap

      public void setGap(int gap)
    • getGap

      public int getGap()
    • setOrientation

      public void setOrientation(int orientation)
    • getOrientation

      public int getOrientation()
    • getConstraint

      public se.datadosen.component.buttonbar.PercentLayout.Constraint getConstraint(Component component)
    • setConstraint

      public void setConstraint(Component component, Object constraints)
    • addLayoutComponent

      public void addLayoutComponent(Component component, Object constraints)
      Specified by:
      addLayoutComponent in interface LayoutManager2
    • getLayoutAlignmentX

      public float getLayoutAlignmentX(Container target)
      Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
      Specified by:
      getLayoutAlignmentX in interface LayoutManager2
    • getLayoutAlignmentY

      public float getLayoutAlignmentY(Container target)
      Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
      Specified by:
      getLayoutAlignmentY in interface LayoutManager2
    • invalidateLayout

      public void invalidateLayout(Container target)
      Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
      Specified by:
      invalidateLayout in interface LayoutManager2
    • addLayoutComponent

      public void addLayoutComponent(String name, Component comp)
      Adds the specified component with the specified name to the layout.
      Specified by:
      addLayoutComponent in interface LayoutManager
      Parameters:
      name - the component name
      comp - the component to be added
    • removeLayoutComponent

      public void removeLayoutComponent(Component comp)
      Removes the specified component from the layout.
      Specified by:
      removeLayoutComponent in interface LayoutManager
      Parameters:
      comp - the component ot be removed
    • minimumLayoutSize

      public Dimension minimumLayoutSize(Container parent)
      Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.
      Specified by:
      minimumLayoutSize in interface LayoutManager
      Parameters:
      parent - the component to be laid out
      See Also:
    • maximumLayoutSize

      public Dimension maximumLayoutSize(Container parent)
      Returns the maximum size of this component.
      Specified by:
      maximumLayoutSize in interface LayoutManager2
      See Also:
    • preferredLayoutSize

      public Dimension preferredLayoutSize(Container parent)
      Specified by:
      preferredLayoutSize in interface LayoutManager
    • layoutContainer

      public void layoutContainer(Container parent)
      Specified by:
      layoutContainer in interface LayoutManager