|
||||||||||
| 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.LwCanvas
This is basic implemenation of the light weight component interface that should be used to develop own light weight component. As rule when you develop a lightweight components it is necessary to pass through following steps:
paint method to define the component face.
update method to define the component
background.
recalc method to calculate the component
metrics. 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 "pure"
preferred size of the component face.
| Field Summary | |
protected short |
bits
|
protected int |
height
|
protected long |
insets
|
protected LwComponent |
parent
The component parent. |
protected int |
psHeight
|
protected int |
psWidth
|
protected LwViewMan |
skins
The component view manager. |
protected int |
width
|
protected int |
x
|
protected int |
y
|
| Fields inherited from class org.zaval.util.ValidationObject |
isValidFlag |
| Constructor Summary | |
LwCanvas()
|
|
| Method Summary | |
protected java.awt.Dimension |
calcPreferredSize()
Gets the "pure" preferred size for this component. |
boolean |
canHaveFocus()
Specifies if the component can have focus. |
java.awt.Color |
getBackground()
Gets the background color of this lightweight component. |
java.awt.Rectangle |
getBounds()
Gets the bounds of this component. |
int |
getHeight()
Gets the height of this component. |
java.awt.Insets |
getInsets()
Calculates and returns the insets of this component. |
java.awt.Point |
getLocation()
Gets the location of this component point specifying the component top-left corner. |
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. |
LwComponent |
getLwParent()
Gets the lightweight parent of this component. |
java.awt.Point |
getOrigin()
Returns an origin of the component. |
java.awt.Dimension |
getPreferredSize()
Gets the preferred size of this component. |
java.awt.Dimension |
getSize()
Returns a size of this component. |
LwViewMan |
getViewMan(boolean autoCreate)
Returns a view manager of the component. |
java.awt.Rectangle |
getVisiblePart()
Returns the bounding rectangle of the visible part for the component. |
int |
getWidth()
Gets the width of this component. |
int |
getX()
Gets the x location of this component specifying the component top-left corner. |
int |
getY()
Gets the y location of this component specifying the component top-left corner. |
boolean |
hasFocus()
Tests if the component is a focus owner. |
void |
invalidate()
Invalidates this component. |
boolean |
isEnabled()
Determines whether this component is enabled. |
boolean |
isOpaque()
Gets the opaque of this component. |
boolean |
isVisible()
Determines if this component is visible. |
void |
paint(java.awt.Graphics g)
Paints this component. |
protected void |
recalc()
Invoked with validate method only if the component is not valid. |
void |
repaint()
Performs repainting process of this component. |
void |
repaint(int x,
int y,
int w,
int h)
Performs repainting process of the specified rectangle. |
void |
requestFocus()
Requests focus for this component. |
void |
setBackground(java.awt.Color c)
Sets the background color of this component. |
void |
setEnabled(boolean b)
Enables or disables this component. |
void |
setInsets(int top,
int left,
int bottom,
int right)
Sets the specified insets for the component. |
void |
setLocation(int xx,
int yy)
Sets a new location for this component. |
void |
setLwParent(LwComponent o)
Sets the lightweight parent of this component. |
void |
setOpaque(boolean b)
Sets the opaque of this component. |
void |
setPSSize(int w,
int h)
Sets the specified preferred size for the component. |
void |
setSize(int w,
int h)
Sets the specified size for this component. |
void |
setViewMan(LwViewMan man)
Sets the specified view manager for the component. |
void |
setVisible(boolean b)
Shows or hides this lightweight component depending on the value of parameter b. |
java.lang.String |
toString()
Returns a string representation of the object. |
void |
update(java.awt.Graphics g)
Updates this component. |
void |
validate()
Validates this component. |
protected void |
viewManChanged()
Invoked whenever the view manager has been changed. |
protected void |
vrp()
Invalidates and then repaints the component. |
| 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.util.Validationable |
isValid |
| Field Detail |
protected long insets
protected short bits
protected int x
protected int y
protected int width
protected int height
protected int psWidth
protected int psHeight
protected LwComponent parent
protected LwViewMan skins
| Constructor Detail |
public LwCanvas()
| Method Detail |
public java.awt.Insets getInsets()
setInsets
method.getInsets in interface Layoutablepublic int getX()
Layoutablex location of this component specifying the component top-left corner.
The location is relative to the parent component coordinate space.getX in interface Layoutableorg.zaval.lw.Layoutablex coordinate representing the top-left corner
of the component bounds in the coordinate space of the component parent.public int getY()
Layoutabley location of this component specifying the component top-left corner.
The location is relative to the parent component coordinate space.getY in interface Layoutableorg.zaval.lw.Layoutabley coordinate representing the top-left corner
of the component bounds in the coordinate space of the component parent.public int getWidth()
LayoutablegetWidth in interface Layoutableorg.zaval.lw.Layoutablepublic int getHeight()
LayoutablegetHeight in interface Layoutableorg.zaval.lw.Layoutable
public void setInsets(int top,
int left,
int bottom,
int right)
top - the top indent.left - the left indent.bottom - the bottom indent.right - the right indent.public java.awt.Dimension getSize()
java.awt.Dimension class.getSize in interface LayoutableDimension object that indicates the
size of this component.public java.awt.Rectangle getVisiblePart()
getVisiblePart in interface LwComponentpublic void setLwParent(LwComponent o)
setLwParent in interface LwComponento - the parent component of this lightweight component.public java.awt.Point getLocation()
getLocation in interface LayoutablePoint representing the top-left corner
of the component bounds in the coordinate space of the component parent.public java.awt.Color getBackground()
getBackground in interface Drawablepublic boolean isVisible()
isVisible in interface Layoutabletrue if the component is visible;
false otherwise.public void setVisible(boolean b)
b. The method performs appropriate LwComponentEvent.setVisible in interface LwComponentb - if it is true, shows this component;
otherwise, hides this component.public boolean isEnabled()
true than the component is enabled and can participate in event
handling and performing processes. Components are enabled initially by default.
A component can be enabled or disabled by calling its setEnabled
method.isEnabled in interface Drawabletrue if the component is enabled; false otherwise.public void setEnabled(boolean b)
setEnabled in interface LwComponentb - if true, this component is
enabled; otherwise this component is disabled.public void setBackground(java.awt.Color c)
setBackground in interface LwComponentc - the color to become this component background color. Use null
as the color value to set the background to the default color value.public void invalidate()
invalidate in interface Validationableinvalidate in class ValidationObjectpublic void validate()
recalc method to calculate the component metrics if it is necessary. So,
override the method (recalc method) to calculate some metrical characteristics
to minimize the computation time.validate in interface Validationablevalidate in class ValidationObject
public void setLocation(int xx,
int yy)
x and y
parameters in the coordinate space of this component parent.setLocation in interface Layoutablexx - the x-coordinate of the new location
top-left corner in the parent coordinate space.yy - The y-coordinate of the new location
top-left corner in the parent coordinate space.
public void setSize(int w,
int h)
setSize in interface Layoutablew - the width of this component.h - the height of this component.public java.awt.Rectangle getBounds()
java.awt.Rectangle class.getBounds in interface Layoutable
public LwComponent getLwComponentAt(int xx,
int yy)
getLwComponentAt in interface LwComponentxx - the x coordinate.yy - the y coordinate.null if the location doesn't belong to visible part of
this component.public LwComponent getLwParent()
getLwParent in interface LwComponentprotected void recalc()
validate method only if the component is not valid.
The method shoud be overrided to calculate metrical characteristics of the component to
minimize computation time of the preferred size for the component. For example, you can
calculate a preferred size inside the method and just return it by
calcPreferredSize method.recalc in class ValidationObjectpublic void repaint()
update and than paint methods.
The method bases on appropriate method of LwPaintManager.repaint in interface Drawable
public void repaint(int x,
int y,
int w,
int h)
update and than paint methods.
The method bases on appropriate method of LwPaintManager.repaint in interface Drawablex - the x coordinate.y - the y coordinate.w - the width.h - the height.public void update(java.awt.Graphics g)
paint method and it is performed with
repaint method. The method can be used to fill the drawable
component with the background color if the component is opaque.
In the implementation light weight component is updated (using the background
color) with LwPaintManager, so it is not necessary to care about it.
You can use the method to define own background pattern.
update in interface Drawableg - the specified context to be used for updating.public void paint(java.awt.Graphics g)
paint in interface Drawableg - the graphics context to be used for painting.public java.awt.Dimension getPreferredSize()
getInsets method) and
a "pure" preferred size (returned with calcPreferredSize method).
You should not override the method, use calcPreferredSize method to
define the "pure" preferred size of this component.getPreferredSize in interface Layoutablepublic LwViewMan getViewMan(boolean autoCreate)
null.
The input argument autoCreate defines if the view manager has to be created
automatically in a case if it has not been determined before. It means, if the argument is
true and the view manager is null, than the component will
try to create and initialize its view manager by a default view manager. If the argument
is false than the method returns the component view manager as is.getViewMan in interface LwComponentautoCreate - the flag defines if the view manager should be created
automatically.public void setViewMan(LwViewMan man)
setViewMan in interface LwComponentman - the view manager to set for the component.public java.lang.String toString()
toString in class java.lang.Objectprotected java.awt.Dimension calcPreferredSize()
getPreferredSize method.public boolean canHaveFocus()
LwComponentcanHaveFocus in interface LwComponentorg.zaval.lw.LwComponenttrue if the component can have the focus.public boolean hasFocus()
true if the component is a focus owner; otherwise
falsepublic void requestFocus()
public void setOpaque(boolean b)
false
argument value to make a transparent component from this component.
The painting process will not use update method and the background view
for a transparent component.setOpaque in interface Drawableb - the opaque flag.public boolean isOpaque()
false than the component is transparent, in this case
update method has not be called during painting process and LwPaintManager
doesn't clear the component with the background color.isOpaque in interface Drawabletrue if the component is opaque; otherwise
false.
public void setPSSize(int w,
int h)
getPreferredSize method returns the fixed size.w - the width to be used as the preferred size width.
If the width is less zero than the width will be calculated basing on the component
insets and the returned by calcPreferredSize width.h - the height to be used as the preferred size height.
If the height is less zero than the height will be calculated basing on the component
insets and the returned by calcPreferredSize height.public java.awt.Point getOrigin()
null, in this case the origin is (0, 0).getOrigin in interface Drawableprotected void viewManChanged()
protected void vrp()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||