|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.golden.gamedev.object.font.SystemFont
Field Summary | |
protected FontMetrics |
fm
|
protected Font |
font
|
Fields inherited from interface com.golden.gamedev.object.GameFont |
CENTER, JUSTIFY, LEFT, RIGHT |
Constructor Summary | |
SystemFont(Font font)
|
|
SystemFont(Font font,
Color color)
|
Method Summary | |
int |
drawString(Graphics2D g,
String s,
int x,
int y)
Draw single line text into graphics context. |
int |
drawString(Graphics2D g,
String s,
int alignment,
int x,
int y,
int width)
|
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. |
Color |
getColor()
|
int |
getHeight()
Returns height of this font. |
int |
getWidth(char c)
Returns width of char c using this font. |
int |
getWidth(String st)
Returns width of String st using this font. |
void |
setColor(Color c)
|
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected final Font font
protected final FontMetrics fm
Constructor Detail |
public SystemFont(Font font, Color color)
public SystemFont(Font font)
Method Detail |
public Color getColor()
public void setColor(Color c)
public int drawString(Graphics2D g, String s, int x, int y)
GameFont
drawString
in interface GameFont
x
coordinate, used to draw next text.public int drawString(Graphics2D g, String s, int alignment, int x, int y, int width)
drawString
in interface GameFont
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 drawn.text
- text to be drawn.alignment
- text alignment: LEFT, RIGHT, CENTER, or JUSTIFY.x
- text x
coordinate.y
- text y
coordinate.width
- width per line.vspace
- additional vertical spacing, in pixel.firstIndent
- first line indentation, in pixel.
y
coordinate, used to draw next paragraph.GameFont.LEFT
,
GameFont.RIGHT
,
GameFont.CENTER
,
GameFont.JUSTIFY
public int getWidth(String st)
GameFont
String st
using this font.
getWidth
in interface GameFont
public int getWidth(char c)
GameFont
char c
using this font.
getWidth
in interface GameFont
public int getHeight()
GameFont
getHeight
in interface GameFont
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |