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.Renderables 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 floatangleprotected java.awt.Colorbackgroundprotected java.awt.Colorcolorintfontsizeprotected booleanhiddenprotected booleanisDirtyprotected java.awt.geom.Point2Doriginprotected intpickColorintstyleprotected java.awt.DimensiontextSizeprotected java.lang.StringtxtStr
-
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 voidclose()disposes of the GL resources of this text object, i.e deletes the vertex array.floatgetAngle()java.awt.ColorgetBackground()java.awt.geom.Rectangle2DgetBounds()java.awt.geom.Rectangle2DgetBoundsWithRotation()java.awt.ColorgetColor()floatgetColorA()floatgetColorB()floatgetColorG()floatgetColorR()java.awt.geom.Point2DgetOrigin()intgetPickColor()floatgetPickColorA()floatgetPickColorB()floatgetPickColorG()floatgetPickColorR()java.awt.DimensiongetTextSize()java.lang.StringgetTextString()ContourPlot.Texthide(boolean hide)Hides or unhides this Text object, i.e. sets theisHidden()field value.booleanintersects(java.awt.geom.Rectangle2D rect)tests if thisContourPlot.Renderableintersects or contains the specified rectangle.booleanisDirty()if true, indicates that a call to#updateGL(boolean)is necessary to sync this objects GL resources to its current state.booleanisHidden()Indicates whether this Renderable is hidden i.e. will not be drawn.ContourPlot.TextsetAngle(double angle)Sets the rotation angle in radian by which this text object is rotated around its origin.voidsetBackground(int argb)Sets the background color of the text, per default this is transparent black (0x00000000) which wont be visible.voidsetBackground(java.awt.Color background)Sets the background color of the text, per default this is transparent black (0x00000000) which wont be visible.ContourPlot.TextsetColor(int argb)Sets the color of this text in integer packed ARGB format.ContourPlot.TextsetColor(java.awt.Color color)Sets the color of this textContourPlot.TextsetDirty()Sets theisDirty()state of this renderable to true.ContourPlot.TextsetOrigin(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.TextsetOrigin(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.TextsetPickColor(int pickColor)Sets the picking color of thisContourPlot.Textobject.ContourPlot.TextsetTextString(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.ITALICor 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.ITALICor 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.ITALICor 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.Renderableto 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.Renderabletests if thisContourPlot.Renderableintersects or contains the specified rectangle.- Specified by:
intersectsin 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.Renderableif true, indicates that a call to#updateGL(boolean)is necessary to sync this objects GL resources to its current state.- Specified by:
isDirtyin 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.Textobject. 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.Textobject
-
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.RenderableIndicates whether this Renderable is hidden i.e. will not be drawn.- Specified by:
isHiddenin 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
-
-