Package org.apache.pivot.wtk.text

Examples of org.apache.pivot.wtk.text.Element$ElementListenerList


    }

    private Font getEffectiveFont() {
        Font font = null;
        // run up the tree until we find an element's style to apply
        Element element = getNode().getParent();
        while (element != null) {
            font = element.getFont();
            if (font != null) {
                break;
            }

            element = element.getParent();
        }
        // if we find nothing, use the default font
        if (element == null) {
            font = getTextPaneSkin().getFont();
        }
View Full Code Here


    }

    private Color getEffectiveForegroundColor() {
        Color foregroundColor = null;
        // run up the tree until we find an element's style to apply
        Element element = getNode().getParent();
        while (element != null) {
            foregroundColor = element.getForegroundColor();
            if (foregroundColor != null) {
                break;
            }

            element = element.getParent();
        }
        // if we find nothing, use the default color
        if (element == null) {
            foregroundColor = getTextPaneSkin().getColor();
        }
View Full Code Here

        return foregroundColor;
    }

    private boolean getEffectiveUnderline() {
        // run up the tree until we find an element's style to apply
        Element element = getNode().getParent();
        while (element != null) {
            if (element.isUnderline()) {
                return true;
            }

            element = element.getParent();
        }
        return false;
    }
View Full Code Here

        return false;
    }

    private boolean getEffectiveStrikethrough() {
        // run up the tree until we find an element's style to apply
        Element element = getNode().getParent();
        while (element != null) {
            if (element.isStrikethrough()) {
                return true;
            }

            element = element.getParent();
        }
        return false;
    }
View Full Code Here

            printStream.append("</" + node.getClass().getSimpleName() + ">");
            printStream.println();
        } else {
            printStream.println();
            if (node instanceof Element) {
                Element element = (Element)node;

                for (Node childNode : element) {
                    dumpDocumentNode(childNode, printStream, indent + 1);
                }
            } else {
View Full Code Here

        StyleApplicator styleApplicator, org.apache.pivot.wtk.text.TextNode textNode,
        int characterCount, org.apache.pivot.wtk.Span textSpan) {
        if (selectionSpan.contains(textSpan)) {
            // if the text-node is contained wholly inside the selection, remove
            // the text-node, replace it with a Span, and apply the style
            Element parent = textNode.getParent();
            org.apache.pivot.wtk.text.Span newSpanNode = new org.apache.pivot.wtk.text.Span();
            newSpanNode.add(new TextNode(textNode.getText()));
            styleApplicator.apply(newSpanNode);
            int index = parent.remove(textNode);
            parent.insert(newSpanNode, index);
        } else if (selectionSpan.start <= textSpan.start) {
            // if the selection covers the first part of the text-node, split
            // off the first part of the text-node, and apply the style to it
            int intersectionLength = selectionSpan.end - textSpan.start;
            String part1 = textNode.getSubstring(0, intersectionLength);
            String part2 = textNode.getSubstring(intersectionLength, characterCount);

            org.apache.pivot.wtk.text.Span newSpanNode = new org.apache.pivot.wtk.text.Span();
            newSpanNode.add(new TextNode(part1));
            styleApplicator.apply(newSpanNode);

            Element parent = textNode.getParent();
            int index = parent.remove(textNode);
            parent.insert(newSpanNode, index);
            parent.insert(new TextNode(part2), index + 1);
        } else if (selectionSpan.end >= textSpan.end) {
            // if the selection covers the last part of the text-node, split off
            // the last part of the text-node, and apply the style to
            // it
            int intersectionStart = selectionSpan.start - textSpan.start;
            String part1 = textNode.getSubstring(0, intersectionStart);
            String part2 = textNode.getSubstring(intersectionStart, characterCount);

            org.apache.pivot.wtk.text.Span newSpanNode = new org.apache.pivot.wtk.text.Span();
            newSpanNode.add(new TextNode(part2));
            styleApplicator.apply(newSpanNode);

            Element parent = textNode.getParent();
            int index = parent.remove(textNode);
            parent.insert(new TextNode(part1), index);
            parent.insert(newSpanNode, index + 1);
        } else {
            // if the selection covers an internal part of the text-node, split
            // the
            // text-node into 3 parts, and apply the style to the second part
            int part2Start = selectionSpan.start - textSpan.start;
            int part2End = selectionSpan.end - textSpan.start + 1;
            String part1 = textNode.getSubstring(0, part2Start);
            String part2 = textNode.getSubstring(part2Start, part2End);
            String part3 = textNode.getSubstring(part2End, characterCount);

            org.apache.pivot.wtk.text.Span newSpanNode = new org.apache.pivot.wtk.text.Span();
            newSpanNode.add(new TextNode(part2));
            styleApplicator.apply(newSpanNode);

            Element parent = textNode.getParent();
            int index = parent.remove(textNode);
            parent.insert(new TextNode(part1), index);
            parent.insert(newSpanNode, index + 1);
            parent.insert(new TextNode(part3), index + 2);
        }
    }
View Full Code Here

            // off the first part of the span-node, and apply the style to it
            int intersectionLength = selectionSpan.end - textSpan.start;
            org.apache.pivot.wtk.text.Span node1 = spanNode.getRange(0, intersectionLength);
            styleApplicator.apply(node1);
            Node node2 = spanNode.getRange(intersectionLength, characterCount - intersectionLength);
            Element parent = spanNode.getParent();
            int index = parent.remove(spanNode);
            parent.insert(node1, index);
            parent.insert(node2, index + 1);
        } else if (selectionSpan.end >= textSpan.end) {
            // if the selection covers the last part of the span-node, split off
            // the last part of the span-node, and apply the style to it
            int intersectionStart = selectionSpan.start - textSpan.start;
            org.apache.pivot.wtk.text.Span part1 = spanNode.getRange(0, intersectionStart);
            org.apache.pivot.wtk.text.Span part2 = spanNode.getRange(intersectionStart,
                characterCount - intersectionStart);

            styleApplicator.apply(part2);

            Element parent = spanNode.getParent();
            int index = parent.remove(spanNode);
            parent.insert(part1, index);
            parent.insert(part2, index + 1);
        } else {
            // if the selection covers an internal part of the span-node, split
            // the
            // span-node into 3 parts, and apply the style to the second part
            int part2Start = selectionSpan.start - textSpan.start;
            int part2End = selectionSpan.end - textSpan.start;
            org.apache.pivot.wtk.text.Span part1 = spanNode.getRange(0, part2Start);
            org.apache.pivot.wtk.text.Span part2 = spanNode.getRange(part2Start, part2End
                - part2Start);
            org.apache.pivot.wtk.text.Span part3 = spanNode.getRange(part2End, characterCount
                - part2End);

            styleApplicator.apply(part2);

            Element parent = spanNode.getParent();
            int index = parent.remove(spanNode);
            parent.insert(part1, index);
            parent.insert(part2, index + 1);
            parent.insert(part3, index + 2);
        }
    }
View Full Code Here

        // don't worry about the text-nodes that are children of Span nodes.
        if (node instanceof org.apache.pivot.wtk.text.Span) {
            return;
        }
        if (node instanceof org.apache.pivot.wtk.text.Element) {
            Element element = (Element)node;
            for (Node child : element) {
                nodeList.add(child);
                collectNodes(child, nodeList);
            }
        }
View Full Code Here

    }

    private Font getEffectiveFont() {
        Font font = null;
        // run up the tree until we find an element's style to apply
        Element element = getNode().getParent();
        while (element != null) {
            font = element.getFont();
            if (font != null) {
                break;
            }

            element = element.getParent();
        }
        // if we find nothing, use the default font
        if (element == null) {
            font = textPaneSkin.getFont();
        }
View Full Code Here

    }

    private Color getEffectiveForegroundColor() {
        Color foregroundColor = null;
        // run up the tree until we find an element's style to apply
        Element element = getNode().getParent();
        while (element != null) {
            foregroundColor = element.getForegroundColor();
            if (foregroundColor != null) {
                break;
            }

            element = element.getParent();
        }
        // if we find nothing, use the default color
        if (element == null) {
            foregroundColor = textPaneSkin.getColor();
        }
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.text.Element$ElementListenerList

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.