fr.ove.palette
Class PaletteLayout

java.lang.Object
  extended byfr.ove.palette.PaletteLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2, java.io.Serializable

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

A layout manager for component to be laid out as a palette.
We can specified the number max of element allowed by row or by column according to the constraint chosen. For example PaletteLayout(PaletteLayout.COLUMN_CONSTRAINT, 3) will lay a container with the constraint that, for the most, we can have 3 components by column.
All components have the same size, which corresponds to the biggest "preferredWidth" and the biggest "preferredHeight".

Version:
1.0 17/09/1999
Author:
© 1999 DIRAT Laurent
See Also:
Serialized Form

Field Summary
static byte COLUMN_CONSTRAINT
          The specified number of elements correspond to the number max by row.
static byte ROW_CONSTRAINT
          The specified number of elements correspond to the number max by row.
 
Constructor Summary
PaletteLayout()
          The default constructor.
PaletteLayout(byte constraint, int nbElement)
          The constructor.
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
          Adds the specified component to the layout, using the specified constraint object.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Adds the specified component with the specified name to the layout.
 byte getConstraint()
          Returns the constraint put on the container laid out.
 float getLayoutAlignmentX(java.awt.Container target)
          Returns the alignment along the x axis.
 float getLayoutAlignmentY(java.awt.Container target)
          Returns the alignment along the y axis.
 int getNbElement()
          Returns the number max of element allowed by row (resp. column) with the ROW_CONSTRAINT (resp.
 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 parent)
          Lays out the container in the specified panel.
 java.awt.Dimension maximumLayoutSize(java.awt.Container target)
          Returns the maximum size of this component.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout.
 void setConstraint(byte constraint)
          Sets the constraint (ROW_CONSTRAINT or COLUMN_CONSTRAINT) for ordering the components in the container laid out.
 void setNbElement(int nbElement)
          Sets the number max of element allowed by row (resp. column) with the ROW_CONSTRAINT (resp.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROW_CONSTRAINT

public static final byte ROW_CONSTRAINT
The specified number of elements correspond to the number max by row.

See Also:
Constant Field Values

COLUMN_CONSTRAINT

public static final byte COLUMN_CONSTRAINT
The specified number of elements correspond to the number max by row.

See Also:
Constant Field Values
Constructor Detail

PaletteLayout

public PaletteLayout()
The default constructor. The default is a container laid out with 3, for the most, elements by row.


PaletteLayout

public PaletteLayout(byte constraint,
                     int nbElement)
The constructor.

Parameters:
nbElement - the number max of element allowed by row (resp. column) with the ROW_CONSTRAINT (resp. COLUMN_CONSTRAINT) constraint.
Method Detail

setConstraint

public void setConstraint(byte constraint)
Sets the constraint (ROW_CONSTRAINT or COLUMN_CONSTRAINT) for ordering the components in the container laid out.
After a call to this method, a call to validate on the container laid out should be performed to see the change take effect.

Parameters:
constraint - the constraint to set.

getConstraint

public byte getConstraint()
Returns the constraint put on the container laid out.


setNbElement

public void setNbElement(int nbElement)
Sets the number max of element allowed by row (resp. column) with the ROW_CONSTRAINT (resp. COLUMN_CONSTRAINT) constraint. After a call to this method, a call to validate on the container laid out should be performed to see the change take effect.

Parameters:
nbElement - the number of element allowed.

getNbElement

public int getNbElement()
Returns the number max of element allowed by row (resp. column) with the ROW_CONSTRAINT (resp. COLUMN_CONSTRAINT) constraint.


addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Adds the specified component with the specified name to the layout.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Parameters:
name - the component name
comp - the component to be added

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the container in the specified panel.

Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
parent - the component which needs to be laid out

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the component to be laid out
See Also:
preferredLayoutSize(java.awt.Container)

preferredLayoutSize

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

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the component to be laid out

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 ot be removed

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object constraints)
Adds the specified component to the layout, using the specified constraint object.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager2
Parameters:
comp - the component to be added
constraints - where/how the component is added to the layout.

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 the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Specified by:
getLayoutAlignmentX in interface java.awt.LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.Container target)
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

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


Copyright © 1999-2007 Universit?© de Nice Sophia-Antipolis, I3S, Ove SARL, DFKI and Universit?§t des Saarlandes. All Rights Reserved.