Eclipse Draw2d
2.1

org.eclipse.draw2d
Class AbstractHintLayout

java.lang.Object
  |
  +--org.eclipse.draw2d.AbstractLayout
        |
        +--org.eclipse.draw2d.AbstractHintLayout
All Implemented Interfaces:
LayoutManager
Direct Known Subclasses:
BorderLayout, FlowLayout, ScrollPaneLayout, StackLayout, ToolbarLayout, ViewportLayout

public abstract class AbstractHintLayout
extends AbstractLayout

The foundation for layout managers which are sensitive to width and/or height hints. This class will cache preferred and minimum sizes for a given set of hints. If the hints change in a meaningful way, the cached size is thrown out and redetermined.

Subclasses may be sensitive to one or both hints. By default, this class assumes both hints are important. Subclasses may override this behavior in isSensitiveHorizontally(IFigure) and isSensitiveVertically(IFigure). At least one of these method should return true. Created on :Sep 30, 2002

Since:
2.0

Field Summary
 
Fields inherited from class org.eclipse.draw2d.AbstractLayout
preferredSize
 
Constructor Summary
AbstractHintLayout()
           
 
Method Summary
protected  Dimension calculateMinimumSize(IFigure container, int wHint, int hHint)
          Calculates the minimum size using the given width and height hints.
 Dimension getMinimumSize(IFigure container, int w, int h)
          Returns the minimum size of the given figure.
 Dimension getPreferredSize(IFigure container, int w, int h)
          Returns the preferred size of the given figure, using width and height hints.
 void invalidate()
          Extends the superclass implementation to flush the cached minimum size.
protected  boolean isSensitiveHorizontally(IFigure container)
          Returns whether this layout manager is sensitive to changes in the horizontal hint.
protected  boolean isSensitiveVertically(IFigure container)
          Returns whether this layout manager is sensitive to changes in the vertical hint.
 
Methods inherited from class org.eclipse.draw2d.AbstractLayout
calculatePreferredSize, calculatePreferredSize, getBorderPreferredSize, getConstraint, getMinimumSize, getPreferredSize, invalidate, remove, setConstraint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.draw2d.LayoutManager
layout
 

Constructor Detail

AbstractHintLayout

public AbstractHintLayout()
Method Detail

calculateMinimumSize

protected Dimension calculateMinimumSize(IFigure container,
                                         int wHint,
                                         int hHint)
Calculates the minimum size using the given width and height hints. This method is called from getMinimumSize(IFigure, int, int) whenever the cached minimum size has been flushed.

By default, this method just calls getPreferredSize(IFigure, int, int), meaning minimum and preferres sizes will be the same unless this method is overridden.

Parameters:
container - the Figure on which this layout is installed
wHint - the width hint
hHint - the height hint
Returns:
the layout's minimum size

getMinimumSize

public Dimension getMinimumSize(IFigure container,
                                int w,
                                int h)
Description copied from interface: LayoutManager
Returns the minimum size of the given figure.

Specified by:
getMinimumSize in interface LayoutManager
Overrides:
getMinimumSize in class AbstractLayout
See Also:
LayoutManager.getMinimumSize(IFigure, int, int)

getPreferredSize

public final Dimension getPreferredSize(IFigure container,
                                        int w,
                                        int h)
Description copied from class: AbstractLayout
Returns the preferred size of the given figure, using width and height hints. If the preferred size is cached, that size is returned. Otherwise, AbstractLayout.calculatePreferredSize(IFigure, int, int) is called.

Specified by:
getPreferredSize in interface LayoutManager
Overrides:
getPreferredSize in class AbstractLayout
Parameters:
container - The figure
w - The width hint
h - The height hint
Returns:
The preferred size
See Also:
LayoutManager.getPreferredSize(IFigure, int, int)

invalidate

public void invalidate()
Extends the superclass implementation to flush the cached minimum size.

Specified by:
invalidate in interface LayoutManager
Overrides:
invalidate in class AbstractLayout
See Also:
LayoutManager.invalidate()

isSensitiveHorizontally

protected boolean isSensitiveHorizontally(IFigure container)
Returns whether this layout manager is sensitive to changes in the horizontal hint. By default, this method returns true.

Parameters:
container - the layout's container
Returns:
true if this layout is sensite to horizontal hint changes

isSensitiveVertically

protected boolean isSensitiveVertically(IFigure container)
Returns whether this layout manager is sensitive to changes in the vertical hint. By default, this method returns true.

Parameters:
container - the layout's container
Returns:
true if this layout is sensite to vertical hint changes

Eclipse Draw2d
2.1

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.