Class MTextDocument

    • Constructor Detail

      • MTextDocument

        public MTextDocument()
        Constructs an empty document.
      • MTextDocument

        public MTextDocument​(String s)
        Constructs a document from the specified string.
        Parameters:
        s - the string
      • MTextDocument

        public MTextDocument​(MTextDocument d)
        Copy constructor.
        Parameters:
        d - the document to copy
    • Method Detail

      • getPlainText

        public final String getPlainText()
        Gets the document as plain text.
        Returns:
        the text
      • setPlainText

        public void setPlainText​(String s)
        Sets the document as plain text.
        Parameters:
        s - the text
      • length

        public final int length()
        Gets the length of the document.
        Returns:
        the length
      • charAt

        public final char charAt​(int i)
        Gets a character of the document.
        Returns:
        the character
      • endsWith

        public boolean endsWith​(char c)
        Tests whether the document ends with the specified character.
        Parameters:
        c - the character
        Returns:
        true if c is the last character, false otherwise
      • substring

        public final String substring​(int start)
        Gets a substring of the document.
        Parameters:
        start - index of first character
        Returns:
        the substring
      • substring

        public final String substring​(int start,
                                      int end)
        Gets a substring of the document.
        Parameters:
        start - index of first character
        end - index of last character + 1
        Returns:
        the substring
      • getSubDocument

        public MTextDocument getSubDocument​(int start,
                                            int end)
      • remove

        public final void remove​(int start,
                                 int len)
        Deletes a substring in the document.
        Parameters:
        start - index of first character to delete
        len - number of characters to delete
      • append

        public final void append​(String s,
                                 MTextAttributes attr)
        Append text to end of document.
        Parameters:
        s - text to add
        attr - section attributes or null
      • insert

        public final void insert​(int i,
                                 MTextDocument src)
      • insert

        public final void insert​(int i,
                                 String s,
                                 MTextAttributes attr)
        Inserts a string.
        Parameters:
        i - character index
        s - string to insert
        attr - text attributes or null
      • replace

        public final void replace​(int start,
                                  int len,
                                  String s)
        Replaces a substring in the document.
        Parameters:
        start - index of first character to delete
        len - number of characters to replace
        s - substitution
      • getAttributes

        public final MTextAttributes getAttributes​(int start,
                                                   int len,
                                                   int set0)
        Gets attributes of the text of len length from start that are supposed to be set even if their values are "default".
        Parameters:
        start - position of first character
        len - number of characters
        set0 - the set of attributes that are supposed to be set even if their values are "default"
        Returns:
        the attributes and the flags
      • isFontDefaultInRange

        public final boolean isFontDefaultInRange​(int start,
                                                  int len)
        Tests whether the default font is used in the specified range.
        Returns:
        true if only the default font is used, false otherwise
      • isFontRegularInRange

        public final boolean isFontRegularInRange​(int start,
                                                  int len)
        Tests whether the default font is used in the specified range.
        Returns:
        true if only the default font is used, false otherwise
      • getPortion

        public final MTextDocument.Portion getPortion​(int start,
                                                      int end)
        Gets a portion of the document.
        Parameters:
        start - position of first character
        end - position of last character + 1
        Returns:
        the portion
      • getDefaultFont

        public MFont getDefaultFont()
        Gets the default font.
        Returns:
        the font
      • setDefaultFont

        public void setDefaultFont​(MFont font)
        Sets the default font.
        Parameters:
        font - the font
      • getSectionCount

        public final int getSectionCount()
        Gets the number of sections in the document.
        Returns:
        the number of sections
      • getSectionIndexOfCharAt

        public final int getSectionIndexOfCharAt​(int i)
        Gets the section index of a character.
        Parameters:
        i - character position
        Returns:
        the section index
      • getSection

        public final MTextDocument.Section getSection​(int k)
        Gets a section of the document.
        Parameters:
        k - section number
        Returns:
        the section
      • getSectionShiftY

        public final double getSectionShiftY​(int k)
        Gets the y shift of a section.
        Parameters:
        k - the section number
        Returns:
        the shift
      • findScriptLastSectionIndex

        public final int findScriptLastSectionIndex​(int from,
                                                    int subl)
        Finds the end of a subscript or superscript.
        Parameters:
        from - the first section index
        subl - the script level to query, +1 (superscript) or -1 (subscript)
        Returns:
        the index of the last section containing this subscript or superscript
        Since:
        Marvin 4.1, 02/25/2006
      • getScriptCount

        public final int getScriptCount​(int i1,
                                        int subl)
        Gets the number of subscripts or superscripts on the last normal character.
        Parameters:
        i1 - the position
        subl - the script level to query, +1 (superscript) or -1 (subscript)
        Returns:
        the number of subscripts or superscripts
        Since:
        Marvin 4.1, 02/25/2006
      • getAttrFont

        public MFont getAttrFont​(MTextAttributes attr)
        Gets the font for the specified attribute object.
        Returns:
        the font
      • toString

        public String toString()
        Gets the string representation of the document.
        Overrides:
        toString in class Object
        Returns:
        the string
      • reuseFont

        public MFont reuseFont​(String name,
                               int style,
                               double size)
      • updateSubLevel

        public void updateSubLevel​(double[] sublevX,
                                   double x,
                                   int k)