Package org.apache.pivot.wtk.text

Examples of org.apache.pivot.wtk.text.TextNode


        private int x = 0;

        @Override
        public void run() {
            TextInput textInput = (TextInput)getComponent();
            TextNode textNode = textInput.getTextNode();

            int selectionStart = textInput.getSelectionStart();
            int selectionLength = textInput.getSelectionLength();

            if (x < 0) {
                // Add the previous character to the selection
                if (selectionStart > 0) {
                    selectionStart--;
                    selectionLength++;
                }
            } else {
                // Add the next character to the selection
                if (selectionStart + selectionLength < textNode.getCharacterCount()) {
                    selectionLength++;
                }
            }

            textInput.setSelection(selectionStart, selectionLength);
View Full Code Here


        @Override
        protected void attach() {
            super.attach();

            TextNode textNode = (TextNode)getNode();
            textNode.getTextNodeListeners().add(this);
        }
View Full Code Here

        @Override
        protected void detach() {
            super.detach();

            TextNode textNode = (TextNode)getNode();
            textNode.getTextNodeListeners().remove(this);
        }
View Full Code Here

        }

        @Override
        public void validate() {
            if (!isValid()) {
                TextNode textNode = (TextNode)getNode();
                String text = textNode.getText();

                // Update the length value
                length = text.length() - start;

                // Calculate the size of the text
View Full Code Here

            super.validate();
        }

        @Override
        public void paint(Graphics2D graphics) {
            TextNode textNode = (TextNode)getNode();
            String text = textNode.getText();

            // TODO Use a custom iterator so we don't have to copy the string
            text = text.substring(start, start + length);

            if (text.length() > 0) {
View Full Code Here

            return next;
        }

        @Override
        public int getCharacterAt(int x, int y) {
            TextNode textNode = (TextNode)getNode();

            // TODO This isn't terribly efficient - either use a character
            // iterator or cache the generated string in TextNode#getText()
            String text = textNode.getText();

            // TODO Can we use a glyph vector for this? We could create the
            // vector when the view is created so we don't need to rebuild it
            // every time
            int offset;
View Full Code Here

            return offset + start;
        }

        @Override
        public Bounds getCharacterBounds(int offset) {
            TextNode textNode = (TextNode)getNode();

            // TODO This isn't terribly efficient - either use a character
            // iterator or cache the generated string in TextNode#getText()
            String text = textNode.getText();
            GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, text);

            Shape glyphVisualBounds = glyphVector.getGlyphVisualBounds(offset);
            Rectangle glyphBounds = glyphVisualBounds.getBounds();
            Bounds bounds = new Bounds(glyphBounds.x, 0, glyphBounds.width, getHeight());
View Full Code Here

            invalidate();
        }

        @Override
        public String toString() {
            TextNode textNode = (TextNode)getNode();
            String text = textNode.getText();
            return text.substring(start, start + length);
        }
View Full Code Here

    @Override
    public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
        if (button == Mouse.Button.LEFT
            && count > 1) {
            TextInput textInput = (TextInput)getComponent();
            TextNode textNode = textInput.getTextNode();
            textInput.setSelection(0, textNode.getCharacterCount());
        }

        return super.mouseClick(component, button, x, y, count);
    }
View Full Code Here

        // Ignore characters in the control range and the ASCII delete
        // character
        if (character > 0x1F
            && character != 0x7F) {
            TextInput textInput = (TextInput)getComponent();
            TextNode textNode = textInput.getTextNode();

            if (textNode.getCharacterCount() < textInput.getMaximumLength()) {
                int index = textInput.getSelectionStart();
                Validator validator = textInput.getValidator();

                if (validator != null
                    && strictValidation) {
                    StringBuilder buf = new StringBuilder(textNode.getText());
                    buf.insert(index, character);

                    if (validator.isValid(buf.toString())) {
                        textInput.insertText(character, index);
                    } else {
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.text.TextNode

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.