Class GridBagLayoutBuilder


  • public class GridBagLayoutBuilder
    extends java.lang.Object
    This object builds a series of GridBagLayouts from a list of rectangles (that were defined in a Ascii art drawing, and parsed using a LayoutParser) This is a utility class that handles a list of components and rectangles, and computes the GridBagConstraints for each component. This class is created and used by AsciiArtGridBagLayout, there are few reasons to use this class directly.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean debugBuilder
      set to true to see some debugging messages on System.out .
    • Constructor Summary

      Constructors 
      Constructor Description
      GridBagLayoutBuilder​(java.util.List<CRect> rects)
      Default constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CRect findCRect​(java.lang.String name)
      Find a rectangle with the given name
      java.awt.GridBagLayout getGridBagLayout()
      Get the GridBagLayout
      java.awt.Insets getInsetsToUse()
      Gets the Insets to use.
      java.awt.GridBagConstraints makeGridBagConstraints​(java.lang.String rectName)
      Calculate the GridBagConstraints for the CRect that has the given name Create a GridBagConstraints object for the rectangle of the given name.
      void setInsets​(java.lang.String rectNameList, java.awt.Insets insets)
      Sets the insets for a list of rectangles (comma-separated list of names)
      void setInsetsToUse​(java.awt.Insets insetsToUse)
      Sets the insets to use.
      void setIpadx​(java.lang.String rectNameList, int val)
      Sets the x ipadding for a list of rectangles (comma-separated list of names)
      void setIpady​(java.lang.String rectNameList, int val)
      Sets the y ipadding for a list of rectangles (comma-separated list of names)
      void setWeightx​(java.lang.String rectNameList, double val)
      Sets the x weight for a list of rectangles (comma-separated list of names)
      void setWeighty​(java.lang.String rectNameList, double val)
      Sets the y weight for a list of rectangles (comma-separated list of names)
      static java.lang.String[] split​(java.lang.String str)
      Split the given comma-separated list into an array of Strings
      • Methods inherited from class java.lang.Object

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

      • debugBuilder

        public static boolean debugBuilder
        set to true to see some debugging messages on System.out . Default is false.
    • Constructor Detail

      • GridBagLayoutBuilder

        public GridBagLayoutBuilder​(java.util.List<CRect> rects)
        Default constructor
        Parameters:
        rects - A list of CRect (The list of component rectangles)
    • Method Detail

      • getGridBagLayout

        public java.awt.GridBagLayout getGridBagLayout()
        Get the GridBagLayout
        Returns:
        The contained GridBagLayout
      • findCRect

        public CRect findCRect​(java.lang.String name)
        Find a rectangle with the given name
        Parameters:
        name - The name of the rectangle to look for
        Returns:
        The rectangle or null if not found.
      • makeGridBagConstraints

        public java.awt.GridBagConstraints makeGridBagConstraints​(java.lang.String rectName)
        Calculate the GridBagConstraints for the CRect that has the given name Create a GridBagConstraints object for the rectangle of the given name.
        Parameters:
        rectName - The name of the CRect
        Returns:
        the calculated GridBagConstraints
      • split

        public static java.lang.String[] split​(java.lang.String str)
        Split the given comma-separated list into an array of Strings
        Parameters:
        str - A string that is a comma-separated list of names, e.g. "a,b,x"
        Returns:
        An arrays of String that corresponds to the list, e.g. {"a", "b", "x"}
      • setWeightx

        public void setWeightx​(java.lang.String rectNameList,
                               double val)
        Sets the x weight for a list of rectangles (comma-separated list of names)
        Parameters:
        rectNameList - A string that contains a comma-separated list of names
        val - The value for the x weight
      • setWeighty

        public void setWeighty​(java.lang.String rectNameList,
                               double val)
        Sets the y weight for a list of rectangles (comma-separated list of names)
        Parameters:
        rectNameList - A string that contains a comma-separated list of names
        val - The value for the y weight
      • setIpadx

        public void setIpadx​(java.lang.String rectNameList,
                             int val)
        Sets the x ipadding for a list of rectangles (comma-separated list of names)
        Parameters:
        rectNameList - A string that contains a comma-separated list of names
        val - The value for the x ipadding
      • setIpady

        public void setIpady​(java.lang.String rectNameList,
                             int val)
        Sets the y ipadding for a list of rectangles (comma-separated list of names)
        Parameters:
        rectNameList - A string that contains a comma-separated list of names
        val - The value for the y ipadding
      • setInsets

        public void setInsets​(java.lang.String rectNameList,
                              java.awt.Insets insets)
        Sets the insets for a list of rectangles (comma-separated list of names)
        Parameters:
        rectNameList - A string that contains a comma-separated list of names
        insets - The insets to set
      • getInsetsToUse

        public java.awt.Insets getInsetsToUse()
        Gets the Insets to use. If null, it means we keep the default Insets of the CRect class.
        Returns:
        An Insets object or null
      • setInsetsToUse

        public void setInsetsToUse​(java.awt.Insets insetsToUse)
        Sets the insets to use. Default is null, which means we keep the default insets of 5 that are in the CRects.
        Parameters:
        insetsToUse - An Insets object or null