Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.SplitPane


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

        SplitPane splitPane = (SplitPane)component;
        splitPane.getSplitPaneListeners().add(this);

        splitPane.add(splitter);
        updateSplitterCursor();
    }
View Full Code Here


        int previousWidth = getWidth();
        int previousHeight = getHeight();

        super.setSize(width, height);

        SplitPane splitPane = (SplitPane)getComponent();
        Orientation orientation = splitPane.getOrientation();

        if (splitPane.getResizeMode() == SplitPane.ResizeMode.PRIMARY_REGION
            && ((previousWidth != width && orientation == Orientation.HORIZONTAL)
            || (previousHeight != height && orientation == Orientation.VERTICAL))) {
            SplitPane.Region primaryRegion = splitPane.getPrimaryRegion();
            float splitRatio = splitPane.getSplitRatio();

            if (orientation == Orientation.HORIZONTAL) {
                int splitLocation = (int)(splitRatio * previousWidth);

                if (primaryRegion == SplitPane.Region.BOTTOM_RIGHT) {
                    // Move the split location to maintain size on the right
                    splitLocation += (width - previousWidth);
                }

                splitRatio = (float)limitSplitLocation(splitLocation) / width;
            } else {
                int splitLocation = (int)(splitRatio * previousHeight);

                if (primaryRegion == SplitPane.Region.BOTTOM_RIGHT) {
                    // Move the split location to maintain size on the bottom
                    splitLocation += (height - previousHeight);
                }

                splitRatio = (float)limitSplitLocation(splitLocation) / height;
            }

            splitPane.setSplitRatio(splitRatio);
        }
    }
View Full Code Here

    @Override
    public void layout() {
        int width = getWidth();
        int height = getHeight();

        SplitPane splitPane = (SplitPane)getComponent();

        float splitRatio = splitPane.getSplitRatio();
        Component topLeft = splitPane.getTopLeft();
        Component bottomRight = splitPane.getBottomRight();

        if (splitPane.getOrientation() == Orientation.HORIZONTAL) {
            int splitLocation = limitSplitLocation((int)(splitRatio * width));
            int rightStart = splitLocation + splitterThickness;
            splitter.setLocation(splitLocation, 0);
            splitter.setSize(splitterThickness, height);

View Full Code Here

        // No-op
    }

    private void updateSplitterCursor() {
        Cursor cursor = Cursor.DEFAULT;
        SplitPane splitPane = (SplitPane)getComponent();

        if (!splitPane.isLocked()) {
            switch (splitPane.getOrientation()) {
                case HORIZONTAL: {
                    switch (splitPane.getPrimaryRegion()) {
                        case TOP_LEFT: {
                            cursor = Cursor.RESIZE_EAST;
                            break;
                        }
                        case BOTTOM_RIGHT: {
                            cursor = Cursor.RESIZE_WEST;
                            break;
                        }
                        default: {
                            break;
                        }
                    }

                    break;
                }

                case VERTICAL: {
                    switch (splitPane.getPrimaryRegion()) {
                        case TOP_LEFT: {
                            cursor = Cursor.RESIZE_SOUTH;
                            break;
                        }
                        case BOTTOM_RIGHT: {
View Full Code Here

        splitter.setCursor(cursor);
    }

    private int limitSplitLocation(int splitLocation) {
        SplitPane splitPane = (SplitPane)getComponent();

        Component topLeft = splitPane.getTopLeft();
        Component bottomRight = splitPane.getBottomRight();

        int lower, upper;

        if (splitPane.getOrientation() == Orientation.HORIZONTAL) {
            lower = 0;
            upper = Math.max(getWidth() - splitterThickness, 0);

            if (topLeft  != null) {
                int leftLimit = topLeft.getMinimumWidth();
View Full Code Here

            // No-op
        }

        @Override
        public void paint(Graphics2D graphics) {
            SplitPane splitPane = (SplitPane)TerraSplitPaneSkin.this.getComponent();

            Orientation orientation = splitPane.getOrientation();

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

            int imageWidth, imageHeight;
View Full Code Here

        @Override
        public boolean mouseMove(Component component, int x, int y) {
            boolean consumed = super.mouseMove(component, x, y);

            if (Mouse.getCapturer() == component) {
                SplitPane splitPane = (SplitPane)TerraSplitPaneSkin.this.getComponent();
                Orientation orientation = splitPane.getOrientation();

                // Calculate the would-be new split location
                int splitLocation;
                float splitRatio;
                if (orientation == Orientation.HORIZONTAL) {
                    splitLocation = limitSplitLocation(component.getX() + x - dragOffset);
                    splitRatio = (float)splitLocation / splitPane.getWidth();
                } else {
                    splitLocation = limitSplitLocation(component.getY() + y - dragOffset);
                    splitRatio = (float)splitLocation / splitPane.getHeight();
                }

                if (shadow == null) {
                    // Update the split location immediately
                    splitPane.setSplitRatio(splitRatio);
                } else {
                    // Move the shadow to the split location
                    if (orientation == Orientation.HORIZONTAL) {
                        shadow.setLocation(splitLocation, 0);
                    } else {
View Full Code Here

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

            SplitPane splitPane = (SplitPane)TerraSplitPaneSkin.this.getComponent();

            if (button == Mouse.Button.LEFT
                && !splitPane.isLocked()) {
                Orientation orientation = splitPane.getOrientation();

                if (useShadow) {
                    // Add the shadow to the split pane and lay it out
                    shadow = new SplitterShadow();
                    splitPane.add(shadow);

                    if (orientation == Orientation.HORIZONTAL) {
                        shadow.setLocation(component.getX(), 0);
                    } else {
                        shadow.setLocation(0, component.getY());
View Full Code Here

            boolean consumed = super.mouseUp(component, button, x, y);

            if (button == Mouse.Button.LEFT
                && Mouse.getCapturer() == component) {
                if (shadow != null) {
                    SplitPane splitPane = (SplitPane)TerraSplitPaneSkin.this.getComponent();

                    // Update the split location and remove the shadow
                    int splitLocation;
                    float splitRatio;
                    if (splitPane.getOrientation() == Orientation.HORIZONTAL) {
                        splitLocation = shadow.getX();
                        splitRatio = (float)splitLocation / splitPane.getWidth();
                    } else {
                        splitLocation = shadow.getY();
                        splitRatio = (float)splitLocation / splitPane.getHeight();
                    }

                    splitPane.setSplitRatio(splitRatio);

                    splitPane.remove(shadow);
                    shadow = null;
                }

                Mouse.release();
            }
View Full Code Here

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

        SplitPane splitPane = (SplitPane)component;
        splitPane.getSplitPaneListeners().add(this);

        splitPane.add(splitter);
        updateSplitterCursor();
    }
View Full Code Here

TOP

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

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.