Class AbstractTextRenderer

    • Field Detail

      • text

        private java.lang.String text
      • font

        private java.awt.Font font
      • color

        private java.awt.Color color
      • cachedGlyphVector

        protected java.awt.font.GlyphVector cachedGlyphVector
      • cachedGlyphShapes

        protected java.awt.Shape[] cachedGlyphShapes
      • cachedTextWidth

        protected float cachedTextWidth
      • cachedTextAscent

        protected float cachedTextAscent
      • cachedTextHeight

        protected float cachedTextHeight
      • capitalMAscent

        protected float capitalMAscent
      • cacheValid

        private boolean cacheValid
    • Constructor Detail

      • AbstractTextRenderer

        AbstractTextRenderer​(java.lang.String text)
      • AbstractTextRenderer

        AbstractTextRenderer​(java.lang.String text,
                             java.awt.Font font)
    • Method Detail

      • createDefaultFont

        private static java.awt.Font createDefaultFont()
        Creates and returns a default font object.
        Returns:
        a default font object
      • getColor

        public java.awt.Color getColor()
      • getFont

        public java.awt.Font getFont()
      • getText

        public java.lang.String getText()
      • getHeightMode

        public HeightMode getHeightMode()
      • setColor

        public void setColor​(java.awt.Color color)
      • setHeightMode

        public void setHeightMode​(HeightMode heightMode)
      • setFont

        public void setFont​(java.awt.Font newFont)
        Sets the renderer's font.
        Parameters:
        newFont - the font to be set
      • setText

        public void setText​(java.lang.String newText)
        Sets the renderer's text.
        Parameters:
        newText - the text to be set
      • getAdjustedAscent

        protected float getAdjustedAscent()
        Computes and answers the text ascent using the current height mode.
        Returns:
        the ascent adjusted using the current height mode
        See Also:
        getHeightMode()
      • getAdjustedDescent

        protected float getAdjustedDescent()
        Computes and answers the text descent using the current height mode.
        Returns:
        the descent adjusted to the current height mode
        See Also:
        getHeightMode()
      • isCacheValid

        protected boolean isCacheValid()
      • setCacheValid

        protected void setCacheValid​(boolean b)
      • ensureValidCache

        protected void ensureValidCache​(java.awt.Graphics2D g2)
      • validateCache

        protected void validateCache​(java.awt.Graphics2D g2)
        Validates the cache, here: creates a GlyphVector and computes and stores its size information.
        Parameters:
        g2 - the Graphics object used to get the font render context
      • ensureCapitalMAscentComputed

        private void ensureCapitalMAscentComputed​(java.awt.font.FontRenderContext frc)
        Ensures that the ascent of a capital M has been computed.
        Parameters:
        frc - the font render context used to create the glyph vector
      • invalidateCache

        protected void invalidateCache()
        Invalidates the cache.