Class TextSparseStream

  • Direct Known Subclasses:
    TextDispStr

    public abstract class TextSparseStream
    extends TextStream

    The sparse stream represents a displayable stream whose content and rendering are loaded on demand when needed, rather than up front. Outwardly it behaves like any other displayable stream, allowing the client to use the rich AXTE editing API for manipulating its content.

    The client must derive its own implementation class from this abstract base class, in order to handle the content access events.

    • Constructor Detail

      • TextSparseStream

        public TextSparseStream()
        Default constructor.
      • TextSparseStream

        public TextSparseStream​(TextSparseStream oSource)
        Copy constructor.
        Parameters:
        oSource - - Source sparse stream to copy.
      • TextSparseStream

        public TextSparseStream​(java.lang.String sSource)
        Constructor with source text string.

        Create a text stream whose initial content is copied from the given string. The text stream initially has no attribute pool association. The display is not automatically created.

        Parameters:
        sSource - - String whose contents are to be copied to the text stream.
    • Method Detail

      • setContext

        public void setContext​(TextContext poContext)
        Set the display context.

        A text context allows several text streams to share a number of objects used in creating text displays. By sharing these objects, they need not be created for each stream, an expensive operation.

        Parameters:
        poContext - - Shared context to use. Context objects follow the text reference counting model, so if the caller creates the context on the stack, it must ensure the context continues to exist at least until the text stream is destroyed.
      • getContext

        public TextContext getContext()
        Get the stream's text context object.

        Overridden from the TextStream base class, this method returns a pointer to the stream's text context.

        Overrides:
        getContext in class TextStream
        Returns:
        Pointer to the text context; NULL if none is in effect.
      • setFrameCount

        public void setFrameCount​(int nFrames)
        Set the number of frames in the sparse stream.

        If the given number is greater than the number of frames currently in the stream, null frames are added to round out the number. If the new number is smaller, frames (null and non-null) are removed from the end of the stream.

        Parameters:
        nFrames - - New number of frames to be contained in the stream.
      • getFrameCount

        public int getFrameCount()
        Return the number of frames in the stream.
        Returns:
        Number of frames in the stream. This includes both null and non-null frames.
      • getFrame

        public TextFrame getFrame​(int nIndex)
        Retrieve a specific frame from the stream.
        Parameters:
        nIndex - - Index of the desired frame. Pointer to the requested frame. A null value indicates a null frame.
      • insertFrame

        public TextFrame insertFrame​(int nIndex,
                                     TextFrame oFrame,
                                     TextLayout poLayout)
        Insert a new frame into the stream.
        Parameters:
        nIndex - - Insertion index. Effectively, the existing frame with this index number and all that come after it have their indexes incremented by one. The new frame gets this index number. If the given index is beyond the end of the set of frames, the new frame is appended at the end.
        oFrame - - New frame to append. AXTE makes a clone of this object.
        poLayout - - Pointer to layout to load into the frame. If this pointer is not null, the content in this layout object is added to the sparse stream, and the frames layout is generated from this layout object. If the pointer is null, the streams content from this frame on is reflowed to account for the new frame. This might cause the removal of frames at the end of the stream.
        Returns:
        Pointer to the cloned frame added to the stream.
      • insertFrameRef

        public void insertFrameRef​(int nIndex,
                                   TextFrame poFrame,
                                   TextLayout poLayout)
        Insert a new frame into the stream.
        Parameters:
        nIndex - - Insertion index. Effectively, the existing frame with this index number and all that come after it have their indexes incremented by one. The new frame gets this index number. If the given index is beyond the end of the set of frames, the new frame is appended at the end.
        poFrame - - New frame to insert. This object is assumed to be reference counted and AXTE adds its own reference.
        poLayout - - Pointer to layout to load into the frame. If this pointer is not null, the content in this layout object is added to the sparse stream, and the frames layout is generated from this layout object. If the pointer is null, the streams content from this frame on is reflowed to account for the new frame. This might cause the removal of frames at the end of the stream.
      • appendFrame

        public TextFrame appendFrame​(TextFrame oFrame,
                                     TextLayout poLayout)
        Append a new frame at the end of the stream.
        Parameters:
        oFrame - - New frame to append. AXTE makes a clone of this object.
        poLayout - - Pointer to layout to load into the frame. If this pointer is not null, the content in this layout object is added to the sparse stream, and the frames layout is generated from this layout object. If the pointer is null, the streams content from this frame on is reflowed to account for the new frame. Note: it doesnt really make sense to pass a null pointer, as any attempt at reflow will not generate content for the frame and it will be automatically removed.
        Returns:
        Pointer to the cloned frame added to the stream.
      • appendFrameRef

        public void appendFrameRef​(TextFrame poFrame,
                                   TextLayout poLayout)
        Append a new frame at the end of the stream.
        Parameters:
        poFrame - - New frame to insert. This object is assumed to be reference counted and AXTE adds its own reference.
        poLayout - - Pointer to layout to load into the frame. If this pointer is not null, the content in this layout object is added to the sparse stream, and the frames layout is generated from this layout object. If the pointer is null, the streams content from this frame on is reflowed to account for the new frame. Note: it doesnt really make sense to pass a null pointer, as any attempt at reflow will not generate content for the frame and it will be automatically removed.
      • appendFrameRef

        public void appendFrameRef​(TextFrame oFrame)
      • setFrame

        public TextFrame setFrame​(int nIndex,
                                  TextFrame oFrame,
                                  TextLayout poLayout)
        Change the definition of a frame.

        This method serves three purposes:

        • Load a previously null frame.
        • Change the geometry of a frame and reflow its text.
        • Change the geometry and content of a frame.
          Parameters:
          nIndex - - Index of the frame to update. It is an error if this number is out of range.
          oFrame - - New frame to set. AXTE makes a clone of this object.
          poLayout - - Pointer to layout to load into the frame. If this pointer is not null, the content in this layout object replaces the former frames content, and the frames layout is regenerated from this layout object. If the frame was previously null, this effectively loads the frame. If this parameter is null, the streams content from this frame on is reflowed to account for the new frame. This might cause the addition or removal of frames at the end of the stream.
          Returns:
          - Pointer to the cloned frame added to the stream.
        • setFrameRef

          public void setFrameRef​(int nIndex,
                                  TextFrame poFrame,
                                  TextLayout poLayout)
          Change the definition of a frame.

          This method serves three purposes:

          • Load a previously null frame.
          • Change the geometry of a frame and reflow its text.
          • Change the geometry and content of a frame.
            Parameters:
            nIndex - - Index of the frame to update. It is an error if this number is out of range.
            poFrame - - New frame to set. This object is assumed to be reference counted and AXTE adds its own reference.
            poLayout - - Pointer to layout to load into the frame. If this pointer is not null, the content in this layout object replaces the former frames content, and the frames layout is regenerated from this layout object. If the frame was previously null, this effectively loads the frame. If this parameter is null, the streams content from this frame on is reflowed to account for the new frame. This might cause the addition or removal of frames at the end of the stream.
          • removeFrame

            public void removeFrame​(int nIndex,
                                    boolean bRemoveContent)
            Remove a frame from a sparse stream.

            This can simply remove the frame definition from the streams flow, or it can also remove the corresponding content from the stream.

            Parameters:
            nIndex - - Index of the frame to remove. It is an error if this number is out of range.
            bRemoveContent - - True if the corresponding content is to be removed from the stream. False if this frame is to be removed from the stream and text reflowed in the remaining frames. In this case, AXTE may need to create new frames at the end of the stream.
          • removeFrame

            public void removeFrame​(int nIndex)
          • defaultDirection

            public int defaultDirection()
            Obtain the direction override for this stream.

            A displayable stream can have a default (paragraph) direction set, which determines what side to start on and influences word ordering in true bidirectional text. If this value is neutral, the default paragraph direction is determined from the attributes in effect at the start of the text.

            Returns:
            Default paragraph direction value.
          • defaultDirection

            public void defaultDirection​(int eNewDirection)
            Change the default direction override for this stream.

            See the first overload of this method for how the default text direction is used.

            Parameters:
            eNewDirection - - New direction to set for this stream.
          • createDisplay

            public TextDisplay createDisplay()
            Create display with optional scroller and graphic environment.

            THis method allows the caller to create the stream's display by passing optional scroller and graphic environment. Once the display has been created, it exists until the displayable stream is deleted. Subsequent calls to this method simply return the pointer to the display that already exists.

            Returns:
            Pointer to the text stream's display object.
          • onLoadFrame

            public abstract TextFrame onLoadFrame​(int nIndex)
            Client-implemented event handler to load a frame's content.

            The client implementation is expected to call SetFrame() or SetFrameRef() before returning.

            Parameters:
            nIndex - - Index number of frame to load. The client can assume that the frame is currently null.
            Returns:
            Pointer to the frame that was loaded. This would be the return value of SetFrame() or the pointer passed into SetFrameRef(). The return value is for informational purposes only; the client does not increment the reference count before returning.
          • onNewFrame

            public TextFrame onNewFrame()
            Notify the client that a new frame must be created at the end of the stream to handle content overflow.

            This method is called if editing pushes content beyond the set of frames established by the client.

            Returns:
            Pointer to the frame that was created. The client can return null, indicating a "text full" situation. The default implementation returns null. AXTE takes over ownership of the reference. Consequently, the client implementation must add a reference if necessary. Typically, the client uses a Clone() method, which will establish the reference count correctly.
          • onRemoveFrame

            public void onRemoveFrame​(int nIndex,
                                      boolean bForced,
                                      boolean bRemoveContent)
            Notify the client that a frame is about to be removed.

            This call is made before the frame is removed.

            Parameters:
            nIndex - - Index number of frame about to be removed.
            bForced - - True if this is the result of a call to RemoveFrame() or SetFrameCount(); false if the frame is being removed from the end of the stream because of reflow.
            bRemoveContent - - True if the corresponding content is to be removed from the stream (can occur only if this is a forced removal). False if this frame is to be removed from the stream and text reflowed in the remaining frames. Note that this parameter is provided for informational purposes only. AXTE will take care of removing the content.
          • onFrameRemoved

            public void onFrameRemoved​(int nIndex)
            Post-removal callback.

            AXTE calls this method after a frame has been removed, but before AXTE's reference is released.

            Parameters:
            nIndex - - Index number of frame about to be removed.
          • forceFrame

            public TextFrame forceFrame​(int nIndex,
                                        boolean bReflow)
          • forceFrame

            public TextFrame forceFrame​(int nIndex)