SyntaxUtilities (jEdit API Documentation)

Package org.gjt.sp.util

## Class SyntaxUtilities

- java.lang.Object
- - org.gjt.sp.util.SyntaxUtilities

-     public class SyntaxUtilities
      extends java.lang.Object

  Syntax utilities that depends on JDK only and syntax package.
  Since:
    4.3pre13

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static IPropertyManager` | `propertyManager` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static java.lang.String` | `getColorHexString​(java.awt.Color c)` | Converts a color object to its hex value.
    `static java.lang.String` | `getColorMatrixString​(java.awt.Color[][] matrix)` |
    `static SyntaxStyle[]` | `loadStyles​(java.lang.String family, int size)` | Loads the syntax styles from the properties, giving them the specified base font family and size.
    `static SyntaxStyle[]` | `loadStyles​(java.lang.String family, int size, boolean color)` | Loads the syntax styles from the properties, giving them the specified base font family and size.
    `static java.awt.Color` | `parseColor​(java.lang.String name, java.awt.Color defaultColor)` |
    `static java.awt.Color[][]` | `parseColorMatrix​(java.lang.String matrix, java.awt.Color[][] defaultColorMatrix)` | Parses a color matrix of the form `"[[red, green], [blue, yellow]]"` into a two dimensional array.
    `static SyntaxStyle` | `parseStyle​(java.lang.String str, java.lang.String family, int size, boolean color)` | Converts a style string to a style object.
    `static SyntaxStyle` | `parseStyle​(java.lang.String str, java.lang.String family, int size, boolean color, java.awt.Color defaultFgColor)` | Converts a style string to a style object.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### propertyManager

          public static IPropertyManager propertyManager

  - ### Method Detail

    - #### getColorHexString

          public static java.lang.String getColorHexString​(java.awt.Color c)

      Converts a color object to its hex value. The hex value prefixed is with `#', for example `#ff0088'.
      Parameters:
        `c` - The color object
      Returns:
        the color (it is prefixed with alpha channel)
      Since:
        jEdit 4.3pre13

    - #### parseColor

          public static java.awt.Color parseColor​(java.lang.String name,
                                                  java.awt.Color defaultColor)

      Since:
        jEdit 4.3pre13

    - #### getColorMatrixString

          public static java.lang.String getColorMatrixString​(java.awt.Color[][] matrix)

    - #### parseColorMatrix

          public static java.awt.Color[][] parseColorMatrix​(java.lang.String matrix,
                                                            java.awt.Color[][] defaultColorMatrix)

      Parses a color matrix of the form `"[[red, green], [blue, yellow]]"` into a two dimensional array. If the syntax is invalid, the given default value is returned. For the individual colors the same syntax as for `parseColor(String, Color)` is supported.

      Only rectangular matrices are supported. If the lines of the matrix have different lengths, also the default value is returned.

      Parameters:
        `matrix` - The color matrix
        `defaultColorMatrix` - The default value if there was a syntax error
      Since:
        jEdit 5.6

    - #### parseStyle

          public static SyntaxStyle parseStyle​(java.lang.String str,
                                               java.lang.String family,
                                               int size,
                                               boolean color,
                                               java.awt.Color defaultFgColor)
                                        throws java.lang.IllegalArgumentException

      Converts a style string to a style object.
      Parameters:
        `str` - The style string
        `family` - Style strings only specify font style, not font family
        `size` - Style strings only specify font style, not font family
        `color` - If false, the styles will be monochrome
        `defaultFgColor` - Default foreground color (if not specified in style string)
      Throws:
        `java.lang.IllegalArgumentException` - if the style is invalid
      Since:
        jEdit 4.3pre17

    - #### parseStyle

          public static SyntaxStyle parseStyle​(java.lang.String str,
                                               java.lang.String family,
                                               int size,
                                               boolean color)
                                        throws java.lang.IllegalArgumentException

      Converts a style string to a style object.
      Parameters:
        `str` - The style string
        `family` - Style strings only specify font style, not font family
        `size` - Style strings only specify font style, not font family
        `color` - If false, the styles will be monochrome
      Throws:
        `java.lang.IllegalArgumentException` - if the style is invalid
      Since:
        jEdit 4.3pre13

    - #### loadStyles

          public static SyntaxStyle[] loadStyles​(java.lang.String family,
                                                 int size)

      Loads the syntax styles from the properties, giving them the specified base font family and size.
      Parameters:
        `family` - The font family
        `size` - The font size
      Since:
        jEdit 4.3pre13

    - #### loadStyles

          public static SyntaxStyle[] loadStyles​(java.lang.String family,
                                                 int size,
                                                 boolean color)

      Loads the syntax styles from the properties, giving them the specified base font family and size.
      Parameters:
        `family` - The font family
        `size` - The font size
        `color` - If false, the styles will be monochrome
      Since:
        jEdit 4.3pre13