Package gov.nih.mipav.model.algorithms
Class ContourPlot.CharacterAtlas
- java.lang.Object
-
- gov.nih.mipav.model.algorithms.ContourPlot.CharacterAtlas
-
- Enclosing class:
- ContourPlot
public static class ContourPlot.CharacterAtlas extends java.lang.Object
The CharacterAtlas class is a texture atlas for looking up character textures. That is a texture containing rendered characters at specific positions. This is used to be able to render an arbitrary sequence of characters by looking up the corresponding area in the texture. AContourPlot.CharacterAtlas
is defined by:- its font size
- its font style (PLAIN, ITALIC, BOLD, BOLD|ITALIC)
ContourPlot.FontProvider
. This implementation limits the possible characters to the ones listed inContourPlot.SignedDistanceCharacters.CHARACTERS
. Any other character will be mapped to white space and will thus be invisible in the render. To obtain a character atlas use the staticCharacterAtlas#get(int, int)
method. AVertexArray
with 2D vertices on the first attribute and 2D texture coordinates on the second can be retrieved for a specified string usingCharacterAtlas#createVAforString(String, VertexArray)
.- Author:
- hageldave
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.HashMap<java.lang.Integer,java.util.HashMap<ContourPlot.GenericKey,ContourPlot.CharacterAtlas>>
ATLAS_COLLECTION
protected static float
botPaddingFactor
private static char[]
CHARACTERS
int
charHeigth
int
charWidth
protected static java.util.HashMap<java.lang.Integer,java.util.HashMap<java.lang.Integer,int[]>>
CONTEXT_2_STYLE_2_TEXTUREREF
java.awt.Font
font
protected static ContourPlot.Img
FONTMETRIC_IMG
int
fontSize
protected static float
leftPaddingFactor
int
owningCanvasID
protected static float
rightPaddingFactor
ContourPlot.SignedDistanceCharacters
sdChars
int
style
protected int
texID
protected static float
topPaddingFactor
-
Constructor Summary
Constructors Constructor Description CharacterAtlas()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.awt.geom.Rectangle2D
boundsForText(int textlength, int fontSize, int style)
CallsboundsForText(int, Font)
with corresponding Ubuntu Mono font.static java.awt.geom.Rectangle2D
boundsForText(int textlength, java.awt.Font font)
Calculates the bounding rectangle for a specific number of characters in the specified font.
-
-
-
Field Detail
-
CHARACTERS
private static final char[] CHARACTERS
-
FONTMETRIC_IMG
protected static final ContourPlot.Img FONTMETRIC_IMG
-
ATLAS_COLLECTION
protected static final java.util.HashMap<java.lang.Integer,java.util.HashMap<ContourPlot.GenericKey,ContourPlot.CharacterAtlas>> ATLAS_COLLECTION
-
CONTEXT_2_STYLE_2_TEXTUREREF
protected static final java.util.HashMap<java.lang.Integer,java.util.HashMap<java.lang.Integer,int[]>> CONTEXT_2_STYLE_2_TEXTUREREF
-
leftPaddingFactor
protected static final float leftPaddingFactor
- See Also:
- Constant Field Values
-
rightPaddingFactor
protected static final float rightPaddingFactor
- See Also:
- Constant Field Values
-
topPaddingFactor
protected static final float topPaddingFactor
- See Also:
- Constant Field Values
-
botPaddingFactor
protected static final float botPaddingFactor
- See Also:
- Constant Field Values
-
font
public java.awt.Font font
-
charWidth
public int charWidth
-
charHeigth
public int charHeigth
-
fontSize
public int fontSize
-
style
public int style
-
owningCanvasID
public int owningCanvasID
-
texID
protected int texID
-
sdChars
public ContourPlot.SignedDistanceCharacters sdChars
-
-
Method Detail
-
boundsForText
public static java.awt.geom.Rectangle2D boundsForText(int textlength, int fontSize, int style)
CallsboundsForText(int, Font)
with corresponding Ubuntu Mono font.- Parameters:
textlength
- number of charactersfontSize
- point size of the fontstyle
- of the font e.g.Font.PLAIN
.- Returns:
- bounding rectangle for a text of specified length and font.
-
boundsForText
public static java.awt.geom.Rectangle2D boundsForText(int textlength, java.awt.Font font)
Calculates the bounding rectangle for a specific number of characters in the specified font. The returned bounds are baseline relative which means that the origin may have a negative y coordinate that is the distance of the descent line from the baseline.- Parameters:
textlength
- number of charactersfont
- to measure with (has to be monospaced, or else bounds will be incorrect)- Returns:
- bounding rectangle for a text of specified length and font.
-
-