|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gwtwidgets.client.ui.canvas.Font
org.gwtwidgets.client.ui.canvas.impl.BitmapFontImpl
public class BitmapFontImpl
A BitmapFontImpl object encapsulates a font and knows how to
draw text on a canvas. This base implementation renders bitmap fonts read from
an image and a font descriptor.
The font is usually not usable right after instantiation because asynchronous requests are made towards the server in order to retrieve font specific information. If required, load listeners can be attached to the font object in order to poll its load status.
BitmapFontImpl objects are expensive to create and maintain as two requests are made to the server for the font bitmap and the font descriptor, the entire bitmap is stored in the browser's cache and a costly parsing of the font descriptor is performed.
| Field Summary | |
|---|---|
protected com.google.gwt.user.client.Element |
bitmap
|
protected int |
blockHeight
|
protected java.util.Map |
characters
|
protected boolean |
descriptionLoaded
|
protected boolean |
imageLoaded
|
protected FontLoadListener |
listener
|
| Constructor Summary | |
|---|---|
BitmapFontImpl(java.lang.String bitmapPath,
java.lang.String descriptionPath,
FontLoadListener listener)
Constructs a canvas font and loads required resources from the server. |
|
| Method Summary | |
|---|---|
protected FontLoadListener |
doWithListener(FontLoadListener listener)
Allows substitution of a listener in the constructor of extending classes |
protected void |
drawGlyph(char c,
Canvas canvas,
double charOffsetLeft,
double charOffsetTop,
double charWidth,
double blockHeight,
double destinationX,
double destinationY,
double destinationWidth,
double destinationHeight)
Draws a character. |
void |
drawText(java.lang.String text,
Canvas canvas,
double x,
double y)
|
void |
onError(com.google.gwt.http.client.Request request,
java.lang.Throwable exception)
|
void |
onResponseReceived(com.google.gwt.http.client.Request request,
com.google.gwt.http.client.Response response)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.util.Map characters
protected int blockHeight
protected boolean imageLoaded
protected boolean descriptionLoaded
protected FontLoadListener listener
protected com.google.gwt.user.client.Element bitmap
| Constructor Detail |
|---|
public BitmapFontImpl(java.lang.String bitmapPath,
java.lang.String descriptionPath,
FontLoadListener listener)
bitmapPath to retrieve the
font bitmap as created by the BitmapFontCreatordescriptionPath
bitmapPath - URL to the bitmap containing the font's graphical
representation.descriptionPath - URL to the font's descriptor.listener - Optional listener to execute when the font is ready to use.
Can be null.token - Token to be passed to the listener| Method Detail |
|---|
protected FontLoadListener doWithListener(FontLoadListener listener)
listener -
protected void drawGlyph(char c,
Canvas canvas,
double charOffsetLeft,
double charOffsetTop,
double charWidth,
double blockHeight,
double destinationX,
double destinationY,
double destinationWidth,
double destinationHeight)
drawText(String, Canvas, double, double). Can be overridden by
extending implementations.
c - Character to drawcanvas - Canvas to draw oncharOffsetLeft - Horizontal character offset on the template bitmapcharOffsetTop - Vertical character offset on the template bitmapcharWidth - Glyph widthblockHeight - Glyph heightdestinationX - Destination X on canvasdestinationY - Destination Y on canvasdestinationWidth - Width of character to drawdestinationHeight - Height of character to draw
public void drawText(java.lang.String text,
Canvas canvas,
double x,
double y)
drawText in class Font
public void onError(com.google.gwt.http.client.Request request,
java.lang.Throwable exception)
onError in interface com.google.gwt.http.client.RequestCallback
public void onResponseReceived(com.google.gwt.http.client.Request request,
com.google.gwt.http.client.Response response)
onResponseReceived in interface com.google.gwt.http.client.RequestCallback
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||