Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Tooltip


                // Gets the underlying file
                File file = (File) fileTableView.getTableData().get(fileTableView.getRowAt(y));

                // Construct and show the tooltip.
                final Tooltip tooltip = new Tooltip();

                String text = null;

                if (file != null){
                    text = file.getName();
                }

                if (text == null || text.isEmpty()) {
                    return;
                }

                TextArea toolTipTextArea = new TextArea();

                toolTipTextArea.setText(text);
                toolTipTextArea.getStyles().put("wrapText", true);

                tooltip.setContent(toolTipTextArea);

                Point location = comp.getDisplay().getMouseLocation();
                x = location.x;
                y = location.y;

                // Ensure that the tooltip stays on screen
                Display display = comp.getDisplay();
                int tooltipHeight = tooltip.getPreferredHeight();
                if (y + tooltipHeight > display.getHeight()) {
                    y -= tooltipHeight;
                }

                int tooltipXOffset = 16;
                int padding = 15;

                toolTipTextArea.setMaximumWidth(display.getWidth() - ( x + tooltipXOffset + padding) );
                tooltip.setLocation(x + tooltipXOffset, y);
                tooltip.open(comp.getWindow());
            }
        });

        rootDirectoryChanged(fileBrowser, null);
        selectedFilesChanged(fileBrowser, null);
View Full Code Here


        if (tooltipText != null) {
            Label tooltipLabel = new Label(tooltipText);
            boolean tooltipWrapText = component.getTooltipWrapText();
            tooltipLabel.getStyles().put("wrapText", tooltipWrapText);
            Tooltip tooltip = new Tooltip(tooltipLabel);

            Display display = component.getDisplay();
            Point location = component.mapPointToAncestor(display, x, y);

            // Ensure that the tooltip stays on screen
            int tooltipX = location.x + 16;
            int tooltipY = location.y;

            int tooltipWidth = tooltip.getPreferredWidth();
            int tooltipHeight = tooltip.getPreferredHeight();
            if (tooltipX + tooltipWidth > display.getWidth()) {
                // Try to just fit it inside the display if
                // there would be room to shift it above the
                // cursor, otherwise move it to the left of
                // the cursor
                if (tooltipY > tooltipHeight) {
                    tooltipX = display.getWidth() - tooltipWidth;
                } else {
                    tooltipX = location.x - tooltipWidth - 16;
                }
                if (tooltipX < 0) {
                    tooltipX = 0;
                }
                // Adjust the y location if the tip ends up
                // being behind the mouse cursor because of
                // these x adjustments
                if (tooltipX < location.x && tooltipX + tooltipWidth > location.x) {
                    tooltipY -= tooltipHeight;
                    if (tooltipY < 0) {
                        tooltipY = 0;
                    }
                }
            }
            if (tooltipY + tooltipHeight > display.getHeight()) {
                tooltipY -= tooltipHeight;
            }

            tooltip.setLocation(tooltipX, tooltipY);
            tooltip.open(component.getWindow());
        }
    }
View Full Code Here

    @Override
    public void install(Component component) {
        super.install(component);

        Tooltip tooltip = (Tooltip)component;

        dropShadowDecorator = new DropShadowDecorator(5, 2, 2);
        tooltip.getDecorators().add(dropShadowDecorator);

        tooltip.setContent(border);
        tooltip.getTooltipListeners().add(this);

        label.setText(tooltip.getText());
    }
View Full Code Here

            String tooltipText = component.getTooltipText();

            // The tooltip text may have been cleared while the timeout was
            // outstanding; if so, don't display the tooltip
            if (tooltipText != null) {
                final Tooltip tooltip = new Tooltip(tooltipText);

                Point location = component.getDisplay().getMouseLocation();
                int x = location.x;
                int y = location.y;

                // Ensure that the tooltip stays on screen
                Display display = component.getDisplay();
                int tooltipHeight = tooltip.getPreferredHeight();
                if (y + tooltipHeight > display.getHeight()) {
                    y -= tooltipHeight;
                }

                tooltip.setLocation(x + 16, y);
                tooltip.open(component.getWindow());
            }
        }
View Full Code Here

    @Override
    public void install(Component component) {
        super.install(component);

        Tooltip tooltip = (Tooltip)component;

        dropShadowDecorator = new DropShadowDecorator(5, 2, 2);
        tooltip.getDecorators().add(dropShadowDecorator);
    }
View Full Code Here

    @Override
    public int getPreferredWidth(int height) {
        int preferredWidth = 0;

        Tooltip tooltip = (Tooltip)getComponent();
        Component content = tooltip.getContent();

        if (height != -1) {
            height -= (padding.top + padding.bottom + 2);
        }
View Full Code Here

    @Override
    public int getPreferredHeight(int width) {
        int preferredHeight = 0;

        Tooltip tooltip = (Tooltip)getComponent();
        Component content = tooltip.getContent();

        if (width != -1) {
            width -= (padding.left + padding.right + 2);
        }
View Full Code Here

    @Override
    public Dimensions getPreferredSize() {
        int preferredWidth = 0;
        int preferredHeight = 0;

        Tooltip tooltip = (Tooltip)getComponent();
        Component content = tooltip.getContent();

        if (content != null) {
            Dimensions contentSize = content.getPreferredSize();
            preferredWidth = contentSize.width;
            preferredHeight = contentSize.height;
View Full Code Here

        return new Dimensions(preferredWidth, preferredHeight);
    }

    @Override
    public void layout() {
        Tooltip tooltip = (Tooltip)getComponent();
        Component content = tooltip.getContent();

        if (content != null) {
            int contentWidth = Math.max(getWidth() - (padding.left + padding.right + 2), 0);
            int contentHeight = Math.max(getHeight() - (padding.top + padding.bottom + 2), 0);
            content.setSize(contentWidth, contentHeight);
View Full Code Here

    @Override
    public void tooltipTriggered(Component componentArgument, int x, int y) {
        String tooltipText = component.getTooltipText();

        if (tooltipText != null) {
            Tooltip tooltip = new Tooltip(new Label(tooltipText));

            Display display = component.getDisplay();
            Point location = component.mapPointToAncestor(display, x, y);

            // Ensure that the tooltip stays on screen
            int tooltipX = location.x + 16;
            int tooltipY = location.y;

            int tooltipWidth = tooltip.getPreferredWidth();
            int tooltipHeight = tooltip.getPreferredHeight();
            if (tooltipX + tooltipWidth > display.getWidth()) {
                // Try to just fit it inside the display if
                // there would be room to shift it above the
                // cursor, otherwise move it to the left of
                // the cursor
                if (tooltipY > tooltipHeight) {
                    tooltipX = display.getWidth() - tooltipWidth;
                } else {
                    tooltipX = location.x - tooltipWidth - 16;
                }
                if (tooltipX < 0) {
                    tooltipX = 0;
                }
                // Adjust the y location if the tip ends up
                // being behind the mouse cursor because of
                // these x adjustments
                if (tooltipX < location.x && tooltipX + tooltipWidth > location.x) {
                    tooltipY -= tooltipHeight;
                    if (tooltipY < 0) {
                        tooltipY = 0;
                    }
                }
            }
            if (tooltipY + tooltipHeight > display.getHeight()) {
                tooltipY -= tooltipHeight;
            }

            tooltip.setLocation(tooltipX, tooltipY);
            tooltip.open(component.getWindow());
        }
    }
View Full Code Here

TOP

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

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.