Class GridBagBuilder


  • final class GridBagBuilder
    extends java.lang.Object
    A builder for Java's GridBagConstraints class.
    Since:
    2018-11-30, v0.1.0
    Author:
    Adrien Hopkins
    • Field Detail

      • gridx

        private final int gridx
        The built GridBagConstraints's gridx property.

        Specifies the cell containing the leading edge of the component's display area, where the first cell in a row has gridx=0. The leading edge of a component's display area is its left edge for a horizontal, left-to-right container and its right edge for a horizontal, right-to-left container. The value RELATIVE specifies that the component be placed immediately following the component that was added to the container just before this component was added.

        The default value is RELATIVE. gridx should be a non-negative value.

        See Also:
        Object.clone(), GridBagConstraints.gridy, ComponentOrientation
      • gridy

        private final int gridy
        The built GridBagConstraints's gridy property.

        Specifies the cell at the top of the component's display area, where the topmost cell has gridy=0. The value RELATIVE specifies that the component be placed just below the component that was added to the container just before this component was added.

        The default value is RELATIVE. gridy should be a non-negative value.

        See Also:
        Object.clone(), GridBagConstraints.gridx
      • gridwidth

        private final int gridwidth
        The built GridBagConstraints's gridwidth property.

        Specifies the number of cells in a row for the component's display area.

        Use REMAINDER to specify that the component's display area will be from gridx to the last cell in the row. Use RELATIVE to specify that the component's display area will be from gridx to the next to the last one in its row.

        gridwidth should be non-negative and the default value is 1.

        See Also:
        Object.clone(), GridBagConstraints.gridheight
      • gridheight

        private final int gridheight
        The built GridBagConstraints's gridheight property.

        Specifies the number of cells in a column for the component's display area.

        Use REMAINDER to specify that the component's display area will be from gridy to the last cell in the column. Use RELATIVE to specify that the component's display area will be from gridy to the next to the last one in its column.

        gridheight should be a non-negative value and the default value is 1.

        See Also:
        Object.clone(), GridBagConstraints.gridwidth
      • weightx

        private double weightx
        The built GridBagConstraints's weightx property.

        Specifies how to distribute extra horizontal space.

        The grid bag layout manager calculates the weight of a column to be the maximum weightx of all the components in a column. If the resulting layout is smaller horizontally than the area it needs to fill, the extra space is distributed to each column in proportion to its weight. A column that has a weight of zero receives no extra space.

        If all the weights are zero, all the extra space appears between the grids of the cell and the left and right edges.

        The default value of this field is 0. weightx should be a non-negative value.

        See Also:
        Object.clone(), GridBagConstraints.weighty
      • weighty

        private double weighty
        The built GridBagConstraints's weighty property.

        Specifies how to distribute extra vertical space.

        The grid bag layout manager calculates the weight of a row to be the maximum weighty of all the components in a row. If the resulting layout is smaller vertically than the area it needs to fill, the extra space is distributed to each row in proportion to its weight. A row that has a weight of zero receives no extra space.

        If all the weights are zero, all the extra space appears between the grids of the cell and the top and bottom edges.

        The default value of this field is 0. weighty should be a non-negative value.

        See Also:
        Object.clone(), GridBagConstraints.weightx
      • anchor

        private int anchor
        The built GridBagConstraints's anchor property.

        This field is used when the component is smaller than its display area. It determines where, within the display area, to place the component.

        There are three kinds of possible values: orientation relative, baseline relative and absolute. Orientation relative values are interpreted relative to the container's component orientation property, baseline relative values are interpreted relative to the baseline and absolute values are not. The absolute values are: CENTER, NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, and NORTHWEST. The orientation relative values are: PAGE_START, PAGE_END, LINE_START, LINE_END, FIRST_LINE_START, FIRST_LINE_END, LAST_LINE_START and LAST_LINE_END. The baseline relative values are: BASELINE, BASELINE_LEADING, BASELINE_TRAILING, ABOVE_BASELINE, ABOVE_BASELINE_LEADING, ABOVE_BASELINE_TRAILING, BELOW_BASELINE, BELOW_BASELINE_LEADING, and BELOW_BASELINE_TRAILING. The default value is CENTER.

        See Also:
        Object.clone(), ComponentOrientation
      • fill

        private int fill
        The built GridBagConstraints's fill property.

        This field is used when the component's display area is larger than the component's requested size. It determines whether to resize the component, and if so, how.

        The following values are valid for fill:

        • NONE: Do not resize the component.
        • HORIZONTAL: Make the component wide enough to fill its display area horizontally, but do not change its height.
        • VERTICAL: Make the component tall enough to fill its display area vertically, but do not change its width.
        • BOTH: Make the component fill its display area entirely.

        The default value is NONE.

        See Also:
        Object.clone()
      • insets

        private java.awt.Insets insets
        The built GridBagConstraints's insets property.

        This field specifies the external padding of the component, the minimum amount of space between the component and the edges of its display area.

        The default value is new Insets(0, 0, 0, 0).

        See Also:
        Object.clone()
      • ipadx

        private int ipadx
        The built GridBagConstraints's ipadx property.

        This field specifies the internal padding of the component, how much space to add to the minimum width of the component. The width of the component is at least its minimum width plus ipadx pixels.

        The default value is 0.

        See Also:
        Object.clone(), GridBagConstraints.ipady
      • ipady

        private int ipady
        The built GridBagConstraints's ipady property.

        This field specifies the internal padding, that is, how much space to add to the minimum height of the component. The height of the component is at least its minimum height plus ipady pixels.

        The default value is 0.

        See Also:
        Object.clone(), GridBagConstraints.ipadx
    • Constructor Detail

      • GridBagBuilder

        public GridBagBuilder​(int gridx,
                              int gridy)
        Parameters:
        gridx - x position
        gridy - y position
        Since:
        2018-11-30, v0.1.0
      • GridBagBuilder

        public GridBagBuilder​(int gridx,
                              int gridy,
                              int gridwidth,
                              int gridheight)
        Parameters:
        gridx - x position
        gridy - y position
        gridwidth - number of cells occupied horizontally
        gridheight - number of cells occupied vertically
        Since:
        2018-11-30, v0.1.0
      • GridBagBuilder

        private GridBagBuilder​(int gridx,
                               int gridy,
                               int gridwidth,
                               int gridheight,
                               double weightx,
                               double weighty,
                               int anchor,
                               int fill,
                               java.awt.Insets insets,
                               int ipadx,
                               int ipady)
        Parameters:
        gridx - x position
        gridy - y position
        gridwidth - number of cells occupied horizontally
        gridheight - number of cells occupied vertically
        weightx -
        weighty -
        anchor -
        fill -
        insets -
        ipadx -
        ipady -
        Since:
        2018-11-30, v0.1.0
    • Method Detail

      • build

        public java.awt.GridBagConstraints build()
        Returns:
        GridBagConstraints created by this builder
        Since:
        2018-11-30, v0.1.0
      • getAnchor

        public int getAnchor()
        Returns:
        anchor
        Since:
        2018-11-30, v0.1.0
      • getFill

        public int getFill()
        Returns:
        fill
        Since:
        2018-11-30, v0.1.0
      • getGridheight

        public int getGridheight()
        Returns:
        gridheight
        Since:
        2018-11-30, v0.1.0
      • getGridwidth

        public int getGridwidth()
        Returns:
        gridwidth
        Since:
        2018-11-30, v0.1.0
      • getGridx

        public int getGridx()
        Returns:
        gridx
        Since:
        2018-11-30, v0.1.0
      • getGridy

        public int getGridy()
        Returns:
        gridy
        Since:
        2018-11-30, v0.1.0
      • getInsets

        public java.awt.Insets getInsets()
        Returns:
        insets
        Since:
        2018-11-30, v0.1.0
      • getIpadx

        public int getIpadx()
        Returns:
        ipadx
        Since:
        2018-11-30, v0.1.0
      • getIpady

        public int getIpady()
        Returns:
        ipady
        Since:
        2018-11-30, v0.1.0
      • getWeightx

        public double getWeightx()
        Returns:
        weightx
        Since:
        2018-11-30, v0.1.0
      • getWeighty

        public double getWeighty()
        Returns:
        weighty
        Since:
        2018-11-30, v0.1.0
      • setAnchor

        public GridBagBuilder setAnchor​(int anchor)
        Parameters:
        anchor - anchor to set
        Since:
        2018-11-30, v0.1.0
      • setFill

        public GridBagBuilder setFill​(int fill)
        Parameters:
        fill - fill to set
        Since:
        2018-11-30, v0.1.0
      • setInsets

        public GridBagBuilder setInsets​(java.awt.Insets insets)
        Parameters:
        insets - insets to set
        Since:
        2018-11-30, v0.1.0
      • setIpadx

        public GridBagBuilder setIpadx​(int ipadx)
        Parameters:
        ipadx - ipadx to set
        Since:
        2018-11-30, v0.1.0
      • setIpady

        public GridBagBuilder setIpady​(int ipady)
        Parameters:
        ipady - ipady to set
        Since:
        2018-11-30, v0.1.0
      • setWeightx

        public GridBagBuilder setWeightx​(double weightx)
        Parameters:
        weightx - weightx to set
        Since:
        2018-11-30, v0.1.0
      • setWeighty

        public GridBagBuilder setWeighty​(double weighty)
        Parameters:
        weighty - weighty to set
        Since:
        2018-11-30, v0.1.0