org.openbp.swing.components.treetable.resize
Class ColumnSizeConstraint

java.lang.Object
  extended by org.openbp.swing.components.treetable.resize.ColumnSizeConstraint
Direct Known Subclasses:
FullVisibleConstraint, RatioConstraint

public class ColumnSizeConstraint
extends java.lang.Object

Constraint for the column width. Each column get the preferred width of the component with the maximal width.

Author:
Baumgartner Michael

Field Summary
protected  int absoluteMinSize
          The absolute minimal width of a column.
protected  int[][] columnSizes
          Hold the mix/max/prefered sizes for each column.
protected static int MAX
          Index for max width.
protected static int MIN
          Index for min width.
protected  int[] minSizeOfColumns
          Minimal size of the columns.
protected static int PREFERRED
          Index for preferred width.
protected  int treeColumnMaxWidth
          Max width of tree column.
 
Constructor Summary
ColumnSizeConstraint()
          Constructor.
 
Method Summary
 void addMaxSizeForColumn(int column, double maxValue)
          Add a maximal width for a column
 void adjustMaximalWidthOfColumn(JTreeTable treetable)
          Update the max width of column if they are set.
 void adjustPreferredToWidth(JTreeTable treetable)
          Adjust the prefered width of all columns to the width of the whole tree table.
 void calculateColumnSizes(JTreeTable treetable)
          Calculates the size of each column in the tree table.
 int determineMaxColumnWidth(JTreeTable treetable, int column)
          Determines the maximum width of the tree column according to the text displayed.
 int determineMaxTreeColumnWidth(JTreeTable treetable)
          Determines the maximum width of the tree column according to the text displayed.
 int getAbsoluteMinimum()
          Get the absolute minimal widht of all columns.
 int getMaxWidthOfColumn(int column)
          Get the maximal widht of the column
 int getMinWidthOfColumn(int column)
          Get the minimal width of the column
 int getPreferredWidthOfColumn(int column)
          Get the preferred widht of the column
 boolean isRecalculateNeeded(JTreeTable treetable)
          Determine if the preferred width of the columns needs to be re-calculated or not.
 void setAboluteMinimun(int minSize)
          Set the absolute minimal width of all columns.
protected  void setColumnWidth(int type, int column, int width)
          Set a width for a column.
 void setMinimumOfColumn(int columnWidth, int column, JTreeTable treetable)
          Set the minimal width of a column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

absoluteMinSize

protected int absoluteMinSize
The absolute minimal width of a column.


MAX

protected static final int MAX
Index for max width.

See Also:
Constant Field Values

MIN

protected static final int MIN
Index for min width.

See Also:
Constant Field Values

PREFERRED

protected static final int PREFERRED
Index for preferred width.

See Also:
Constant Field Values

columnSizes

protected int[][] columnSizes
Hold the mix/max/prefered sizes for each column.


minSizeOfColumns

protected int[] minSizeOfColumns
Minimal size of the columns.


treeColumnMaxWidth

protected int treeColumnMaxWidth
Max width of tree column.

Constructor Detail

ColumnSizeConstraint

public ColumnSizeConstraint()
Constructor.

Method Detail

calculateColumnSizes

public void calculateColumnSizes(JTreeTable treetable)
Calculates the size of each column in the tree table. The results can be queried by the getMinWidthOfColumn(int), getMaxWidthOfColumn(int) and getPreferredWidthOfColumn(int). The sizes don't change until the method is re-executed.

Parameters:
treetable - The treetable whose columns are to be resized

adjustPreferredToWidth

public void adjustPreferredToWidth(JTreeTable treetable)
Adjust the prefered width of all columns to the width of the whole tree table.

Parameters:
treetable - The treetable whose columns are to be resized

adjustMaximalWidthOfColumn

public void adjustMaximalWidthOfColumn(JTreeTable treetable)
Update the max width of column if they are set.

Parameters:
treetable - The tree table

isRecalculateNeeded

public boolean isRecalculateNeeded(JTreeTable treetable)
Determine if the preferred width of the columns needs to be re-calculated or not. Only if the width of the tree table has been changed, the values must be adjusted.

Parameters:
treetable - The tree table
Returns:
true A recalculate must be executed. false There is no need to recalculate the preferred width.

getMinWidthOfColumn

public int getMinWidthOfColumn(int column)
Get the minimal width of the column

Parameters:
column - The column
Returns:
the minimal width

getMaxWidthOfColumn

public int getMaxWidthOfColumn(int column)
Get the maximal widht of the column

Parameters:
column - The column
Returns:
the maximal width

getPreferredWidthOfColumn

public int getPreferredWidthOfColumn(int column)
Get the preferred widht of the column

Parameters:
column - The column
Returns:
the maximal width

setColumnWidth

protected void setColumnWidth(int type,
                              int column,
                              int width)
Set a width for a column.

Parameters:
type - The type to set MAX, MIN or PREFERRED
column - The column to set
width - The width to set

setAboluteMinimun

public void setAboluteMinimun(int minSize)
Set the absolute minimal width of all columns. The columns can not be smaller than this.

Parameters:
minSize - the width

getAbsoluteMinimum

public int getAbsoluteMinimum()
Get the absolute minimal widht of all columns.

Returns:
the width

setMinimumOfColumn

public void setMinimumOfColumn(int columnWidth,
                               int column,
                               JTreeTable treetable)
Set the minimal width of a column. If the width is less than the absolute minimal, then the absolute is set.

Parameters:
columnWidth - The minimal width
column - The index of the column
treetable - The treetable

determineMaxColumnWidth

public int determineMaxColumnWidth(JTreeTable treetable,
                                   int column)
Determines the maximum width of the tree column according to the text displayed.

Parameters:
treetable - The treetable
column - The index of the column
Returns:
The maximum width or 0 if it cannot be determined yet

determineMaxTreeColumnWidth

public int determineMaxTreeColumnWidth(JTreeTable treetable)
Determines the maximum width of the tree column according to the text displayed.

Parameters:
treetable - The treetable
Returns:
The maximum width or 0 if it cannot be determined yet

addMaxSizeForColumn

public void addMaxSizeForColumn(int column,
                                double maxValue)
Add a maximal width for a column

Parameters:
column - The column for that the maximal width is set
maxValue - The maximal value wherea 1.0 means the column can be as width as the tree table and 0.5 means the column can be maximal half as width as the tree table.


Copyright © 2011. All Rights Reserved.