Class GridBagBuilder
- java.lang.Object
-
- org.unitConverter.converterGUI.GridBagBuilder
-
final class GridBagBuilder extends java.lang.Object
A builder for Java'sGridBagConstraints
class.- Since:
- 2018-11-30, v0.1.0
- Author:
- Adrien Hopkins
-
-
Field Summary
Fields Modifier and Type Field Description private int
anchor
The builtGridBagConstraints
'sanchor
property.private int
fill
The builtGridBagConstraints
'sfill
property.private int
gridheight
The builtGridBagConstraints
'sgridheight
property.private int
gridwidth
The builtGridBagConstraints
'sgridwidth
property.private int
gridx
The builtGridBagConstraints
'sgridx
property.private int
gridy
The builtGridBagConstraints
'sgridy
property.private java.awt.Insets
insets
The builtGridBagConstraints
'sinsets
property.private int
ipadx
The builtGridBagConstraints
'sipadx
property.private int
ipady
The builtGridBagConstraints
'sipady
property.private double
weightx
The builtGridBagConstraints
'sweightx
property.private double
weighty
The builtGridBagConstraints
'sweighty
property.
-
Constructor Summary
Constructors Modifier Constructor Description GridBagBuilder(int gridx, int gridy)
GridBagBuilder(int gridx, int gridy, int gridwidth, int gridheight)
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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.GridBagConstraints
build()
int
getAnchor()
int
getFill()
int
getGridheight()
int
getGridwidth()
int
getGridx()
int
getGridy()
java.awt.Insets
getInsets()
int
getIpadx()
int
getIpady()
double
getWeightx()
double
getWeighty()
GridBagBuilder
setAnchor(int anchor)
GridBagBuilder
setFill(int fill)
GridBagBuilder
setInsets(java.awt.Insets insets)
GridBagBuilder
setIpadx(int ipadx)
GridBagBuilder
setIpady(int ipady)
GridBagBuilder
setWeightx(double weightx)
GridBagBuilder
setWeighty(double weighty)
-
-
-
Field Detail
-
gridx
private final int gridx
The builtGridBagConstraints
'sgridx
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 valueRELATIVE
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 builtGridBagConstraints
'sgridy
property.Specifies the cell at the top of the component's display area, where the topmost cell has
gridy=0
. The valueRELATIVE
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 builtGridBagConstraints
'sgridwidth
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 fromgridx
to the last cell in the row. UseRELATIVE
to specify that the component's display area will be fromgridx
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 builtGridBagConstraints
'sgridheight
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 fromgridy
to the last cell in the column. UseRELATIVE
to specify that the component's display area will be fromgridy
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 builtGridBagConstraints
'sweightx
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 builtGridBagConstraints
'sweighty
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 builtGridBagConstraints
'sanchor
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
, andNORTHWEST
. The orientation relative values are:PAGE_START
,PAGE_END
,LINE_START
,LINE_END
,FIRST_LINE_START
,FIRST_LINE_END
,LAST_LINE_START
andLAST_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
, andBELOW_BASELINE_TRAILING
. The default value isCENTER
.- See Also:
Object.clone()
,ComponentOrientation
-
fill
private int fill
The builtGridBagConstraints
'sfill
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 builtGridBagConstraints
'sinsets
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 builtGridBagConstraints
'sipadx
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 builtGridBagConstraints
'sipady
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 positiongridy
- y position- Since:
- 2018-11-30, v0.1.0
-
GridBagBuilder
public GridBagBuilder(int gridx, int gridy, int gridwidth, int gridheight)
- Parameters:
gridx
- x positiongridy
- y positiongridwidth
- number of cells occupied horizontallygridheight
- 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 positiongridy
- y positiongridwidth
- number of cells occupied horizontallygridheight
- number of cells occupied verticallyweightx
-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
-
-