Package org.opentrafficsim.draw.core
Class TextProperties
java.lang.Object
org.opentrafficsim.draw.core.TextProperties
- All Implemented Interfaces:
Serializable
Properties for text to identify animated objects in OTS.
Copyright (c) 2013-2023 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
ConstructorsConstructorDescriptionConstruct 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 ColorgetColor()final StringgetFont()final floatfinal TextAlignmentfinal Map<TextAttribute,Object> final voidsetBold(boolean bold) Set the weight to either WEIGHT_REGULAR or WEIGHT_BOLD.final voidsetBold(TextWeight weight) Set the weight to one of multiple weight constants.final voidsetItalic(boolean italic) Set the posture to either POSTURE_REGULAR or POSTURE_OBLIQUE (italic).final voidsetStrikethrough(boolean strikethrough) Set the strikethrough on or off.final voidsetUnderline(boolean underline) Set the underline on or off.final voidsetWeightBold(TextWidth width) Set the width to WIDTH_CONDENSED, WIDTH_REGULAR, or WIDTH_EXTENDED.final StringtoString()
-
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
-