org.zaval.lw
Class LwPanel

java.lang.Object
  |
  +--org.zaval.util.ValidationObject
        |
        +--org.zaval.lw.LwCanvas
              |
              +--org.zaval.lw.LwPanel
All Implemented Interfaces:
Drawable, Layoutable, LayoutContainer, LwComponent, LwContainer, Validationable
Direct Known Subclasses:
LwActContainer, LwBaseLayer, LwBorderPan, LwColorPanel, LwCombo, LwFilePanel, LwFontPanel, LwGrid, LwList, LwMenuBar, LwNotebook, LwScroll, LwScrollPan, LwSpin, LwSplitPan, LwStatusBar, LwWindow

public class LwPanel
extends LwCanvas
implements LwContainer

This is implementation of the light weight container interface that has to be used to develop own light weight containers. The container implementation inherits the light weight component implementation. Draw attention at the following features:


Field Summary
protected  java.util.Vector children
           
 
Fields inherited from class org.zaval.lw.LwCanvas
bits, height, insets, parent, psHeight, psWidth, skins, width, x, y
 
Fields inherited from class org.zaval.util.ValidationObject
isValidFlag
 
Constructor Summary
LwPanel()
          Constructs the container.
 
Method Summary
 void add(LwComponent c)
          Adds the specified lightweight component as a child of this container.
 void add(java.lang.Object s, LwComponent c)
          Adds the specified lightweight component with the specified constraints as a child of this container.
protected  java.awt.Dimension calcPreferredSize()
          Gets the "pure" preferred size for this component.
 int count()
          Returns the number of child components in this container.
 Layoutable get(int i)
          Gets a child component at the given index.
protected  LwLayout getDefaultLayout()
          Gets the default layout manager that is set with the container during initialization.
 java.awt.Point getLayoutOffset()
          Returns the offset.
 LwComponent getLwComponentAt(int xx, int yy)
          Determines if the component or an immediate child component contains the (xx, yy) location in its visible part and if so, returns the component.
 LwLayout getLwLayout()
          Gets the layout manager of this container.
 int indexOf(LwComponent c)
          Searches the specified component among this container children and returns an index of the component in the child list.
 void insert(int i, LwComponent d)
          Inserts the specified lightweight component as a child of this container at the specified position in the container list.
 void insert(int i, java.lang.Object s, LwComponent d)
          Inserts the specified lightweight component with the specified constraints as a child of this container at the specified position in the container list.
 void invalidate()
          Invalidates this object.
 void paintOnTop(java.awt.Graphics g)
          Paints additional elements (for example, marker) after the container and its child components have been rendered.
protected  void recalc()
          Invoked with validate method only if the component is not valid.
 void remove(int i)
          Removes the component at the specified index from this container.
 void remove(LwComponent c)
          Removes the specified component from this container.
 void removeAll()
          Removes all child components from this container.
 void setBackground(java.awt.Color c)
          Sets the background color of this container.
 void setLwLayout(LwLayout m)
          Sets the layout manager for this container.
 void setOpaque(boolean b)
          Sets the opaque of this component.
 void toFront(LwComponent c)
          Sets the specified child component to be painted over other child components.
protected  void updateCashedPs(int w, int h)
           
 
Methods inherited from class org.zaval.lw.LwCanvas
canHaveFocus, getBackground, getBounds, getHeight, getInsets, getLocation, getLwParent, getOrigin, getPreferredSize, getSize, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isVisible, paint, repaint, repaint, requestFocus, setEnabled, setInsets, setLocation, setLwParent, setPSSize, setSize, setViewMan, setVisible, toString, update, validate, viewManChanged, vrp
 
Methods inherited from class org.zaval.util.ValidationObject
isValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zaval.lw.LwComponent
canHaveFocus, getLwParent, getViewMan, getVisiblePart, setEnabled, setLwParent, setViewMan, setVisible
 
Methods inherited from interface org.zaval.lw.Drawable
getBackground, getOrigin, isEnabled, isOpaque, paint, repaint, repaint, update
 
Methods inherited from interface org.zaval.util.Validationable
isValid, validate
 
Methods inherited from interface org.zaval.lw.Layoutable
getBounds, getHeight, getInsets, getLocation, getPreferredSize, getSize, getWidth, getX, getY, isVisible, setLocation, setSize
 

Field Detail

children

protected java.util.Vector children
Constructor Detail

LwPanel

public LwPanel()
Constructs the container.
Method Detail

paintOnTop

public void paintOnTop(java.awt.Graphics g)
Description copied from interface: LwContainer
Paints additional elements (for example, marker) after the container and its child components have been rendered.
Specified by:
paintOnTop in interface LwContainer
Following copied from interface: org.zaval.lw.LwContainer
Parameters:
g - the graphics context.

add

public void add(java.lang.Object s,
                LwComponent c)
Adds the specified lightweight component with the specified constraints as a child of this container. The method calls componentAdded method its layout manager to inform the layout manager that the new child has been added with the given constraints.
Specified by:
add in interface LwContainer
Parameters:
s - the object expressing layout constraints for this.
c - the lightweight component to be added.

add

public void add(LwComponent c)
Adds the specified lightweight component as a child of this container. The method calls componentAdded method its layout manager to inform the layout manager that the new child has been added.
Specified by:
add in interface LwContainer
Parameters:
c - the lightweight component to be added.

insert

public void insert(int i,
                   LwComponent d)
Inserts the specified lightweight component as a child of this container at the specified position in the container list. The method calls componentAdded method its layout manager to inform the layout manager that the new child has been added.
Parameters:
i - the position in the container list at which to insert the component.
d - the lightweight component to be added.

insert

public void insert(int i,
                   java.lang.Object s,
                   LwComponent d)
Inserts the specified lightweight component with the specified constraints as a child of this container at the specified position in the container list. The method calls componentAdded method its layout manager to inform the layout manager that the new child has been added with the given constraints.
Specified by:
insert in interface LwContainer
Parameters:
i - the position in the container list at which to insert the component.
s - the object expressing layout contraints for this.
d - the lightweight component to be added.

remove

public void remove(LwComponent c)
Removes the specified component from this container. The layout manager of this container is informed by calling componentRemoved method of the manager.
Parameters:
c - the specified component to be removed.

remove

public void remove(int i)
Removes the component at the specified index from this container. The layout manager of this container is informed by calling componentRemoved method of the manager.
Specified by:
remove in interface LwContainer
Parameters:
i - the index of the component to be removed.

removeAll

public void removeAll()
Removes all child components from this container. The layout manager of this container is informed by calling componentRemoved method of the manager for every child that has been removed.
Specified by:
removeAll in interface LwContainer

indexOf

public int indexOf(LwComponent c)
Searches the specified component among this container children and returns an index of the component in the child list. If the component has not been found than the method returns -1.
Specified by:
indexOf in interface LwContainer
Parameters:
c - the component to get index.
Returns:
the child index.

get

public Layoutable get(int i)
Gets a child component at the given index.
Specified by:
get in interface LayoutContainer
Parameters:
i - the specified index of the child to be returned.
Returns:
a child component at the specified index.

count

public int count()
Returns the number of child components in this container.
Specified by:
count in interface LayoutContainer
Returns:
a number of child components in this container.

setLwLayout

public void setLwLayout(LwLayout m)
Sets the layout manager for this container. It is impossible to use null as a layout manager, in this case IllegalArgumentException will be thrown.
Specified by:
setLwLayout in interface LwContainer
Parameters:
m - the specified layout manager.

getLwLayout

public LwLayout getLwLayout()
Gets the layout manager of this container.
Specified by:
getLwLayout in interface LwContainer
Returns:
a layout manager.

setBackground

public void setBackground(java.awt.Color c)
Sets the background color of this container. Additionally the method sets the background color for every child component.
Specified by:
setBackground in interface LwComponent
Overrides:
setBackground in class LwCanvas
Parameters:
c - the color to become this component background color.

setOpaque

public void setOpaque(boolean b)
Sets the opaque of this component. Use false argument value to make a transparent component from this component. Additionally the method sets the specified opaque for every child component.
Specified by:
setOpaque in interface Drawable
Overrides:
setOpaque in class LwCanvas
Parameters:
b - the opaque flag.

getLwComponentAt

public LwComponent getLwComponentAt(int xx,
                                    int yy)
Determines if the component or an immediate child component contains the (xx, yy) location in its visible part and if so, returns the component.
Specified by:
getLwComponentAt in interface LwComponent
Overrides:
getLwComponentAt in class LwCanvas
Parameters:
xx - the x coordinate.
yy - the y coordinate.
Returns:
the component or sub-component that contains the (x, y) location; null if the location is outside of this component visible part.

toFront

public void toFront(LwComponent c)
Sets the specified child component to be painted over other child components.
Parameters:
c - the specified child component.

recalc

protected void recalc()
Invoked with validate method only if the component is not valid. The method should not be overrided for this container like it can be done for LwCanvas, because the method starts validating and layouting of the child components.
Overrides:
recalc in class LwCanvas

getLayoutOffset

public java.awt.Point getLayoutOffset()
Returns the offset. The offset can be used with a layout manager to offset child components locations of the container according to the offset values. The offset is represented with java.awt.Point class, the x is offset for x-coordinates and y is offset for y-coordinates. The ability to offset child components with a layout manager is used with the library to organize scrolling.
Specified by:
getLayoutOffset in interface LayoutContainer
Returns:
an offset to move children.

invalidate

public void invalidate()
Description copied from interface: Validationable
Invalidates this object.
Specified by:
invalidate in interface Validationable
Overrides:
invalidate in class LwCanvas

calcPreferredSize

protected java.awt.Dimension calcPreferredSize()
Gets the "pure" preferred size for this component. The method has not be overrided, because it determines the preferred size by the layout manager.
Overrides:
calcPreferredSize in class LwCanvas
Returns:
a "pure" preferred size.

getDefaultLayout

protected LwLayout getDefaultLayout()
Gets the default layout manager that is set with the container during initialization. This implementation of the method returns LwRastLayout as the default layout manager, the layout manager is got as a static object by "layout.raster" key.
Returns:
a layout manager.

updateCashedPs

protected void updateCashedPs(int w,
                              int h)


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org