Class TextRenderer

java.lang.Object
org.jzy3d.plot3d.text.AbstractTextRenderer
org.jzy3d.plot3d.text.renderers.TextRenderer
All Implemented Interfaces:
ITextRenderer
Direct Known Subclasses:
AxisBox2d.RotatedTextBitmapRenderer

public class TextRenderer extends AbstractTextRenderer implements ITextRenderer
The ITextRenderer computes text layout according to Horizontal, Vertical settings, text length, font size and text position. This is achieved with the help of TextLayout processor. It can be given a 2D offset in screen coordinates and a 3D offset in world coordinates that are applied after the initial layout is processed according to the settings, the text length, the font size and the text position. It supports Unicode characters and all fonts made available by Font. Rendering text relies on IPainter.drawText(Font, String, Coord3d, Color, float) which was introduced as of Jzy3D 2.0 and offers much more flexibility than the initial simple IPainter.glutBitmapString(int, String) which only support two fonts. Rotation of a text is always made from the center of the text, whatever the LEFT/CENTER/RIGHT layout of the text, which lead to all these possible layouts.

This image was generated with
invalid @link
ITTest_Text#main()
  • Field Details

    • LOGGER

      protected static org.apache.logging.log4j.Logger LOGGER
    • layout

      protected TextLayout layout
    • showPosition

      protected boolean showPosition
    • positionColor

      protected Color positionColor
    • positionWidth

      protected float positionWidth
    • useGlutBitmap

      protected boolean useGlutBitmap
  • Constructor Details

    • TextRenderer

      public TextRenderer()
  • Method Details

    • drawText

      public BoundingBox3d drawText(IPainter painter, Font font, String text, Coord3d position, float rotation, Horizontal halign, Vertical valign, Color color, Coord2d screenOffset, Coord3d sceneOffset)
      Draw a string at the specified position and return the 3d volume occupied by the string according to the current Camera configuration.
      Specified by:
      drawText in interface ITextRenderer
    • to3D

      protected Coord3d to3D(IPainter painter, Coord3d screen)
      Convert a 2D screen position to 3D world coordinate
    • computeTextBounds

      protected BoundingBox3d computeTextBounds(IPainter painter, Font font, Coord3d posScreenShifted, float strlen)
    • isShowPosition

      public boolean isShowPosition()
    • setShowPosition

      public void setShowPosition(boolean showPosition)
    • getPositionColor

      public Color getPositionColor()
    • setPositionColor

      public void setPositionColor(Color positionColor)
    • getPositionWidth

      public float getPositionWidth()
    • setPositionWidth

      public void setPositionWidth(float positionWidth)
    • isUseGlutBitmap

      public boolean isUseGlutBitmap()
    • setUseGlutBitmap

      public void setUseGlutBitmap(boolean useGlutBitmap)