Package pivot.wtk

Examples of pivot.wtk.TabPane


        buttonFlowPane.getStyles().put("spacing", 2);
    }

  @Override
  public void setSize(int width, int height) {
    TabPane tabPane = (TabPane)getComponent();
    Orientation tabOrientation = tabPane.getTabOrientation();

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


  }

    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 button panorama and flow pane
        buttonPanorama.getStyles().put("buttonBackgroundColor", borderColor);
        buttonPanorama.getStyles().put("buttonPadding", 6);
        buttonPanorama.setView(buttonFlowPane);
        tabPane.add(buttonPanorama);

        // Apply the current tab orientation
        tabOrientationChanged(tabPane);

        // Add buttons for all existing tabs
        for (Component tab : tabPane.getTabs()) {
            TabButton tabButton = new TabButton(new ButtonData(TabPane.getIcon(tab),
                TabPane.getName(tab)));
            tabButton.setGroup(tabButtonGroup);

            buttonFlowPane.add(tabButton);
View Full Code Here

        selectedIndexChanged(tabPane, -1);
    }

    public void uninstall() {
        TabPane tabPane = (TabPane)getComponent();

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

        // Remove the button panorama
        tabPane.remove(buttonPanorama);

        super.uninstall();
    }
View Full Code Here

    }

    public int getPreferredWidth(int height) {
        int preferredWidth;

        TabPane tabPane = (TabPane)getComponent();
        Orientation tabOrientation = tabPane.getTabOrientation();

        if (expandTransition == null
        || tabOrientation == Orientation.VERTICAL) {
          preferredWidth = 0;

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

            switch (tabOrientation) {
                case HORIZONTAL: {
                    if (height != -1) {
                        if (corner != null
                            && corner.isDisplayable()) {
                            height = Math.max(height - Math.max(corner.getPreferredHeight(-1),
                                Math.max(buttonPanorama.getPreferredHeight(-1) - 1, 0)), 0);
                        } else {
                            height = Math.max(height - (buttonPanorama.getPreferredHeight(-1) - 1), 0);
                        }

                        height = Math.max(height - (padding.top + padding.bottom + 2), 0);
                    }

                    if (selectedTab != null) {
                        for (Component tab : tabPane.getTabs()) {
                            preferredWidth = Math.max(preferredWidth,
                                tab.getPreferredWidth(height));
                        }

                        preferredWidth += (padding.left + padding.right + 2);
                    }

                    int buttonAreaPreferredWidth = buttonPanorama.getPreferredWidth(-1);

                    if (corner != null
                        && corner.isDisplayable()) {
                        buttonAreaPreferredWidth += corner.getPreferredWidth(-1);
                    }

                    preferredWidth = Math.max(preferredWidth,
                        buttonAreaPreferredWidth);

                    break;
                }

                case VERTICAL: {
                    if (height != -1) {
                        height = Math.max(height - (padding.top + padding.bottom + 2), 0);
                    }

                    if (selectedTab != null) {
                      if (expandTransition == null) {
                          int contentWidth = 0;
                            for (Component tab : tabPane.getTabs()) {
                                contentWidth = Math.max(contentWidth,
                                    tab.getPreferredWidth(height));
                            }

                            preferredWidth += (padding.left + padding.right + contentWidth);
View Full Code Here

    }

    public int getPreferredHeight(int width) {
        int preferredHeight;

        TabPane tabPane = (TabPane)getComponent();
        Orientation tabOrientation = tabPane.getTabOrientation();

        if (expandTransition == null
        || tabOrientation == Orientation.HORIZONTAL) {
          preferredHeight = 0;
            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);
                    }

                    if (selectedTab != null) {
                      if (expandTransition == null) {
                        int contentHeight = 0;
                            for (Component tab : tabPane.getTabs()) {
                              contentHeight = Math.max(contentHeight,
                                    tab.getPreferredHeight(width));
                            }

                            preferredHeight += (padding.top + padding.bottom + contentHeight);
                      } else {
                        float scale = expandTransition.getScale();
                            preferredHeight += (int)(scale * (float)(padding.top + padding.bottom
                            + selectedTab.getHeight()));
                      }

                        preferredHeight += 2;
                    } else {
                        preferredHeight += 1;
                    }

                    if (corner != null
                        && corner.isDisplayable()) {
                        preferredHeight += Math.max(corner.getPreferredHeight(-1),
                            Math.max(buttonPanorama.getPreferredHeight(-1) - 1, 0));
                    } else {
                        preferredHeight += Math.max(buttonPanorama.getPreferredHeight(-1) - 1, 0);
                    }

                    break;
                }

                case VERTICAL: {
                    if (width != -1) {
                        if (corner != null
                            && corner.isDisplayable()) {
                            width = Math.max(width - Math.max(corner.getPreferredWidth(-1),
                                Math.max(buttonPanorama.getPreferredWidth(-1) - 1, 0)), 0);
                        } else {
                            width = Math.max(width - (buttonPanorama.getPreferredWidth(-1) - 1), 0);
                        }

                        width = Math.max(width - (padding.left + padding.right + 2), 0);
                    }

                    if (selectedTab != null) {
                        for (Component tab : tabPane.getTabs()) {
                            preferredHeight = Math.max(preferredHeight,
                                tab.getPreferredHeight(width));
                        }

                        preferredHeight += (padding.top + padding.bottom + 2);
View Full Code Here

        // TODO Optimize
        return new Dimensions(getPreferredWidth(-1), getPreferredHeight(-1));
    }

    public void layout() {
        TabPane tabPane = (TabPane)getComponent();
        int width = getWidth();
        int height = getHeight();

        int tabX = 0;
        int tabY = 0;
        int tabWidth = 0;
        int tabHeight = 0;

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

        Dimensions buttonPanoramaSize;
        if (expandTransition == null) {
          buttonPanoramaSize = buttonPanorama.getPreferredSize();
        } else {
          buttonPanoramaSize = buttonPanorama.getSize();
        }

        Orientation tabOrientation = tabPane.getTabOrientation();
        switch (tabOrientation) {
            case HORIZONTAL: {
                int buttonPanoramaWidth = Math.min(width,
                    buttonPanoramaSize.width);
                int buttonPanoramaHeight = buttonPanoramaSize.height;
                int buttonPanoramaX = 0;
                int buttonPanoramaY = 0;

                if (corner != null) {
                    if (corner.isDisplayable()) {
                        int cornerWidth = width - buttonPanoramaWidth;
                        int cornerHeight = Math.max(corner.getPreferredHeight(-1), buttonPanoramaSize.height - 1);
                        int cornerX = buttonPanoramaWidth;
                        int cornerY = Math.max(buttonPanoramaHeight - cornerHeight - 1, 0);

                        buttonPanoramaY = Math.max(cornerHeight - buttonPanoramaHeight + 1, 0);

                        corner.setVisible(true);
                        corner.setLocation(cornerX, cornerY);
                        corner.setSize(cornerWidth, cornerHeight);
                    } else {
                        corner.setVisible(false);
                    }
                }

                buttonPanorama.setLocation(buttonPanoramaX, buttonPanoramaY);
                buttonPanorama.setSize(buttonPanoramaWidth, buttonPanoramaHeight);

                tabX = padding.left + 1;
                tabY = padding.top + buttonPanoramaY + buttonPanoramaHeight;
                tabWidth = Math.max(width - (padding.left + padding.right + 2), 0);
                tabHeight = Math.max(height - (padding.top + padding.bottom
                    + buttonPanoramaY + buttonPanoramaHeight + 1), 0);

                break;
            }

            case VERTICAL: {
                int buttonPanoramaWidth = buttonPanoramaSize.width;
                int buttonPanoramaHeight = Math.min(height,
                    buttonPanoramaSize.height);
                int buttonPanoramaX = 0;
                int buttonPanoramaY = 0;

                if (corner != null) {
                    if (corner.isDisplayable()) {
                        int cornerWidth = corner.getPreferredWidth(-1);
                        int cornerHeight = height - buttonPanoramaHeight;
                        int cornerX = Math.max(buttonPanoramaWidth - cornerWidth - 1, 0);
                        int cornerY = buttonPanoramaHeight;

                        buttonPanoramaX = Math.max(cornerWidth - buttonPanoramaWidth + 1, 0);

                        corner.setVisible(true);
                        corner.setLocation(cornerX, cornerY);
                        corner.setSize(cornerWidth, cornerHeight);
                    } else {
                        corner.setVisible(false);
                    }
                }

                buttonPanorama.setLocation(buttonPanoramaX, buttonPanoramaY);
                buttonPanorama.setSize(buttonPanoramaWidth, buttonPanoramaHeight);

                tabX = padding.left + buttonPanoramaX + buttonPanoramaWidth;
                tabY = padding.top + 1;
                tabWidth = Math.max(width - (padding.left + padding.right
                    + buttonPanoramaX + buttonPanoramaWidth + 1), 0);
                tabHeight = Math.max(height - (padding.top + padding.bottom + 2), 0);

                break;
            }
        }

        if (expandTransition == null) {
            for (Component tab : tabPane.getTabs()) {
                if (tab == selectedTab) {
                    // Show the selected tab
                    tab.setVisible(true);

                    // Set the tab's size and location
                    tab.setLocation(tabX, tabY);
                    tab.setSize(tabWidth, tabHeight);
                } else {
                    tab.setVisible(false);
                }
            }
        } else {
          if (expandTransition.isRunning()) {
              // Update the clip
              expandTransition.clipDecorator.setWidth(tabWidth);
              expandTransition.clipDecorator.setHeight(tabHeight);
          } else {
              switch (tabOrientation) {
                case HORIZONTAL: {
                  tabHeight = 0;
                  for (Component tab : tabPane.getTabs()) {
                    tabHeight = Math.max(tab.getPreferredHeight(tabWidth), tabHeight);
                  }

                  break;
                }

                case VERTICAL: {
                  tabWidth = 0;
                  for (Component tab : tabPane.getTabs()) {
                    tabWidth = Math.max(tab.getPreferredWidth(tabHeight), tabWidth);
                  }

                  break;
                }
View Full Code Here

        }
    }

    @Override
    public void paint(Graphics2D graphics) {
        TabPane tabPane = (TabPane)getComponent();

        Bounds tabPaneBounds = tabPane.getBounds();

        // Call the base class to paint the background
        super.paint(graphics);

        graphics.setStroke(new BasicStroke());

        // Paint the content background and border
        int x = 0;
        int y = 0;
        int width = 0;
        int height = 0;

        Orientation tabOrientation = tabPane.getTabOrientation();

        switch (tabOrientation) {
            case HORIZONTAL: {
                x = 0;
                y = Math.max(buttonPanorama.getY() + buttonPanorama.getHeight() - 1, 0);
                width = tabPaneBounds.width;
                height = Math.max(tabPaneBounds.height - y, 0);

                break;
            }

            case VERTICAL: {
                x = Math.max(buttonPanorama.getX() + buttonPanorama.getWidth() - 1, 0);
                y = 0;
                width = Math.max(tabPaneBounds.width - x, 0);
                height = tabPaneBounds.height;

                break;
            }
        }

        Bounds contentBounds = new Bounds(x, y, width, height);

        if (!contentBounds.isEmpty()) {
            // If a tab is selected, paint the active background color; otherwise,
            // paint the inactive background color
            int selectedIndex = tabPane.getSelectedIndex();
            graphics.setPaint((selectedIndex == -1) ? inactiveTabColor : activeTabColor);
            graphics.fillRect(contentBounds.x, contentBounds.y,
                contentBounds.width, contentBounds.height);

            // Draw the border
View Full Code Here

    public void setButtonSpacing(int buttonSpacing) {
        buttonFlowPane.getStyles().put("spacing", buttonSpacing);
    }

    protected void updateButtonData(Component tab) {
        TabPane tabPane = (TabPane)getComponent();
        int tabIndex = tabPane.getTabs().indexOf(tab);

        if (tabIndex != -1) {
            TabButton tabButton =
                (TabButton)buttonFlowPane.get(tabIndex);
View Full Code Here

    // Button group events
    public void selectionChanged(Group group, Button previousSelection) {
        Button button = tabButtonGroup.getSelection();
        int index = (button == null) ? -1 : buttonFlowPane.indexOf(button);

        TabPane tabPane = (TabPane)getComponent();
        tabPane.setSelectedIndex(index);
    }
View Full Code Here

        @Override
        public void press() {
            // If the tab pane is collapsible, toggle the button selection;
            // otherwise, select it
            TabPane tabPane = (TabPane)TerraTabPaneSkin.this.getComponent();
            setSelected(tabPane.isCollapsible() ? !isSelected() : true);

            super.press();
        }
View Full Code Here

TOP

Related Classes of 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.