Methods Summary |
---|
public java.lang.String | getTitle()Get the title of this layer.
return title;
|
protected void | initialize()The TitleLayer overrides the initialize method in order to locate
the title layer in the window at the position and dimensions defined
in the TitleSkin.
super.initialize();
setAnchor();
|
protected void | paintBody(Graphics g)Draw the body of this layer. This method uses settings in the
TitleSkin to render the title at the correct location using
specified font and color values.
String title = this.title;
if (title == null) {
return;
}
if (titlex == 0) {
// anchor isn't set yet
titlew = TitleSkin.FONT.stringWidth(title);
if (titlew > (ScreenSkin.WIDTH - (2 * TitleSkin.MARGIN))) {
titlew = ScreenSkin.WIDTH - (2 * TitleSkin.MARGIN);
}
switch (TitleSkin.TEXT_ALIGN_X) {
case Graphics.HCENTER:
titlex = (ScreenSkin.WIDTH - titlew) / 2;
break;
case Graphics.RIGHT:
titlex =
(ScreenSkin.WIDTH - TitleSkin.MARGIN - titlew);
break;
case Graphics.LEFT:
default:
titlex = TitleSkin.MARGIN;
break;
}
// We center the title vertically in the
// space provided
titleh = TitleSkin.FONT.getHeight();
if (titleh < TitleSkin.HEIGHT) {
titley = (TitleSkin.HEIGHT - titleh) / 2;
} else {
titley = 0;
}
}
g.translate(titlex, titley);
Text.drawTruncStringShadowed(g, title, TitleSkin.FONT, TitleSkin.COLOR_FG,
TitleSkin.COLOR_FG_SHD, TitleSkin.TEXT_SHD_ALIGN,
titlew);
g.translate(-titlex, -titley);
|
public void | setAnchor()Sets the anchor constraints for rendering operation.
bounds[X] = 0;
bounds[Y] = 0;
bounds[W] = ScreenSkin.WIDTH;
bounds[H] = TitleSkin.HEIGHT;
titlex = 0;
|
public boolean | setTitle(java.lang.String title)Set the title of this title layer.
boolean oldVisible = this.visible;
this.title = title;
setDirty();
this.visible = (title != null);
// force a re-calc of the text anchor location
titlex = 0;
return (oldVisible != this.visible);
|
public void | update(com.sun.midp.chameleon.CLayer[] layers)Update bounds of layer
super.update(layers);
setAnchor();
|