Package org.apache.pivot.text

Examples of org.apache.pivot.text.CharSequenceCharacterIterator


            // NOTE We use a character iterator here only because it is the most
            // efficient way to measure the character bounds (as of Java 6, the version
            // of Font#getStringBounds() that takes a String performs a string copy,
            // whereas the version that takes a character iterator does not)
            CharSequenceCharacterIterator ci = new CharSequenceCharacterIterator(characters);
            while (i < n) {
                char c = characters.charAt(i);
                if (Character.isWhitespace(c)) {
                    lastWhitespaceIndex = i;
                }
View Full Code Here


        valid = true;
    }

    private void appendLine(CharSequence characters, int start, int end,
        Font font, FontRenderContext fontRenderContext) {
        CharSequenceCharacterIterator line = new CharSequenceCharacterIterator(characters,
            start, end, start);
        GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, line);
        rows.add(new Row(glyphVector, start));

        Rectangle2D textBounds = glyphVector.getLogicalBounds();
View Full Code Here

                characters = passwordBuilder;
            } else {
                characters = textInput.getCharacters();
            }

            CharSequenceCharacterIterator ci = new CharSequenceCharacterIterator(characters);

            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
            glyphVector = font.createGlyphVector(fontRenderContext, ci);

            Rectangle2D textBounds = glyphVector.getLogicalBounds();
View Full Code Here

    @Override
    protected void childLayout(int breakWidth) {
        TextNode textNode = (TextNode)getNode();
        FontRenderContext fontRenderContext = Platform.getFontRenderContext();

        CharSequenceCharacterIterator ci = new CharSequenceCharacterIterator(textNode.getCharacters(), start);

        float lineWidth = 0;
        int lastWhitespaceIndex = -1;

        Font effectiveFont = getEffectiveFont();
        char c = ci.first();
        while (c != CharacterIterator.DONE
            && lineWidth < breakWidth) {
            if (Character.isWhitespace(c)) {
                lastWhitespaceIndex = ci.getIndex();
            }

            int i = ci.getIndex();
            Rectangle2D characterBounds = effectiveFont.getStringBounds(ci, i, i + 1, fontRenderContext);
            lineWidth += characterBounds.getWidth();

            c = ci.current();
        }

        int end;
        if (getTextPaneSkin().getWrapText()) {
            if (textNode.getCharacterCount() == 0) {
                end = start;
            } else {
                if (lineWidth < breakWidth) {
                    end = ci.getEndIndex();
                } else {
                    if (lastWhitespaceIndex == -1) {
                        end = ci.getIndex() - 1;
                        if (end <= start) {
                            end = start + 1;
                        }
                    } else {
                        end = lastWhitespaceIndex + 1;
                    }
                }
            }
        } else {
            end = ci.getEndIndex();
        }

        glyphVector = getEffectiveFont().createGlyphVector(fontRenderContext,
            new CharSequenceCharacterIterator(textNode.getCharacters(), start, end));

        if (end < ci.getEndIndex()) {
            length = end - start;
            next = new TextPaneSkinTextNodeView(textNode, end);
            next.setParent(getParent());
        } else {
            length = ci.getEndIndex() - start;
            // set to null in case this node used to be broken across multiple, but is no longer
            next = null;
        }

        Rectangle2D textBounds = glyphVector.getLogicalBounds();
View Full Code Here

    @Override
    public Dimensions getPreferredSize(int breakWidth) {
        TextNode textNode = (TextNode)getNode();
        FontRenderContext fontRenderContext = Platform.getFontRenderContext();

        CharSequenceCharacterIterator ci = new CharSequenceCharacterIterator(textNode.getCharacters(), start);

        float lineWidth = 0;
        int lastWhitespaceIndex = -1;

        Font effectiveFont = getEffectiveFont();
        char c = ci.first();
        while (c != CharacterIterator.DONE
            && lineWidth < breakWidth) {
            if (Character.isWhitespace(c)) {
                lastWhitespaceIndex = ci.getIndex();
            }

            int i = ci.getIndex();
            Rectangle2D characterBounds = effectiveFont.getStringBounds(ci, i, i + 1, fontRenderContext);
            lineWidth += characterBounds.getWidth();

            c = ci.current();
        }

        int end;
        if (getTextPaneSkin().getWrapText()) {
            if (textNode.getCharacterCount() == 0) {
                end = start;
            } else {
                if (lineWidth < breakWidth) {
                    end = ci.getEndIndex();
                } else {
                    if (lastWhitespaceIndex == -1) {
                        end = ci.getIndex() - 1;
                        if (end <= start) {
                            end = start + 1;
                        }
                    } else {
                        end = lastWhitespaceIndex + 1;
                    }
                }
            }
        } else {
            end = ci.getEndIndex();
        }

        GlyphVector glyphVectorLocal = getEffectiveFont().createGlyphVector(fontRenderContext,
            new CharSequenceCharacterIterator(textNode.getCharacters(), start, end));

        Rectangle2D textBounds = glyphVectorLocal.getLogicalBounds();
        return new Dimensions((int)Math.ceil(textBounds.getWidth()),
            (int)Math.ceil(textBounds.getHeight()));
    }
View Full Code Here

            // NOTE We use a character iterator here only because it is the most
            // efficient way to measure the character bounds (as of Java 6, the version
            // of Font#getStringBounds() that takes a String performs a string copy,
            // whereas the version that takes a character iterator does not)
            CharSequenceCharacterIterator ci = new CharSequenceCharacterIterator(characters);
            while (i < n) {
                char c = characters.charAt(i);
                if (Character.isWhitespace(c)) {
                    lastWhitespaceIndex = i;
                }
View Full Code Here

        valid = true;
    }

    private void appendLine(CharSequence characters, int start, int end,
        Font font, FontRenderContext fontRenderContext) {
        CharSequenceCharacterIterator line = new CharSequenceCharacterIterator(characters,
            start, end, start);
        GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, line);
        rows.add(new Row(glyphVector, start));

        Rectangle2D textBounds = glyphVector.getLogicalBounds();
View Full Code Here

    @Override
    protected void childLayout(int breakWidth) {
        TextNode textNode = (TextNode)getNode();
        FontRenderContext fontRenderContext = Platform.getFontRenderContext();

        CharSequenceCharacterIterator ci = new CharSequenceCharacterIterator(textNode.getCharacters(), start);

        float lineWidth = 0;
        int lastWhitespaceIndex = -1;

        Font effectiveFont = getEffectiveFont();
        char c = ci.first();
        while (c != CharacterIterator.DONE
            && lineWidth < breakWidth) {
            if (Character.isWhitespace(c)) {
                lastWhitespaceIndex = ci.getIndex();
            }

            int i = ci.getIndex();
            Rectangle2D characterBounds = effectiveFont.getStringBounds(ci, i, i + 1, fontRenderContext);
            lineWidth += characterBounds.getWidth();

            c = ci.current();
        }

        int end;
        if (getTextPaneSkin().getWrapText()) {
            if (textNode.getCharacterCount() == 0) {
                end = start;
            } else {
                if (lineWidth < breakWidth) {
                    end = ci.getEndIndex();
                } else {
                    if (lastWhitespaceIndex == -1) {
                        end = ci.getIndex() - 1;
                        if (end <= start) {
                            end = start + 1;
                        }
                    } else {
                        end = lastWhitespaceIndex + 1;
                    }
                }
            }
        } else {
            end = ci.getEndIndex();
        }

        glyphVector = getEffectiveFont().createGlyphVector(fontRenderContext,
            new CharSequenceCharacterIterator(textNode.getCharacters(), start, end));

        if (end < ci.getEndIndex()) {
            length = end - start;
            next = new TextPaneSkinTextNodeView(textNode, end);
            next.setParent(getParent());
        } else {
            length = ci.getEndIndex() - start;
            // set to null in case this node used to be broken across multiple, but is no longer
            next = null;
        }

        Rectangle2D textBounds = glyphVector.getLogicalBounds();
View Full Code Here

    @Override
    public Dimensions getPreferredSize(int breakWidth) {
        TextNode textNode = (TextNode)getNode();
        FontRenderContext fontRenderContext = Platform.getFontRenderContext();

        CharSequenceCharacterIterator ci = new CharSequenceCharacterIterator(textNode.getCharacters(), start);

        float lineWidth = 0;
        int lastWhitespaceIndex = -1;

        Font effectiveFont = getEffectiveFont();
        char c = ci.first();
        while (c != CharacterIterator.DONE
            && lineWidth < breakWidth) {
            if (Character.isWhitespace(c)) {
                lastWhitespaceIndex = ci.getIndex();
            }

            int i = ci.getIndex();
            Rectangle2D characterBounds = effectiveFont.getStringBounds(ci, i, i + 1, fontRenderContext);
            lineWidth += characterBounds.getWidth();

            c = ci.current();
        }

        int end;
        if (getTextPaneSkin().getWrapText()) {
            if (textNode.getCharacterCount() == 0) {
                end = start;
            } else {
                if (lineWidth < breakWidth) {
                    end = ci.getEndIndex();
                } else {
                    if (lastWhitespaceIndex == -1) {
                        end = ci.getIndex() - 1;
                        if (end <= start) {
                            end = start + 1;
                        }
                    } else {
                        end = lastWhitespaceIndex + 1;
                    }
                }
            }
        } else {
            end = ci.getEndIndex();
        }

        GlyphVector glyphVector = getEffectiveFont().createGlyphVector(fontRenderContext,
            new CharSequenceCharacterIterator(textNode.getCharacters(), start, end));

        Rectangle2D textBounds = glyphVector.getLogicalBounds();
        return new Dimensions((int)Math.ceil(textBounds.getWidth()),
            (int)Math.ceil(textBounds.getHeight()));
    }
View Full Code Here

                characters = passwordBuilder;
            } else {
                characters = textInput.getCharacters();
            }

            CharSequenceCharacterIterator ci = new CharSequenceCharacterIterator(characters);

            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
            glyphVector = font.createGlyphVector(fontRenderContext, ci);

            Rectangle2D textBounds = glyphVector.getLogicalBounds();
View Full Code Here

TOP

Related Classes of org.apache.pivot.text.CharSequenceCharacterIterator

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.