Class AttributesHelper

java.lang.Object
net.sourceforge.jeuclid.elements.support.attributes.AttributesHelper

public final class AttributesHelper extends Object
Class contains utility methods for working with elements attributes.
Version:
$Revision: 1e57f05a780b $
  • Field Details

    • COLOR_TRANSPARENT

      public static final String COLOR_TRANSPARENT
      Constant for "Transparent" color.
      See Also:
    • VERYVERYTHINMATHSPACE

      public static final String VERYVERYTHINMATHSPACE
      Width of veryverythinmath space according to 3.3.4.2.
      See Also:
    • VERYTHINMATHSPACE

      public static final String VERYTHINMATHSPACE
      Width of verythinmath space according to 3.3.4.2.
      See Also:
    • THINMATHSPACE

      public static final String THINMATHSPACE
      Width of thinmath space according to 3.3.4.2.
      See Also:
    • MEDIUMMATHSPACE

      public static final String MEDIUMMATHSPACE
      Width of mediummath space according to 3.3.4.2.
      See Also:
    • THICKMATHSPACE

      public static final String THICKMATHSPACE
      Width of tickmath space according to 3.3.4.2.
      See Also:
    • VERYTHICKMATHSPACE

      public static final String VERYTHICKMATHSPACE
      Width of verytickmath space according to 3.3.4.2.
      See Also:
    • VERYVERYTHICKMATHSPACE

      public static final String VERYVERYTHICKMATHSPACE
      Width of veryverytickmath space according to 3.3.4.2.
      See Also:
    • PT

      public static final String PT
      Unit for pt.
      See Also:
    • INFINITY

      public static final String INFINITY
      Infinity. Should be reasonably large.
      See Also:
  • Method Details

    • parseRelativeSize

      public static float parseRelativeSize(String sizeString, LayoutContext context, float relativeTo)
      Parse a size that is relative to a given size.
      Parameters:
      sizeString - sizeString to parse
      context - Context to use to calculate for absolute sizes.
      relativeTo - This size is relative to the given size (must be in pt).
      Returns:
      a size in pt.
    • convertSizeToPt

      public static float convertSizeToPt(String sizeString, LayoutContext context, String defaultUnit)
      Translates size into pt.
      Parameters:
      sizeString - string to convert
      context - LayoutContext this size is relative to. This is usually the context of the parent or the element itself.
      defaultUnit - default Unit to use in this context. May be px, pt, em, etc.
      Returns:
      Translated value of the size attribute into Point (=Java Pixels).
    • stringToColor

      public static Color stringToColor(String value, Color defaultValue)
      Creates a color from a given string.

      This function supports a wide variety of inputs.

      • #RGB (hex 0..f)
      • #RGBA (hex 0..f)
      • #RRGGBB (hex 00..ff)
      • #RRGGBBAA (hex 00..ff)
      • rgb(r,g,b) (0..255 or 0%..100%)
      • java.awt.Color[r=r,g=g,b=b] (0..255)
      • system-color(colorname)
      • transparent
      • colorname
      Parameters:
      value - the string to parse.
      defaultValue - a default color to use in case of failure.
      Returns:
      a Color representing the string if possible
    • colorTOsRGBString

      public static String colorTOsRGBString(Color color)
      Creates a re-parsable string representation of the given color.

      First, the color will be converted into the sRGB colorspace. It will then be printed as #rrggbb, or as #rrrggbbaa if an alpha value is present.

      Parameters:
      color - the color to represent.
      Returns:
      a re-parsable string representadion.