Flying Saucer Project Release ${app.version}

org.xhtmlrenderer.swing
Class Java2DTextRenderer

java.lang.Object
  extended by org.xhtmlrenderer.swing.Java2DTextRenderer
All Implemented Interfaces:
TextRenderer

public class Java2DTextRenderer
extends java.lang.Object
implements TextRenderer

Renders to a Graphics2D instance.

Author:
Joshua Marinacci, Torbjoern Gannholm

Constructor Summary
Java2DTextRenderer()
           
 
Method Summary
 void drawGlyphVector(OutputDevice outputDevice, FSGlyphVector fsGlyphVector, float x, float y)
           
 void drawString(OutputDevice outputDevice, java.lang.String string, float x, float y)
          
 void drawString(OutputDevice outputDevice, java.lang.String string, float x, float y, JustificationInfo info)
           
 float getFontScale()
           
 FSFontMetrics getFSFontMetrics(FontContext fc, FSFont font, java.lang.String string)
           
 java.awt.Rectangle getGlyphBounds(OutputDevice outputDevice, FSFont font, FSGlyphVector fsGlyphVector, int index, float x, float y)
           
 float[] getGlyphPositions(OutputDevice outputDevice, FSFont font, FSGlyphVector fsGlyphVector)
           
 float[] getGlyphPositions(OutputDevice outputDevice, FSFont font, java.lang.String text)
           
 FSGlyphVector getGlyphVector(OutputDevice outputDevice, FSFont font, java.lang.String text)
           
 java.lang.Object getRenderingHints()
          If anti-alias text is enabled, the value from RenderingHints to use for AA smoothing in Java2D.
 int getSmoothingLevel()
           
 int getWidth(FontContext fc, FSFont font, java.lang.String string)
           
 void setFontScale(float scale)
           
 void setRenderingHints(java.lang.Object renderingHints)
          If anti-alias text is enabled, the value from RenderingHints to use for AA smoothing in Java2D.
 void setSmoothingLevel(int level)
           
 void setSmoothingThreshold(float fontsize)
          Set the smoothing threashold.
 void setup(FontContext fontContext)
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Java2DTextRenderer

public Java2DTextRenderer()
Method Detail

drawString

public void drawString(OutputDevice outputDevice,
                       java.lang.String string,
                       float x,
                       float y)

Specified by:
drawString in interface TextRenderer

drawString

public void drawString(OutputDevice outputDevice,
                       java.lang.String string,
                       float x,
                       float y,
                       JustificationInfo info)
Specified by:
drawString in interface TextRenderer

drawGlyphVector

public void drawGlyphVector(OutputDevice outputDevice,
                            FSGlyphVector fsGlyphVector,
                            float x,
                            float y)
Specified by:
drawGlyphVector in interface TextRenderer

setup

public void setup(FontContext fontContext)

Specified by:
setup in interface TextRenderer

setFontScale

public void setFontScale(float scale)
Specified by:
setFontScale in interface TextRenderer

setSmoothingThreshold

public void setSmoothingThreshold(float fontsize)
Description copied from interface: TextRenderer
Set the smoothing threashold. This is a font size above which all text will be anti-aliased. Text below this size will not be antialiased. Set to -1 for no antialiasing. Set to 0 for all antialising. Else, set to the threshold font size. does not take font scaling into account.

Specified by:
setSmoothingThreshold in interface TextRenderer

setSmoothingLevel

public void setSmoothingLevel(int level)
Specified by:
setSmoothingLevel in interface TextRenderer
Parameters:
level - no-op

getFSFontMetrics

public FSFontMetrics getFSFontMetrics(FontContext fc,
                                      FSFont font,
                                      java.lang.String string)
Specified by:
getFSFontMetrics in interface TextRenderer

getWidth

public int getWidth(FontContext fc,
                    FSFont font,
                    java.lang.String string)
Specified by:
getWidth in interface TextRenderer

getFontScale

public float getFontScale()
Specified by:
getFontScale in interface TextRenderer

getSmoothingLevel

public int getSmoothingLevel()
Specified by:
getSmoothingLevel in interface TextRenderer

getRenderingHints

public java.lang.Object getRenderingHints()
If anti-alias text is enabled, the value from RenderingHints to use for AA smoothing in Java2D. Defaults to RenderingHints.VALUE_TEXT_ANTIALIAS_ON.

Returns:
Current AA rendering hint

setRenderingHints

public void setRenderingHints(java.lang.Object renderingHints)
If anti-alias text is enabled, the value from RenderingHints to use for AA smoothing in Java2D. Defaults to RenderingHints.VALUE_TEXT_ANTIALIAS_ON.

Parameters:
renderingHints - rendering hint for AA smoothing in Java2D

getGlyphPositions

public float[] getGlyphPositions(OutputDevice outputDevice,
                                 FSFont font,
                                 java.lang.String text)

getGlyphBounds

public java.awt.Rectangle getGlyphBounds(OutputDevice outputDevice,
                                         FSFont font,
                                         FSGlyphVector fsGlyphVector,
                                         int index,
                                         float x,
                                         float y)
Specified by:
getGlyphBounds in interface TextRenderer

getGlyphPositions

public float[] getGlyphPositions(OutputDevice outputDevice,
                                 FSFont font,
                                 FSGlyphVector fsGlyphVector)
Specified by:
getGlyphPositions in interface TextRenderer

getGlyphVector

public FSGlyphVector getGlyphVector(OutputDevice outputDevice,
                                    FSFont font,
                                    java.lang.String text)
Specified by:
getGlyphVector in interface TextRenderer

Flying Saucer Project Release ${app.version}

Flying Saucer Project Home