|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.zaval.util.ValidationObject | +--org.zaval.lw.LwView
This abstract class is used as base for lightweight views implementations. A view is used to provide painting for a decorative element (box, border and so on). To develop a view it is necessary to pass through following steps:
paint
method to define the face of the view.
recalc
method to calculate the view
merics. For example, you can calculate "pure" preferred size inside the method or
some metrical characteristics that are used to calculate the preferred size.
calcPreferredSize
method to define the "pure" preferred size.
This is very important bacause if your view uses ORIGINAL type than the preferred size
will be used to calculate a preferred size for an owner light weight component.
Field Summary | |
static int |
MOSAIC
The mosaic type of the view. |
static int |
ORIGINAL
The original type of the view. |
static int |
STRETCH
The stretch type of the view. |
Fields inherited from class org.zaval.util.ValidationObject |
isValidFlag |
Constructor Summary | |
LwView()
Constructs the view. |
|
LwView(int type)
Constructs the view with the specified view type. |
Method Summary | |
protected java.awt.Dimension |
calcPreferredSize()
Calculates and returns the view preferred size. |
java.awt.Insets |
getInsets()
Gets the view insets. |
java.awt.Dimension |
getPreferredSize()
Gets the view preferred size. |
int |
getType()
Gets the type of the view. |
protected void |
ownerChanged(Validationable v)
The method is called whenever the view owner has been changed. |
void |
paint(java.awt.Graphics g,
int x,
int y,
Drawable d)
Paints the view using the preferred size of the view. |
abstract void |
paint(java.awt.Graphics g,
int x,
int y,
int w,
int h,
Drawable d)
Paints the view using a given width and height. |
protected void |
recalc()
Invoked with validate method if the view is invalid. |
void |
setType(int t)
Sets the specified type of the view. |
Methods inherited from class org.zaval.util.ValidationObject |
invalidate, isValid, validate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int STRETCH
public static final int MOSAIC
public static final int ORIGINAL
Constructor Detail |
public LwView()
public LwView(int type)
type
- the view type.Method Detail |
public int getType()
public void setType(int t)
paint
method of the view gets own preferred size as
the view size.
paint
method of the view gets own preferred size as
the view size, but the view will be painted as many times as it can be placed inside
the owner component surface.
t
- the specified view type.public java.awt.Insets getInsets()
public java.awt.Dimension getPreferredSize()
calcPreferredSize
method)
and the view insets. The preferred size is used with an owner component to
compute own preferred size.protected java.awt.Dimension calcPreferredSize()
protected void recalc()
validate
method if the view is invalid. The method
can be overrided to calculate metrical characteristics of the view and the method
is called only if it is realy necessary, so there is not necessaty to care about
superfluous calling and computing.recalc
in class ValidationObject
public void paint(java.awt.Graphics g, int x, int y, Drawable d)
x
and y
coordinates.g
- the specified context to be used for painting.x
- the x coordinate.y
- the y coordinate.d
- the owner component.public abstract void paint(java.awt.Graphics g, int x, int y, int w, int h, Drawable d)
x
and y
coordinates. This abstract method has to be implmented to define a "face" for the view.g
- the specified context to be used for painting.x
- the x coordinate.y
- the y coordinate.w
- the width of the view.h
- the height of the view.d
- the owner component.protected void ownerChanged(Validationable v)
v
- the new view owner.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |