Package mars.venus

Class EditorFont

java.lang.Object
mars.venus.EditorFont

public class EditorFont extends Object
Specialized Font class designed to be used by both the settings menu methods and the Settings class.
Version:
July 2007
Author:
Pete Sanderson
  • Field Details

  • Constructor Details

    • EditorFont

      public EditorFont()
  • Method Details

    • getCommonFamilies

      public static String[] getCommonFamilies()
      Obtain an array of common font family names. These are guaranteed to be available at runtime, as they were checked against the local GraphicsEnvironment.
      Returns:
      Array of strings, each is a common and available font family name.
    • getAllFamilies

      public static String[] getAllFamilies()
      Obtain an array of all available font family names. These are guaranteed to be available at runtime, as they come from the local GraphicsEnvironment.
      Returns:
      Array of strings, each is an available font family name.
    • getStyle

      public static EditorFont.Style getStyle(String name)
      Given the name of a font style, returns the corresponding EditorFont.Style. The style name is not case-sensitive.
      Parameters:
      name - The name of the font style.
      Returns:
      The style with the name given. If the name does not correspond to a valid style, EditorFont.Style.DEFAULT is returned.
    • getStyle

      public static EditorFont.Style getStyle(int flags)
      Given an int field of flags that represents a font style from the Font class, returns the corresponding EditorFont.Style.
      Parameters:
      flags - A combination of style flags from the Font class.
      Returns:
      The style corresponding to the flags given. If the flags do not correspond to a valid style, EditorFont.Style.DEFAULT is returned.
    • sizeIntToSizeString

      public static String sizeIntToSizeString(int size)
      Given an int representing font size, returns corresponding string.
      Parameters:
      size - Int representing size.
      Returns:
      String value of parameter, unless it is less than MIN_SIZE (returns MIN_SIZE as String) or greater than MAX_SIZE (returns MAX_SIZE as String).
    • sizeStringToSizeInt

      public static int sizeStringToSizeInt(String size)
      Given a String representing font size, returns corresponding int.
      Parameters:
      size - String representing size.
      Returns:
      int value of parameter, unless it is less than MIN_SIZE (returns MIN_SIZE) or greater than MAX_SIZE (returns MAX_SIZE). If the string cannot be parsed as a decimal integer, it returns DEFAULT_SIZE.
    • createFontFromStringValues

      public static Font createFontFromStringValues(String family, String style, String size)
      Creates a new Font object based on the given String specifications. This is different than Font's constructor, which requires ints for style and size. It assures that defaults and size limits are applied when necessary.
      Parameters:
      family - String containing font family.
      style - String containing font style. A list of available styles can be obtained from getFontStyleStrings(). The default style is substituted if necessary.
      size - String containing font size. The defaults and limits of sizeStringToSizeInt() are substituted if necessary.
    • substituteSpacesForTabs

      public static String substituteSpacesForTabs(String string, int tabSize)
      Handy utility to produce a string that substitutes spaces for all tab characters in the given string. The number of spaces generated is based on the position of the tab character and the specified tab size.
      Parameters:
      string - The original string
      tabSize - The number of spaces each tab character represents
      Returns:
      New string in which spaces are substituted for tabs
      Throws:
      NullPointerException - if string is null