Class TextPainter

java.lang.Object
org.csstudio.swt.widgets.util.TextPainter

public final class TextPainter extends Object
Utility class for drawing text at different angles and alignments.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
    Alignment constants.
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    drawRotatedText(org.eclipse.draw2d.Graphics gfx, String text, double angle, int x, int y, int align)
    Draws the given text, rotated for the specified angle (counter-clockwise).
    static void
    drawText(org.eclipse.draw2d.Graphics gfx, String text, int x, int y, int align)
    Draws the given string horizontally at the given anchor point.
    static org.eclipse.draw2d.geometry.Point
    getDelta(org.eclipse.draw2d.Graphics gfx, String text, int align)
    Calculates the offset to the top-left corner of the text, according to the given anchor point.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • TextPainter

      public TextPainter()
  • Method Details

    • getDelta

      public static org.eclipse.draw2d.geometry.Point getDelta(org.eclipse.draw2d.Graphics gfx, String text, int align)
      Calculates the offset to the top-left corner of the text, according to the given anchor point.
      Parameters:
      gfx - the graphics context (need this to get the font)
      text - the text to be drawn
      align - alignment
      Returns:
      the point at which the text is to be drawn
    • drawText

      public static void drawText(org.eclipse.draw2d.Graphics gfx, String text, int x, int y, int align)
      Draws the given string horizontally at the given anchor point.
      Parameters:
      gfx - the graphics context
      text - the text to be drawn
      x - the x coordinate of the anchor
      y - the y coordinate of the anchor
      align - where on the bounding box the anchor is
    • drawRotatedText

      public static void drawRotatedText(org.eclipse.draw2d.Graphics gfx, String text, double angle, int x, int y, int align)
      Draws the given text, rotated for the specified angle (counter-clockwise). The text will be rotated around the anchor.
      Parameters:
      gfx - the graphics context
      text - the text to be drawn
      angle - the rotation of the text, in degrees
      x - the x coordinate of the anchor
      y - the y coordinate of the anchor
      align - where on the bounding box the anchor is