Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Bounds


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

        // Get the item bounds
        Bounds itemBounds = listViewArgument.getItemBounds(itemIndexArgument);
        int itemIndent = listViewArgument.getItemIndent();
        itemBounds = new Bounds(itemBounds.x + itemIndent, itemBounds.y,
            itemBounds.width - itemIndent, itemBounds.height);

        // Render the item data
        ListViewItemRenderer itemRenderer = (ListViewItemRenderer)listViewArgument.getItemRenderer();
        itemRenderer.render(listItem, itemIndexArgument, listViewArgument, false, false, false, false);
        itemRenderer.setSize(itemBounds.width, itemBounds.height);

        // Calculate the text bounds
        Bounds textBounds = itemRenderer.getTextBounds();

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

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


    }

    @Override
    public Bounds getRowBounds(int row) {
        if (rowHeights == null) {
            return new Bounds(0, 0, 0, 0);
        }

        if (row < 0
            || row >= rowHeights.length) {
            throw new IndexOutOfBoundsException(String.valueOf(row));
        }

        int rowY = padding.top;

        for (int i = 0; i < row; i++) {
            rowY += rowHeights[i] + verticalSpacing;
        }

        return new Bounds(0, rowY, getWidth(), rowHeights[row]);
    }
View Full Code Here

    }

    @Override
    public Bounds getColumnBounds(int column) {
        if (columnWidths == null) {
            return new Bounds(0, 0, 0, 0);
        }

        if (column < 0
            || column >= columnWidths.length) {
            throw new IndexOutOfBoundsException(String.valueOf(column));
        }

        int columnX = padding.left;

        for (int j = 0; j < column; j++) {
            columnX += columnWidths[j] + horizontalSpacing;
        }

        return new Bounds(columnX, 0, columnWidths[column], getHeight());
    }
View Full Code Here

        for (int i = 0; i < row; i++) {
            rowY += cellHeight + verticalSpacing;
        }

        return new Bounds(0, rowY, getWidth(), cellHeight);
    }
View Full Code Here

        for (int j = 0; j < column; j++) {
            columnX += cellWidth + horizontalSpacing;
        }

        return new Bounds(columnX, 0, cellWidth, getHeight());
    }
View Full Code Here

    public int getRowCount() {
        return rows.getLength();
    }

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

        CharSequence characters = paragraph.getCharacters();
        int characterCount = characters.length();

        int rowIndex, xLocal, widthLocal;
        if (index == characterCount) {
            // This is the terminator character
            rowIndex = rows.getLength() - 1;
            Row row = rows.get(rowIndex);

            Rectangle2D glyphVectorBounds = row.glyphVector.getLogicalBounds();
            xLocal = (int)Math.floor(glyphVectorBounds.getWidth());
            widthLocal = PARAGRAPH_TERMINATOR_WIDTH;
        } else {
            // This is a visible character
            rowIndex = getRowAt(index);
            Row row = rows.get(rowIndex);

            Shape glyphBounds = row.glyphVector.getGlyphLogicalBounds(index - row.offset);
            Rectangle2D glyphBounds2D = glyphBounds.getBounds2D();
            xLocal = (int)Math.floor(glyphBounds2D.getX());
            widthLocal = (int)Math.ceil(glyphBounds2D.getWidth());
        }

        Font font = textAreaSkin.getFont();
        FontRenderContext fontRenderContext = Platform.getFontRenderContext();
        LineMetrics lm = font.getLineMetrics("", fontRenderContext);
        float rowHeight = lm.getAscent() + lm.getDescent();

        characterBounds = new Bounds(xLocal, (int)Math.floor(rowIndex * rowHeight), widthLocal,
            (int)Math.ceil(rowHeight));

        return characterBounds;
    }
View Full Code Here

    /**
     * Gets the bounding box defined by the specified node, or <tt>null</tt>
     * if the node is not currently visible.
     */
    protected final Bounds getNodeBounds(NodeInfo nodeInfo) {
        Bounds bounds = null;

        int index = visibleNodes.indexOf(nodeInfo);

        if (index >= 0) {
            int nodeHeight = getNodeHeight();
            int nodeY = index * (nodeHeight + VERTICAL_SPACING);

            bounds = new Bounds(0, nodeY, getWidth(), nodeHeight);
        }

        return bounds;
    }
View Full Code Here

    /**
     * Repaints the region occupied by the specified node.
     */
    protected void repaintNode(NodeInfo nodeInfo) {
        Bounds bounds = getNodeBounds(nodeInfo);
        if (bounds != null) {
            repaintComponent(bounds);
        }
    }
View Full Code Here

        Sequence<Path> selectedPaths = treeView.getSelectedPaths();
        int n = selectedPaths.getLength();

        if (n > 0) {
            Bounds nodeBounds = null;

            for (int i = n - 1; i >= 0 && nodeBounds == null; i--) {
                NodeInfo nodeInfo = getNodeInfoAt(selectedPaths.get(i));
                nodeBounds = getNodeBounds(nodeInfo);
            }

            if (nodeBounds != null) {
                Bounds visibleSelectionBounds = treeView.getVisibleArea(nodeBounds);
                if (visibleSelectionBounds != null
                    && visibleSelectionBounds.height < nodeBounds.height) {
                    treeView.scrollAreaToVisible(nodeBounds);
                }
            }
View Full Code Here

    @Override
    public boolean mouseWheel(Component component, Mouse.ScrollType scrollType, int scrollAmount,
        int wheelRotation, int x, int y) {
        if (highlightedNode != null) {
            Bounds nodeBounds = getNodeBounds(highlightedNode);

            highlightedNode.setHighlighted(false);
            highlightedNode = null;

            if (nodeBounds != null) {
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.