Package org.opentrafficsim.draw.core
Class TextProperties
- java.lang.Object
-
- org.opentrafficsim.draw.core.TextProperties
-
- All Implemented Interfaces:
java.io.Serializable
public class TextProperties extends java.lang.Object implements java.io.Serializable
Properties for text to identify animated objects in OTS.Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
$LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Jan 17, 2017
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TextProperties()
Construct a default set of text properties for animation.TextProperties(TextAlignment textAlignment, java.awt.Color color, float fontSize)
Construct a set of text properties for animation with alignment, color and size.TextProperties(TextAlignment textAlignment, java.awt.Color color, float fontSize, java.lang.String font, java.util.Map<java.awt.font.TextAttribute,java.lang.Object> textAttributes)
Construct a set of text properties for animation with alignment, color and size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.Color
getColor()
java.lang.String
getFont()
float
getFontSize()
TextAlignment
getTextAlignment()
java.util.Map<java.awt.font.TextAttribute,java.lang.Object>
getTextAttributes()
void
setBold(boolean bold)
Set the weight to either WEIGHT_REGULAR or WEIGHT_BOLD.void
setBold(TextWeight weight)
Set the weight to one of multiple weight constants.void
setItalic(boolean italic)
Set the posture to either POSTURE_REGULAR or POSTURE_OBLIQUE (italic).void
setStrikethrough(boolean strikethrough)
Set the strikethrough on or off.void
setUnderline(boolean underline)
Set the underline on or off.void
setWeightBold(TextWidth width)
Set the width to WIDTH_CONDENSED, WIDTH_REGULAR, or WIDTH_EXTENDED.java.lang.String
toString()
-
-
-
Constructor Detail
-
TextProperties
public TextProperties()
Construct a default set of text properties for animation.
-
TextProperties
public TextProperties(TextAlignment textAlignment, java.awt.Color color, float fontSize)
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, java.awt.Color color, float fontSize, java.lang.String font, java.util.Map<java.awt.font.TextAttribute,java.lang.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 Detail
-
getTextAlignment
public final TextAlignment getTextAlignment()
- Returns:
- textAlignment
-
getColor
public final java.awt.Color getColor()
- Returns:
- color
-
getFont
public final java.lang.String getFont()
- Returns:
- font
-
getTextAttributes
public final java.util.Map<java.awt.font.TextAttribute,java.lang.Object> 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
public final void setBold(TextWeight weight)
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
public final void setWeightBold(TextWidth width)
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
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-