Class TextPainterHelper

java.lang.Object
org.eclipse.nebula.widgets.ganttchart.utils.TextPainterHelper

public class TextPainterHelper
extends java.lang.Object
Helper class to draw texts with markups within the GanttChart. Currently used for rendering tooltips and section details. Following markups are supported:
  • \\ce - render the following text in black
  • \\c[0-9]{9} - render the following text in the specified rbg color (Note that there need to be nine digits)
  • \\s[0-9]{1,3} - render the following text with the specified font size
  • \\i - render the following text italic
  • \\b - render the following text bold
  • \\x - normalize, which means to reset the previous assigned markups and render with the default font and color
  • Constructor Summary

    Constructors 
    Constructor Description
    TextPainterHelper()  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String cleanUp​(java.lang.String string)
    Removes all markups out of the given string.
    static org.eclipse.swt.graphics.Point drawText​(org.eclipse.swt.graphics.GC gc, java.lang.String text, int x, int y)
    Will draw the given text to the given GC.
    static org.eclipse.swt.graphics.Color getColor​(java.lang.String str)
    Gets the color for a color markup in the given string.
    static int getSize​(java.lang.String str)
    Gets the font size out of a size markup in the given string.
    static boolean isBold​(java.lang.String str)
    Checks for the existence of the bold markup.
    static boolean isItalic​(java.lang.String str)
    Checks for the existence of the italic markup.
    static boolean isNormalize​(java.lang.String str)
    Checks for the existence of the normalize markup.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • drawText

      public static org.eclipse.swt.graphics.Point drawText​(org.eclipse.swt.graphics.GC gc, java.lang.String text, int x, int y)
      Will draw the given text to the given GC. Before drawing the containing markups will be interpreted to apply color and font settings.
      Parameters:
      gc - The GC to draw the text to
      text - The text to draw
      x - The x coordinate where the text should be drawed to the GC
      y - The y coordinate where the text should be drawed to the GC
      Returns:
      The end point of the drawed text.
    • cleanUp

      public static java.lang.String cleanUp​(java.lang.String string)
      Removes all markups out of the given string. Needed to render after all markups have been resolved.
      Parameters:
      string - The string whose markups should be removed.
      Returns:
      The given string without any further markups.
    • isNormalize

      public static boolean isNormalize​(java.lang.String str)
      Checks for the existence of the normalize markup. The normalize markup can be used to reset all former assigned markups for the following text to render. The normalize markup is \\x
      Parameters:
      str - The string to check for the normalize markup
      Returns:
      true if the given string contains the normalize markup
    • isBold

      public static boolean isBold​(java.lang.String str)
      Checks for the existence of the bold markup. The bold markup is \\b
      Parameters:
      str - The string to check for the bold markup
      Returns:
      true if the given string contains the bold markup
    • isItalic

      public static boolean isItalic​(java.lang.String str)
      Checks for the existence of the italic markup. The italic markup is \\i
      Parameters:
      str - The string to check for the italic markup
      Returns:
      true if the given string contains the italic markup
    • getSize

      public static int getSize​(java.lang.String str)
      Gets the font size out of a size markup in the given string. A size markup is specified \\s[0-9]{1,3}
      Parameters:
      str - The string containing the size markup
      Returns:
      The font size to use for rendering
    • getColor

      public static org.eclipse.swt.graphics.Color getColor​(java.lang.String str)
      Gets the color for a color markup in the given string. A color markup is either \\ce for black or \\c[0-9]{9} to specify a custom color by rgb code
      Parameters:
      str - The string containing a color markup
      Returns:
      The Color that is specified by the color markup