com.accountingenhancements.layouttools
Class GroupLayoutPanelFactory

java.lang.Object
  extended by com.accountingenhancements.layouttools.GroupLayoutPanelFactory

public class GroupLayoutPanelFactory
extends java.lang.Object

Create a group layout panel from the layout pattern defined in the layout array.
Each layout line represents a row. Comma's separate fields. Each field is assumed to be parallel with the same field position of the next line down unless brackets are used.
Each index represents a new line. Use square brackets to define groupings. You can name a grouping as long as the name ends with a pipe. This allows you to have a common grouping across multiple, unrelated lines. Unnamed groupings are all considered to belong to a different group each.
Exampe: Labels are parallel, Fields (1,4,5,8) are parallel and, because of named grouping, Field1 and Field8 are parallel, Field 3 and Field 9 are parallel.
Line 3 Fields (5,6,7) are in their own group.
layout(0)="\"Line 1\",[Group1|Field1,Field2,Field3]"
layout(1)="\"Line 2\",Field4"
layout(3)="\"Line 3\",[Field5,Field6,Field7]"
layout(4)="\"Line 4\",[Group1|Field8,Field9]"
Use dash - to leave an empty field position.
Quoted text will be turned into labels.
Greater than symbol > at start of field means right justify field.
This is only meaningful in the first entry of a parallel grouping.
While creating the HorizontalGroup and moving to the next column, the alignment of the first component determines the justification used in GroupLayout.createParallelGroup(int Justification).
Exclamations ! before fields mean suppress component description labels, after the field suppresses the component but keeps the label. If used, must be after the > justification symbol. If using curly brackets, must be before openint bracket
LinkSize: To link the size between multiple components, use the caret ^ and a case-insensitive direction of h, v, or b for Horizontal, Vertical, or Both, followed by a group name followed by the pipe |.
Note: If used, if must be after the right justify > symbol (if it exists) but before exclamation ! symbol (if it exists).
Example:
layout(0)="^vGrpA|{1},^vGrpA|{2}"
layout(1)="{3},^vGrpA|{4}"
Will group fields 1, 2, and 4 together and apply GroupLayout().linkSize(...,GroupLayout.VERTICAL) to them so that they are all the same height.
a component can belong to different vertical and horizontal groups.
layout(0)="^vGrp1|^hGrpA|{1},^vGrp1|^hGrpB|{2}"
layout(1)="^vGrp2|^hGrpA|{3},^bGrp2|^hGrpB|{4}"
Column 0 rows have same width and column 2 rows have same width. Row 1 columns have same height and row 2 columns have same height. But the column 1 width is not the save as the column 2 width and row 1 height is not the same as row 2 height.
LinkSize is usually used to control the size of bordered panels or buttons.
FieldSize: It is suggested that Open/Close parentheses can be used to override column widths of fields fieldName(20) -> fld.setColumns(20)
It is up your ConverStringToJComponent implementation to carry out this functionality. fieldName(20) would be handed to the converter as is.
Example:
First/Middle/Last .1............. .2............. .3.............
                Address .4...............................
                Address .5...............................
            City/St/Zip .6............. .7. .8........
                                Phone (9..)...-.... Gender .10...
layout(0)=">\"First/Middle/Last\",[0|!{1}(15),!{2}(15),!{3{(15)]"
layout(1)="{4}"
layout(2)="{5}"
layout(3)=">\"City/St/Zip\",[0|!{6},!{7},{8}]"
layout(4)="-,[1|{9},{10}]"
objectList(0)={null,null}; objectList(1)={JTextField,new JLabel("First Name")}
objectList(1)={JTextField,new JLabel("Middle Name")}; objectList(3)={JTextField,new JLabel("Last Name")}
objectList(4)={JTextField(),new JLabel("Address")}
objectList(5)={JTextField(),new JLabel("Address")}
objectList(6)={JTextField(),new JLabel("City")}; objectList(7)={JComboBox,new JLabel("State")}
objectList(8)={JTextField,new JLabel("State")}
objectList(9)={JTextField,new JLabel("Phone")}; objectList(8)={JComboBox, new JLabel("Gender")}


Constructor Summary
GroupLayoutPanelFactory()
          Unused since all methods are static
 
Method Summary
static org.jdesktop.layout.GroupLayout.Group addBranchToGroupLayout(org.jdesktop.layout.GroupLayout layout, BranchNode<javax.swing.JComponent> branch)
           
static org.jdesktop.layout.GroupLayout.Group addBranchToGroupLayout(org.jdesktop.layout.GroupLayout layout, BranchNode<javax.swing.JComponent> branch, java.lang.Boolean isHorizontal)
          BranchNode and LeafNode attributes BranchNode Attribute "groupType": "root" = trunk of tree "HorizontalParallel" = Horizontal Group starting point.
static Tree<javax.swing.JComponent> buildTreeFromStringArray(java.util.ArrayList<java.lang.String> layout, ConvertStringToJComponent converter, java.util.ArrayList supportParameters, java.util.ArrayList<javax.swing.JComponent[]> objectList, java.lang.Integer horizontalMin, java.lang.Integer horizontalPref, java.lang.Integer horizontalMax, java.lang.Integer verticalMin, java.lang.Integer verticalPref, java.lang.Integer verticalMax)
          Create a Tree of JComponents with which to build a GroupLayout structure
static javax.swing.JPanel createClusteredPanels(java.util.ArrayList<java.lang.String> layout, ConvertStringToJComponent converter, java.util.ArrayList supportParameters, PanelFromStringArrayParameters parameters, boolean createEtchedBorder)
           
static javax.swing.JPanel createClusteredPanels(java.util.ArrayList<java.lang.String> layout, ConvertStringToJComponent converter, java.util.ArrayList supportParameters, PanelFromStringArrayParameters parameters, javax.swing.border.Border border)
           
static javax.swing.JPanel createPanelFromStringArray(java.util.ArrayList<java.lang.String> layout, ConvertStringToJComponent converter, java.util.ArrayList supportParameters, java.util.ArrayList<javax.swing.JComponent[]> objectList, boolean autoCreateContainerGaps)
          Create a GroupLayout panel from a String Array
static javax.swing.JPanel createPanelFromStringArray(java.util.ArrayList<java.lang.String> layout, ConvertStringToJComponent converter, java.util.ArrayList supportParameters, java.util.ArrayList<javax.swing.JComponent[]> objectList, boolean autoCreateContainerGaps, java.lang.Integer horizontalPref, java.lang.Integer verticalPref)
          Create a GroupLayout panel from a String Array
static javax.swing.JPanel createPanelFromStringArray(java.util.ArrayList<java.lang.String> layout, ConvertStringToJComponent converter, java.util.ArrayList supportParameters, java.util.ArrayList<javax.swing.JComponent[]> objectList, boolean autoCreateContainerGaps, java.lang.Integer horizontalMin, java.lang.Integer horizontalPref, java.lang.Integer horizontalMax, java.lang.Integer verticalMin, java.lang.Integer verticalPref, java.lang.Integer verticalMax)
          Create a group layout panel from the layout pattern defined in the layout array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupLayoutPanelFactory

public GroupLayoutPanelFactory()
Unused since all methods are static

Method Detail

createClusteredPanels

public static javax.swing.JPanel createClusteredPanels(java.util.ArrayList<java.lang.String> layout,
                                                       ConvertStringToJComponent converter,
                                                       java.util.ArrayList supportParameters,
                                                       PanelFromStringArrayParameters parameters,
                                                       boolean createEtchedBorder)

createClusteredPanels

public static javax.swing.JPanel createClusteredPanels(java.util.ArrayList<java.lang.String> layout,
                                                       ConvertStringToJComponent converter,
                                                       java.util.ArrayList supportParameters,
                                                       PanelFromStringArrayParameters parameters,
                                                       javax.swing.border.Border border)

createPanelFromStringArray

public static javax.swing.JPanel createPanelFromStringArray(java.util.ArrayList<java.lang.String> layout,
                                                            ConvertStringToJComponent converter,
                                                            java.util.ArrayList supportParameters,
                                                            java.util.ArrayList<javax.swing.JComponent[]> objectList,
                                                            boolean autoCreateContainerGaps,
                                                            java.lang.Integer horizontalMin,
                                                            java.lang.Integer horizontalPref,
                                                            java.lang.Integer horizontalMax,
                                                            java.lang.Integer verticalMin,
                                                            java.lang.Integer verticalPref,
                                                            java.lang.Integer verticalMax)
Create a group layout panel from the layout pattern defined in the layout array.

Parameters:
layout - an ArrayList of Strings that defines the layout of the components
converter - n abstract for a user-created class that contains code that turns field descriptions into JComponents
supportParameters - a ArrayList of Objects that is handed to the converter class so that users can hand various variables and values to the converter.
objectList - a ArrayList of components that is handed to the converter class so that programmers can hand various extranious components to the converter. ConvertStringToJComponent.getComponentAndLabelSimple(..) uses this when converting curly bracketed numbers (indexes) to JComponents. It Expects objectList.get(index) to be an JComponent[] where objectList.get(index)[0]=component and objectList.get(index)[1]=JLabel("Component Description")
autoCreateContainerGaps - set true to have gaps between the components and the container walls.
horizontalMin - GroupLayout.Group size setting for components. set null for default.
horizontalPref - GroupLayout.Group size setting for components. set null for default.
horizontalMax - GroupLayout.Group size setting for components. set null for default.
verticalMin - GroupLayout.Group size setting for components. set null for default.
verticalPref - GroupLayout.Group size setting for components. set null for default.
verticalMax - GroupLayout.Group size setting for components. set null for default.
Returns:
a JPanel with all of the components loaded.

createPanelFromStringArray

public static javax.swing.JPanel createPanelFromStringArray(java.util.ArrayList<java.lang.String> layout,
                                                            ConvertStringToJComponent converter,
                                                            java.util.ArrayList supportParameters,
                                                            java.util.ArrayList<javax.swing.JComponent[]> objectList,
                                                            boolean autoCreateContainerGaps)
Create a GroupLayout panel from a String Array

Parameters:
layout - an ArrayList of Strings that defines the layout of the components
converter - n abstract for a user-created class that contains code that turns field descriptions into JComponents
supportParameters - a ArrayList of Objects that is handed to the converter class so that users can hand various variables and values to the converter.
objectList - a ArrayList of components that is handed to the converter class so that programmers can hand various extranious components to the converter. ConvertStringToJComponent.getComponentAndLabelSimple(..) uses this when converting curly bracketed numbers (indexes) to JComponents. It Expects objectList.get(index) to be an JComponent[] where objectList.get(index)[0]=component and objectList.get(index)[1]=JLabel("Component Description")
autoCreateContainerGaps - set true to have gaps between the components and the container walls.
Returns:
a Treel with all of the components loaded.

createPanelFromStringArray

public static javax.swing.JPanel createPanelFromStringArray(java.util.ArrayList<java.lang.String> layout,
                                                            ConvertStringToJComponent converter,
                                                            java.util.ArrayList supportParameters,
                                                            java.util.ArrayList<javax.swing.JComponent[]> objectList,
                                                            boolean autoCreateContainerGaps,
                                                            java.lang.Integer horizontalPref,
                                                            java.lang.Integer verticalPref)
Create a GroupLayout panel from a String Array

Parameters:
layout - an ArrayList of Strings that defines the layout of the components
converter - n abstract for a user-created class that contains code that turns field descriptions into JComponents
supportParameters - a ArrayList of Objects that is handed to the converter class so that users can hand various variables and values to the converter.
objectList - a ArrayList of components that is handed to the converter class so that programmers can hand various extranious components to the converter. ConvertStringToJComponent.getComponentAndLabelSimple(..) uses this when converting curly bracketed numbers (indexes) to JComponents. It Expects objectList.get(index) to be an JComponent[] where objectList.get(index)[0]=component and objectList.get(index)[1]=JLabel("Component Description")
autoCreateContainerGaps - set true to have gaps between the components and the container walls.
horizontalPref - GroupLayout.Group size setting for components. set null for default.
verticalPref - GroupLayout.Group size setting for components. set null for default.
Returns:
a Treel with all of the components loaded.

buildTreeFromStringArray

public static Tree<javax.swing.JComponent> buildTreeFromStringArray(java.util.ArrayList<java.lang.String> layout,
                                                                    ConvertStringToJComponent converter,
                                                                    java.util.ArrayList supportParameters,
                                                                    java.util.ArrayList<javax.swing.JComponent[]> objectList,
                                                                    java.lang.Integer horizontalMin,
                                                                    java.lang.Integer horizontalPref,
                                                                    java.lang.Integer horizontalMax,
                                                                    java.lang.Integer verticalMin,
                                                                    java.lang.Integer verticalPref,
                                                                    java.lang.Integer verticalMax)
Create a Tree of JComponents with which to build a GroupLayout structure

Parameters:
layout - an ArrayList of Strings that defines the layout of the components
converter - n abstract for a user-created class that contains code that turns field descriptions into JComponents
supportParameters - a ArrayList of Objects that is handed to the converter class so that users can hand various variables and values to the converter.
objectList - a ArrayList of components that is handed to the converter class so that programmers can hand various extranious components to the converter. ConvertStringToJComponent.getComponentAndLabelSimple(..) uses this when converting curly bracketed numbers (indexes) to JComponents. It Expects objectList.get(index) to be an JComponent[] where objectList.get(index)[0]=component and objectList.get(index)[1]=JLabel("Component Description")
horizontalMin - GroupLayout.Group size setting for components. set null for default.
horizontalPref - GroupLayout.Group size setting for components. set null for default.
horizontalMax - GroupLayout.Group size setting for components. set null for default.
verticalMin - GroupLayout.Group size setting for components. set null for default.
verticalPref - GroupLayout.Group size setting for components. set null for default.
verticalMax - GroupLayout.Group size setting for components. set null for default.
Returns:
a Treel with all of the components loaded.

addBranchToGroupLayout

public static org.jdesktop.layout.GroupLayout.Group addBranchToGroupLayout(org.jdesktop.layout.GroupLayout layout,
                                                                           BranchNode<javax.swing.JComponent> branch)

addBranchToGroupLayout

public static org.jdesktop.layout.GroupLayout.Group addBranchToGroupLayout(org.jdesktop.layout.GroupLayout layout,
                                                                           BranchNode<javax.swing.JComponent> branch,
                                                                           java.lang.Boolean isHorizontal)
BranchNode and LeafNode attributes BranchNode Attribute "groupType": "root" = trunk of tree "HorizontalParallel" = Horizontal Group starting point. The layout.setHorizontalGroup points to this group
"VerticalParallel" = Vertical Group starting point. The layout.setVerticalGroup points to this group
"Parallel" = a Parallel group.
"Sequential" = a Sequential group.
BranchNode Attribute "justification": expects an Integer return value isused when creating Parallel groups See GroupLayout.{LEADING, TRAILING, BASELINE, etc}. If non-existant defaults to LEADING for Horizontal, and BASELINE for Vertical.
Trunk BranchNode attribute "LinkSizeList" = HashMap of components that should be linked using GroupLayout.LinkSize(). If the Key of the HashMap begins with V| then vertical linking, H| then horizontal linking, B| then both. IE: Key="V|GroupBlaBla" will use layout.LinkSize(linkSizeList.get("V|GroupBlaBla").toArray(), GroupLayout.VERTICAL)