Package org.hkmi2.aagbl
Class GridBagLayoutBuilder
- java.lang.Object
-
- org.hkmi2.aagbl.GridBagLayoutBuilder
-
public class GridBagLayoutBuilder extends java.lang.ObjectThis 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 theGridBagConstraintsfor each component. This class is created and used byAsciiArtGridBagLayout, there are few reasons to use this class directly.
-
-
Field Summary
Fields Modifier and Type Field Description static booleandebugBuilderset 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 CRectfindCRect(java.lang.String name)Find a rectangle with the given namejava.awt.GridBagLayoutgetGridBagLayout()Get the GridBagLayoutjava.awt.InsetsgetInsetsToUse()Gets theInsetsto use.java.awt.GridBagConstraintsmakeGridBagConstraints(java.lang.String rectName)Calculate the GridBagConstraints for the CRect that has the given name Create aGridBagConstraintsobject for the rectangle of the given name.voidsetInsets(java.lang.String rectNameList, java.awt.Insets insets)Sets the insets for a list of rectangles (comma-separated list of names)voidsetInsetsToUse(java.awt.Insets insetsToUse)Sets the insets to use.voidsetIpadx(java.lang.String rectNameList, int val)Sets the x ipadding for a list of rectangles (comma-separated list of names)voidsetIpady(java.lang.String rectNameList, int val)Sets the y ipadding for a list of rectangles (comma-separated list of names)voidsetWeightx(java.lang.String rectNameList, double val)Sets the x weight for a list of rectangles (comma-separated list of names)voidsetWeighty(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
-
-
-
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 aGridBagConstraintsobject 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 namesval- 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 namesval- 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 namesval- 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 namesval- 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 namesinsets- The insets to set
-
getInsetsToUse
public java.awt.Insets getInsetsToUse()
Gets theInsetsto use. If null, it means we keep the defaultInsetsof the CRect class.- Returns:
- An
Insetsobject 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- AnInsetsobject or null
-
-