Class 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. A ContourPlot.CharacterAtlas is defined by:
    • its font size
    • its font style (PLAIN, ITALIC, BOLD, BOLD|ITALIC)
    The font used is Ubuntu Mono which is a monospaced font, which can be accessed through the ContourPlot.FontProvider. This implementation limits the possible characters to the ones listed in ContourPlot.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 static CharacterAtlas#get(int, int) method. A VertexArray with 2D vertices on the first attribute and 2D texture coordinates on the second can be retrieved for a specified string using CharacterAtlas#createVAforString(String, VertexArray).
    Author:
    hageldave
    • Field Detail

      • CHARACTERS

        private static final char[] CHARACTERS
      • 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
      • 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
    • Constructor Detail

      • CharacterAtlas

        public CharacterAtlas()
    • Method Detail

      • boundsForText

        public static java.awt.geom.Rectangle2D boundsForText​(int textlength,
                                                              int fontSize,
                                                              int style)
        Calls boundsForText(int, Font) with corresponding Ubuntu Mono font.
        Parameters:
        textlength - number of characters
        fontSize - point size of the font
        style - 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 characters
        font - to measure with (has to be monospaced, or else bounds will be incorrect)
        Returns:
        bounding rectangle for a text of specified length and font.