Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Slider$SliderListenerList


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

        Slider slider = (Slider)component;
        slider.add(thumb);
    }
View Full Code Here


        slider.add(thumb);
    }

    @Override
    public int getPreferredWidth(int height) {
        Slider slider = (Slider)getComponent();

        int preferredWidth;
        if (slider.getOrientation() == Orientation.HORIZONTAL) {
            preferredWidth = DEFAULT_WIDTH;
        } else {
            preferredWidth = thumbHeight;
        }
View Full Code Here

        return preferredWidth;
    }

    @Override
    public int getPreferredHeight(int width) {
        Slider slider = (Slider)getComponent();

        int preferredHeight;
        if (slider.getOrientation() == Orientation.HORIZONTAL) {
            preferredHeight = thumbHeight;
        } else {
            preferredHeight = DEFAULT_WIDTH;
        }
View Full Code Here

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

    @Override
    public void layout() {
        Slider slider = (Slider)getComponent();

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

        int start = slider.getStart();
        int end = slider.getEnd();
        int value = slider.getValue();

        float ratio = (float)(value - start) / (end - start);

        if (slider.getOrientation() == Orientation.HORIZONTAL) {
            thumb.setSize(thumbWidth, thumbHeight);
            thumb.setLocation((int)((width - thumbWidth) * ratio), (height - thumbHeight) / 2);
        } else {
            thumb.setSize(thumbHeight, thumbWidth);
            thumb.setLocation((width - thumbHeight) / 2, (int)(height - ((height - thumbWidth) * ratio) - thumbWidth));
View Full Code Here

    @Override
    public void paint(Graphics2D graphics) {
        super.paint(graphics);

        Slider slider = (Slider)getComponent();

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

        graphics.setColor(trackColor);
        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
        if (slider.getOrientation() == Orientation.HORIZONTAL) {
            graphics.fillRect(0, (height - trackWidth) / 2, width, trackWidth);
        } else {
            graphics.fillRect((width - trackWidth) / 2, 0, trackWidth, height);
        }
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) {
                Slider slider = (Slider)TerraSliderSkin.this.getComponent();
                if (slider.getOrientation() == Orientation.HORIZONTAL) {
                    int sliderWidth = slider.getWidth();
                    int thumbWidth = thumb.getWidth();

                    Point sliderLocation = thumb.mapPointToAncestor(slider, x, y);
                    int sliderX = sliderLocation.x;

                    int minX = dragOffset.x;
                    if (sliderX < minX) {
                        sliderX = minX;
                    }

                    int maxX = (sliderWidth - thumbWidth) + dragOffset.x;
                    if (sliderX > maxX) {
                        sliderX = maxX;
                    }

                    float ratio = (float)(sliderX - dragOffset.x) / (sliderWidth - thumbWidth);

                    int start = slider.getStart();
                    int end = slider.getEnd();

                    int value = (int)(start + (end - start) * ratio);
                    slider.setValue(value);
                } else {
                    int sliderHeight = slider.getHeight();
                    int thumbHeight = thumb.getHeight();

                    Point sliderLocation = thumb.mapPointToAncestor(slider, x, y);
                    int sliderY = sliderLocation.y;

                    int minY = dragOffset.y;
                    if (sliderY < minY) {
                        sliderY = minY;
                    }

                    int maxY = (sliderHeight) + dragOffset.y;
                    if (sliderY > maxY) {
                        sliderY = maxY;
                    }

                    float ratio = (float)(sliderHeight - sliderY + dragOffset.y) / (sliderHeight - thumbHeight);

                    int start = slider.getStart();
                    int end = slider.getEnd();

                    int value = (int)(start + (end - start) * ratio);
                    slider.setValue(value);
                }
            }

            return consumed;
        }
View Full Code Here

        @Override
        public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
            boolean consumed = super.keyPressed(component, keyCode, keyLocation);

            Slider slider = (Slider)TerraSliderSkin.this.getComponent();

            int start = slider.getStart();
            int end = slider.getEnd();
            int length = end - start;

            int value = slider.getValue();
            int increment = length / 10;

            if (keyCode == Keyboard.KeyCode.LEFT
                || keyCode == Keyboard.KeyCode.DOWN) {
                slider.setValue(Math.max(start, value - increment));
                consumed = true;
            } else if (keyCode == Keyboard.KeyCode.RIGHT
                || keyCode == Keyboard.KeyCode.UP) {
                slider.setValue(Math.min(end, value + increment));
                consumed = true;
            }

            return consumed;
        }
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) {
                Slider slider = (Slider)TerraSliderSkin.this.getComponent();
                if (slider.getOrientation() == Orientation.HORIZONTAL) {
                    int sliderWidth = slider.getWidth();
                    int thumbWidthLocal = thumb.getWidth();

                    Point sliderLocation = thumb.mapPointToAncestor(slider, x, y);
                    int sliderX = sliderLocation.x;

                    int minX = dragOffset.x;
                    if (sliderX < minX) {
                        sliderX = minX;
                    }

                    int maxX = (sliderWidth - thumbWidthLocal) + dragOffset.x;
                    if (sliderX > maxX) {
                        sliderX = maxX;
                    }

                    float ratio = (float)(sliderX - dragOffset.x) / (sliderWidth - thumbWidthLocal);

                    int start = slider.getStart();
                    int end = slider.getEnd();

                    int value = (int)(start + (end - start) * ratio);
                    slider.setValue(value);
                } else {
                    int sliderHeight = slider.getHeight();
                    int thumbHeightLocal = thumb.getHeight();

                    Point sliderLocation = thumb.mapPointToAncestor(slider, x, y);
                    int sliderY = sliderLocation.y;

                    int minY = dragOffset.y;
                    if (sliderY < minY) {
                        sliderY = minY;
                    }

                    int maxY = (sliderHeight - thumbHeightLocal) + dragOffset.y;
                    if (sliderY > maxY) {
                        sliderY = maxY;
                    }

                    float ratio = (float)(sliderY - dragOffset.y) / (sliderHeight - thumbHeightLocal);

                    int start = slider.getStart();
                    int end = slider.getEnd();

                    int value = (int)(start + (end - start) * ratio);
                    slider.setValue(value);
                }
            }

            return consumed;
        }
View Full Code Here

         */
        @Override
        public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
            boolean consumed = super.keyPressed(component, keyCode, keyLocation);

            Slider slider = (Slider)TerraSliderSkin.this.getComponent();

            int start = slider.getStart();
            int end = slider.getEnd();
            int length = end - start;

            int value = slider.getValue();
            int increment = length / 10;

            if (keyCode == Keyboard.KeyCode.LEFT
                || keyCode == Keyboard.KeyCode.DOWN) {
                slider.setValue(Math.max(start, value - increment));
                consumed = true;
            } else if (keyCode == Keyboard.KeyCode.RIGHT
                || keyCode == Keyboard.KeyCode.UP) {
                slider.setValue(Math.min(end, value + increment));
                consumed = true;
            }

            return consumed;
        }
View Full Code Here

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

        Slider slider = (Slider)component;
        slider.add(thumb);
    }
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.Slider$SliderListenerList

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.