Package org.opentrafficsim.draw
Class TextProperties
java.lang.Object
org.opentrafficsim.draw.TextProperties
- All Implemented Interfaces:
Serializable
Properties for text to identify animated objects in OTS.
Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
-
Constructor Summary
ConstructorDescriptionConstruct a default set of text properties for animation.TextProperties
(TextAlignment textAlignment, Color color, float fontSize) Construct a set of text properties for animation with alignment, color and size.TextProperties
(TextAlignment textAlignment, Color color, float fontSize, String font, Map<TextAttribute, Object> textAttributes) Construct a set of text properties for animation with alignment, color and size. -
Method Summary
Modifier and TypeMethodDescriptionfinal Color
getColor()
final String
getFont()
final float
final TextAlignment
final Map<TextAttribute,
Object> final void
setBold
(boolean bold) Set the weight to either WEIGHT_REGULAR or WEIGHT_BOLD.final void
setBold
(TextWeight weight) Set the weight to one of multiple weight constants.final void
setItalic
(boolean italic) Set the posture to either POSTURE_REGULAR or POSTURE_OBLIQUE (italic).final void
setStrikethrough
(boolean strikethrough) Set the strikethrough on or off.final void
setUnderline
(boolean underline) Set the underline on or off.final void
setWeightBold
(TextWidth width) Set the width to WIDTH_CONDENSED, WIDTH_REGULAR, or WIDTH_EXTENDED.final String
toString()
-
Constructor Details
-
TextProperties
public TextProperties()Construct a default set of text properties for animation. -
TextProperties
Construct a set of text properties for animation with alignment, color and size.- Parameters:
textAlignment
- TextAlignment; the text alignment (LEFT, CENTER or RIGHT)color
- Color; the color of the textfontSize
- float; the size of the font (in units of the animation, e.g., meters)
-
TextProperties
public TextProperties(TextAlignment textAlignment, Color color, float fontSize, String font, Map<TextAttribute, Object> textAttributes) Construct a set of text properties for animation with alignment, color and size.- Parameters:
textAlignment
- TextAlignment; the text alignment (LEFT, CENTER or RIGHT)color
- Color; the color of the text, e.g., Color.REDfontSize
- float; the size of the font (in units of the animation, e.g., meters)font
- String; the name of the font, e.g., specified as Font.SERIFtextAttributes
- Map<TextAttribute,Object>; a map of text attributes to set, e.g., UNDERLINE or WEIGHT
-
-
Method Details
-
getTextAlignment
- Returns:
- textAlignment
-
getColor
- Returns:
- color
-
getFont
- Returns:
- font
-
getTextAttributes
- Returns:
- textAttributes
-
getFontSize
public final float getFontSize()- Returns:
- fontSize
-
setBold
public final void setBold(boolean bold) Set the weight to either WEIGHT_REGULAR or WEIGHT_BOLD.- Parameters:
bold
- boolean; whether the font is bold or regular
-
setBold
Set the weight to one of multiple weight constants.- Parameters:
weight
- TextWeight; the weight of the font to use
-
setItalic
public final void setItalic(boolean italic) Set the posture to either POSTURE_REGULAR or POSTURE_OBLIQUE (italic).- Parameters:
italic
- boolean; whether the font is italic or regular
-
setWeightBold
Set the width to WIDTH_CONDENSED, WIDTH_REGULAR, or WIDTH_EXTENDED.- Parameters:
width
- TextWidth; the TextWidth to use
-
setUnderline
public final void setUnderline(boolean underline) Set the underline on or off.- Parameters:
underline
- boolean; whether the font is underlined or regular
-
setStrikethrough
public final void setStrikethrough(boolean strikethrough) Set the strikethrough on or off.- Parameters:
strikethrough
- boolean; whether the font is strikethrough or regular
-
toString
-