uk.co.ist.mwt
Class ClipLayout

java.lang.Object
  |
  +--uk.co.ist.mwt.ClipLayout

public class ClipLayout
extends java.lang.Object
implements java.awt.LayoutManager, ScrollConstants, java.io.Serializable

A ClipLayout is used to lay out a Panel contained in a ScrolledPanel; this Panel is used as a clipping window by the ScrolledPanel. It is not really for use outside this package, but has been made public in case someone finds a use for it... NB. only the first child is used; all others are disregarded.

See Also:
Serialized Form

Fields inherited from interface uk.co.ist.mwt.ScrollConstants
kEast, kFill, kNorth, kNorthEast, kNorthWest, kSouth, kSouthEast, kSouthWest, kWest
 
Constructor Summary
ClipLayout()
           
 
Method Summary
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Adds the specified component with the specified name to the layout.
 int getChildPlacement()
          Gets the placement of the child for when the size of the child is smaller than the parent container.
 java.awt.Scrollbar getHSB()
          Gets the horizontal scroll bar for this clipping layout.
 java.awt.Scrollbar getVSB()
          Gets the vertical scroll bar for this clipping layout.
 int getXOffset()
          Gets the X offset
 int getYOffset()
          Gets the Y offset
protected  void handleSmallChildCase(java.awt.Dimension childSize, java.awt.Dimension mySize)
          Handle the layout when the child component is smaller than the parent container.
 boolean hsbNeeded(java.awt.Container clipWindow, java.awt.Dimension pSz)
          Function to see if the horizontal scroll bar will be needed (eg.
 void layoutContainer(java.awt.Container parent)
          Lays out the container .
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Calculates the minimum dimensions for the specified panel given the components in the specified parent container.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculates the preferred 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 scrollLeft(int delta)
          Tell the clipping region to scroll (pan) left by a certain increment.
 void scrollUp(int delta)
          Tell the clipping region to scroll (pan) up by a certain increment.
 void setChildPlacement(int newPlacement)
          Sets the placement of the child for when the size of the child is smaller than the parent container.
 void setHSB(java.awt.Scrollbar hsb)
          Sets the horizontal scroll bar for this clipping layout.
 void setVSB(java.awt.Scrollbar vsb)
          Sets the vertical scroll bar for this clipping layout.
 void setXOffset(int newX)
          Sets the X offset; newX must be in the range 0..100, where 0 means that the child's LHS is at the LHS of the clipping window, and 100 means that the child's RHS is at the RHS of the clipping window
 void setYOffset(int newY)
          Sets the Y offset; newY must be in the range 0..100, where 0 means that the child's top is at the top of the clipping window, and 100 means that the child's bottom is at the bottom of the clipping window
protected  void updateChild(java.awt.Container parent)
          Update the current work area to match the children belonging to the clip window parent passed in
 boolean vsbNeeded(java.awt.Container clipWindow, java.awt.Dimension pSz)
          Function to see if the vertical scroll bar will be needed (eg.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClipLayout

public ClipLayout()
Method Detail

setChildPlacement

public void setChildPlacement(int newPlacement)
Sets the placement of the child for when the size of the child is smaller than the parent container.

getChildPlacement

public int getChildPlacement()
Gets the placement of the child for when the size of the child is smaller than the parent container.

setXOffset

public void setXOffset(int newX)
Sets the X offset; newX must be in the range 0..100, where 0 means that the child's LHS is at the LHS of the clipping window, and 100 means that the child's RHS is at the RHS of the clipping window
Parameters:
newX - the new value
See Also:
getXOffset(), setYOffset(int), getYOffset(), scrollUp(int), scrollLeft(int)

getXOffset

public int getXOffset()
Gets the X offset
See Also:
setXOffset(int)

setYOffset

public void setYOffset(int newY)
Sets the Y offset; newY must be in the range 0..100, where 0 means that the child's top is at the top of the clipping window, and 100 means that the child's bottom is at the bottom of the clipping window
Parameters:
newY - the new value
See Also:
getYOffset(), setXOffset(int), getXOffset(), scrollUp(int), scrollLeft(int)

getYOffset

public int getYOffset()
Gets the Y offset
See Also:
setYOffset(int)

scrollUp

public void scrollUp(int delta)
Tell the clipping region to scroll (pan) up by a certain increment. The allowable offsets are 0..100, and this is added to the current vertical offset. If the resulting value is out of range, it is cropped to the nearest bound.
Parameters:
delta - the amount by which to pan. Can be negative.
See Also:
setXOffset(int), setYOffset(int), scrollLeft(int)

scrollLeft

public void scrollLeft(int delta)
Tell the clipping region to scroll (pan) left by a certain increment. The allowable offsets are 0..100, and this is added to the current horizontal offset. If the resulting value is out of range, it is cropped to the nearest bound.
Parameters:
delta - the amount by which to pan. Can be negative.
See Also:
setXOffset(int), setYOffset(int), scrollUp(int)

setHSB

public void setHSB(java.awt.Scrollbar hsb)
Sets the horizontal scroll bar for this clipping layout. This is used to set the page increment to appropriate values, and if left as the default null will cause no problems.
Parameters:
vsb - the new horizontal scroll bar
See Also:
getHSB()

getHSB

public java.awt.Scrollbar getHSB()
Gets the horizontal scroll bar for this clipping layout.
See Also:
setHSB(java.awt.Scrollbar)

setVSB

public void setVSB(java.awt.Scrollbar vsb)
Sets the vertical scroll bar for this clipping layout. This is used to set the page increment to appropriate values, and if left as the default null will cause no problems.
Parameters:
vsb - the new vertical scroll bar
See Also:
getVSB()

getVSB

public java.awt.Scrollbar getVSB()
Gets the vertical scroll bar for this clipping layout.
See Also:
setVSB(java.awt.Scrollbar)

updateChild

protected void updateChild(java.awt.Container parent)
Update the current work area to match the children belonging to the clip window parent passed in
Parameters:
parent - the parent container to which this layout is attached

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Calculates the preferred 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
See Also:
minimumLayoutSize(java.awt.Container)

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Calculates the minimum 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)

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the container .
Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
parent - the component which needs to be laid out

handleSmallChildCase

protected void handleSmallChildCase(java.awt.Dimension childSize,
                                    java.awt.Dimension mySize)
Handle the layout when the child component is smaller than the parent container.
Parameters:
childSize - the preferred size of the child
mySize - the size of this component
See Also:
layoutContainer

vsbNeeded

public boolean vsbNeeded(java.awt.Container clipWindow,
                         java.awt.Dimension pSz)
Function to see if the vertical scroll bar will be needed (eg. if the container passed in is taller than the child)
Parameters:
clipWindow - the container whose layout this ClipLayout is
pSz - this clipWindow's size.

hsbNeeded

public boolean hsbNeeded(java.awt.Container clipWindow,
                         java.awt.Dimension pSz)
Function to see if the horizontal scroll bar will be needed (eg. if the container passed in is wider than the child)
Parameters:
clipWindow - the container whose layout this ClipLayout is
pSz - this clipWindow's size.

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

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