org.zaval.lw
Class LwViewMan

java.lang.Object
  |
  +--org.zaval.util.ValidationObject
        |
        +--org.zaval.lw.LwViewMan
All Implemented Interfaces:
Validationable
Direct Known Subclasses:
LwAdvViewMan

public class LwViewMan
extends ValidationObject

This class is used to support set of views. Actually the view manager is a views container that provides following abilities:


Fields inherited from class org.zaval.util.ValidationObject
isValidFlag
 
Constructor Summary
LwViewMan()
           
 
Method Summary
protected  LwView[] getAllViews()
          Returns all views that are provided with the view manager.
 LwView getBg()
          Gets the view that should be used as a background view for the owner component.
 LwView getBorder()
          Gets the view that should be used as a border view for the owner component.
 java.awt.Insets getInsets()
          Gets the insets of the view manager that is calculated as maximal value among all views.
 Drawable getParent()
          Gets the owner component for this view manager.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of the view manager.
 LwView getView()
          Gets the view that should be used as a face view for the owner component.
protected  LwView getView(java.lang.String key)
          Resolves the view by the specified view name.
 void invalidate()
          Invalidates the view manager.
protected  void recalc()
          Calculates the view manager metrics.
 void setBg(LwView s)
          Sets the background view.
 void setBg(java.lang.String s)
          Sets the background view for the owner component by the specified view name.
 void setBorder(LwView s)
          Sets the border view.
 void setBorder(java.lang.String s)
          Sets the border view for the owner component by the specified view name.
protected  void setParent(Drawable p)
          Sets the owner component for this view manager.
 void setView(LwView s)
          Sets the face view.
 void setView(java.lang.String s)
          Sets the face view for the owner component by the specified view name.
 
Methods inherited from class org.zaval.util.ValidationObject
isValid, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LwViewMan

public LwViewMan()
Method Detail

setParent

protected void setParent(Drawable p)
Sets the owner component for this view manager.
Parameters:
p - the specified owner component.

getParent

public Drawable getParent()
Gets the owner component for this view manager.
Returns:
an owner component.

getInsets

public java.awt.Insets getInsets()
Gets the insets of the view manager that is calculated as maximal value among all views.
Returns:
an insets.

getBg

public LwView getBg()
Gets the view that should be used as a background view for the owner component.
Returns:
an background view.

getBorder

public LwView getBorder()
Gets the view that should be used as a border view for the owner component.
Returns:
a border view.

getView

public LwView getView()
Gets the view that should be used as a face view for the owner component.
Returns:
a face view.

setBg

public void setBg(java.lang.String s)
Sets the background view for the owner component by the specified view name. The method tries to resolve the string name by getView method. This implementation of the method uses the name as a key to find the view among static objects. The library defines some of standard views as static objects (for example border views, button views, checkbox views and so on) and lightweight components use the standard views to paint itself.
Parameters:
s - the name of the background view.

setBorder

public void setBorder(java.lang.String s)
Sets the border view for the owner component by the specified view name. The method tries to resolve the string name by getView method. This implementation of the method uses the name as a key to find the view among static objects. The library defines some of standard views as static objects (for example border views, button views, checkbox views and so on) and lightweight components use the standard views to paint itself.
Parameters:
s - the name of the border view.

setView

public void setView(java.lang.String s)
Sets the face view for the owner component by the specified view name. The method tries to resolve the string name by getView method. This implementation of the method uses the name as a key to find the view among static objects. The library defines some of standard views as static objects (for example border views, button views, checkbox views and so on) and lightweight components use the standard views to paint itself.
Parameters:
s - the name of the face view.

setBg

public void setBg(LwView s)
Sets the background view.
Parameters:
s - the background view.

setBorder

public void setBorder(LwView s)
Sets the border view.
Parameters:
s - the border view.

setView

public void setView(LwView s)
Sets the face view.
Parameters:
s - the face view.

invalidate

public void invalidate()
Invalidates the view manager. The view manager performs invalidation of the owner component if it is not null.
Overrides:
invalidate in class ValidationObject

recalc

protected void recalc()
Calculates the view manager metrics. The method is invoked during validation of the view manager if it is necessary. The main purpose of the metod to calculate preferred size and insets of the view manager basing on the views set (border, background and face views).
Overrides:
recalc in class ValidationObject

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of the view manager. The preferred size is computed basing on the views preferred sizes (border, face, background views)
Returns:
a preferred size.

getView

protected LwView getView(java.lang.String key)
Resolves the view by the specified view name. The method binds a view with a name. This class implementation uses the name as a static object key, so the method returns a view by the name from the set of static objects. The method provides ability to implement own mapping mechanism. For example, LwButton component uses "button.on" and "button.off" names for the face view depending on the button state, so it is possible to override the method for a new view manager implementation to change the button face, but the library provides LwAdvViewMan implementation to support custom views.
Parameters:
key - the name of the view.
Returns:
a view.

getAllViews

protected LwView[] getAllViews()
Returns all views that are provided with the view manager. The method is used with recalc method to compute insets and preferred size of the view manager.
Returns:
an array of views.


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