net.sourceforge.jeuclid.elements.support.attributes
Class AttributesHelper

java.lang.Object
  extended by 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 Summary
static String COLOR_TRANSPARENT
          Constant for "Transparent" color.
static String INFINITY
          Infinity.
static String MEDIUMMATHSPACE
          Width of mediummath space according to 3.3.4.2.
static String PT
          Unit for pt.
static String THICKMATHSPACE
          Width of tickmath space according to 3.3.4.2.
static String THINMATHSPACE
          Width of thinmath space according to 3.3.4.2.
static String VERYTHICKMATHSPACE
          Width of verytickmath space according to 3.3.4.2.
static String VERYTHINMATHSPACE
          Width of verythinmath space according to 3.3.4.2.
static String VERYVERYTHICKMATHSPACE
          Width of veryverytickmath space according to 3.3.4.2.
static String VERYVERYTHINMATHSPACE
          Width of veryverythinmath space according to 3.3.4.2.
 
Method Summary
static String colorTOsRGBString(Color color)
          Creates a re-parsable string representation of the given color.
static float convertSizeToPt(String sizeString, LayoutContext context, String defaultUnit)
          Translates size into pt.
static float parseRelativeSize(String sizeString, LayoutContext context, float relativeTo)
          Parse a size that is relative to a given size.
static Color stringToColor(String value, Color defaultValue)
          Creates a color from a given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLOR_TRANSPARENT

public static final String COLOR_TRANSPARENT
Constant for "Transparent" color.

See Also:
Constant Field Values

VERYVERYTHINMATHSPACE

public static final String VERYVERYTHINMATHSPACE
Width of veryverythinmath space according to 3.3.4.2.

See Also:
Constant Field Values

VERYTHINMATHSPACE

public static final String VERYTHINMATHSPACE
Width of verythinmath space according to 3.3.4.2.

See Also:
Constant Field Values

THINMATHSPACE

public static final String THINMATHSPACE
Width of thinmath space according to 3.3.4.2.

See Also:
Constant Field Values

MEDIUMMATHSPACE

public static final String MEDIUMMATHSPACE
Width of mediummath space according to 3.3.4.2.

See Also:
Constant Field Values

THICKMATHSPACE

public static final String THICKMATHSPACE
Width of tickmath space according to 3.3.4.2.

See Also:
Constant Field Values

VERYTHICKMATHSPACE

public static final String VERYTHICKMATHSPACE
Width of verytickmath space according to 3.3.4.2.

See Also:
Constant Field Values

VERYVERYTHICKMATHSPACE

public static final String VERYVERYTHICKMATHSPACE
Width of veryverytickmath space according to 3.3.4.2.

See Also:
Constant Field Values

PT

public static final String PT
Unit for pt.

See Also:
Constant Field Values

INFINITY

public static final String INFINITY
Infinity. Should be reasonably large.

See Also:
Constant Field Values
Method Detail

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.

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.


Copyright © 2002-2010 The JEuclid project. All Rights Reserved.