Class TextSymbol

All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
LabelSymbol, ValueSymbol

public class TextSymbol extends MetSymbol
A representation of a text MetSymbol.
Version:
$Revision: 1.41 $
Author:
Metapps development team
  • Field Details

    • numberFormatString

      protected String numberFormatString
      Format string for numbers.
    • FONT_SIZES

      public static final String[] FONT_SIZES
      Array of default font sizes used for incrementing/decrementing fonts.
      See Also:
  • Constructor Details

    • TextSymbol

      public TextSymbol()
      Default constructor.
    • TextSymbol

      public TextSymbol(int x, int y)
      Construct a TextSymbol at the position specified. Use the default name and long name.
      Parameters:
      x - x position on the canvas
      y - y position on the canvas
    • TextSymbol

      public TextSymbol(DisplayCanvas canvas, int x, int y)
      Construct a TextSymbol to use on the canvas specified at the position specified. Use the default name and long name.
      Parameters:
      canvas - canvas to draw on.
      x - x position on the canvas
      y - y position on the canvas
    • TextSymbol

      public TextSymbol(String param, String paramDesc)
      Construct a TextSymbol with the name specified.
      Parameters:
      param - parameter to display
      paramDesc - description of the parameter (i.e., long name)
    • TextSymbol

      public TextSymbol(int x, int y, String param, String paramDesc)
      Construct a TextSymbol at the position specified.
      Parameters:
      x - x position on the canvas
      y - y position on the canvas
      param - parameter to display
      paramDesc - description of the parameter (i.e., long name)
    • TextSymbol

      public TextSymbol(DisplayCanvas canvas, int x, int y, String param, String paramDesc)
      Construct a TextSymbol to use on the canvas specified at the position specified.
      Parameters:
      canvas - canvas to draw on.
      x - x position on the canvas
      y - y position on the canvas
      param - parameter to display
      paramDesc - description of the parameter (i.e., long name)
  • Method Details

    • getLabel

      public String getLabel()
      Get the label to show the user what I am in the properties
      Overrides:
      getLabel in class MetSymbol
      Returns:
      label
    • setFont

      public void setFont(Font font)
      Set the font to use when displaying this symbol.
      Parameters:
      font - font to use.
    • getFont

      public Font getFont()
      Get the currently used font.
      Returns:
      current font. May be null
    • incrFontSize

      public void incrFontSize()
      Increase the font size by one step in the FONT_SIZES array.
    • decrFontSize

      public void decrFontSize()
      Decrease the font size by one step in the fontSizes array.
    • getFontList

      public static Font[] getFontList()
      Get a list of fonts to use with this object.
      Returns:
      array of fonts
    • setCurrFontNo

      public void setCurrFontNo(int index)
      Set the index into the array of font sizes.
      Parameters:
      index - index into the FONT_SIZES array
    • getCurrFontNo

      public int getCurrFontNo()
      Get the current font number
      Returns:
      index of current font in the FONT_SIZES array.
    • getFontMetrics

      public FontMetrics getFontMetrics()
      Get the metrics of the current font.
      Returns:
      current font metrics.
    • setFontSize

      public void setFontSize(int size)
      Set the font size.
      Parameters:
      size - point size of font.
    • getFontSize

      public int getFontSize()
      Get the current font size.
      Returns:
      currentFontSize
    • getValueString

      protected String getValueString()
      Get the value string
      Returns:
      a string representation of the size
    • getNumberFormatString

      public String getNumberFormatString()
      Get the format pattern for numeric values.
      Returns:
      formatting pattern string.
      See Also:
    • setNumberFormatString

      public void setNumberFormatString(String s)
      Set the format pattern for numeric values.
      Parameters:
      s - formatting pattern string.
      See Also:
    • formatNumber

      public String formatNumber(double d)
      Format a number using the format pattern set for this instance.
      Parameters:
      d - double to format
      Returns:
      formatted number as a String
      See Also:
    • format

      public String format(Real d)
      Format a Real
      Parameters:
      d - the Real
      Returns:
      the formatted value
    • format

      public String format(double d)
      Format a double values
      Parameters:
      d - the double
      Returns:
      formatted number
    • format

      public String format(float d)
      Format a float
      Parameters:
      d - float
      Returns:
      the formatted number
    • getValue

      public String getValue()
      Get the string representation for the value of this object.
      Returns:
      String representation of number.
    • setValue

      public void setValue(double d)
      Set the value for this object.
      Parameters:
      d - value
    • setValue

      public void setValue(String s)
      Set the value for this object.
      Parameters:
      s - String representation of the value for this object.
    • getParamValue

      public Object getParamValue(int index)
      Get the parameter value for the index specified.
      Overrides:
      getParamValue in class MetSymbol
      Parameters:
      index - index of the parameter (ignored for this instance)
      Returns:
      String value associated with this instance.
    • setParamValue

      public void setParamValue(int index, Object v)
      Set the parameter value for the index specified.
      Overrides:
      setParamValue in class MetSymbol
      Parameters:
      index - index of the parameter (ignored for this instance)
      v - Object that this should represent
    • draw

      public void draw(Graphics2D g, int x, int y, int width, int height)
      Draw this object to the graphics device.
      Specified by:
      draw in class MetSymbol
      Parameters:
      g - Graphics object
      x - x position of the object
      y - y position of the object
      width - width to draw
      height - height to draw
    • toString

      public String toString()
      String representation of this object.
      Overrides:
      toString in class MetSymbol
      Returns:
      String version of this object.
    • makeDefaultFont

      protected Font makeDefaultFont()
      Make a font from the size and using the default.
      Returns:
      a default Font