- java.lang.Object
-
- net.miginfocom.layout.IDEUtil
-
public class IDEUtil extends java.lang.ObjectThis class contains static methods to be used by IDE vendors to convert to and from String/API constraints.Note that
LayoutUtil.setDesignTime(ContainerWrapper, boolean)should be set totruefor this class' methods to work.
-
-
Field Summary
Fields Modifier and Type Field Description static UnitValueBASELINE_IDENTITYA direct reference to the corresponding value for predefined UnitValues inUnitValue.static UnitValueBOTTOMA direct reference to the corresponding value for predefined UnitValues inUnitValue.static UnitValueCENTERA direct reference to the corresponding value for predefined UnitValues inUnitValue.static UnitValueINFA direct reference to the corresponding value for predefined UnitValues inUnitValue.static UnitValueLABELA direct reference to the corresponding value for predefined UnitValues inUnitValue.static UnitValueLEADINGA direct reference to the corresponding value for predefined UnitValues inUnitValue.static UnitValueLEFTA direct reference to the corresponding value for predefined UnitValues inUnitValue.static UnitValueRIGHTA direct reference to the corresponding value for predefined UnitValues inUnitValue.static UnitValueTOPA direct reference to the corresponding value for predefined UnitValues inUnitValue.static UnitValueTRAILINGA direct reference to the corresponding value for predefined UnitValues inUnitValue.private static java.lang.String[]X_Y_STRINGSstatic UnitValueZEROA direct reference to the corresponding value for predefined UnitValues inUnitValue.
-
Constructor Summary
Constructors Constructor Description IDEUtil()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidaddComponentDimConstraintString(DimConstraint dc, java.lang.StringBuffer sb, boolean asAPI, boolean isHor, boolean noGrowAdd)Returns the a constraint string that can be re-parsed to be the exact same DimConstraint.private static voidaddRowDimConstraintString(DimConstraint dc, java.lang.StringBuffer sb, boolean asAPI)Adds the a constraint string that can be re-parsed to be the exact same DimConstraint.private static voidappendBoundSize(BoundSize size, java.lang.StringBuffer sb, boolean isHor, boolean asAPI)private static java.lang.StringfloatObjectToString(float f, boolean asAPI)private static java.lang.StringfloatToString(float f, boolean asAPI)Converts afloatto a string and is removing the ".0" if the float is an integer.private static java.lang.StringgetBS(BoundSize bs)private static java.lang.StringgetBS(BoundSize bs, boolean asAPI)static int[][]getColumnSizes(java.lang.Object parentContainer)Returns the sizes of the columns and gaps for a container.static java.lang.StringgetConstraintString(AC ac, boolean asAPI, boolean isCols)Returns the a constraint string that can be re-parsed to be the exact same AxisConstraint.static java.lang.StringgetConstraintString(CC cc, boolean asAPI)Returns the a constraint string that can be re-parsed to be the exact same LayoutConstraint.static java.lang.StringgetConstraintString(LC lc, boolean asAPI)Returns the a constraint string that can be re-parsed to be the exact same LayoutConstraint.static java.util.HashMap<java.lang.Object,int[]>getGridPositions(java.lang.Object parentContainer)Returns the grid cells that the components inparentContainerhas.java.lang.StringgetIDEUtilVersion()Returns the version of IDEUtilstatic int[][]getRowSizes(java.lang.Object parentContainer)Returns the sizes of the rows and gaps for a container.private static java.lang.StringgetUV(UnitValue uv)private static java.lang.StringgetUV(UnitValue uv, boolean asAPI)private static booleanisDialogInsets(UnitValue[] insets)private static booleanisPanelInsets(UnitValue[] insets)private static voidremoveTrailingSpace(java.lang.StringBuffer sb)
-
-
-
Field Detail
-
ZERO
public static final UnitValue ZERO
A direct reference to the corresponding value for predefined UnitValues inUnitValue.
-
TOP
public static final UnitValue TOP
A direct reference to the corresponding value for predefined UnitValues inUnitValue.
-
LEADING
public static final UnitValue LEADING
A direct reference to the corresponding value for predefined UnitValues inUnitValue.
-
LEFT
public static final UnitValue LEFT
A direct reference to the corresponding value for predefined UnitValues inUnitValue.
-
CENTER
public static final UnitValue CENTER
A direct reference to the corresponding value for predefined UnitValues inUnitValue.
-
TRAILING
public static final UnitValue TRAILING
A direct reference to the corresponding value for predefined UnitValues inUnitValue.
-
RIGHT
public static final UnitValue RIGHT
A direct reference to the corresponding value for predefined UnitValues inUnitValue.
-
BOTTOM
public static final UnitValue BOTTOM
A direct reference to the corresponding value for predefined UnitValues inUnitValue.
-
LABEL
public static final UnitValue LABEL
A direct reference to the corresponding value for predefined UnitValues inUnitValue.
-
INF
public static final UnitValue INF
A direct reference to the corresponding value for predefined UnitValues inUnitValue.
-
BASELINE_IDENTITY
public static final UnitValue BASELINE_IDENTITY
A direct reference to the corresponding value for predefined UnitValues inUnitValue.
-
X_Y_STRINGS
private static final java.lang.String[] X_Y_STRINGS
-
-
Method Detail
-
getIDEUtilVersion
public java.lang.String getIDEUtilVersion()
Returns the version of IDEUtil- Returns:
- The version.
-
getGridPositions
public static java.util.HashMap<java.lang.Object,int[]> getGridPositions(java.lang.Object parentContainer)
Returns the grid cells that the components inparentContainerhas.- Parameters:
parentContainer- The parent container. It is an object since MigLayout is GUI toolkit independent.- Returns:
- A new hashmap with the components mapped to an array [x, y, spanx, spany].
Dock components will always have x and y less than -30000 or more than 30000. This is since they are actually part of the grid, but on the outer edges.
Components that span the "rest of the row/column" have really large span values. Actually 30000-x or 30000-y.
Generally, the grid does not need to have the upper left at 0, 0. Though it normally does if you don't set the cells explicitly to other values. Rows and columns that are completely empty and that does not have an explicit row/column constraint will be totally disregarded.
-
getRowSizes
public static int[][] getRowSizes(java.lang.Object parentContainer)
Returns the sizes of the rows and gaps for a container. There will be two arrays returned [0] and [1].The first array will be the indexes of the rows where indexes that are less than 30000 or larger than 30000 is docking rows. There might be extra docking rows that aren't visible but they always have size 0. Non docking indexes will probably always be 0, 1, 2, 3, etc..
The second array is the sizes of the form:
[left inset][row size 1][gap 1][row size 2][gap 2][row size n][right inset].The returned sizes will be the ones calculated in the last layout cycle.
- Parameters:
parentContainer- The container to return the row sizes and gaps for. In Swing it will be aContainerand in SWT it will be a org.eclipse.swt.widgets.Composite.- Returns:
- The sizes or
nullifLayoutUtil.isDesignTime(ContainerWrapper)isfalseorparentContainerdoes not have a MigLayout layout manager. The returned sizes will be the ones calculated in the last layout cycle. - See Also:
LayoutUtil.isDesignTime(ContainerWrapper)
-
getColumnSizes
public static int[][] getColumnSizes(java.lang.Object parentContainer)
Returns the sizes of the columns and gaps for a container. There will be two arrays returned [0] and [1].The first array will be the indexes of the columns where indexes that are less than 30000 or larger than 30000 is docking columns. There might be extra docking columns that aren't visible but they always have size 0. Non docking indexes will probably always be 0, 1, 2, 3, etc..
The second array is the sizes of the form:
[top inset][column size 1][gap 1][column size 2][gap 2][column size n][bottom inset].The returned sizes will be the ones calculated in the last layout cycle.
- Parameters:
parentContainer- The container to return the column sizes and gaps for. In Swing it will be aContainerand in SWT it will be a org.eclipse.swt.widgets.Composite.- Returns:
- The sizes and indexes or
nullifLayoutUtil.isDesignTime(ContainerWrapper)isfalseorparentContainerdoes not have a MigLayout layout manager. The returned sizes will be the ones calculated in the last layout cycle. - See Also:
LayoutUtil.isDesignTime(ContainerWrapper)
-
getConstraintString
public static java.lang.String getConstraintString(AC ac, boolean asAPI, boolean isCols)
Returns the a constraint string that can be re-parsed to be the exact same AxisConstraint.- Parameters:
ac- The axis constraint to return as a constraint string.asAPI- If the returned string should be of API type (e.g. .flowX().gap("rel").align("right")) or as a String type (e.g. "flowx, gap rel, right").isCols- The the constraint should be returned for columns rather than rows.- Returns:
- A String. Never
null.
-
addRowDimConstraintString
private static void addRowDimConstraintString(DimConstraint dc, java.lang.StringBuffer sb, boolean asAPI)
Adds the a constraint string that can be re-parsed to be the exact same DimConstraint.- Parameters:
dc- The layout constraint to return as a constraint string.asAPI- If the returned string should be of API type (e.g. .flowX().gap("rel").align("right")) or as a String type (e.g. "flowx, gap rel, right").
-
addComponentDimConstraintString
private static void addComponentDimConstraintString(DimConstraint dc, java.lang.StringBuffer sb, boolean asAPI, boolean isHor, boolean noGrowAdd)
Returns the a constraint string that can be re-parsed to be the exact same DimConstraint.- Parameters:
dc- The layout constraint to return as a constraint string.asAPI- If the returned string should be of API type (e.g. .flowX().gap("rel").align("right")) or as a String type (e.g. "flowx, gap rel, right").isHor- The the DimConstraint is decoration something horizontal (column or x).noGrowAdd- Iftrueno grow constraints will be added.
-
appendBoundSize
private static void appendBoundSize(BoundSize size, java.lang.StringBuffer sb, boolean isHor, boolean asAPI)
-
getConstraintString
public static java.lang.String getConstraintString(CC cc, boolean asAPI)
Returns the a constraint string that can be re-parsed to be the exact same LayoutConstraint.- Parameters:
cc- The component constraint to return as a constraint string.asAPI- If the returned string should be of API type (e.g. .flowX().gap("rel").align("right")) or as a String type (e.g. "flowx, gap rel, right").- Returns:
- A String. Never
null.
-
getConstraintString
public static java.lang.String getConstraintString(LC lc, boolean asAPI)
Returns the a constraint string that can be re-parsed to be the exact same LayoutConstraint.- Parameters:
lc- The layout constraint to return as a constraint string.asAPI- If the returned string should be of API type (e.g. .flowX().gap("rel").align("right")) or as a String type (e.g. "flowx, gap rel, right").- Returns:
- A String. Never
null.
-
getUV
private static java.lang.String getUV(UnitValue uv)
-
getUV
private static java.lang.String getUV(UnitValue uv, boolean asAPI)
-
getBS
private static java.lang.String getBS(BoundSize bs)
-
getBS
private static java.lang.String getBS(BoundSize bs, boolean asAPI)
-
isDialogInsets
private static boolean isDialogInsets(UnitValue[] insets)
-
isPanelInsets
private static boolean isPanelInsets(UnitValue[] insets)
-
floatToString
private static java.lang.String floatToString(float f, boolean asAPI)Converts afloatto a string and is removing the ".0" if the float is an integer.- Parameters:
f- the float.- Returns:
fas a string. Nevernull.
-
floatObjectToString
private static java.lang.String floatObjectToString(float f, boolean asAPI)
-
removeTrailingSpace
private static void removeTrailingSpace(java.lang.StringBuffer sb)
-
-