Class XSLFTextShape

    • Method Detail

      • getTextBody

        @Beta
        public org.apache.poi.xddf.usermodel.text.XDDFTextBody getTextBody()
      • getText

        public java.lang.String getText()
        Description copied from interface: TextShape
        Returns the text contained in this text frame, which has been made safe for printing and other use.
        Specified by:
        getText in interface TextShape<XSLFShape,​XSLFTextParagraph>
        Returns:
        the text string for this textbox.
      • clearText

        public void clearText()
        unset text from this shape
      • setText

        public XSLFTextRun setText​(java.lang.String text)
        Description copied from interface: TextShape
        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
        Specified by:
        setText in interface TextShape<XSLFShape,​XSLFTextParagraph>
        Parameters:
        text - the text string used by this object.
        Returns:
        the last text run of the - potential split - text
      • appendText

        public XSLFTextRun appendText​(java.lang.String text,
                                      boolean newParagraph)
        Description copied from interface: TextShape
        Adds the supplied text onto the end of the TextParagraphs, creating a new RichTextRun for it to sit in.
        Specified by:
        appendText in interface TextShape<XSLFShape,​XSLFTextParagraph>
        Parameters:
        text - the text string to be appended.
        newParagraph - if true, a new paragraph will be added, which will contain the added text
      • addNewTextParagraph

        public XSLFTextParagraph addNewTextParagraph()
        add a new paragraph run to this shape
        Returns:
        created paragraph run
      • setHorizontalCentered

        public void setHorizontalCentered​(java.lang.Boolean isCentered)
        Description copied from interface: TextShape
        Sets if the paragraphs are horizontal centered
        Specified by:
        setHorizontalCentered in interface TextShape<XSLFShape,​XSLFTextParagraph>
        Parameters:
        isCentered - true, if the paragraphs are horizontal centered A null values unsets this property.
      • isHorizontalCentered

        public boolean isHorizontalCentered()
        Description copied from interface: TextShape
        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
        Specified by:
        isHorizontalCentered in interface TextShape<XSLFShape,​XSLFTextParagraph>
        Returns:
        true, if the text anchor is horizontal centered
      • getTextRotation

        public java.lang.Double getTextRotation()
        Description copied from interface: TextShape
        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
        Specified by:
        getTextRotation in interface TextShape<XSLFShape,​XSLFTextParagraph>
        Returns:
        text rotation in degrees, returns null if no rotation is given
      • setTextRotation

        public void setTextRotation​(java.lang.Double rotation)
        Description copied from interface: TextShape
        Sets the text rotation. For XSLF this can ben an arbitrary degree, for HSLF the rotation is rounded to next 90 degree step
        Specified by:
        setTextRotation in interface TextShape<XSLFShape,​XSLFTextParagraph>
        Parameters:
        rotation - the text rotation, or null to unset the rotation
      • getBottomInset

        public double getBottomInset()
        Returns the distance (in points) between the bottom of the text frame and the bottom of the inscribed rectangle of the shape that contains the text.
        Returns:
        the bottom inset in points
      • getLeftInset

        public double getLeftInset()
        Returns the distance (in points) between the left edge of the text frame and the left edge of the inscribed rectangle of the shape that contains the text.
        Returns:
        the left inset in points
      • getRightInset

        public double getRightInset()
        Returns the distance (in points) between the right edge of the text frame and the right edge of the inscribed rectangle of the shape that contains the text.
        Returns:
        the right inset in points
      • getTopInset

        public double getTopInset()
        Returns the distance (in points) between the top of the text frame and the top of the inscribed rectangle of the shape that contains the text.
        Returns:
        the top inset in points
      • setBottomInset

        public void setBottomInset​(double margin)
        Sets the bottom margin.
        Parameters:
        margin - the bottom margin
        See Also:
        getBottomInset()
      • setLeftInset

        public void setLeftInset​(double margin)
        Sets the left margin.
        Parameters:
        margin - the left margin
        See Also:
        getLeftInset()
      • setRightInset

        public void setRightInset​(double margin)
        Sets the right margin.
        Parameters:
        margin - the right margin
        See Also:
        getRightInset()
      • setTopInset

        public void setTopInset​(double margin)
        Sets the top margin.
        Parameters:
        margin - the top margin
        See Also:
        getTopInset()
      • setTextAutofit

        public void setTextAutofit​(TextShape.TextAutofit value)
        Specifies that a shape should be auto-fit to fully contain the text described within it. Auto-fitting is when text within a shape is scaled in order to contain all the text inside
        Parameters:
        value - type of autofit
      • getTextHeight

        public double getTextHeight​(java.awt.Graphics2D graphics)
        Description copied from interface: TextShape
        Compute the cumulative height occupied by the text
        Specified by:
        getTextHeight in interface TextShape<XSLFShape,​XSLFTextParagraph>
        Parameters:
        graphics - a customized graphics context, e.g. which contains font mappings
        Returns:
        the cumulative height occupied by the text
      • resizeToFitText

        public java.awt.geom.Rectangle2D resizeToFitText()
        Description copied from interface: TextShape
        Adjust the size of the shape so it encompasses the text inside it.
        Specified by:
        resizeToFitText in interface TextShape<XSLFShape,​XSLFTextParagraph>
        Returns:
        a Rectangle2D that is the bounds of this shape.
      • resizeToFitText

        public java.awt.geom.Rectangle2D resizeToFitText​(java.awt.Graphics2D graphics)
        Description copied from interface: TextShape
        Adjust the size of the shape so it encompasses the text inside it.
        Specified by:
        resizeToFitText in interface TextShape<XSLFShape,​XSLFTextParagraph>
        Parameters:
        graphics - a customized graphics context, e.g. which contains font mappings
        Returns:
        a Rectangle2D that is the bounds of this shape.
      • findDefinedParagraphProperty

        public <R> java.util.Optional<R> findDefinedParagraphProperty​(java.util.function.Function<CTTextParagraphProperties,​java.lang.Boolean> isSet,
                                                                      java.util.function.Function<CTTextParagraphProperties,​R> getter)
        Specified by:
        findDefinedParagraphProperty in interface org.apache.poi.xddf.usermodel.text.TextContainer
      • findDefinedRunProperty

        public <R> java.util.Optional<R> findDefinedRunProperty​(java.util.function.Function<CTTextCharacterProperties,​java.lang.Boolean> isSet,
                                                                java.util.function.Function<CTTextCharacterProperties,​R> getter)
        Specified by:
        findDefinedRunProperty in interface org.apache.poi.xddf.usermodel.text.TextContainer