Class ContourPlot.Text

java.lang.Object
gov.nih.mipav.model.algorithms.ContourPlot.Text
All Implemented Interfaces:
ContourPlot.Renderable
Enclosing class:
ContourPlot

public class ContourPlot.Text extends Object implements ContourPlot.Renderable
Abstract class for ContourPlot.Renderables representing text that can be rendered using the ContourPlot.TextRenderer. A text object describes a line of characters together with the following attributes:
  • fontsize (e.g. 12 pts.)
  • font style (e.g. FontFont.BOLD)
  • color
  • origin - the bottom left corner of the rectangle enclosing the text
  • angle - the rotation of the text (around origin)
  • picking color - the picking color with which the text is rendered into the (invisible) picking color attachment of an
    invalid reference
    FBO
    . This color may serve as an identifier of the object that can be queried from a location of the rendering canvas. It may take on a value in range of 0xff000001 to 0xffffffff (16.777.214 possible values) or 0.
Author:
hageldave
  • Field Details

    • fontsize

      public final int fontsize
    • style

      public final int style
    • textSize

      protected Dimension textSize
    • color

      protected Color color
    • background

      protected Color background
    • pickColor

      protected int pickColor
    • origin

      protected Point2D origin
    • angle

      protected float angle
    • txtStr

      protected String txtStr
    • isDirty

      protected boolean isDirty
    • hidden

      protected boolean hidden
  • Constructor Details

    • Text

      public Text(String textstr, int fontsize, int style, Color textcolor)
      Creates a new Text object with the specified string and font configuration.
      Parameters:
      textstr - the text to be displayed
      fontsize - point size of the font
      style - of the font - one of Font.PLAIN, Font.BOLD, Font.ITALIC or bitwise union BOLD|ITALIC.
      textcolor - color of the text
    • Text

      public Text(String textstr, int fontsize, int style, int textcolor)
      Creates a new Text object with the specified string and font configuration.
      Parameters:
      textstr - the text to be displayed
      fontsize - point size of the font
      style - of the font - one of Font.PLAIN, Font.BOLD, Font.ITALIC or bitwise union BOLD|ITALIC.
      textcolor - color of the text (integer packed ARGB)
    • Text

      public Text(String textstr, int fontsize, int style)
      Creates a new Text object with the specified string and font configuration.
      Parameters:
      textstr - the text to be displayed
      fontsize - point size of the font
      style - of the font - one of Font.PLAIN, Font.BOLD, Font.ITALIC or bitwise union BOLD|ITALIC.
  • Method Details

    • setTextString

      public ContourPlot.Text setTextString(String txtStr)
      Sets the string of this text. Only characters that are ASCII printable (more precisely ASCII characters [32..126]) will be displayed, other characters are mapped to whitespace for rendering. This set the isDirty() state of this ContourPlot.Renderable to true.
      Parameters:
      txtStr - the text string this object should display.
      Returns:
      this for chaining
    • getTextString

      public String getTextString()
      Returns:
      the String this text object displays
    • intersects

      public boolean intersects(Rectangle2D rect)
      Description copied from interface: ContourPlot.Renderable
      tests if this ContourPlot.Renderable intersects or contains the specified rectangle.
      Specified by:
      intersects in interface ContourPlot.Renderable
      Parameters:
      rect - rectangle to test
      Returns:
      true when intersecting
    • setDirty

      public ContourPlot.Text setDirty()
      Sets the isDirty() state of this renderable to true. This indicates that an
      invalid reference
      #updateGL(boolean)
      call is necessary to sync GL resources.
      Returns:
      this for chaining
    • isDirty

      public boolean isDirty()
      Description copied from interface: ContourPlot.Renderable
      if true, indicates that a call to
      invalid reference
      #updateGL(boolean)
      is necessary to sync this objects GL resources to its current state.
      Specified by:
      isDirty in interface ContourPlot.Renderable
      Returns:
      true if dirty
    • close

      public void close()
      disposes of the GL resources of this text object, i.e deletes the vertex array.
    • setColor

      public ContourPlot.Text setColor(Color color)
      Sets the color of this text
      Parameters:
      color - to set
      Returns:
      this for chaining
    • setColor

      public ContourPlot.Text setColor(int argb)
      Sets the color of this text in integer packed ARGB format. e.g. 0xff00ff00 for opaque green.
      Parameters:
      argb - integer packed ARGB color value
      Returns:
      this for chaining
    • getColor

      public Color getColor()
      Returns:
      this text's color
    • setBackground

      public void setBackground(Color background)
      Sets the background color of the text, per default this is transparent black (0x00000000) which wont be visible.
      Parameters:
      background - color
    • setBackground

      public void setBackground(int argb)
      Sets the background color of the text, per default this is transparent black (0x00000000) which wont be visible.
      Parameters:
      argb - integer packed ARGB color value
    • getBackground

      public Color getBackground()
    • getColorR

      public float getColorR()
      Returns:
      normalized red channel of this text's color (in [0,1])
    • getColorG

      public float getColorG()
      Returns:
      normalized green channel of this text's color (in [0,1])
    • getColorB

      public float getColorB()
      Returns:
      normalized blue channel of this text's color (in [0,1])
    • getColorA

      public float getColorA()
      Returns:
      normalized alpha channel of this text's color (in [0,1])
    • setPickColor

      public ContourPlot.Text setPickColor(int pickColor)
      Sets the picking color of this ContourPlot.Text object. The picking color is the color with which quads of the individual characters are rendered into the (invisible) picking color attachment of an
      invalid reference
      FBO
      . This color may serve as an identifier of the object that can be queried from a location of the rendering canvas. It may take on a value in range of 0xff000001 to 0xffffffff (16.777.214 possible values).
      Parameters:
      pickColor - opaque integer packed RGB value, 0 or one in [0xff000001..0xffffffff]. When a transparent color is specified its alpha channel will be set to 0xff to make it opaque.
      Returns:
      this for chaining
    • getPickColor

      public int getPickColor()
      Returns:
      the picking color of this ContourPlot.Text object
    • getPickColorR

      public float getPickColorR()
      Returns:
      the normalized red channel of the picking color (in [0,1])
    • getPickColorG

      public float getPickColorG()
      Returns:
      the normalized green channel of the picking color (in [0,1])
    • getPickColorB

      public float getPickColorB()
      Returns:
      the normalized blue channel of the picking color (in [0,1])
    • getPickColorA

      public float getPickColorA()
      Returns:
      the normalized alpha channel of the picking color (in [0,1])
    • getTextSize

      public Dimension getTextSize()
      Returns:
      the dimensions in pixels of this text object
    • getBounds

      public Rectangle2D getBounds()
      Returns:
      the bounding rectangle of this text
    • getBoundsWithRotation

      public Rectangle2D getBoundsWithRotation()
      Returns:
      the bounding rectangle of this text with its rotation taken into account.
    • getOrigin

      public Point2D getOrigin()
      Returns:
      the origin of this text object, i.e. the bottom left corner of the rectangle enclosing the text, the text's location so to say
    • setOrigin

      public ContourPlot.Text setOrigin(Point2D origin)
      Sets the origin of this text object, i.e. the bottom left corner of the rectangle enclosing the text, the text's location so to say
      Parameters:
      origin - to set
      Returns:
      this for chaining
    • setOrigin

      public ContourPlot.Text setOrigin(int x, int y)
      Sets the origin of this text object, i.e. the bottom left corner of the rectangle enclosing the text, the text's location so to say
      Parameters:
      x - coordinate of origin
      y - coordinate of origin
      Returns:
      this for chaining
    • getAngle

      public float getAngle()
      Returns:
      the rotation angle in radian by which this text object is rotated around its origin.
    • setAngle

      public ContourPlot.Text setAngle(double angle)
      Sets the rotation angle in radian by which this text object is rotated around its origin.
      Parameters:
      angle - rotation angle
      Returns:
      this for chaining
    • isHidden

      public boolean isHidden()
      Description copied from interface: ContourPlot.Renderable
      Indicates whether this Renderable is hidden i.e. will not be drawn.
      Specified by:
      isHidden in interface ContourPlot.Renderable
      Returns:
      true when hidden
    • hide

      public ContourPlot.Text hide(boolean hide)
      Hides or unhides this Text object, i.e. sets the isHidden() field value. When hidden, renderers will not draw it.
      Parameters:
      hide - true when hiding
      Returns:
      this for chaining