Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## mars.util
Class EditorFont

    java.lang.Object
      mars.util.EditorFont

    public class EditorFont

extends Object

Specialized Font class designed to be used by both the settings menu methods and the Settings class.

Author:
  Pete Sanderson

Field Summary
`static int` | `DEFAULT_SIZE`
`static int` | `DEFAULT_STYLE_INT`
`static String` | `DEFAULT_STYLE_STRING`
`static int` | `MAX_SIZE`
`static int` | `MIN_SIZE`

Constructor Summary
`EditorFont()`

Method Summary
`static Font` | `createFontFromStringValues(String family, String style, String size)` Creates a new Font object based on the given String specifications.
`static String[]` | `getAllFamilies()` Obtain an array of all available font family names.
`static String[]` | `getCommonFamilies()` Obtain an array of common font family names.
`static String[]` | `getFontStyleStrings()` Get array containing String values for font style names.
`static String` | `sizeIntToSizeString(int size)` Given an int representing font size, returns corresponding string.
`static int` | `sizeStringToSizeInt(String size)` Given a String representing font size, returns corresponding int.
`static String` | `styleIntToStyleString(int style)` Given an int that represents a font style from the Font class, returns the corresponding String.
`static int` | `styleStringToStyleInt(String style)` Given a string that represents a font style, returns the corresponding final int defined in Font: PLAIN, BOLD, ITALIC.
`static String` | `substituteSpacesForTabs(String string)`
`static String` | `substituteSpacesForTabs(String string, int tabSize)` Handy utility to produce a string that substitutes spaces for all tab characters in the given string.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_STYLE_STRING

    public static final String DEFAULT_STYLE_STRING

### DEFAULT_STYLE_INT

    public static final int DEFAULT_STYLE_INT

### MIN_SIZE

    public static final int MIN_SIZE

See Also:
  Constant Field Values

### MAX_SIZE

    public static final int MAX_SIZE

See Also:
  Constant Field Values

### DEFAULT_SIZE

    public static final int DEFAULT_SIZE

See Also:
  Constant Field Values

Constructor Detail

### EditorFont

    public EditorFont()

Method Detail

### 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.

### getFontStyleStrings

    public static String[] getFontStyleStrings()

  Get array containing String values for font style names.

### styleStringToStyleInt

    public static int styleStringToStyleInt(String style)

  Given a string that represents a font style, returns the corresponding final int defined in Font: PLAIN, BOLD, ITALIC. It is not case-sensitive.

  Parameters:
    `style` - String representing the font style name
  Returns:
    The int value of the corresponding Font style constant. If the string does not match any style name, returns Font.PLAIN.

### styleIntToStyleString

    public static String styleIntToStyleString(int style)

  Given an int that represents a font style from the Font class, returns the corresponding String.

  Parameters:
    `style` - Must be one of Font.PLAIN, Font.BOLD, Font.ITALIC.
  Returns:
    The String representation of that style. If the parameter is not one of the above, returns "Plain".

### 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 of styleStringToStyleInt() 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)

### 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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD