Package pivot.wtk.text

Examples of pivot.wtk.text.Paragraph


        @Override
        public void validate() {
            if (!isValid()) {
                // Build the row list
                Paragraph paragraph = (Paragraph)getNode();
                ArrayList<ArrayList<NodeView>> rows = new ArrayList<ArrayList<NodeView>>();

                // Break the views into multiple rows
                int breakWidth = Math.max(getBreakWidth() - PARAGRAPH_TERMINATOR_WIDTH, 0);
View Full Code Here


            return null;
        }

        @Override
        public int getCharacterAt(int x, int y) {
            Paragraph paragraph = (Paragraph)getNode();
            int terminatorOffset = paragraph.getCharacterCount() - 1;
            Bounds terminatorBounds = getCharacterBounds(terminatorOffset);

            int offset;
            if (terminatorBounds.contains(x, y)) {
                offset = terminatorOffset;
View Full Code Here

        @Override
        public Bounds getCharacterBounds(int offset) {
            Bounds bounds;

            Paragraph paragraph = (Paragraph)getNode();
            if (offset == paragraph.getCharacterCount() - 1) {
                bounds = new Bounds(terminatorBounds);
            } else {
                bounds = super.getCharacterBounds(offset);
            }
View Full Code Here

            } catch(SerializationException exception) {
            } catch(IOException exception) {
            }
        } else {
            document = new Document();
            document.add(new Paragraph(""));
        }

        setDocument(document);
    }
View Full Code Here

            // The caret is positioned within an existing text node
            TextNode textNode = (TextNode)descendant;
            textNode.insertText(text, offset);
        } else if (descendant instanceof Paragraph) {
            // The caret is positioned on the paragraph terminator
            Paragraph paragraph = (Paragraph)descendant;

            int n = paragraph.getLength();
            if (n > 0) {
                Node node = paragraph.get(n - 1);
                if (node instanceof TextNode) {
                    // Insert the text into the existing node
                    TextNode textNode = (TextNode)node;
                    textNode.insertText(text, offset);
                } else {
                    // Append a new text node
                    paragraph.add(new TextNode(text));
                }
            } else {
                // The paragraph is currently empty
                paragraph.add(new TextNode(text));
            }
        } else {
            // The caret is positioned on a non-text character node; insert
            // the text into the descendant's parent
            Element parent = descendant.getParent();
View Full Code Here

        while (!(descendant instanceof Paragraph)) {
            descendant = descendant.getParent();
        }

        // Split the paragraph at the insertion point
        Paragraph leadingSegment = (Paragraph)descendant;
        int offset = selectionStart - leadingSegment.getDocumentOffset();
        int characterCount = leadingSegment.getCharacterCount() - offset;

        Paragraph trailingSegment = (Paragraph)leadingSegment.removeRange(offset, characterCount);

        Element parent = leadingSegment.getParent();
        int index = parent.indexOf(leadingSegment);
        parent.insert(trailingSegment, index + 1);
View Full Code Here

                && offset < document.getCharacterCount()) {
                Node descendant = document.getDescendantAt(offset);

                if (descendant instanceof Paragraph) {
                    // We are deleting a paragraph terminator
                    Paragraph paragraph = (Paragraph)descendant;

                    Element parent = paragraph.getParent();
                    int index = parent.indexOf(paragraph);

                    // Attempt to merge any successive content into the paragraph
                    if (index < parent.getLength() - 1) {
                        // TODO This won't always be a paragraph - we'll need to
                        // find the next paragraph by walking the tree, then
                        // remove any empty nodes
                        Sequence<Node> removed = parent.remove(index + 1, 1);
                        Paragraph nextParagraph = (Paragraph)removed.get(0);
                        paragraph.insertRange(nextParagraph, paragraph.getCharacterCount() - 1);

                        // Move the caret to the merge point
                        setSelection(offset, 0);
                    }
View Full Code Here

        @Override
        public void validate() {
            if (!isValid()) {
                // Build the row list
                Paragraph paragraph = (Paragraph)getNode();
                ArrayList<ArrayList<NodeView>> rows = new ArrayList<ArrayList<NodeView>>();

                // Break the views into multiple rows
                int breakWidth = Math.max(getBreakWidth() - PARAGRAPH_TERMINATOR_WIDTH, 0);
View Full Code Here

            return null;
        }

        @Override
        public int getCharacterAt(int x, int y) {
            Paragraph paragraph = (Paragraph)getNode();
            int terminatorOffset = paragraph.getCharacterCount() - 1;
            Bounds terminatorBounds = getCharacterBounds(terminatorOffset);

            int offset;
            if (terminatorBounds.contains(x, y)) {
                offset = terminatorOffset;
View Full Code Here

        @Override
        public Bounds getCharacterBounds(int offset) {
            Bounds bounds;

            Paragraph paragraph = (Paragraph)getNode();
            if (offset == paragraph.getCharacterCount() - 1) {
                bounds = new Bounds(terminatorBounds);
            } else {
                bounds = super.getCharacterBounds(offset);
            }
View Full Code Here

TOP

Related Classes of pivot.wtk.text.Paragraph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.