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

public class Style
extends StyleConstants
A style is a whole set of settings for a graphic element.

Styles inherit each others. By default a style is all set to invalid values meaning "unset". This means that the value is to be taken from the parent. The getters are able to resolve this process by themselves and therefore must be used instead of a direct access to fields.

  • Constructor Details

    • Style

      public Style()
      New style with all settings to a special value meaning "unset". In this modeField, all the settings are inherited from the parent (when set).
    • Style

      public Style​(Rule parent)
      New style with all settings to a special value meaning "unset". In this modeField, all the settings are inherited from the parent.
      Parameters:
      parent - The parent style.
  • Method Details

    • getParent

      public Rule getParent()
      The parent style.
      Returns:
      a style from which some settings are inherited.
    • getValue

      public Object getValue​(String property, String... events)
      Get the value of a given property. This code is the same for all "getX" methods so we explain it once here. This is the implementation of style inheritance. First if some event is actually occurring, the alternative styles are searched first. If these events have unset values for the property, their parent are then searched. If the value for the property is not found in the alternative styles, alternative styles parents, or if there is no event occurring actually, this style is checked. If its value is unset, the parents of this style are checked. Classes are not checked here, they are processed in the StyleGroup class.
      Parameters:
      property - The style property the value is searched for.
    • hasValue

      public boolean hasValue​(String field, String... events)
      True if the given field exists in this style only (not the parents).
      Parameters:
      field - The field to test.
      Returns:
      True if this style has a value for the given field.
    • getFillMode

      public StyleConstants.FillMode getFillMode()
      How to fill the content of an element.
    • getFillColors

      public Colors getFillColors()
      Which color(s) to use for fill modes that use it.
    • getFillColorCount

      public int getFillColorCount()
    • getFillColor

      public Color getFillColor​(int i)
    • getFillImage

      public String getFillImage()
      Which image to use when filling the element contents with it.
    • getStrokeMode

      public StyleConstants.StrokeMode getStrokeMode()
      How to draw the element contour.
    • getStrokeColor

      public Colors getStrokeColor()
      How to color the element contour.
    • getStrokeColorCount

      public int getStrokeColorCount()
    • getStrokeColor

      public Color getStrokeColor​(int i)
    • getStrokeWidth

      public Value getStrokeWidth()
      Width of the element contour.
    • getShadowMode

      public StyleConstants.ShadowMode getShadowMode()
      How to draw the shadow of the element.
    • getShadowColors

      public Colors getShadowColors()
      Color(s) of the element shadow.
    • getShadowColorCount

      public int getShadowColorCount()
    • getShadowColor

      public Color getShadowColor​(int i)
    • getShadowWidth

      public Value getShadowWidth()
      Width of the element shadow.
    • getShadowOffset

      public Values getShadowOffset()
      Offset of the element shadow centre according to the element centre.
    • getPadding

      public Values getPadding()
      Additional space to add inside the element between its contour and its contents.
    • getTextMode

      public StyleConstants.TextMode getTextMode()
      How to draw the text of the element.
    • getTextVisibilityMode

      public StyleConstants.TextVisibilityMode getTextVisibilityMode()
      How and when to show the text of the element.
    • getTextVisibility

      public Values getTextVisibility()
      Visibility values if the text visibility changes.
    • getTextColor

      public Colors getTextColor()
      The text color(s).
    • getTextColorCount

      public int getTextColorCount()
    • getTextColor

      public Color getTextColor​(int i)
    • getTextStyle

      public StyleConstants.TextStyle getTextStyle()
      The text font style variation.
    • getTextFont

      public String getTextFont()
      The text font.
    • getTextSize

      public Value getTextSize()
      The text size in points.
    • getIconMode

      public StyleConstants.IconMode getIconMode()
      How to draw the icon around the text (or instead of the text).
    • getIcon

      public String getIcon()
      The icon image to use.
    • getVisibilityMode

      public StyleConstants.VisibilityMode getVisibilityMode()
      How and when to show the element.
    • getVisibility

      public Values getVisibility()
      The element visibility if it is variable.
    • getSizeMode

      public StyleConstants.SizeMode getSizeMode()
      How to size the element.
    • getSize

      public Values getSize()
      The element dimensions.
    • getShapePoints

      public Values getShapePoints()
      The element polygonal shape.
    • getTextAlignment

      public StyleConstants.TextAlignment getTextAlignment()
      How to align the text according to the element centre.
    • getTextBackgroundMode

      public StyleConstants.TextBackgroundMode getTextBackgroundMode()
    • getTextBackgroundColor

      public Colors getTextBackgroundColor()
    • getTextBackgroundColor

      public Color getTextBackgroundColor​(int i)
    • getTextOffset

      public Values getTextOffset()
      Offset of the text from its computed position.
    • getTextPadding

      public Values getTextPadding()
      Padding of the text inside its background, if any.
    • getShape

      public StyleConstants.Shape getShape()
      The element shape.
    • getJComponent

      public StyleConstants.JComponents getJComponent()
      The element JComponent type if available.
    • getSpriteOrientation

      public StyleConstants.SpriteOrientation getSpriteOrientation()
      How to orient a sprite according to its attachement.
    • getArrowShape

      public StyleConstants.ArrowShape getArrowShape()
      The shape of edges arrows.
    • getArrowImage

      public String getArrowImage()
      Image to use for the arrow.
    • getArrowSize

      public Values getArrowSize()
      Edge arrow dimensions.
    • getCanvasColor

      public Colors getCanvasColor()
      Colour of all non-graph, non-edge, non-node, non-sprite things.
    • getCanvasColorCount

      public int getCanvasColorCount()
    • getCanvasColor

      public Color getCanvasColor​(int i)
    • getZIndex

      public Integer getZIndex()
    • setDefaults

      public void setDefaults()
      Set the default values for each setting.
    • augment

      public void augment​(Style other)
      Copy all the settings of the other style that are set, excepted the parent. Only the settings that have a value (different from "unset") are copied. The parent field is never copied.
      Parameters:
      other - Another style.
    • reparent

      public void reparent​(Rule parent)
      Set or change the parent of the style.
      Parameters:
      parent - The new parent.
    • addAlternateStyle

      public void addAlternateStyle​(String event, Rule alternateStyle)
      Add an alternative style for specific events.
      Parameters:
      event - The event that triggers the alternate style.
      alternateStyle - The alternative style.
    • setValue

      public void setValue​(String field, Object value)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString​(int level)