Package view
Class TextView
java.lang.Object
view.EntityView
view.TextView
- All Implemented Interfaces:
Configuration
The text view class provides a view for the TextEntity class. If presents a text message, rendered in a specific font, using a specific color.
The default font is "Courier New", in bold with a point size of 12 pixels. The default color is white.
-
Nested Class Summary
Nested classes/interfaces inherited from interface common.Configuration
Configuration.Direction -
Field Summary
Fields inherited from interface common.Configuration
AUDIO_DIR, DEFAULT_FRAME_RATE, DRAWABLE_DIR, GAMELOGGER, setViewCallChain -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the dimensions for the rendered text for the font and point size.getColor()Returns the color for this renderinggetFont()Returns the font in useintThe height of the scaled visual representation for this entity.intgetWidth()The width of the scaled visual representation for this entity.iterator()voidmodifyMessage(String message) Changes the current text to the specified message.Methods inherited from class view.EntityView
draw, drawBounds, getAnimation, getDimension, getScaleX, getScaleY, isWrappedView, setAnimation, setScaleFactor, setWrappedView
-
Constructor Details
-
TextView
Constructor creates a text view with the specified font and color. The width and height are computed based on the font selected.- Parameters:
message- The text messagefont- The font type specifying name, style, and point size.color- The color of the font- See Also:
-
DEFAULT_FONTDEFAULT_COLOR
-
TextView
Constructor using default font with the specified color- Parameters:
message- the displayed textcolor- font color
-
TextView
Constructor using default setting- Parameters:
message- The text to be rendered
-
-
Method Details
-
getFont
Returns the font in use- Returns:
- f The font used to render text
-
getColor
Returns the color for this rendering- Returns:
- color The color setting
-
getBounds
Returns the dimensions for the rendered text for the font and point size.- Returns:
- dim The dimension defining the width and height of the rendered text
-
modifyMessage
Changes the current text to the specified message. The width, the height, and the appearance of the text is modified as needed.- Parameters:
message- The new message
-
iterator
-
getWidth
public int getWidth()Description copied from class:EntityViewThe width of the scaled visual representation for this entity.- Specified by:
getWidthin classEntityView- Returns:
- width
-
getHeight
public int getHeight()Description copied from class:EntityViewThe height of the scaled visual representation for this entity.- Specified by:
getHeightin classEntityView- Returns:
- height
-