Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Bounds


        }
    }

    @Override
    public Bounds getClientArea() {
        return new Bounds(0, 0, getWidth(), getHeight());
    }
View Full Code Here


    public int getInsertionPoint(int x, int y) {
        int offset = -1;

        for (int i = 0, n = getLength(); i < n; i++) {
            TextPaneSkinNodeView nodeView = get(i);
            Bounds nodeViewBounds = nodeView.getBounds();

            if (y >= nodeViewBounds.y
                && y < nodeViewBounds.y + nodeViewBounds.height) {
                offset = nodeView.getInsertionPoint(x - nodeView.getX(), y - nodeView.getY())
                    + nodeView.getOffset();
View Full Code Here

        return 0;
    }

    @Override
    public Bounds getCharacterBounds(int offset) {
        return new Bounds(0, 0, getWidth(), getHeight());
    }
View Full Code Here

        String text = treeNode.getText();
        textInput.setText(text != null ? text : "");
        textInput.selectAll();

        // Get the node bounds
        Bounds nodeBounds = treeViewArgument.getNodeBounds(pathArgument);
        int nodeIndent = treeViewArgument.getNodeIndent(pathArgument.getLength());
        nodeBounds = new Bounds(nodeBounds.x + nodeIndent, nodeBounds.y,
            nodeBounds.width - nodeIndent, nodeBounds.height);

        // Render the node data
        TreeViewNodeRenderer nodeRenderer = (TreeViewNodeRenderer)treeViewArgument.getNodeRenderer();
        nodeRenderer.render(treeNode, pathArgument, treeViewArgument.getRowIndex(pathArgument), treeViewArgument, false, false,
            TreeView.NodeCheckState.UNCHECKED, false, false);
        nodeRenderer.setSize(nodeBounds.width, nodeBounds.height);

        // Get the text bounds
        Bounds textBounds = nodeRenderer.getTextBounds();

        // Calculate the bounds of what is being edited
        Insets padding = (Insets)textInput.getStyles().get("padding");
        Bounds editBounds = new Bounds(nodeBounds.x + textBounds.x - (padding.left + 1),
            nodeBounds.y, nodeBounds.width - textBounds.x + (padding.left + 1),
            nodeBounds.height);

        // Scroll to make the node as visible as possible
        treeViewArgument.scrollAreaToVisible(editBounds.x, editBounds.y,
View Full Code Here

        // Load the row data into the editor components
        tablePane.load(tableRow);

        // Get the row bounds
        Bounds rowBounds = tableViewArgument.getRowBounds(rowIndexArgument);
        rowImage.bounds = rowBounds;

        // Scroll to make the row as visible as possible
        tableViewArgument.scrollAreaToVisible(rowBounds.x, rowBounds.y, rowBounds.width, rowBounds.height);
View Full Code Here

        return rowCount;
    }

    @Override
    public Bounds getCharacterBounds(int index) {
        Bounds characterBounds = null;

        if (paragraphViews.getLength() > 0) {
            TextArea textArea = (TextArea)getComponent();
            TextAreaSkinParagraphView paragraphView = paragraphViews.get(textArea.getParagraphAt(index));
            characterBounds = paragraphView.getCharacterBounds(index
                - paragraphView.getParagraph().getOffset());

            characterBounds = new Bounds(characterBounds.x + paragraphView.getX(),
                characterBounds.y + paragraphView.getY(),
                characterBounds.width, characterBounds.height);
        }

        return characterBounds;
View Full Code Here

    public Area getSelection() {
        return selection;
    }

    private void scrollCharacterToVisible(int index) {
        Bounds characterBounds = getCharacterBounds(index);

        if (characterBounds != null) {
            TextArea textArea = (TextArea)getComponent();
            textArea.scrollAreaToVisible(characterBounds.x, characterBounds.y,
                characterBounds.width, characterBounds.height);
View Full Code Here

        boolean consumed = super.mouseMove(component, x, y);

        if (Mouse.getCapturer() == component) {
            TextArea textArea = (TextArea)getComponent();

            Bounds visibleArea = textArea.getVisibleArea();
            visibleArea = new Bounds(visibleArea.x, visibleArea.y, visibleArea.width,
                visibleArea.height);

            // if it's inside the visible area, stop the scroll timer
            if (y >= visibleArea.y
                && y < visibleArea.y + visibleArea.height) {
View Full Code Here

                            if (index != -1) {
                                selectionLength = selectionStart + selectionLength - index;
                            }
                        } else {
                            // reduce downward size
                            Bounds trailingSelectionBounds = getCharacterBounds(selectionStart + selectionLength - 1);
                            int x = trailingSelectionBounds.x + trailingSelectionBounds.width;
                            index = getNextInsertionPoint(x, selectionStart + selectionLength - 1, TextArea.ScrollDirection.UP);
                            if (index != -1) {
                                if (index < anchor) {
                                    selectionLength = anchor - index;
                                } else {
                                    selectionLength = index - selectionStart;
                                    index = selectionStart;
                                }
                            }
                        }
                    }
                } else {
                    index = getNextInsertionPoint(caretX, selectionStart, TextArea.ScrollDirection.UP);
                    if (index != -1) {
                        selectionLength = 0;
                    }
                    anchor = -1;
                }

                if (index != -1) {
                    textArea.setSelection(index, selectionLength);
                    scrollCharacterToVisible(index);
                    caretX = caret.x;
                }

                consumed = true;
            } else if (keyCode == Keyboard.KeyCode.DOWN) {
                int selectionStart = textArea.getSelectionStart();
                int selectionLength = textArea.getSelectionLength();

                if (shiftPressed) {
                    int from;
                    int x;
                    int index;

                    if (anchor == -1) {
                        anchor = selectionStart;
                        index = getNextInsertionPoint(caretX, selectionStart, TextArea.ScrollDirection.DOWN);
                        if (index != -1) {
                            selectionLength = index - selectionStart;
                        }
                    } else {
                        if (selectionStart < anchor) {
                            // Reducing upward size
                            // Get next insertion point from leading selection character
                            from = selectionStart;
                            x = caretX;

                            index = getNextInsertionPoint(x, from, TextArea.ScrollDirection.DOWN);

                            if (index != -1) {
                                if (index < anchor) {
                                    selectionStart = index;
                                    selectionLength = anchor - index;
                                } else {
                                    selectionStart = anchor;
                                    selectionLength = index - anchor;
                                }

                                textArea.setSelection(selectionStart, selectionLength);
                                scrollCharacterToVisible(selectionStart);
                            }
                        } else {
                            // Increasing downward size
                            // Get next insertion point from right edge of trailing selection
                            // character
                            from = selectionStart + selectionLength - 1;

                            Bounds trailingSelectionBounds = getCharacterBounds(from);
                            x = trailingSelectionBounds.x + trailingSelectionBounds.width;

                            index = getNextInsertionPoint(x, from, TextArea.ScrollDirection.DOWN);

                            if (index != -1) {
View Full Code Here

        if (paragraphViews.getLength() > 0) {
            // Update the caret
            int selectionStart = textArea.getSelectionStart();

            Bounds leadingSelectionBounds = getCharacterBounds(selectionStart);
            caret = leadingSelectionBounds.toRectangle();
            caret.width = 1;

            // Update the selection
            int selectionLength = textArea.getSelectionLength();

            if (selectionLength > 0) {
                int selectionEnd = selectionStart + selectionLength - 1;
                Bounds trailingSelectionBounds = getCharacterBounds(selectionEnd);
                selection = new Area();

                int firstRowIndex = getRowAt(selectionStart);
                int lastRowIndex = getRowAt(selectionEnd);
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.Bounds

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.