| java.lang.Object com.sun.midp.chameleon.CLayer
All known Subclasses: com.sun.midp.chameleon.layers.ScrollIndLayer, com.sun.midp.chameleon.layers.SoftButtonLayer, com.sun.midp.chameleon.layers.BackgroundLayer, com.sun.midp.chameleon.layers.TickerLayer, com.sun.midp.chameleon.layers.PopupLayer, com.sun.midp.chameleon.layers.BodyLayer, com.sun.midp.chameleon.layers.TitleLayer, com.sun.midp.chameleon.layers.WashLayer,
CLayer | public class CLayer (Code) | | This class represents a "layer". A layer is an element used to comprise
a higher-level "window" (see CWindow.java). A layer has several properties
such as its visibility, whether it accepts input, its size, etc. A layer
also has content, such as its background and its foreground.
|
Field Summary | |
final public static int | H | final public static int | W | final public static int | X | final public static int | Y | protected int | bgColor | protected Image[] | bgImage The image to use as a background for this layer if this layer
is not transparent and does not use a fill color. | public int[] | bounds An array holding the bounds of this layer. | protected int[] | boundsCopy | protected int[] | dirtyBounds Array holding a bounding rectangle of an area needing repainting. | protected int[] | dirtyBoundsCopy | int | graphicsColor When in the paint() routine, graphicsColor will be set to the
default graphics color. | Font | graphicsFont When in the paint() routine, graphicsFont will be set to the
default graphics Font. | protected boolean | opaque Flag indicating this layer is either completely opaque, or not.
By default, a layer is not opaque, and thus requires the background
and any layers below it to be painted in addition to itself. | protected CWindow | owner The window which owns this layer. | protected boolean | supportsInput Flag indicating the ability of this layer to support key/pen input. | protected boolean | tileBG If this layer is not transparent and uses a background image,
a flag indicating if that image should be tiled or otherwise centered. | protected boolean | transparent Flag indicating if this layer has a transparent background or not. | protected boolean | visible Flag indicating the current visibility state of this layer. |
Constructor Summary | |
public | CLayer() Construct a default, transparent layer. | public | CLayer(Image bgImage, int bgColor) Construct a layer with the given background image if it is not null
or with a background fill color.
The color should be in the 0xaarrggbb format. | public | CLayer(Image[] bgImages, int bgColor) Construct a layer with the given background images (if not null)
or with a background fill color and border. |
Method Summary | |
public void | addDirtyRegion() Add this layer's entire area to be marked for repaint. | public boolean | addDirtyRegion(int x, int y, int w, int h) Add an area to be marked for repaint to this layer. | public void | addNotify() Called by CWindow to notify the layer that is has been
added to the active stack. | protected void | cleanDirty() Clean any dirty regions of the layer and mark layer as not dirty. | protected void | cleanDirtyRegions() Clean any dirty regions of the layer. | public boolean | containsPoint(int x, int y) Utility method to determine if the given point lies within
the bounds of this layer. | void | copyLayerBounds() | public int[] | getBounds() Return the bounds of this layer (in the coordinate space of
its parent Window). | public boolean | handlePoint(int x, int y) Utility method to determine if this layer wanna handle
the given point. | protected void | initialize() Finish initialization of this CLayer. | public boolean | isDirty() Returns true if this layer is in need of repainting. | protected boolean | isEmptyDirtyRegions() Determines whether dirty regions are empty. | public boolean | isOpaque() | public boolean | isVisible() Determine the current visibility of this layer. | public boolean | keyInput(int type, int code) Handle key input from a keypad. | protected String | layerID() | public boolean | methodInput(String str) Handle input from some type of device-dependent
input method. | public void | paint(Graphics g) Paint this layer. | protected void | paintBackground(Graphics g) Paint the background of this layer. | protected void | paintBody(Graphics g) Paint the body or content of this layer. | public boolean | pointerInput(int type, int x, int y) Handle input from a pen tap. | public void | relocateNotify(int[] oldBounds) Called by CWindow to notify the layer that is has been
moved to another location. | public void | removeNotify(CWindow owner) Called by CWindow to notify the layer that is has been
removed from the active stack. | public void | requestRepaint() Request a repaint for the entire contents of this layer. | public void | requestRepaint(int x, int y, int w, int h) Request a repaint for a specific region of this layer. | public void | setBackground(Image bgImage, boolean tileBG, int bgColor) Establish a background. | public void | setBackground(Image[] bgImages, int bgColor) Establish a background. | public void | setBounds(int x, int y, int w, int h) Establish the bounds of this layer. | protected void | setDirty() Mark this layer as being dirty. | protected void | setDirtyButNotNotifyOwner() Mark this layer as being dirty
but don't mark the containing window. | public void | setOpaque(boolean opaque) Set the opacity flag for this layer. | public void | setSupportsInput(boolean support) Toggle the ability of this layer to receive input. | public void | setVisible(boolean visible) Toggle the visibility state of this layer within its containing
window. | boolean | subDirtyRegion(int x, int y, int w, int h) Subtract a layer area not needed for repaint of this layer. | public boolean | supportsInput() Determine if this layer supports input, such as key and pen events. | public String | toString() | public void | update(CLayer[] mainLayers) |
H | final public static int H(Code) | | Constant used to reference the '3' index of the bounds array
|
W | final public static int W(Code) | | Constant used to reference the '2' index of the bounds array
|
X | final public static int X(Code) | | Constant used to reference the '0' index of the bounds array
|
Y | final public static int Y(Code) | | Constant used to reference the '1' index of the bounds array
|
bgColor | protected int bgColor(Code) | | If this layer has a filled color background,
the 0xrrggbbaa value of that color
|
bgImage | protected Image[] bgImage(Code) | | The image to use as a background for this layer if this layer
is not transparent and does not use a fill color.
|
bounds | public int[] bounds(Code) | | An array holding the bounds of this layer. The indices are
as follows:
0 = layer's 'x' coordinate
1 = layer's 'y' coordinate
2 = layer's width
3 = layer's height
The 'x' and 'y' coordinates are in the coordinate space of the
window which contains this layer.
|
boundsCopy | protected int[] boundsCopy(Code) | | Copy of the layer bounds needed to unlock the layers for painting
|
dirtyBounds | protected int[] dirtyBounds(Code) | | Array holding a bounding rectangle of an area needing repainting.
|
dirtyBoundsCopy | protected int[] dirtyBoundsCopy(Code) | | Copy of the dirty bounds needed to unlock the layers for painting
|
graphicsColor | int graphicsColor(Code) | | When in the paint() routine, graphicsColor will be set to the
default graphics color. This is a convenience variable for
subclasses to easily modify and then reset the graphics color.
|
graphicsFont | Font graphicsFont(Code) | | When in the paint() routine, graphicsFont will be set to the
default graphics Font. This is a convenience variable for
subclasses to easily modify and then reset the graphics font.
|
opaque | protected boolean opaque(Code) | | Flag indicating this layer is either completely opaque, or not.
By default, a layer is not opaque, and thus requires the background
and any layers below it to be painted in addition to itself. However,
if a layer is opaque, it does not require anything it is obscuring to
be painted, just itself. All layers are opaque by default.
|
owner | protected CWindow owner(Code) | | The window which owns this layer. If this layer has not been added
to a window or it has been removed from a window, the owner will be
null.
|
supportsInput | protected boolean supportsInput(Code) | | Flag indicating the ability of this layer to support key/pen input.
|
tileBG | protected boolean tileBG(Code) | | If this layer is not transparent and uses a background image,
a flag indicating if that image should be tiled or otherwise centered.
|
transparent | protected boolean transparent(Code) | | Flag indicating if this layer has a transparent background or not.
|
visible | protected boolean visible(Code) | | Flag indicating the current visibility state of this layer.
|
CLayer | public CLayer()(Code) | | Construct a default, transparent layer. As a result, the
'transparent' value will be set to true.
|
CLayer | public CLayer(Image bgImage, int bgColor)(Code) | | Construct a layer with the given background image if it is not null
or with a background fill color.
The color should be in the 0xaarrggbb format. If the bgColor is
invalid and bgImage is null, this layer will be transparent and
equal to the no-argument constructor.
Parameters: bgImage - The background image to use for this layer. Parameters: bgColor - The color (0xaarrggbb) to use as the background fill |
CLayer | public CLayer(Image[] bgImages, int bgColor)(Code) | | Construct a layer with the given background images (if not null)
or with a background fill color and border. The background images
should be a 9 element array, creating a 9-piece image background.
The color should be in the 0xaarrggbb format. If the bgColor is
invalid and bgImages are null, this layer will be transparent and
equal to the no-argument constructor.
Parameters: bgImages - The background image to use for this layer. Parameters: bgColor - The color (0xaarrggbb) to use as the background fill |
addDirtyRegion | public void addDirtyRegion()(Code) | | Add this layer's entire area to be marked for repaint. Any pending
dirty regions will be cleared and the entire layer will be painted
on the next repaint.
|
addDirtyRegion | public boolean addDirtyRegion(int x, int y, int w, int h)(Code) | | Add an area to be marked for repaint to this layer. This could
be needed for a variety of reasons, such as this layer being
obscured by another layer or window element. The new region should
be in the coordinate space of this layer.
Parameters: x - the x coordinate of the region Parameters: y - the y coordinate of the region Parameters: w - the width of the region Parameters: h - the height of the region true if dirty region of the layer was changed,false otherwise |
addNotify | public void addNotify()(Code) | | Called by CWindow to notify the layer that is has been
added to the active stack. By default this method do nothing.
This method could be re-implemented by particular layer to
do some specific action as soon as it's added to the stack
|
cleanDirty | protected void cleanDirty()(Code) | | Clean any dirty regions of the layer and mark layer as not dirty.
|
cleanDirtyRegions | protected void cleanDirtyRegions()(Code) | | Clean any dirty regions of the layer.
|
containsPoint | public boolean containsPoint(int x, int y)(Code) | | Utility method to determine if the given point lies within
the bounds of this layer. The point should be in the coordinate
space of this layer's containing CWindow.
Parameters: x - the "x" coordinate of the point Parameters: y - the "y" coordinate of the point true if the coordinate lies in the bounds of this layer |
copyLayerBounds | void copyLayerBounds()(Code) | | Copy bounds of the layer to use them on dirty layers painting
when the layers are not locked for changes from other threads
|
getBounds | public int[] getBounds()(Code) | | Return the bounds of this layer (in the coordinate space of
its parent Window). Returns a 4 element array, containing the
x, y, width, and height representing this layer's bounding
rectangle
this layer's bounding rectangle in the coordinate spaceof its parent window |
handlePoint | public boolean handlePoint(int x, int y)(Code) | | Utility method to determine if this layer wanna handle
the given point. By default the layer handles the point if it
lies within the bounds of this layer. The point should be in
the coordinate space of this layer's containing CWindow.
Parameters: x - the "x" coordinate of the point Parameters: y - the "y" coordinate of the point true if the coordinate lies in the bounds of this layer |
initialize | protected void initialize()(Code) | | Finish initialization of this CLayer. This can
be extended by subclasses. The dimensions of the
CLayer are stored in its bounds[]. The 'x' and 'y'
coordinates are in the coordinate space of the
window which contains this layer. By default, a layer is
located at the origin and is as large as the screen size.
The X and Y coordinates represent the upper left position
of this CLayer in the containing CWindow's coordinate space.
|
isDirty | public boolean isDirty()(Code) | | Returns true if this layer is in need of repainting.
true if this layer is marked as 'dirty' and needs repainting. |
isEmptyDirtyRegions | protected boolean isEmptyDirtyRegions()(Code) | | Determines whether dirty regions are empty.
true if dirty regions are not set,false otherwise |
isOpaque | public boolean isOpaque()(Code) | | Determine if this layer is opaque
true if this layer does not have any transparentor translucent areas |
isVisible | public boolean isVisible()(Code) | | Determine the current visibility of this layer. Note that this
state only pertains to the layer's visibility status within its
containing window. The window itself may or may not be actually
visible on the physical display.
true if this layer is currently visible in a window |
keyInput | public boolean keyInput(int type, int code)(Code) | | Handle key input from a keypad. Parameters describe
the type of key event and the platform-specific
code for the key. (Codes are translated using the
lcdui.Canvas)
Parameters: type - the type of key event Parameters: code - the numeric code assigned to the key |
layerID | protected String layerID()(Code) | | A String identifier used by subclasses (for debug purposes)
abbreviated class name of the layer instance |
methodInput | public boolean methodInput(String str)(Code) | | Handle input from some type of device-dependent
input method. This could be input from something
such as T9, or a phonebook lookup, etc.
Parameters: str - the text to handle as direct input |
paint | public void paint(Graphics g)(Code) | | Paint this layer. This method should not generally be overridden by
subclasses. This method carefully stores the clip, translation, and
color before calling into subclasses. The graphics region will be
translated such that it is in this layer's coordinate space (0,0 is
the top left corner of this layer). The paintBackground() method will
be called first, then the paintBody() method. The graphics will then
carefully be put back into its original state before returning.
Subclasses should override the paintBody() method and do not generally
need to do any translates or bother to undo any changes made to
the Graphics object.
Parameters: g - The graphics object to use to paint this layer. |
paintBackground | protected void paintBackground(Graphics g)(Code) | | Paint the background of this layer. This method will automatically
handle a transparent layer, a layer with a background color (and/or
border color), and a layer with a background image (either centered
or tiled). Subclasses may override this method if they require a
more advanced background (note that the transparent value should be
set to false in order for the paintBackground() method to be called),
but subclasses must be careful to reset any modifications made to
the Graphics object before returning.
Parameters: g - The Graphics object to use to paint the background. |
paintBody | protected void paintBody(Graphics g)(Code) | | Paint the body or content of this layer. This method should be
overridden by subclasses. Note that the Graphics object will
already be translated into this layer's coordinate space. Subclasses
do not need to reset any changes made to the Graphics object as the
CLayer paint() routine will do that automatically.
Parameters: g - The Graphics object to use to paint the content of this layer |
pointerInput | public boolean pointerInput(int type, int x, int y)(Code) | | Handle input from a pen tap.
Parameters describe the type of pen event and the x,y location in the
layer at which the event occurred.
Important: the x,y location of the pen tap will already be translated
into the coordinate space of the layer.
Parameters: type - the type of pen event Parameters: x - the x coordinate of the event Parameters: y - the y coordinate of the event |
relocateNotify | public void relocateNotify(int[] oldBounds)(Code) | | Called by CWindow to notify the layer that is has been
moved to another location. By default this method do nothing.
This method could be re-implemented by particular layer to
do some specific action as soon as it's moved
Parameters: oldBounds - original bounds of this layer before it has been moved |
removeNotify | public void removeNotify(CWindow owner)(Code) | | Called by CWindow to notify the layer that is has been
removed from the active stack. By default this method do nothing.
This method could be re-implemented by particular layer to
do some specific action as soon as it's removed from the stack
Parameters: owner - an instance of CWindow this layer has been removed from |
requestRepaint | public void requestRepaint()(Code) | | Request a repaint for the entire contents of this layer.
|
requestRepaint | public void requestRepaint(int x, int y, int w, int h)(Code) | | Request a repaint for a specific region of this layer.
Parameters: x - The 'x' coordinate of the upper left corner of therepaint region Parameters: y - The 'y' coordinate of the upper right corner of therepaint region Parameters: w - The width of the repaint region Parameters: h - The height of the repaint region |
setBackground | public void setBackground(Image bgImage, boolean tileBG, int bgColor)(Code) | | Establish a background. This method will evaluate the parameters
and create a background which is appropriate. If the image is non-null,
the image will be used to create the background. If the image is null,
the values for the colors will be used and the background will be
painted in fill color instead. If the image is null, and the background
color is a negative value, this layer will become transparent and no
background will be painted.
Parameters: bgImage - the image to use for the background tile (or null) Parameters: tileBG - If true, then tile the background image as necessaryto fill a larger screen. If false, treat the imageas fullsize. Parameters: bgColor - if the image is null, use this color as a backgroundfill color |
setBackground | public void setBackground(Image[] bgImages, int bgColor)(Code) | | Establish a background. This method will evaluate the parameters
and create a background which is appropriate. If the images are
non-null, the images will be used to create a 9-piece background.
If the images are null, the value for the color will be used and
the background will be painted in fill color instead. If the images
are null, and the background color is a negative value, this layer
will become transparent and no background will be painted.
Parameters: bgImages - an array containing a 9-piece image set to be usedas the background for this layer Parameters: bgColor - if the images are null, use this color as a backgroundfill color |
setBounds | public void setBounds(int x, int y, int w, int h)(Code) | | Establish the bounds of this layer. The coordinate space for
the 'x' and 'y' anchor will be interpreted in that of the window
which contains this layer.
Parameters: x - The 'x' coordinate of this layer's origin Parameters: y - The 'y' coordinate of this layer's origin Parameters: w - The width of this layer Parameters: h - The height of this layer |
setDirty | protected void setDirty()(Code) | | Mark this layer as being dirty.
By default, this will also mark the containing window (if there is one)
as being dirty as well.
|
setDirtyButNotNotifyOwner | protected void setDirtyButNotNotifyOwner()(Code) | | Mark this layer as being dirty
but don't mark the containing window.
|
setOpaque | public void setOpaque(boolean opaque)(Code) | | Set the opacity flag for this layer. True means that this
layer does not have any transparent or translucent areas
Parameters: opaque - a flag indicating the layer's opacity |
setSupportsInput | public void setSupportsInput(boolean support)(Code) | | Toggle the ability of this layer to receive input.
Parameters: support - If true, this layer will receive user input events(as long as the layer is also visible) |
setVisible | public void setVisible(boolean visible)(Code) | | Toggle the visibility state of this layer within its containing
window.
Parameters: visible - If true, this layer will be painted as part of itscontaining window, as well as receive events if itsupports input. |
subDirtyRegion | boolean subDirtyRegion(int x, int y, int w, int h)(Code) | | Subtract a layer area not needed for repaint of this layer.
It could be needed for a variety of reasons, such as layer being
overlapped with opague higher layer or window element.
The subtracted region should be in the coordinate space
of this layer.
Parameters: x - the x coordinate of the region Parameters: y - the y coordinate of the region Parameters: w - the width of the region Parameters: h - the height of the region true if dirty region of the layer was changed,false otherwise |
supportsInput | public boolean supportsInput()(Code) | | Determine if this layer supports input, such as key and pen events.
true if this layer supports handling input events |
toString | public String toString()(Code) | | Get the layer details including
its bound and dirty region information
String with layer details |
|
|