org.nuiton.widget
Class GridFlowLayout

java.lang.Object
  extended by org.nuiton.widget.GridFlowLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2

public class GridFlowLayout
extends Object
implements LayoutManager2

Ce layout place les composants de gauche à droite ou de droite à gauche selon la valeur de Component.getComponentOrientation(). Si un composant n'a pas assez de place pour se mettre sur la ligne courant, il est mis sur la ligne suivante et les composants sont redimensionnés pour prendre le maximum de place disponible sur la ligne. Si le container est dans un JViewport (ou JScrollPane), ce layout essai de ne jamais faire apparaitre le ScrollBar horizontal.

Tous les composants ont la même taille.


Field Summary
protected  Map<Component,Object> positions
           
 
Constructor Summary
GridFlowLayout()
          GridFlowLayout constructor make a GridFlowLayout with default value (1) for gap
GridFlowLayout(int hgap, int vgap)
          GridFlowLayout constructor
 
Method Summary
 void addLayoutComponent(Component comp, Object constraints)
          Method addLayoutComponent
 void addLayoutComponent(String name, Component comp)
          Method addLayoutComponent
 Component[] computeOrder(Component[] components)
          Method []
protected  int getComponentVisibleCount(Container parent)
          Method getComponentVisibleCount
 Number getConstraints(Component comp)
          Method getConstraints
 int getHgap()
          Gets the horizontal gap between components.
 float getLayoutAlignmentX(Container target)
          Method getLayoutAlignmentX
 float getLayoutAlignmentY(Container target)
          Method getLayoutAlignmentY
protected  Dimension getMaxWidthHeight(Container parent)
          Method getMaxWidthHeight
protected  Dimension getMinWidthHeight(Container parent)
          Method getMinWidthHeight
 int getVgap()
          Gets the vertical gap between components.
 void invalidateLayout(Container target)
          Method invalidateLayout
 void layoutContainer(Container parent)
          Method layoutContainer
static void main(String[] args)
           
 Dimension maximumLayoutSize(Container target)
          Method maximumLayoutSize
 Dimension minimumLayoutSize(Container parent)
          Method minimumLayoutSize
 Dimension preferredLayoutSize(Container parent)
          Method preferredLayoutSize
 void removeLayoutComponent(Component comp)
          Method removeLayoutComponent
 void setConstraints(Component comp, Number constraints)
          Method setConstraints
 void setHgap(int hgap)
          Sets the horizontal gap between components.
 void setVgap(int vgap)
          Sets the vertical gap between components.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

positions

protected Map<Component,Object> positions
Constructor Detail

GridFlowLayout

public GridFlowLayout()
GridFlowLayout constructor make a GridFlowLayout with default value (1) for gap


GridFlowLayout

public GridFlowLayout(int hgap,
                      int vgap)
GridFlowLayout constructor

Parameters:
hgap - the horizontal gap between two components
vgap - the vertical gap between two components
Method Detail

getHgap

public int getHgap()
Gets the horizontal gap between components.

Returns:
the horizontal gap between components
See Also:
setHgap(int)

setHgap

public void setHgap(int hgap)
Sets the horizontal gap between components.

Parameters:
hgap - the horizontal gap between components
See Also:
getHgap()

getVgap

public int getVgap()
Gets the vertical gap between components.

Returns:
the vertical gap between components
See Also:
setVgap(int)

setVgap

public void setVgap(int vgap)
Sets the vertical gap between components.

Parameters:
vgap - the vertical gap between components
See Also:
getVgap()

addLayoutComponent

public void addLayoutComponent(Component comp,
                               Object constraints)
Method addLayoutComponent

Specified by:
addLayoutComponent in interface LayoutManager2
Parameters:
comp - the component to add
constraints - a constraint which is a Number (position)

setConstraints

public void setConstraints(Component comp,
                           Number constraints)
Method setConstraints

Parameters:
comp - the compoenent
constraints -

getConstraints

public Number getConstraints(Component comp)
Method getConstraints

Parameters:
comp -
Returns:
a number that corresponding to the constraint

getLayoutAlignmentX

public float getLayoutAlignmentX(Container target)
Method getLayoutAlignmentX

Specified by:
getLayoutAlignmentX in interface LayoutManager2
Parameters:
target -
Returns:
the X layout alignement

getLayoutAlignmentY

public float getLayoutAlignmentY(Container target)
Method getLayoutAlignmentY

Specified by:
getLayoutAlignmentY in interface LayoutManager2
Parameters:
target -
Returns:
the Y layout alignement

invalidateLayout

public void invalidateLayout(Container target)
Method invalidateLayout

Specified by:
invalidateLayout in interface LayoutManager2
Parameters:
target -

addLayoutComponent

public void addLayoutComponent(String name,
                               Component comp)
Method addLayoutComponent

Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
name -
comp -

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Method minimumLayoutSize

Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
parent -
Returns:
the minimum dimension of the layout

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Method preferredLayoutSize

Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
parent -
Returns:
the preferred dimension of the layout

maximumLayoutSize

public Dimension maximumLayoutSize(Container target)
Method maximumLayoutSize

Specified by:
maximumLayoutSize in interface LayoutManager2
Parameters:
target -
Returns:
the max dimension of the layout

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Method removeLayoutComponent

Specified by:
removeLayoutComponent in interface LayoutManager
Parameters:
comp -

layoutContainer

public void layoutContainer(Container parent)
Method layoutContainer

Specified by:
layoutContainer in interface LayoutManager
Parameters:
parent -

getComponentVisibleCount

protected int getComponentVisibleCount(Container parent)
Method getComponentVisibleCount

Parameters:
parent -
Returns:
an integer that corresponding to the number of visible components

getMaxWidthHeight

protected Dimension getMaxWidthHeight(Container parent)
Method getMaxWidthHeight

Parameters:
parent -
Returns:
the max size

getMinWidthHeight

protected Dimension getMinWidthHeight(Container parent)
Method getMinWidthHeight

Parameters:
parent -
Returns:
the dimension of this layout

computeOrder

public Component[] computeOrder(Component[] components)
Method []

Parameters:
components -
Returns:
une tablean de composants contenus dans le layout

main

public static void main(String[] args)


Copyright © 2004-2010 CodeLutin. All Rights Reserved.