Class TextProperties

java.lang.Object
org.opentrafficsim.draw.TextProperties
All Implemented Interfaces:
Serializable

public class TextProperties extends Object implements 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 Details

    • TextProperties

      public TextProperties()
      Construct a default set of text properties for animation.
    • TextProperties

      public TextProperties(TextAlignment textAlignment, 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 text
      fontSize - 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.RED
      fontSize - 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.SERIF
      textAttributes - Map<TextAttribute,Object>; a map of text attributes to set, e.g., UNDERLINE or WEIGHT
  • Method Details

    • getTextAlignment

      public final TextAlignment getTextAlignment()
      Returns:
      textAlignment
    • getColor

      public final Color getColor()
      Returns:
      color
    • getFont

      public final String getFont()
      Returns:
      font
    • getTextAttributes

      public final Map<TextAttribute,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 String toString()
      Overrides:
      toString in class Object