org.graphstream.ui.graphicGraph.stylesheet
Class StyleConstants

java.lang.Object
  extended by 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.


Nested Class Summary
static class StyleConstants.ArrowShape
          Possible shapes for arrows on edges.
static class StyleConstants.FillMode
          How to fill the contents of the element.
static class StyleConstants.IconMode
          Where to place the icon around the text (or instead of the text).
static class StyleConstants.JComponents
          Possible JComponents.
static class StyleConstants.ShadowMode
          How to draw the shadow of the element.
static class StyleConstants.Shape
          Possible shapes for elements.
static class StyleConstants.ShapeKind
           
static class StyleConstants.SizeMode
          How to set the size of the element.
static class StyleConstants.SpriteOrientation
          Orientation of a sprite toward its attachment point.
static class StyleConstants.StrokeMode
          How to draw the contour of the element.
static class StyleConstants.TextAlignment
          How to align words around their attach point.
static class StyleConstants.TextBackgroundMode
           
static class StyleConstants.TextMode
          How to draw the text of an element.
static class StyleConstants.TextStyle
          Variant of the font.
static class StyleConstants.TextVisibilityMode
          How to show the text of an element.
static class StyleConstants.Units
          The available units for numerical values.
static class StyleConstants.VisibilityMode
          How to show an element.
 
Constructor Summary
StyleConstants()
           
 
Method Summary
static Color convertColor(Object anyValue)
          Try to convert the given string value to a colour.
static String convertLabel(Object value)
          Check if the given value is an instance of CharSequence (String is) and return it as a string.
static Value convertValue(Object value)
          Convert an object to a value with units.
static float convertWidth(Object value)
          Try to convert an arbitrary value to a float.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StyleConstants

public StyleConstants()
Method Detail

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.


Copyright © 2013. All Rights Reserved.