|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.golden.gamedev.object.font.BitmapFont
public class BitmapFont
Game font that use images for the letter, all the images must have equal dimension (same width and height).
BitmapFont
takes up two parameters, the array of images font and
the sequence of the images, for example if the images font array sequence is
ordered as follow: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", specify the parameter letter
sequence as is.
If the images font has different width, use
AdvanceBitmapFont
instead.
Field Summary | |
---|---|
protected int[] |
charIndex
|
Fields inherited from interface com.golden.gamedev.object.GameFont |
---|
CENTER, JUSTIFY, LEFT, RIGHT |
Constructor Summary | |
---|---|
BitmapFont(BufferedImage[] imagefont)
Creates new BitmapFont with specified images font and
default letter sequence :
! |
|
BitmapFont(BufferedImage[] imagefont,
String letterSequence)
Creates new BitmapFont with specified images font and letter
sequence. |
Method Summary | |
---|---|
int |
drawString(Graphics2D g,
String s,
int x,
int y)
Draw a single line string into graphics context. |
int |
drawString(Graphics2D g,
String s,
int alignment,
int x,
int y,
int width)
Draw a single line string into graphics context with specified alignment. |
int |
drawText(Graphics2D g,
String text,
int alignment,
int x,
int y,
int width,
int vspace,
int firstIndent)
Draw multiple line text into graphics context. |
int |
getHeight()
Returns the height of this font in pixel. |
BufferedImage[] |
getImageFont()
Returns the images font used to draw this bitmap font. |
int |
getWidth(char c)
Returns the width of char c in pixel. |
int |
getWidth(String st)
Returns the width of String st in pixel. |
boolean |
isAvailable(char c)
Returns whether the specified char c is available to draw
by this game font. |
void |
setImageFont(BufferedImage[] imagefont,
String letterSequence)
Sets images font to draw this bitmap font. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int[] charIndex
Constructor Detail |
---|
public BitmapFont(BufferedImage[] imagefont, String letterSequence)
BitmapFont
with specified images font and letter
sequence.
imagefont
- the images font, all images must have same sizeletterSequence
- the order sequence of the images fontpublic BitmapFont(BufferedImage[] imagefont)
BitmapFont
with specified images font and
default letter sequence :
! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ' a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~
imagefont
- the images font, all images must have same sizeMethod Detail |
---|
public int drawString(Graphics2D g, String s, int x, int y)
GameFont
drawString
in interface GameFont
g
- the graphics contexts
- the string to be drawnx
- the x
screen coordinate to draw the texty
- the y
screen coordinate to draw the text
x
coordinate to draw next text.public int drawString(Graphics2D g, String s, int alignment, int x, int y, int width)
GameFont
drawString
in interface GameFont
g
- the graphics contexts
- the string to be drawnalignment
- text alignment: LEFT, RIGHT, CENTER, or JUSTIFYx
- the x
screen coordinate to draw the texty
- the y
screen coordinate to draw the textwidth
- width of the text
x
coordinate to draw next text.public int drawText(Graphics2D g, String text, int alignment, int x, int y, int width, int vspace, int firstIndent)
GameFont
Example to write two paragraph text:
// creates bounding box, to ensure the paragraph exactly in the box g.drawRect(10, 10, 620, 100); int nexty = GameFont.drawText(g, "Paragraph one, sample paragraph using GameFont drawText.", GameFont.LEFT, 10, 10, 620, 0, 50); GameFont.drawText(g, "Paragraph two, notice that each paragraph have 50 pixel indentation.", GameFont.LEFT, // left alignment 10, // x nexty, // y 620, // width 0, // no additional vertical spacing 50); // 50 pixel indentation
drawText
in interface GameFont
g
- graphics context where the text will be drawntext
- text to be drawnalignment
- text alignment: LEFT, RIGHT, CENTER, or JUSTIFYx
- text x
coordinatey
- text y
coordinatewidth
- width per linevspace
- additional vertical spacing, in pixelfirstIndent
- first line indentation, in pixel
y
coordinate to draw next paragraph.GameFont.LEFT
,
GameFont.RIGHT
,
GameFont.CENTER
,
GameFont.JUSTIFY
public BufferedImage[] getImageFont()
public void setImageFont(BufferedImage[] imagefont, String letterSequence)
public int getWidth(char c)
GameFont
char c
in pixel.
getWidth
in interface GameFont
public int getWidth(String st)
GameFont
String st
in pixel.
getWidth
in interface GameFont
public int getHeight()
GameFont
getHeight
in interface GameFont
public String toString()
toString
in class Object
public boolean isAvailable(char c)
GameFont
char c
is available to draw
by this game font.
isAvailable
in interface GameFont
|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |