Class TextBox

All Implemented Interfaces:
SafeDisposable
Direct Known Subclasses:
DicomInfo

public class TextBox extends SoAnnotation
(Preview Feature) Shape node to display a text box in window coordinates.

Preview Feature means this class is fully supported and can be used in Open Inventor applications. Being tagged as a Preview Feature just means that the implementation is still subject to API changes and adjustments based on feedback from early adopters. Please be also aware that source compatibility might be broken regardless of the Open Inventor compatibility changes policy due to our commitment to bring needed changes to be sure the specifications of this Preview Feature match the expectations of our customers.

This node displays a text box at a fixed location in the viewer window.

The position is specified in normalized device coordinates -1 to 1. Horizontal alignmentH and vertical alignmentV can be specified. For example position -0.98, -0.98, 0 with TOP/LEFT alignment (the default) puts a text box in the upper left corner of the window. The text box automatically expands or shrinks when lines of text are added to or deleted from the box. Positioning a text box in the lower left corner creates a sort of 'console' output overlaying the scene. Note that the alignment options control the positioning of the text box. The text can be left, center or right justified inside the box using the alignmentH field.

In order to have convenient default values for the font properties, by default the font properties are not inherited from the scene graph. By default the text is rendered using an SoText2 node with font name 'Arial:Bold', font size 15 and line spacing 1.1. The application can modify the fontName and fontSize fields or modify text properties directly using the getFontNode() and getTextNode() methods.

Lighting and picking are disabled. A border can be drawn around the box. Text will be rendered on top of whatever is rendered in the main scene graph. The application can modify the text strings directly, but this class also provides some convenience methods that are very useful. For example, the addLine() method appends a new string to the end of the list.

The bounding box of this node is ignored, i.e. it does not contribute to an SoGetBoundingBoxAction traversal and it does not affect a "viewAll" call on the camera or viewer.

File format/default:

TextBox {

    position 0 0 0
    alignmentH LEFT
    alignmentV TOP
    textAlignH LEFT
    fontName Arial:Bold
    fontSize 15
    border FALSE
    borderColor 1 1 1
}

See Also:
  • Field Details

    • position

      public SoSFVec3f position
      Position of the text box in normalized screen coordinates (-1 to 1). Default is 0,0,0.
    • alignmentH

      public SoSFEnum<TextBox.AlignmentH> alignmentH
      Horizontal alignment of the text box (default is LEFT).
    • alignmentV

      public SoSFEnum<TextBox.AlignmentV> alignmentV
      Vertical alignment of the text box (default is TOP).
    • textAlignH

      public SoSFEnum<TextBox.AlignmentH> textAlignH
      Horizontal alignment of the text inside the box (default is LEFT).
    • fontName

      public SoSFString fontName
      Specify the font name (default is "Arial:Bold"). See SoFont.name for details
    • fontSize

      public SoSFFloat fontSize
      Specify the font size in pixels (default is 15).
    • border

      public SoSFBool border
      Enable drawing a border around the text box (default is false).
    • borderColor

      public SoSFColor borderColor
      Border color (default is 1,1,1).
  • Constructor Details

    • TextBox

      public TextBox()
      Constructor
  • Method Details

    • setLine

      public void setLine(String text, int line)
      Set the contents of the specified line of text (convenience method).
    • addLine

      public void addLine(String text)
      Add a line of text at the bottom of the box.
    • getNumLines

      public int getNumLines()
      Get number of lines of text currently in the box
    • getRenderEngineMode

      public SoNode.RenderModes getRenderEngineMode()
      Description copied from class: SoNode
      Returns the supported Render engine mode.

      For custom node, this method returns by default SoNode.RenderModes.OIV_UNKNOWN_RENDERING_MODE, override this method to specify the Render engine mode supported by your custom node.

      Overrides:
      getRenderEngineMode in class SoNode
      Returns:
      the supported Render engine mode for this node.