Class ContourPlot.Text

  • All Implemented Interfaces:
    ContourPlot.Renderable
    Enclosing class:
    ContourPlot

    public class ContourPlot.Text
    extends java.lang.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 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 Summary

      Fields 
      Modifier and Type Field Description
      protected float angle  
      protected java.awt.Color background  
      protected java.awt.Color color  
      int fontsize  
      protected boolean hidden  
      protected boolean isDirty  
      protected java.awt.geom.Point2D origin  
      protected int pickColor  
      int style  
      protected java.awt.Dimension textSize  
      protected java.lang.String txtStr  
    • Constructor Summary

      Constructors 
      Constructor Description
      Text​(java.lang.String textstr, int fontsize, int style)
      Creates a new Text object with the specified string and font configuration.
      Text​(java.lang.String textstr, int fontsize, int style, int textcolor)
      Creates a new Text object with the specified string and font configuration.
      Text​(java.lang.String textstr, int fontsize, int style, java.awt.Color textcolor)
      Creates a new Text object with the specified string and font configuration.
    • Field Detail

      • fontsize

        public final int fontsize
      • style

        public final int style
      • textSize

        protected java.awt.Dimension textSize
      • color

        protected java.awt.Color color
      • background

        protected java.awt.Color background
      • pickColor

        protected int pickColor
      • origin

        protected java.awt.geom.Point2D origin
      • angle

        protected float angle
      • txtStr

        protected java.lang.String txtStr
      • isDirty

        protected boolean isDirty
      • hidden

        protected boolean hidden
    • Constructor Detail

      • Text

        public Text​(java.lang.String textstr,
                    int fontsize,
                    int style,
                    java.awt.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​(java.lang.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​(java.lang.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 Detail

      • setTextString

        public ContourPlot.Text setTextString​(java.lang.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 java.lang.String getTextString()
        Returns:
        the String this text object displays
      • setDirty

        public ContourPlot.Text setDirty()
        Sets the isDirty() state of this renderable to true. This indicates that an #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 #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​(java.awt.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 java.awt.Color getColor()
        Returns:
        this text's color
      • setBackground

        public void setBackground​(java.awt.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 java.awt.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 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 java.awt.Dimension getTextSize()
        Returns:
        the dimensions in pixels of this text object
      • getBounds

        public java.awt.geom.Rectangle2D getBounds()
        Returns:
        the bounding rectangle of this text
      • getBoundsWithRotation

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

        public java.awt.geom.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​(java.awt.geom.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
      • 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