|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectfang.Sprite
fang.StringSprite
public class StringSprite
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 tipgame.fonts 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 tipgame.fonts to make sure the target computers are able to properly display the font (since not all computers have the same fonts available by default). This class differs from the PrettyStringSprite in that it is much faster and sometimes does not represent the font as cleanly.
| Field Summary |
|---|
| Fields inherited from class fang.Sprite |
|---|
color, config, DEBUG_BOUNDING_BOX, DEBUG_INTERSECTS, debugBoundingBoxColor, image, optimizeForBitmap, shape, tracker, transform |
| Constructor Summary | |
|---|---|
StringSprite()
makes a Sprite containing a String resized so that the height is 1 pixel |
|
StringSprite(double initialScale)
Create a StringSprite with a height scale set to the given value. |
|
StringSprite(String text)
makes a Sprite containing a String resized so that the height is 1 pixel |
|
StringSprite(String text,
boolean keepAspect)
makes a Sprite containing a String resized so that the height is 1 pixel |
|
StringSprite(String text,
boolean keepAspect,
double baseRotate)
makes a Sprite containing a String resized so that the height is 1 pixel |
|
StringSprite(String text,
double initialScale)
Create a StringSprite with a height scale set to the given value. |
|
| 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. |
boolean |
getAspect()
gets whether the dimensions should or should not be manipulated to fill a square |
Box2D |
getBounds2D()
gets the bounds of the shape |
Font |
getFont()
gets the style of the current text |
String |
getFontFamilyName()
gets the family name of the font |
double |
getHeight()
gets the height of this Sprite in pixels |
double |
getLineHeight()
gets the full height that this StringSprite could have with any given text |
double |
getLineWidth(int index)
gets the width of a given line of text in this sprite. |
double |
getRotation()
gets the rotation of this sprite. |
double |
getScale()
gets the scale in pixels. |
Shape |
getShape()
gets the rotated bounds of the shape. |
String |
getText()
gets the characters currently in this StringSprite |
double |
getWidth()
gets the width of this Sprite in pixels |
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 |
void |
paint(Graphics2D brush)
paints the text by transforming the brush and placing the characters from the letterRepository |
void |
rightJustify()
makes the position represent the right most position of the string |
void |
scale(double s)
scales the StringSprite by a given factor relative to it's current scale. |
void |
setBold(boolean bold)
sets the thickness of the lettering |
void |
setColor(Color color)
sets the color of this sprite |
void |
setFont(Font font)
sets the style of the current text |
void |
setFontFamilyName(String familyName)
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 |
setKeepAspect(boolean keepAspect)
sets whether the dimensions should or should not be manipulated to fill a square |
void |
setLineHeight(double height)
sets the height of an individual line in pixels |
void |
setMonospaced(boolean monospaced)
sets whether this text should be represented with fixed or variable width text. |
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 |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StringSprite()
public StringSprite(double initialScale)
initialScale - -
scale, in screens, for the full height of the StringSpritepublic StringSprite(String text)
text - -
the String to display
public StringSprite(String text,
boolean keepAspect)
text - the String to displaykeepAspect - true indicates to leave the aspect ratio of the text unchanged
while false means to shrink or expand the text to fit into a
square
public StringSprite(String text,
boolean keepAspect,
double baseRotate)
text - the String to displaykeepAspect - true indicates to leave the aspect ratio of the text unchanged
while false means to shrink or expand the text to fit into a
squarebaseRotate - an initial offset for the rotation which does not affect its
original orientation
public StringSprite(String text,
double initialScale)
text - -
the String to displayinitialScale - -
scale, in screens, for the full height of the StringSprite| Method Detail |
|---|
public void bottomJustify()
public void centerJustify()
public boolean getAspect()
public Box2D getBounds2D()
getBounds2D in class Spritepublic Font getFont()
public String getFontFamilyName()
public double getHeight()
getHeight in class Spritepublic double getLineHeight()
public double getLineWidth(int index)
index - the line number with 0 being the first line
public double getRotation()
getRotation in class Spritefang.core.Sprite#getRotation()public double getScale()
getScale in class Spritepublic Shape getShape()
getShape in class Spritepublic String getText()
public double getWidth()
getWidth in class Spritepublic boolean isBold()
public boolean isItalicized()
public boolean isUnderlined()
public void leftJustify()
public void paint(Graphics2D brush)
paint in class Spritebrush - the drawing instrumentpublic void rightJustify()
public void scale(double s)
scale in class Sprites - the scaling factorpublic void setBold(boolean bold)
bold - true indicates thick lettering, false indicates normal thicknesspublic void setColor(Color color)
setColor in class Spritecolor - the shade of the spritepublic void setFont(Font font)
font - the font being used to generate the textpublic void setFontFamilyName(String familyName)
familyName - the family name of the fontpublic void setHeight(double height)
height - the pixels high of the lines of textpublic void setItalicized(boolean italics)
italics - true indicates slant, false is for no slantpublic void setKeepAspect(boolean keepAspect)
keepAspect - true indicates the normal dimensions should remain unchanged,
false means the text should be expanded to fit a squarepublic void setLineHeight(double height)
height - the height of one line of text in pixelspublic void setMonospaced(boolean monospaced)
monospaced - true indicates fixed width text, false means variable width textpublic void setScale(double scale)
setScale in class Spritescale - the size in pixelspublic void setText(String text)
text - the String for the Sprite to contain
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 square
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 linepublic void setUnderlined(boolean underline)
underline - true indicates there should be a line, false indicates no line
should be therepublic void setWidth(double width)
width - the pixels wide of the original textpublic void topJustify()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||