Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.TabPane


        }

        @Override
        public Dimensions getPreferredSize() {
            TabButton tabButton = (TabButton)getComponent();
            TabPane tabPane = (TabPane)TerraTabPaneSkin.this.getComponent();

            Button.DataRenderer dataRenderer = tabButton.getDataRenderer();
            dataRenderer.render(tabButton.getButtonData(), tabButton, false);

            Dimensions preferredContentSize = dataRenderer.getPreferredSize();

            int preferredWidth = 0;
            int preferredHeight = 0;
            switch (tabOrientation) {
                case HORIZONTAL: {
                    preferredWidth = preferredContentSize.width
                        + buttonPadding.left + buttonPadding.right + 2;

                    preferredHeight = preferredContentSize.height
                        + buttonPadding.top + buttonPadding.bottom + 2;

                    if (tabPane.isCloseable()
                        && tabButton.isSelected()) {
                        preferredWidth += CLOSE_TRIGGER_SIZE + buttonSpacing;
                    }

                    break;
                }

                case VERTICAL: {
                    preferredWidth = preferredContentSize.height
                        + buttonPadding.top + buttonPadding.bottom + 2;

                    preferredHeight = preferredContentSize.width
                        + buttonPadding.left + buttonPadding.right + 2;

                    if (tabPane.isCloseable()
                        && tabButton.isSelected()) {
                        preferredHeight += CLOSE_TRIGGER_SIZE + buttonSpacing;
                    }

                    break;
View Full Code Here


        }

        @Override
        public void paint(Graphics2D graphics) {
            TabButton tabButton = (TabButton)getComponent();
            TabPane tabPane = (TabPane)TerraTabPaneSkin.this.getComponent();

            boolean active = (selectionChangeTransition != null
                && selectionChangeTransition.getTab() == tabButton.tab);

            Color backgroundColor, buttonBevelColor;
            if (tabButton.isSelected()
                || active) {
                backgroundColor = activeTabColor;
                buttonBevelColor = activeButtonBevelColor;
            } else {
                backgroundColor = inactiveTabColor;
                buttonBevelColor = inactiveButtonBevelColor;
            }

            int width = getWidth();
            int height = getHeight();

            // Draw the background
            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);

            switch(tabOrientation) {
                case HORIZONTAL: {
                    graphics.setPaint(new GradientPaint(width / 2f, 0, buttonBevelColor,
                        width / 2f, height / 2f, backgroundColor));
                    graphics.fill(new RoundRectangle2D.Double(0.5, 0.5, width - 1, height - 1 + buttonCornerRadius,
                        buttonCornerRadius, buttonCornerRadius));
                    break;
                }

                case VERTICAL: {
                    graphics.setPaint(new GradientPaint(0, height / 2f, buttonBevelColor,
                        width / 2f, height / 2f, backgroundColor));
                    graphics.fill(new RoundRectangle2D.Double(0.5, 0.5, width - 1 + buttonCornerRadius, height - 1,
                        buttonCornerRadius, buttonCornerRadius));
                    break;
                }

                default: {
                    break;
                }
            }

            // Draw the border
            graphics.setPaint((tabButton.isSelected() || active) ? borderColor : inactiveBorderColor);
            graphics.setStroke(new BasicStroke(1));

            switch(tabOrientation) {
                case HORIZONTAL: {
                    graphics.draw(new RoundRectangle2D.Double(0.5, 0.5, width - 1, height + buttonCornerRadius - 1,
                        buttonCornerRadius, buttonCornerRadius));
                    break;
                }

                case VERTICAL: {
                    graphics.draw(new RoundRectangle2D.Double(0.5, 0.5, width + buttonCornerRadius - 1, height - 1,
                        buttonCornerRadius, buttonCornerRadius));
                    break;
                }

                default: {
                    break;
                }
            }

            if (!(tabButton.isSelected()
                || active)) {
                graphics.setPaint(borderColor);
                // Draw divider
                switch(tabOrientation) {
                    case HORIZONTAL: {
                        graphics.draw(new Line2D.Double(0.5, height - 0.5, width - 0.5, height - 0.5));
                        break;
                    }

                    case VERTICAL: {
                        graphics.draw(new Line2D.Double(width - 0.5, 0.5, width - 0.5, height - 0.5));
                        break;
                    }

                    default: {
                        break;
                    }
                }
            }

            // Paint the content
            Button.DataRenderer dataRenderer = tabButton.getDataRenderer();
            dataRenderer.render(tabButton.getButtonData(), tabButton, false);

            Graphics2D contentGraphics = (Graphics2D)graphics.create();
            contentGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_OFF);

            switch (tabOrientation) {
                case HORIZONTAL: {
                    int contentWidth = getWidth() - (buttonPadding.left + buttonPadding.right + 2);
                    if (tabPane.isCloseable()
                        && tabButton.isSelected()) {
                        contentWidth -= (CLOSE_TRIGGER_SIZE + buttonSpacing);
                    }

                    dataRenderer.setSize(Math.max(contentWidth, 0),
                        Math.max(getHeight() - (buttonPadding.top + buttonPadding.bottom + 2), 0));

                    contentGraphics.translate(buttonPadding.left + 1, buttonPadding.top + 1);

                    break;
                }

                case VERTICAL: {
                    int contentWidth = getHeight() - (buttonPadding.top + buttonPadding.bottom + 2);
                    if (tabPane.isCloseable()
                        && tabButton.isSelected()) {
                        contentWidth -= (CLOSE_TRIGGER_SIZE + buttonSpacing);
                    }

                    dataRenderer.setSize(Math.max(contentWidth, 0),
                        Math.max(getWidth() - (buttonPadding.left + buttonPadding.right + 2), 0));

                    contentGraphics.translate(buttonPadding.top + 1, buttonPadding.left + 1);
                    contentGraphics.rotate(-Math.PI / 2d);
                    contentGraphics.translate(-dataRenderer.getWidth(), 0);

                    break;
                }

                default: {
                    break;
                }
            }

            contentGraphics.clipRect(0, 0, dataRenderer.getWidth(), dataRenderer.getHeight());
            dataRenderer.paint(contentGraphics);

            contentGraphics.dispose();

            // Draw the close trigger
            if (tabPane.isCloseable()
                && tabButton.isSelected()) {
                graphics.setStroke(new BasicStroke(2.5f));

                int x = 0;
                int y = 0;
View Full Code Here

        @Override
        public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
            boolean consumed = super.mouseClick(component, button, x, y, count);

            TabButton tabButton = (TabButton)getComponent();
            TabPane tabPane = (TabPane)TerraTabPaneSkin.this.getComponent();

            if (tabPane.isCloseable()
                && tabButton.isSelected()
                && getCloseTriggerBounds().contains(x, y)) {
                tabPane.getTabs().remove(tabButton.tab);
            } else {
                tabButton.press();
            }

            return consumed;
View Full Code Here

            this.index = index;
            this.expand = expand;
        }

        public Component getTab() {
            TabPane tabPane = (TabPane)getComponent();
            return tabPane.getTabs().get(index);
        }
View Full Code Here

            return scale;
        }

        @Override
        public void start(TransitionListener transitionListener) {
            TabPane tabPane = (TabPane)getComponent();

            if (expand) {
                getTab().setVisible(true);
            }

            getTab().getDecorators().add(clipDecorator);
            tabPane.setEnabled(false);

            super.start(transitionListener);
        }
View Full Code Here

            super.start(transitionListener);
        }

        @Override
        public void stop() {
            TabPane tabPane = (TabPane)getComponent();

            if (!expand) {
                getTab().setVisible(false);
            }

            getTab().getDecorators().remove(clipDecorator);
            tabPane.setEnabled(true);

            super.stop();
        }
View Full Code Here

            @Override
            public void selectionChanged(ButtonGroup buttonGroup, Button previousSelection) {
                Button button = tabButtonGroup.getSelection();
                int index = (button == null) ? -1 : tabButtonBoxPane.indexOf(button);

                TabPane tabPane = (TabPane)getComponent();
                tabPane.setSelectedIndex(index);
            }
        });

        setButtonSpacing(2);
    }
View Full Code Here

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

        TabPane tabPane = (TabPane)component;

        // Add this as a listener on the tab pane
        tabPane.getTabPaneListeners().add(this);
        tabPane.getTabPaneSelectionListeners().add(this);
        tabPane.getTabPaneAttributeListeners().add(this);

        // Add the tab button container
        tabPane.add(tabButtonPanorama);
    }
View Full Code Here

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

        TabPane tabPane = (TabPane)getComponent();

        Component selectedTab = tabPane.getSelectedTab();
        Component corner = tabPane.getCorner();

        switch (tabOrientation) {
            case HORIZONTAL: {
                if (height != -1) {
                    if (corner != null) {
View Full Code Here

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

        TabPane tabPane = (TabPane)getComponent();

        Component selectedTab = tabPane.getSelectedTab();
        Component corner = tabPane.getCorner();

        switch (tabOrientation) {
            case HORIZONTAL: {
                if (width != -1) {
                    width = Math.max(width - (padding.left + padding.right + 2), 0);
View Full Code Here

TOP

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

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.