Class StyleConstants

java.lang.Object
org.graphstream.ui.graphicGraph.stylesheet.StyleConstants
Direct Known Subclasses:
Style

public class StyleConstants
extends Object
The various constants and static constant conversion methods used for styling.
  • Constructor Details

  • Method Details

    • convertColor

      public static Color convertColor​(Object anyValue)
      Try to convert the given string value to a colour. It understands the 600 colour names of the X11 RGB data base. It also understands colours given in the "#FFFFFF" format and the hexadecimal "0xFFFFFF" format. Finally, it understands colours given as a "rgb(1,10,100)", CSS-like format. If the input value is null, the result is null.
      Parameters:
      anyValue - The value to convert.
      Returns:
      the converted colour or null if the conversion failed.
    • convertLabel

      public static String convertLabel​(Object value)
      Check if the given value is an instance of CharSequence (String is) and return it as a string. Else return null. If the input value is null, the return value is null. If the value returned is larger than 128 characters, this method cuts it to 128 characters. TODO: allow to set the max length of these strings.
      Parameters:
      value - The value to convert.
      Returns:
      The corresponding string, or null.
    • convertWidth

      public static float convertWidth​(Object value)
      Try to convert an arbitrary value to a float. If it is a descendant of Number, the float value is returned. If it is a string, a conversion is tried to change it into a number and if successful, this number is returned as a float. Else, the -1 value is returned as no width can be negative to indicate the conversion failed. If the input is null, the return value is -1.
      Parameters:
      value - The input to convert.
      Returns:
      The value or -1 if the conversion failed. TODO should be named convertNumber
    • convertValue

      public static Value convertValue​(Object value)
      Convert an object to a value with units. The object can be a number, in which case the value returned contains this number in pixel units. The object can be a string. In this case the strings understood by this method are of the form (spaces, number, spaces, unit, spaces). For example "3px", "45gu", "5.5%", " 25.3 gu ", "4", " 28.1 ".
      Parameters:
      value - A Number or a CharSequence.
      Returns:
      A value.