Package pivot.wtk

Examples of pivot.wtk.CardPane


        WTKXSerializer wtkxSerializer = new WTKXSerializer();

        Component content =
            (Component)wtkxSerializer.readObject("pivot/tutorials/buttons/link_buttons.wtkx");

        final CardPane cardPane = (CardPane)wtkxSerializer.getObjectByName("cardPane");

        LinkButton nextButton = (LinkButton)wtkxSerializer.getObjectByName("nextButton");
        nextButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                cardPane.setSelectedIndex(1);
            }
        });

        LinkButton previousButton = (LinkButton)wtkxSerializer.getObjectByName("previousButton");
        previousButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                cardPane.setSelectedIndex(0);
            }
        });

        window = new Window();
        window.setContent(content);
View Full Code Here


        public float getEasedSlidePercentComplete() {
            return slideEasing.easeOut(getElapsedTime(), 0, 1, getDuration());
        }

        public Component getPreviousSelectedCard() {
            CardPane cardPane = (CardPane)getComponent();
            return previousSelectedIndex == -1 ? null : cardPane.get(previousSelectedIndex);
        }
View Full Code Here

            CardPane cardPane = (CardPane)getComponent();
            return previousSelectedIndex == -1 ? null : cardPane.get(previousSelectedIndex);
        }

        public Component getSelectedCard() {
            CardPane cardPane = (CardPane)getComponent();
            return selectedIndex == -1 ? null : cardPane.get(selectedIndex);
        }
View Full Code Here

    @Override
    public void setSize(int width, int height) {
        if (selectionChangeTransition != null) {
            if (!matchSelectedCardSize) {
                CardPane cardPane = (CardPane)getComponent();
                Orientation orientation = cardPane.getOrientation();

                if ((orientation == Orientation.HORIZONTAL && width != getWidth())
                    || (orientation == Orientation.VERTICAL && height != getHeight())) {
                    selectionChangeTransition.end();
                    selectionChangeTransition = null;
View Full Code Here

    }

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

        CardPane cardPane = (CardPane)component;
        cardPane.getCardPaneListeners().add(this);
    }
View Full Code Here

        CardPane cardPane = (CardPane)component;
        cardPane.getCardPaneListeners().add(this);
    }

    public void uninstall() {
        CardPane cardPane = (CardPane)getComponent();
        cardPane.getCardPaneListeners().remove(this);

        super.uninstall();
    }
View Full Code Here

    }

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

        CardPane cardPane = (CardPane)getComponent();

        if (selectionChangeTransition == null) {
            if (matchSelectedCardSize) {
                Component selectedCard = cardPane.getSelectedCard();
                if (selectedCard != null) {
                    preferredWidth = selectedCard.getPreferredWidth(height);
                }
            } else {
                int selectedIndex = cardPane.getSelectedIndex();
                Orientation orientation = cardPane.getOrientation();

                if (selectedIndex != -1
                    || orientation == Orientation.HORIZONTAL) {
                    for (Component card : cardPane) {
                        preferredWidth = Math.max(preferredWidth, card.getPreferredWidth(height));
                    }
                }
            }
        } else {
            float percentComplete = selectionChangeTransition.getPercentComplete();

            Component previousSelectedCard = selectionChangeTransition.getPreviousSelectedCard();
            int previousWidth = (previousSelectedCard == null) ? 0 : previousSelectedCard.getWidth();

            Component selectedCard = selectionChangeTransition.getSelectedCard();
            int width = (selectedCard == null) ? 0 : selectedCard.getWidth();

            Orientation orientation = cardPane.getOrientation();

            if (!matchSelectedCardSize
                && orientation == Orientation.HORIZONTAL) {
                preferredWidth = Math.max(previousWidth, width);
            } else {
View Full Code Here

    }

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

        CardPane cardPane = (CardPane)getComponent();

        if (selectionChangeTransition == null) {
            if (matchSelectedCardSize) {
                Component selectedCard = cardPane.getSelectedCard();
                if (selectedCard != null) {
                    preferredHeight = selectedCard.getPreferredHeight(width);
                }
            } else {
                int selectedIndex = cardPane.getSelectedIndex();
                Orientation orientation = cardPane.getOrientation();

                if (selectedIndex != -1
                    || orientation == Orientation.VERTICAL) {
                    for (Component card : cardPane) {
                        preferredHeight = Math.max(preferredHeight, card.getPreferredHeight(width));
                    }
                }
            }
        } else {
            float percentComplete = selectionChangeTransition.getPercentComplete();

            Component previousSelectedCard = selectionChangeTransition.getPreviousSelectedCard();
            int previousHeight = (previousSelectedCard == null) ? 0 : previousSelectedCard.getHeight();

            Component selectedCard = selectionChangeTransition.getSelectedCard();
            int height = (selectedCard == null) ? 0 : selectedCard.getHeight();

            Orientation orientation = cardPane.getOrientation();

            if (!matchSelectedCardSize
                && orientation == Orientation.VERTICAL) {
                preferredHeight = Math.max(previousHeight, height);
            } else {
View Full Code Here

    }

    public Dimensions getPreferredSize() {
        Dimensions preferredSize;

        CardPane cardPane = (CardPane)getComponent();

        if (selectionChangeTransition == null) {
            if (matchSelectedCardSize) {
                Component selectedCard = cardPane.getSelectedCard();
                if (selectedCard == null) {
                    preferredSize = new Dimensions(0, 0);
                } else {
                    preferredSize = selectedCard.getPreferredSize();
                }
            } else {
                preferredSize = new Dimensions(0, 0);
                Orientation orientation = cardPane.getOrientation();

                int selectedIndex = cardPane.getSelectedIndex();
                for (Component card : cardPane) {
                    Dimensions cardSize = card.getPreferredSize();

                    if (selectedIndex != -1
                        || orientation == Orientation.HORIZONTAL) {
                        preferredSize.width = Math.max(cardSize.width, preferredSize.width);
                    }

                    if (selectedIndex != -1
                        || orientation == Orientation.VERTICAL) {
                        preferredSize.height = Math.max(cardSize.height, preferredSize.height);
                    }
                }
            }
        } else {
            float percentComplete = selectionChangeTransition.getPercentComplete();

            int previousWidth;
            int previousHeight;
            Component previousSelectedCard = selectionChangeTransition.getPreviousSelectedCard();

            if (previousSelectedCard == null) {
                previousWidth = 0;
                previousHeight = 0;
            } else {
                previousWidth = previousSelectedCard.getWidth();
                previousHeight = previousSelectedCard.getHeight();
            }

            int width;
            int height;
            Component selectedCard = selectionChangeTransition.getSelectedCard();

            if (selectedCard == null) {
                width = 0;
                height = 0;
            } else {
                width = selectedCard.getWidth();
                height = selectedCard.getHeight();
            }

            int preferredWidth = 0;
            int preferredHeight = 0;

            Orientation orientation = cardPane.getOrientation();

            if (!matchSelectedCardSize
                && orientation == Orientation.HORIZONTAL) {
                preferredWidth = Math.max(previousWidth, width);
            } else {
View Full Code Here

        return preferredSize;
    }

    public void layout() {
        CardPane cardPane = (CardPane)getComponent();
        int width = getWidth();
        int height = getHeight();

        if (selectionChangeTransition == null) {
            Component selectedCard = cardPane.getSelectedCard();

            for (Component card : cardPane) {
                // Set the size of the selected component to the container's size
                // and show the card
                if (card == selectedCard) {
                    card.setLocation(0, 0);
                    card.setSize(width, height);
                    card.setVisible(true);
                } else {
                    card.setVisible(false);
                }
            }
        } else {
            if (matchSelectedCardSize) {
                Component previousSelectedCard = selectionChangeTransition.getPreviousSelectedCard();
                Component selectedCard = selectionChangeTransition.getSelectedCard();

                Orientation orientation = cardPane.getOrientation();

                if (selectionChangeTransition.isRunning()) {
                    for (Component card : cardPane) {
                        // Center old and new cards and ensure they are visible
                        if (card == previousSelectedCard
                            || card == selectedCard) {
                            int x = (orientation == Orientation.VERTICAL) ?
                                0 : Math.round((float)(width - card.getWidth()) / 2);
                            int y = (orientation == Orientation.HORIZONTAL) ?
                                0 : Math.round((float)(height - card.getHeight()) / 2);

                            card.setLocation(x, y);
                            card.setVisible(true);
                        } else {
                            card.setVisible(false);
                        }
                    }
                } else {
                    if (previousSelectedCard != null) {
                        previousSelectedCard.setSize(previousSelectedCard.getPreferredSize());
                    }

                    if (selectedCard != null) {
                        selectedCard.setSize(selectedCard.getPreferredSize());
                        selectedCard.setVisible(true);
                    }
                }
            } else {
                if (selectionChangeTransition.isRunning()) {
                    int previousSelectedIndex = selectionChangeTransition.previousSelectedIndex;
                    int selectedIndex = selectionChangeTransition.selectedIndex;

                    if (previousSelectedIndex != -1
                        && selectedIndex != -1) {
                        float percentComplete = selectionChangeTransition.getEasedSlidePercentComplete();

                        int direction = Integer.signum(previousSelectedIndex - selectedIndex);

                        int dx = (int)((float)width * percentComplete) * direction;
                        int dy = (int)((float)height * percentComplete) * direction;

                        Orientation orientation = cardPane.getOrientation();

                        for (int i = 0, n = cardPane.getLength(); i < n; i++) {
                            Component card = cardPane.get(i);

                            if (i == previousSelectedIndex) {
                                if (orientation == Orientation.HORIZONTAL) {
                                    card.setLocation(dx, 0);
                                } else {
                                    card.setLocation(0, dy);
                                }

                                card.setVisible(true);
                            } else if (i == selectedIndex) {
                                if (orientation == Orientation.HORIZONTAL) {
                                    card.setLocation(-width * direction + dx, 0);
                                } else {
                                    card.setLocation(0, -height * direction + dy);
                                }

                                card.setVisible(true);
                            } else {
                                card.setVisible(false);
                            }
                        }
                    }
                } else {
                    Component selectedCard = selectionChangeTransition.getSelectedCard();
                    Orientation orientation = cardPane.getOrientation();

                    if (selectedCard != null) {
                        if (orientation == Orientation.HORIZONTAL) {
                            for (Component card : cardPane) {
                                height = Math.max(height, card.getPreferredHeight(width));
View Full Code Here

TOP

Related Classes of pivot.wtk.CardPane

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.