gui.layout
Class HIGLayout

java.lang.Object
  extended bygui.layout.HIGLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2, java.io.Serializable

public class HIGLayout
extends java.lang.Object
implements java.awt.LayoutManager2, java.io.Serializable

Layout manager based on idea of design grid. For description please see tutorial included in download bundle.

Version:
1.0 1/19/2002
Author:
Daniel Michalik (dmi@autel.cz), Romano Caserta (caserta@disy.net), Frank Behrens (frank@pinky.sax.de), Sven Behrens (behrens@disy.net) Alberto Ricart (aricart@smartsoft.com), Peter Reilly (Peter.Reilly@marconi.com)
See Also:
cz.autel.dmi.HIGConstraints, Serialized Form

Field Summary
private  int[] cacheColumnsX
           
private  java.awt.Dimension cacheMinimumLayoutSize
           
private  java.awt.Dimension cachePreferredLayoutSize
           
private  int[] cacheRowsY
           
private  java.util.ArrayList[] colComponents
           
private  int colCount
           
private  int[] colWidths
           
private  java.util.HashMap components
           
private  int[] heightenWeights
           
private  int heightenWeightsSum
           
private  int invisible
           
private  int[] preferredHeights
           
private  int[] preferredWidths
           
private  java.util.ArrayList[] rowComponents
           
private  int rowCount
           
private  int[] rowHeights
           
private  int[] widenWeights
           
private  int widenWeightsSum
           
 
Constructor Summary
HIGLayout(int[] widths, int[] heights)
          Construct a new layout object.
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
          Adds the specified component to the layout, using the HIGConstraints constraint object.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Deprecated. replaced by addLayoutComponent(Component, Object). Throws UnsupportedOperationException.
private  int[] calcMinHeights()
           
private  int[] calcMinWidths()
           
private  int[] calcPreferredHeights()
           
private  int[] calcPreferredWidths()
           
private  void distributeSizeDifference(int desiredLength, int[] lengths, int[] minLengths, int[] weights, int weightSum)
           
(package private)  int[] getColumnsX(int targetWidth, java.awt.Insets insets)
          returns array of x-coordinates of columns.
 float getLayoutAlignmentX(java.awt.Container target)
          Returns 0.
 float getLayoutAlignmentY(java.awt.Container target)
          Returns 0.
(package private)  int[] getRowsY(int targetHeight, java.awt.Insets insets)
          returns array of y-coordinates of rows.
 void invalidateLayout(java.awt.Container target)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
 void layoutContainer(java.awt.Container target)
           
 java.awt.Dimension maximumLayoutSize(java.awt.Container target)
          Returns the maximum size of this component.
 java.awt.Dimension minimumLayoutSize(java.awt.Container target)
           
 java.awt.Dimension preferredLayoutSize(java.awt.Container target)
          Calculates the preferred size dimensions for the specified container given the components in the specified parent container.
private  java.lang.Object reallocArray(java.lang.Object src, int newSize)
           
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout.
 void setColumnWeight(int col, int weight)
          Sets weight of specified column.
 void setColumnWidth(int col, int width)
          Sets column width, realloc arrays if there is need.
 void setPreferredColumnWidth(int col, int width)
          Sets preferred width of specified column.
 void setPreferredRowHeight(int row, int height)
          Sets preferred height of specified row.
 void setRowHeight(int row, int height)
          Sets row height, realloc arrays if there is need.
 void setRowWeight(int row, int weight)
          Sets weight of specified row.
private  void solveCycles(int[] g, int[] lengths)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colWidths

private int[] colWidths

rowHeights

private int[] rowHeights

colCount

private int colCount

rowCount

private int rowCount

colComponents

private java.util.ArrayList[] colComponents

rowComponents

private java.util.ArrayList[] rowComponents

widenWeights

private int[] widenWeights

heightenWeights

private int[] heightenWeights

preferredWidths

private int[] preferredWidths

preferredHeights

private int[] preferredHeights

widenWeightsSum

private int widenWeightsSum

heightenWeightsSum

private int heightenWeightsSum

invisible

private final int invisible
See Also:
Constant Field Values

components

private java.util.HashMap components

cacheColumnsX

private int[] cacheColumnsX

cacheRowsY

private int[] cacheRowsY

cachePreferredLayoutSize

private java.awt.Dimension cachePreferredLayoutSize

cacheMinimumLayoutSize

private java.awt.Dimension cacheMinimumLayoutSize
Constructor Detail

HIGLayout

public HIGLayout(int[] widths,
                 int[] heights)
Construct a new layout object. Length of passed arrays define number of columns and number of rows. Each width or height can be less then 0, equal 0 or greater then 0. Passed arrays defines design grid - sizes and dependences between columns and rows. For details see tutorial.

Parameters:
widths - array of column widths.
heights - array of row heights.
Method Detail

reallocArray

private java.lang.Object reallocArray(java.lang.Object src,
                                      int newSize)
Since:
0.97

setColumnWidth

public void setColumnWidth(int col,
                           int width)
Sets column width, realloc arrays if there is need.

Since:
0.97

setRowHeight

public void setRowHeight(int row,
                         int height)
Sets row height, realloc arrays if there is need.

Since:
0.97

setPreferredColumnWidth

public void setPreferredColumnWidth(int col,
                                    int width)
Sets preferred width of specified column.

Parameters:
col - index of column. Index must be > 0.
width - the width to use in pixels
Since:
1.0

setPreferredRowHeight

public void setPreferredRowHeight(int row,
                                  int height)
Sets preferred height of specified row. of difference when resizing.

Parameters:
row - index of row. Index must be > 0.
height - the height in pixels
Since:
1.0

setColumnWeight

public void setColumnWeight(int col,
                            int weight)
Sets weight of specified column. Weight determines distribution of difference when resizing.

Parameters:
col - index of column. Index must be > 0.

setRowWeight

public void setRowWeight(int row,
                         int weight)
Sets weight of specified row. Weight determines distribution of difference when resizing.

Parameters:
row - index of row. Index must be > 0.

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Deprecated. replaced by addLayoutComponent(Component, Object). Throws UnsupportedOperationException.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Parameters:
comp - the component to be removed

solveCycles

private void solveCycles(int[] g,
                         int[] lengths)

calcMinWidths

private int[] calcMinWidths()

calcMinHeights

private int[] calcMinHeights()

calcPreferredWidths

private int[] calcPreferredWidths()

calcPreferredHeights

private int[] calcPreferredHeights()

distributeSizeDifference

private void distributeSizeDifference(int desiredLength,
                                      int[] lengths,
                                      int[] minLengths,
                                      int[] weights,
                                      int weightSum)

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container target)
Calculates the preferred size dimensions for the specified container given the components in the specified parent container.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
See Also:
minimumLayoutSize(java.awt.Container)

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container target)
Specified by:
minimumLayoutSize in interface java.awt.LayoutManager

getColumnsX

int[] getColumnsX(int targetWidth,
                  java.awt.Insets insets)
returns array of x-coordinates of columns. First coordinate is stored in x[1] Reference to this array is cached, so data should not be modified.


getRowsY

int[] getRowsY(int targetHeight,
               java.awt.Insets insets)
returns array of y-coordinates of rows. First coordinate is stored in y[1]. Reference to this array is cached, so data should not be modified.


layoutContainer

public void layoutContainer(java.awt.Container target)
Specified by:
layoutContainer in interface java.awt.LayoutManager

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object constraints)
Adds the specified component to the layout, using the HIGConstraints constraint object. Constraints object is copied so passed instance can be safely modifed.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager2
Parameters:
comp - the component to be added
See Also:
cz.autel.dmi.HIGConstraints

maximumLayoutSize

public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
Returns the maximum size of this component.

Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2
See Also:
Component.getMinimumSize(), Component.getPreferredSize(), LayoutManager

getLayoutAlignmentX

public float getLayoutAlignmentX(java.awt.Container target)
Returns 0.

Specified by:
getLayoutAlignmentX in interface java.awt.LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.Container target)
Returns 0.

Specified by:
getLayoutAlignmentY in interface java.awt.LayoutManager2

invalidateLayout

public void invalidateLayout(java.awt.Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

Specified by:
invalidateLayout in interface java.awt.LayoutManager2