Package gov.nih.mipav.model.algorithms
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 java.lang.Object implements ContourPlot.Renderable
Abstract class forContourPlot.Renderable
s representing text that can be rendered using theContourPlot.TextRenderer
. A text object describes a line of characters together with the following attributes:- fontsize (e.g. 12 pts.)
- font style (e.g. Font
Font.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
disposes of the GL resources of this text object, i.e deletes the vertex array.float
getAngle()
java.awt.Color
getBackground()
java.awt.geom.Rectangle2D
getBounds()
java.awt.geom.Rectangle2D
getBoundsWithRotation()
java.awt.Color
getColor()
float
getColorA()
float
getColorB()
float
getColorG()
float
getColorR()
java.awt.geom.Point2D
getOrigin()
int
getPickColor()
float
getPickColorA()
float
getPickColorB()
float
getPickColorG()
float
getPickColorR()
java.awt.Dimension
getTextSize()
java.lang.String
getTextString()
ContourPlot.Text
hide(boolean hide)
Hides or unhides this Text object, i.e. sets theisHidden()
field value.boolean
intersects(java.awt.geom.Rectangle2D rect)
tests if thisContourPlot.Renderable
intersects or contains the specified rectangle.boolean
isDirty()
if true, indicates that a call to#updateGL(boolean)
is necessary to sync this objects GL resources to its current state.boolean
isHidden()
Indicates whether this Renderable is hidden i.e. will not be drawn.ContourPlot.Text
setAngle(double angle)
Sets the rotation angle in radian by which this text object is rotated around its origin.void
setBackground(int argb)
Sets the background color of the text, per default this is transparent black (0x00000000) which wont be visible.void
setBackground(java.awt.Color background)
Sets the background color of the text, per default this is transparent black (0x00000000) which wont be visible.ContourPlot.Text
setColor(int argb)
Sets the color of this text in integer packed ARGB format.ContourPlot.Text
setColor(java.awt.Color color)
Sets the color of this textContourPlot.Text
setDirty()
Sets theisDirty()
state of this renderable to true.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 sayContourPlot.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 sayContourPlot.Text
setPickColor(int pickColor)
Sets the picking color of thisContourPlot.Text
object.ContourPlot.Text
setTextString(java.lang.String txtStr)
Sets the string of this text.
-
-
-
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 displayedfontsize
- point size of the fontstyle
- of the font - one ofFont.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 displayedfontsize
- point size of the fontstyle
- of the font - one ofFont.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 displayedfontsize
- point size of the fontstyle
- of the font - one ofFont.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 theisDirty()
state of thisContourPlot.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
-
intersects
public boolean intersects(java.awt.geom.Rectangle2D rect)
Description copied from interface:ContourPlot.Renderable
tests if thisContourPlot.Renderable
intersects or contains the specified rectangle.- Specified by:
intersects
in interfaceContourPlot.Renderable
- Parameters:
rect
- rectangle to test- Returns:
- true when intersecting
-
setDirty
public ContourPlot.Text setDirty()
Sets theisDirty()
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 interfaceContourPlot.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 thisContourPlot.Text
object. The picking color is the color with which quads of the individual characters are rendered into the (invisible) picking color attachment of anFBO
. 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 originy
- 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 interfaceContourPlot.Renderable
- Returns:
- true when hidden
-
hide
public ContourPlot.Text hide(boolean hide)
Hides or unhides this Text object, i.e. sets theisHidden()
field value. When hidden, renderers will not draw it.- Parameters:
hide
- true when hiding- Returns:
- this for chaining
-
-