|
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.SystemFont
public class SystemFont
SystemFont
is standard AWT Font wrapped in game font interface
to be able to draw AWT Font in alignment and other technique.
Field Summary |
---|
Fields inherited from interface com.golden.gamedev.object.GameFont |
---|
CENTER, JUSTIFY, LEFT, RIGHT |
Constructor Summary | |
---|---|
SystemFont(Font font)
Creates new SystemFont with specified AWT Font,
and the color is following graphics context active color. |
|
SystemFont(Font font,
Color color)
Creates new SystemFont with specified AWT Font, and color. |
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. |
Color |
getColor()
Returns the color of this font, or null if the font is drawn following the graphics context active color. |
Font |
getFont()
Returns the AWT Font used to draw this SystemFont . |
FontMetrics |
getFontMetrics()
Returns the font metrics used to measure this SystemFont . |
int |
getHeight()
Returns the height of this font in pixel. |
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 |
setColor(Color c)
Sets the color of this font, or null to draw the font following the graphics context active color. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SystemFont(Font font, Color color)
SystemFont
with specified AWT Font, and color.
font
- AWT Font that used to draw this game fontcolor
- the color to draw the text, or null if the color should follow the graphics context active colorpublic SystemFont(Font font)
SystemFont
with specified AWT Font,
and the color is following graphics context active color.
font
- AWT Font that used to draw this game fontMethod 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 Font getFont()
SystemFont
.
public FontMetrics getFontMetrics()
SystemFont
.
public Color getColor()
public void setColor(Color c)
public int getWidth(String st)
GameFont
String st
in pixel.
getWidth
in interface GameFont
public int getWidth(char c)
GameFont
char c
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 |