Interface TextShape<S extends Shape<S,P>,P extends TextParagraph<S,P,? extends TextRun>>

All Superinterfaces:
IAdjustableShape, Iterable<P>, PlaceableShape<S,P>, Shape<S,P>, SimpleShape<S,P>
All Known Subinterfaces:
AutoShape<S,P>, FreeformShape<S,P>, Line<S,P>, TableCell<S,P>, TextBox<S,P>
All Known Implementing Classes:
HSLFAutoShape, HSLFFreeformShape, HSLFLine, HSLFPlaceholder, HSLFTableCell, HSLFTextBox, HSLFTextShape, Polygon, XSLFAutoShape, XSLFFreeformShape, XSLFTableCell, XSLFTextBox, XSLFTextShape

public interface TextShape<S extends Shape<S,P>,P extends TextParagraph<S,P,? extends TextRun>> extends SimpleShape<S,P>, Iterable<P>
  • Method Details

    • getText

      String getText()
      Returns the text contained in this text frame, which has been made safe for printing and other use.
      Returns:
      the text string for this textbox.
      Since:
      POI 3.14-Beta2
    • setText

      TextRun setText(String text)
      Sets (overwrites) the current text. Uses the properties of the first paragraph / textrun. Text paragraphs are split by \\r or \\n. New lines within text run are split by \\u000b
      Parameters:
      text - the text string used by this object.
      Returns:
      the last text run of the - potential split - text
    • appendText

      TextRun appendText(String text, boolean newParagraph)
      Adds the supplied text onto the end of the TextParagraphs, creating a new RichTextRun for it to sit in.
      Parameters:
      text - the text string to be appended.
      newParagraph - if true, a new paragraph will be added, which will contain the added text
      Since:
      POI 3.14-Beta1
    • getTextParagraphs

      List<P> getTextParagraphs()
      Returns:
      the TextParagraphs for this text box
    • getInsets

      Insets2D getInsets()
      Returns:
      text shape margin
    • setInsets

      void setInsets(Insets2D insets)
      Sets the shape margins
      Parameters:
      insets - the new shape margins
    • getTextHeight

      double getTextHeight()
      Compute the cumulative height occupied by the text
      Returns:
      the cumulative height occupied by the text
    • getTextHeight

      double getTextHeight(Graphics2D graphics)
      Compute the cumulative height occupied by the text
      Parameters:
      graphics - a customized graphics context, e.g. which contains font mappings
      Returns:
      the cumulative height occupied by the text
      Since:
      POI 3.17-beta2
    • getVerticalAlignment

      VerticalAlignment getVerticalAlignment()
      Returns the type of vertical alignment for the text.
      Returns:
      the type of vertical alignment
    • setVerticalAlignment

      void setVerticalAlignment(VerticalAlignment vAlign)
      Sets the type of vertical alignment for the text.
      Parameters:
      vAlign - - the type of alignment. A null values unsets this property.
    • isHorizontalCentered

      boolean isHorizontalCentered()
      Returns if the text is centered. If true and if the individual paragraph settings allow it, the whole text block will be displayed centered, i.e. its left and right margin will be maximized while still keeping the alignment of the paragraphs
      Returns:
      true, if the text anchor is horizontal centered
    • setHorizontalCentered

      void setHorizontalCentered(Boolean isCentered)
      Sets if the paragraphs are horizontal centered
      Parameters:
      isCentered - true, if the paragraphs are horizontal centered A null values unsets this property.
    • getWordWrap

      boolean getWordWrap()
      Returns:
      whether to wrap words within the bounding rectangle
    • setWordWrap

      void setWordWrap(boolean wrap)
      Parameters:
      wrap - whether to wrap words within the bounding rectangle
    • getTextDirection

      TextShape.TextDirection getTextDirection()
      Returns:
      vertical orientation of the text
    • setTextDirection

      void setTextDirection(TextShape.TextDirection orientation)
      sets the vertical orientation
      Parameters:
      orientation - vertical orientation of the text
    • getTextRotation

      Double getTextRotation()
      The text rotation can be independent specified from the shape rotation. For XSLF this can be an arbitrary degree, for HSLF the degree is given in steps of 90 degrees
      Returns:
      text rotation in degrees, returns null if no rotation is given
    • setTextRotation

      void setTextRotation(Double rotation)
      Sets the text rotation. For XSLF this can ben an arbitrary degree, for HSLF the rotation is rounded to next 90 degree step
      Parameters:
      rotation - the text rotation, or null to unset the rotation
    • setTextPlaceholder

      void setTextPlaceholder(TextShape.TextPlaceholder placeholder)
      Sets the text placeholder
    • getTextPlaceholder

      TextShape.TextPlaceholder getTextPlaceholder()
      Returns:
      the text placeholder
    • resizeToFitText

      Rectangle2D resizeToFitText()
      Adjust the size of the shape so it encompasses the text inside it.
      Returns:
      a Rectangle2D that is the bounds of this shape.
      Since:
      POI 3.17-beta2
    • resizeToFitText

      Rectangle2D resizeToFitText(Graphics2D graphics)
      Adjust the size of the shape so it encompasses the text inside it.
      Parameters:
      graphics - a customized graphics context, e.g. which contains font mappings
      Returns:
      a Rectangle2D that is the bounds of this shape.
      Since:
      POI 3.17-beta2