Documentation of 'jas2.util.layout.PnutsLayout' Java class
PnutsLayout
jas2.util.layout

Class PnutsLayout

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


    public class PnutsLayout
    extends java.lang.Object
    implements java.awt.LayoutManager2, java.io.Serializable
    The PnutsLayout is a general purpose geometry manager. It is more user-friendly than any LayoutManager out there and as flexible as GridBagLayout. e.g.
      setLayout(new PnutsLayout("cols = 3"));
      add(button1, "ipadx = 20, ipady = 20");
      add(button2, "padx = 20, pady = 20");
      add(button3, "colspan = 2");
      add(button4, "rowspan = 2");
      add(button3, "halign = left, valign = top");
      add(button3, "halign = right, valign = bottom");
      add(button3, "halign = center, valign = fill");
     
    propertythe meaningdefault
    colsnumber of columns1
    uniformif width and/or height of each columns are all same, "x", "y" or "xy"""
    colspannumber of columns the component occupies1
    rowspannumber of rows the component occupies1
    padxexternal padding (x)0
    padyexternal padding (y)0
    ipadxinternal padding (x)0
    ipadyinternal padding (y)0
    halignalignment of x. One of "left", "right", "center", "fill"center
    valignalignment of y. One of "top", "bottom", "center", "fill"center
    expandexpand as the size of container changes. one of "x", "y", "xy"""

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static int BOTTOM 
      static int CENTER 
      static int H_FIT 
      static int LEFT 
      static int RIGHT 
      static int TOP 
      static int V_FIT 
    • Constructor Summary

      Constructors 
      Constructor and Description
      PnutsLayout()
      construct a PnutsLayout
      PnutsLayout(int cols)
      construct a PnutsLayout with specified number of columns
      PnutsLayout(int cols, int padx, int pady)
      construct a PnutsLayout
      PnutsLayout(java.lang.String str) 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addLayoutComponent(java.awt.Component comp, java.lang.Object obj)
      Adds the specified component to the layout, using the specified constraint object.
      void addLayoutComponent(java.lang.String name, java.awt.Component comp)
      Adds the specified component with the specified name to the layout.
      int getCols()
      Get the number of columns
      int getColspan(java.awt.Component comp) 
      java.util.Hashtable getConstraints(java.awt.Component comp)
      get a Hashtable of constraint for the specified component
      java.lang.String getConstraintString(java.awt.Component comp)
      get a string representaion of constraint for the specified component
      java.lang.String getExpand(java.awt.Component comp) 
      java.awt.Point getGridPoint(java.awt.Container target, int x, int y)
      get left-top point of the component(x,y)
      java.awt.Rectangle getGridRectangle(java.awt.Container target, int idx)
      get bounding-box for idx'th component
      java.lang.String getHAlign(java.awt.Component comp) 
      int getIPadX(java.awt.Component comp) 
      int getIPadY(java.awt.Component comp) 
      float getLayoutAlignmentX(java.awt.Container target)
      Returns the alignment along the x axis.
      float getLayoutAlignmentY(java.awt.Container target)
      Returns the alignment along the y axis.
      int getPadX(java.awt.Component comp) 
      int getPadY(java.awt.Component comp) 
      int getRows()
      get the number of rows
      int getRowspan(java.awt.Component comp) 
      boolean[] getUniform()
      get "uniform" property
      java.lang.String getVAlign(java.awt.Component comp) 
      void invalidateLayout(java.awt.Container target)
      Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
      void layoutContainer(java.awt.Container target)
      Lays out the container.
      java.awt.Dimension maximumLayoutSize(java.awt.Container target)
      Returns the maximum size of this component.
      java.awt.Dimension minimumLayoutSize(java.awt.Container target)
      Returns the minimum dimensions needed to layout the components contained in the specified target container.
      java.awt.Dimension preferredLayoutSize(java.awt.Container target)
      Returns the preferred dimensions for this layout given the components in the specified target container.
      void removeLayoutComponent(java.awt.Component comp)
      Removes the specified component from the layout.
      void setCols(int cols)
      Set the number of columns
      void setColspan(java.awt.Component comp, int colspan) 
      void setConstraints(java.awt.Component comp, java.util.Hashtable table)
      Specify layout constraints with Hashtable
      void setConstraints(java.awt.Component comp, java.lang.String str)
      Specify layout constraints with comma-separated list of "=".
      void setExpand(java.awt.Component comp, java.lang.String ex) 
      void setHAlign(java.awt.Component comp, java.lang.String s) 
      void setIPadding(java.awt.Component comp, int x, int y) 
      void setPadding(java.awt.Component comp, int x, int y) 
      void setRowspan(java.awt.Component comp, int rowspan) 
      void setUniform(boolean x, boolean y)
      set "uniform" property
      void setVAlign(java.awt.Component comp, java.lang.String s) 
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • PnutsLayout

        public PnutsLayout()
        construct a PnutsLayout
      • PnutsLayout

        public PnutsLayout(int cols)
        construct a PnutsLayout with specified number of columns
        Parameters:
        cols - the number of columns
      • PnutsLayout

        public PnutsLayout(int cols,
                           int padx,
                           int pady)
        construct a PnutsLayout
        Parameters:
        cols - the number of columns
        padx - default external padding
        pady - default external padding
      • PnutsLayout

        public PnutsLayout(java.lang.String str)
    • Method Detail

      • addLayoutComponent

        public void addLayoutComponent(java.awt.Component comp,
                                       java.lang.Object obj)
        Adds the specified component to the layout, using the specified constraint object.
        Specified by:
        addLayoutComponent in interface java.awt.LayoutManager2
        Parameters:
        comp - the component to be added.
        obj - an object that determines how the component is added to the layout. Usage: container.add(component, new Object[]{align, colspan, rowspan});
      • setConstraints

        public void setConstraints(java.awt.Component comp,
                                   java.lang.String str)
        Specify layout constraints with comma-separated list of "=". halign ::= left | right | center | fill valign ::= top | bottom | center | fill expand ::= x | y | xy
        Parameters:
        comp - the component
        str - a string that describes how the component is added to the layout.
      • setConstraints

        public void setConstraints(java.awt.Component comp,
                                   java.util.Hashtable table)
        Specify layout constraints with Hashtable
        Parameters:
        comp - the component to be set the constraint.
        table - a Hashtable that describes how the component is added to the layout.
      • getConstraintString

        public java.lang.String getConstraintString(java.awt.Component comp)
        get a string representaion of constraint for the specified component
        Parameters:
        comp - the component to be investigate
        Returns:
        string representaion of the constraint
      • getConstraints

        public java.util.Hashtable getConstraints(java.awt.Component comp)
        get a Hashtable of constraint for the specified component
        Parameters:
        comp - the component to be investigate
        Returns:
        the constraints as Hashtable
      • addLayoutComponent

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

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

        public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
        Returns the maximum size of this component.
        Specified by:
        maximumLayoutSize in interface java.awt.LayoutManager2
        See Also:
        Component.getMinimumSize(), Component.getPreferredSize(), LayoutManager
      • getLayoutAlignmentX

        public float getLayoutAlignmentX(java.awt.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 java.awt.LayoutManager2
      • getLayoutAlignmentY

        public float getLayoutAlignmentY(java.awt.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 java.awt.LayoutManager2
      • invalidateLayout

        public void invalidateLayout(java.awt.Container target)
        Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
        Specified by:
        invalidateLayout in interface java.awt.LayoutManager2
        Parameters:
        target - container to invalidate the layout
      • setCols

        public void setCols(int cols)
        Set the number of columns
        Parameters:
        cols - the number of columns
      • setUniform

        public void setUniform(boolean x,
                               boolean y)
        set "uniform" property
        Parameters:
        x - uniform property for horizontal direction
        y - uniform property for vertical direction
      • getUniform

        public boolean[] getUniform()
        get "uniform" property
        Returns:
        boolean array of "uniform property"
      • setColspan

        public void setColspan(java.awt.Component comp,
                               int colspan)
        Parameters:
        comp - the component of which you want to change colspan
        colspan - the number of columns the component occupies
      • getColspan

        public int getColspan(java.awt.Component comp)
        Parameters:
        comp - the component of which you want to get colspan
        Returns:
        the value of "colspan" property
      • setRowspan

        public void setRowspan(java.awt.Component comp,
                               int rowspan)
        Parameters:
        comp - the component of which you want to change rowspan
        rowspan - the number of rows the component occupies
      • getRowspan

        public int getRowspan(java.awt.Component comp)
        Parameters:
        comp - the component of which you want to get rowspan
        Returns:
        the value of "rowspan" property
      • setHAlign

        public void setHAlign(java.awt.Component comp,
                              java.lang.String s)
        Parameters:
        comp - the component of which you want to change alignment
        align - "left", "right", "fill", "center"
      • setVAlign

        public void setVAlign(java.awt.Component comp,
                              java.lang.String s)
        Parameters:
        comp - the component of which you want to change alignment
        align - "top", "bottom", "fill", "center"
      • getHAlign

        public java.lang.String getHAlign(java.awt.Component comp)
        Parameters:
        comp - the component of which you want to get alignment
        Returns:
        "fill" | "left" | "right" | "center"
      • getVAlign

        public java.lang.String getVAlign(java.awt.Component comp)
        Parameters:
        comp - the component of which you want to get alignment
        Returns:
        "fill" | "top" | "bottom" | "center"
      • setExpand

        public void setExpand(java.awt.Component comp,
                              java.lang.String ex)
        Parameters:
        comp - the component of which you want to set "expand"
      • getExpand

        public java.lang.String getExpand(java.awt.Component comp)
        Parameters:
        comp - the component of which you want to get "expand"
        Returns:
        "x" | "y" | "xy" | ""
      • setPadding

        public void setPadding(java.awt.Component comp,
                               int x,
                               int y)
        Parameters:
        comp - the component of which you want to change alignment
        x - "padx" property
        y - "pady" property
      • getPadX

        public int getPadX(java.awt.Component comp)
        Parameters:
        comp - the component of which you want to get "padx"
        Returns:
        the value of "padx" property
      • getPadY

        public int getPadY(java.awt.Component comp)
        Parameters:
        comp - the component of which you want to get "pady"
        Returns:
        the value of "pady" property
      • setIPadding

        public void setIPadding(java.awt.Component comp,
                                int x,
                                int y)
        Parameters:
        comp - the component of which you want to change alignment
        x - "ipadx" property
        y - "ipady" property
      • getIPadX

        public int getIPadX(java.awt.Component comp)
        Parameters:
        comp - the component of which you want to get "ipadx"
        Returns:
        the value of "ipadx" property
      • getIPadY

        public int getIPadY(java.awt.Component comp)
        Parameters:
        comp - the component of which you want to get "ipady"
        Returns:
        the value of "ipady" property
      • preferredLayoutSize

        public java.awt.Dimension preferredLayoutSize(java.awt.Container target)
        Returns the preferred dimensions for this layout given the components in the specified target container.
        Specified by:
        preferredLayoutSize in interface java.awt.LayoutManager
        Parameters:
        target - the component which needs to be laid out
        See Also:
        Container, minimumLayoutSize(java.awt.Container)
      • minimumLayoutSize

        public java.awt.Dimension minimumLayoutSize(java.awt.Container target)
        Returns the minimum dimensions needed to layout the components contained in the specified target container.
        Specified by:
        minimumLayoutSize in interface java.awt.LayoutManager
        Parameters:
        target - the component which needs to be laid out
        See Also:
        preferredLayoutSize(java.awt.Container)
      • layoutContainer

        public void layoutContainer(java.awt.Container target)
        Lays out the container. This method will actually reshape the components in the target in order to satisfy the constraints of the BorderLayout object.
        Specified by:
        layoutContainer in interface java.awt.LayoutManager
        Parameters:
        target - the specified component being laid out.
        See Also:
        Container
      • getCols

        public int getCols()
        Get the number of columns
        Returns:
        the number of columns
      • getRows

        public int getRows()
        get the number of rows
        Returns:
        the number of rows
      • getGridPoint

        public java.awt.Point getGridPoint(java.awt.Container target,
                                           int x,
                                           int y)
        get left-top point of the component(x,y)
        Parameters:
        x - the index of column
        y - the index of row
        Returns:
        left-top point of the component
      • getGridRectangle

        public java.awt.Rectangle getGridRectangle(java.awt.Container target,
                                                   int idx)
        get bounding-box for idx'th component
        Parameters:
        idx - the index of the component
        Returns:
        bounding-box as Rectangle object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        the String representation of this PnutsLayout's values.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.