3.2.7 - View Layout - JdlViewLayout

John W. Campbell

3.2.7.1 Introduction

This class provides a means of calculating a layout and setting sizes and positions for a set of JdlView objects where several objects are to be fitted together to give a tidy looking layout. The basic look of the layout may be preserved and new positions and sizes automatically calculated if the size requirements of any of the individual objects are changed. The basic procedure requires that the layout is defined in terms of pairs of objects and/or previously defined pairs. Each newly defined pair may be in a horizontal or vertical direction. Minimum size requirements are given for the individual objects and recursive procedures are used to calculate the overall size requirement for the layout and to reset the sizes and positions of the individual objects.

Class, fields, constructor and methods:

Class Details
Accessible Fields
Constructor
Define Layout
Calculate Layout

3.2.7.2 Class Details

Package:
Jdl.JdlView;
Class name:
JdlViewLayout
Class definition:
public class JdlViewLayout
Extends:
Object
Implements:
none
Actions:
none

3.2.7.3 Accessible Fields

The following accessible fields have been defined:

public static final int VERTICAL_PAIR
Vertical pair.
public static final int HORIZONTAL_PAIR
Horizontal pair.
public static final int EXPAND_BOTH
Expand both children.
public static final int FIX_LEFT
Fix left hand child, expand right child.
public static final int FIX_TOP
Fix top child, expand bottom child.
public static final int FIX_RIGHT
Fix right hand child, expand left child.
public static final int FIX_BOTTOM
Fix bottom child, expand top child.
public static final int FIX_LEFT_LEFT
Left/left justify.
public static final int FIX_TOP_TOP
Top/top justify.
public static final int FIX_LEFT_RIGHT
Left/right justify.
public static final int FIX_TOP_BOTTOM
Top/bottom justify.
public static final int FIX_RIGHT_RIGHT
Right/right justify.
public static final int FIX_BOTTOM_BOTTOM
Bottom/bottom justify.
public final static int FREE
Free.

3.2.7.4 Constructor

3.2.7.4.1 Introduction

A single constructor is available.

Constructor:

Standard constructor

3.2.7.4.2 Standard constructor

Constructs a JdlViewLayout object for a program.

Constructor Definition:
public JdlViewLayout(Container c, boolean set)
Parameters List:
c
A container window onto which the objects are to be laid out (may be null if layout is only to be calculated).
set
If true set as well as calculate the layout. (ignored if 'c' is null).

3.2.7.5 Define Layout

3.2.7.5.1 Introduction

This section contains methods to add objects or pairs for the required layout.

Methods:

Add view object - addViewObject
Set horizontal pair - setHorizontalPair
Set vertical pair - setVerticalPair

3.2.7.5.2 Add view object - addViewObject

This method adds a view-object to the layout.

Method Definition:
public int addViewObject (String name, JdlViewObject vob)
Parameters List:
name
A name to identify the object when defining pairs.
vob
The JdlView object.

3.2.7.5.3 Set horizontal pair - setHorizontalPair

This method is used to give details of a horizontal pair of JdlView objects and/or other pairs required in the layout.

Method Definition:
public boolean setHorizontalPair(String name, String child1, String child2, int hjust, double pcnt)
Parameters List:
name
A name which will be used to identify this pair.
child1
The name of the first (left hand) child.
child2
The name of the second (right hand) child.
hjust
Horizontal justification required:
= 1 Expand both children EXPAND_BOTH
= 2 Fix left, expand right FIX_LEFT
= 3 Expand left, fix right FIX_RIGHT
= 4 Left/left justify FIX_LEFT_LEFT
= 5 Left/right justify FIX_LEFT_RIGHT
= 6 Right/right justify FIX_RIGHT_RIGHT
pcnt
An approximate percentage of the total width of the pair to be occupied by the left hand child if both children are expanded.

3.2.7.5.4 Set vertical pair - setVerticalPair

This method is used to give details of a vertical pair of JdlView objects and/or other pairs required in the layout.

Method Definition:
public boolean setVerticalPair(String name, String child1, String child2, int vjust, double pcnt)
Parameters List:
name
A name which will be used to identify this pair.
child1
The name of the first (top) child.
child2
The name of the second (bottom) child.
vjust
Vertical justification required:
= 1 Expand both children EXPAND_BOTH
= 2 Fix top, expand bottom FIX_TOP
= 3 Expand top, fix bottom FIX_BOTTOM
= 4 Top/top justify FIX_TOP_TOP
= 5 Top/Bottom justify FIX_TOP_BOTTOM
= 6 Bottom/bottom justify FIX_BOTTOM_BOTTOM
pcnt
An approximate percentage of the total height of the pair to be occupied by the top child if both children are expanded.

3.2.7.6 Calculate Layout

3.2.7.6.1 Introduction

This section as methods to calculate (and set) the required layout and to determine the required sizes and positions of individual JdlView objects.

Methods:

Set layout - setLayout
Get object size - getSingleLayoutSize
Get object position - getSingleLayoutPosition

3.2.7.6.2 Set layout - setLayout

This method calculates (and sets, if required) the layout given the name of the top level pair defined for the layout.

Method Definition:
public Dimension setLayout (String name)
Parameters List:
name
Name of the top level pair of objects/pairs.

3.2.7.6.3 Get object size - getSingleLayoutSize

This method returns the required size for a JdlView object after the layout has been calculated.

Method Definition:
public Dimension getSingleLayoutSize (JdlViewObject vobj)
Parameters List:
vobj
The JdlView object whose required size is to be found.

3.2.7.6.4 Get object position - getSingleLayoutPosition

This method returns the required position for a JdlView object after the layout has been calculated.

Method Definition:
public Point getSingleLayoutPosition (JdlViewObject vobj)
Parameters List:
vobj
The JdlView object whose required position is to be found.

⇑ Up 3   ⇑ Up 2   ⇑ Up 1   ⇑ Top of this