|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectfang.Sprite
fang.PrettyStringSprite
public class PrettyStringSprite
This class converts text into a sprite. The text can contain multiple lines by putting in newlines. Also, different true type fonts may be used. During development, the fonts may be loaded automatically from the system, but when publishing the game, all fonts used should be copied into the fang.resources package and should have the extension .ttf In Windows, fonts can typically be found in C:\WINDOWS\Fonts. The files corresponding to the fonts used can be copied into fang.resources to make sure the target computers are able to properly display the font (since not all computers have the same fonts available by default).
| Field Summary |
|---|
| Fields inherited from class fang.Sprite |
|---|
color, config, DEBUG_BOUNDING_BOX, DEBUG_INTERSECTS, debugBoundingBoxColor, image, optimizeForBitmap, shape, tracker, transform |
| Constructor Summary | |
|---|---|
PrettyStringSprite(String text)
makes a Sprite containing a String resized to fit within a square |
|
PrettyStringSprite(String text,
boolean aspect)
makes a Sprite containing a String |
|
PrettyStringSprite(String text,
boolean aspect,
double baseRotate)
makes a Sprite containing a String |
|
| Method Summary | |
|---|---|
void |
bottomJustify()
makes the position represent the bottom most position of the string |
void |
centerJustify()
makes the position represent the center position of the string. |
Box2D |
getBounds2D()
gets the smallest rectangle which will surrond the shape |
static Font |
getFont(int fontStyle,
String fontFamily)
makes the font from the font family name |
String |
getFontFamilyName()
gets the family name of the font |
double |
getHeight()
gets the vertical span in pixels of this StringSprite |
double |
getLineHeight()
gets the full height that this StringSprite could have with any given text |
Location2D |
getLocation()
returns the position of this StringSprite. |
Shape |
getRotatedBoundingBox()
gets a tight rectangle which fits around the text. |
double |
getRotation()
gets the rotation of this sprite. |
String |
getText()
gets the characters currently in this StringSprite |
double |
getWidth()
gets the horizontal span in pixels of this StringSprite |
boolean |
isBold()
determines the thickness of the lettering |
boolean |
isItalicized()
determines if the text is slanted |
boolean |
isUnderlined()
determines if there is a line at the baseline of the text |
void |
leftJustify()
makes the position represent the left most position of the string |
protected void |
normalize()
currently disabled to prevent loosing height information by rescaling |
void |
rightJustify()
makes the position represent the right most position of the string |
void |
setBold(boolean bold)
sets the thickness of the lettering |
void |
setFontFamilyName(String style)
sets the family name of the font |
void |
setHeight(double height)
makes the size of this sprite such that the height of all lines of the text is a given number of pixels high |
void |
setItalicized(boolean italics)
sets the slant of the text |
void |
setLineHeight(double height)
sets the height of an individual line in pixels |
void |
setLocation(double x,
double y)
moves the StringSprite from its current location to a new location |
void |
setScale(double scale)
sets the scale while keeping the location constant. |
void |
setText(String text)
sets the text of the Sprite |
void |
setText(String text,
boolean aspect)
sets the text of the Sprite |
void |
setText(String text,
boolean aspect,
boolean underline)
updates the text |
void |
setUnderlined(boolean underline)
sets whether there should or should not be a line at the baseline of the text |
void |
setWidth(double width)
makes the size of this sprite such that the width of the text is a given number of pixels |
void |
topJustify()
makes the position represent the top most position of the string |
void |
translate(double x,
double y)
moves the StringSprite from its current location |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PrettyStringSprite(String text)
text - the String for the Sprite to contain
public PrettyStringSprite(String text,
boolean aspect)
text - the String for the Sprite to containaspect - true indicates original width and height should be retained,
false indicates the text should be resized to fit within a
square
public PrettyStringSprite(String text,
boolean aspect,
double baseRotate)
text - the String for the Sprite to containaspect - true indicates original width and height should be retained,
false indicates the text should be resized to fit within a
squarebaseRotate - the original orientation| Method Detail |
|---|
public void setLineHeight(double height)
height - the height of one line of
text in pixelspublic void setHeight(double height)
height - the pixels high of
the lines of textpublic void setScale(double scale)
setScale in class Spritescale - the size in pixelspublic void setItalicized(boolean italics)
italics - true indicates
slant, false is for no slantpublic void setBold(boolean bold)
bold - true indicates thick
lettering, false indicates normal
thicknesspublic boolean isItalicized()
public boolean isBold()
public void leftJustify()
public void topJustify()
public void bottomJustify()
public void rightJustify()
public void centerJustify()
public void setUnderlined(boolean underline)
underline - true indicates there
should be a line, false indicates no line
should be therepublic String getFontFamilyName()
public void setFontFamilyName(String style)
style - the family name of the fontpublic boolean isUnderlined()
protected void normalize()
normalize in class Spritepublic double getLineHeight()
public void translate(double x,
double y)
translate in class Spritex - the amount to move from the current
horizontal positiony - the amount to move from the current
vertical position
public void setLocation(double x,
double y)
setLocation in class Spritex - the new horizontal positiony - the new vertical positionpublic Location2D getLocation()
getLocation in class Spritepublic double getWidth()
getWidth in class Spritepublic Box2D getBounds2D()
getBounds2D in class Spritepublic double getHeight()
getHeight in class Spritepublic void setWidth(double width)
width - the pixels wide of the original text
public static Font getFont(int fontStyle,
String fontFamily)
fontStyle - the style (PLAIN/BOLD/ITALIC)fontFamily - the font's family name
public void setText(String text,
boolean aspect,
boolean underline)
text - the new textaspect - false means the text
should be expanded to fit a square,
true indicates the text should
retain its original shapeunderline - true indicates there
should be a line at the baseline,
false indicates no line
public void setText(String text,
boolean aspect)
text - the String for the Sprite to containaspect - true indicates original width and height should be retained,
false indicates the text should be resized to fit within a
squarepublic void setText(String text)
text - the String for the Sprite to containpublic double getRotation()
getRotation in class Spritefang.core.Sprite#getRotation()public String getText()
public Shape getRotatedBoundingBox()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||