Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Point


    public int getY() {
        return y;
    }

    public Point getLocation() {
        return new Point(x, y);
    }
View Full Code Here


        }
    }

    private static Component addPointControl(final Dictionary<String, Object> dictionary,
        final String key, Form.Section section) {
        Point point = (Point)dictionary.get(key);

        BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
        section.add(boxPane);
        Form.setLabel(boxPane, key);

        FlowPane flowPane = new FlowPane();
        flowPane.getStyles().put("alignToBaseline", true);
        flowPane.getStyles().put("horizontalSpacing", 5);
        boxPane.add(flowPane);

        TextInput textInput = new TextInput();
        textInput.setTextSize(3);
        textInput.setMaximumLength(4);
        textInput.setValidator(new IntValidator());
        textInput.setText(String.valueOf(point.x));
        flowPane.add(textInput);

        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
            @Override
            public void focusedChanged(Component component, Component obverseComponent) {
                if (!component.isFocused()) {
                    TextInput textInput = (TextInput)component;
                    Point point = (Point)dictionary.get(key);

                    try {
                        int x = Integer.parseInt(textInput.getText());
                        dictionary.put(key, new Point(x, point.y));
                    } catch (Exception exception) {
                        displayErrorMessage(exception, component.getWindow());
                        textInput.setText(String.valueOf(point.x));
                    }
                }
            }
        });

        Label label = new Label("x");
        label.getStyles().put("font", "{italic:true}");
        flowPane.add(label);

        flowPane = new FlowPane();
        flowPane.getStyles().put("alignToBaseline", true);
        flowPane.getStyles().put("horizontalSpacing", 5);
        boxPane.add(flowPane);

        textInput = new TextInput();
        textInput.setTextSize(3);
        textInput.setMaximumLength(4);
        textInput.setValidator(new IntValidator());
        textInput.setText(String.valueOf(point.y));
        flowPane.add(textInput);

        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
            @Override
            public void focusedChanged(Component component, Component obverseComponent) {
                if (!component.isFocused()) {
                    TextInput textInput = (TextInput)component;
                    Point point = (Point)dictionary.get(key);

                    try {
                        int y = Integer.parseInt(textInput.getText());
                        dictionary.put(key, new Point(point.x, y));
                    } catch (Exception exception) {
                        displayErrorMessage(exception, component.getWindow());
                        textInput.setText(String.valueOf(point.y));
                    }
                }
View Full Code Here

    private void updatePointControl(Dictionary<String, Object> dictionary, String key) {
        BoxPane boxPane = (BoxPane)controls.get(key);

        if (boxPane != null) {
            Point point = (Point)dictionary.get(key);

            TextInput xTextInput = (TextInput)((FlowPane)boxPane.get(0)).get(0);
            TextInput yTextInput = (TextInput)((FlowPane)boxPane.get(1)).get(0);

            xTextInput.setText(String.valueOf(point.x));
View Full Code Here

        File file = null;

        FileBrowser fileBrowser = (FileBrowser)getComponent();
        Component component = fileBrowser.getDescendantAt(x, y);
        if (component == fileTableView) {
            Point location = fileTableView.mapPointFromAncestor(fileBrowser, x, y);

            int index = fileTableView.getRowAt(location.y);
            if (index != -1) {
                file = (File)fileTableView.getTableData().get(index);
            }
View Full Code Here

            // Draw the left and top borders
            switch (tabOrientation) {
                case HORIZONTAL: {
                    graphics.draw(new Line2D.Double(left, top, left, bottom));

                    Point selectedTabButtonLocation = activeTabButton.mapPointToAncestor(tabPane, 0, 0);
                    graphics.draw(new Line2D.Double(left, top, selectedTabButtonLocation.x + 0.5, top));
                    graphics.draw(new Line2D.Double(selectedTabButtonLocation.x + activeTabButton.getWidth() - 0.5,
                        top, right, top));

                    break;
                }

                case VERTICAL: {
                    graphics.draw(new Line2D.Double(left, top, right, top));

                    Point selectedTabButtonLocation = activeTabButton.mapPointToAncestor(tabPane, 0, 0);
                    graphics.draw(new Line2D.Double(left, top, left, selectedTabButtonLocation.y + 0.5));
                    graphics.draw(new Line2D.Double(left, selectedTabButtonLocation.y + activeTabButton.getHeight() - 0.5,
                        left, bottom));

                    break;
View Full Code Here

                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;
View Full Code Here

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

            component.requestFocus();

            if (button == Mouse.Button.LEFT) {
                dragOffset = new Point(x, y);
                Mouse.capture(component);
                repaintComponent();

                consumed = true;
            }
View Full Code Here

        if (Mouse.getCapturer() == component) {
            Frame frame = (Frame)getComponent();
            Display display = frame.getDisplay();

            Point location = frame.mapPointToAncestor(display, x, y);

            // Pretend that the mouse can't move off screen (off the display)
            location = new Point(Math.min(Math.max(location.x, 0), display.getWidth() - 1),
                Math.min(Math.max(location.y, 0), display.getHeight() - 1));

            if (dragOffset != null) {
                // Move the frame
                frame.setLocation(location.x - dragOffset.x, location.y - dragOffset.y);
View Full Code Here

        if (button == Mouse.Button.LEFT
            && !maximized) {
            Bounds titleBarBounds = titleBarTablePane.getBounds();

            if (titleBarBounds.contains(x, y)) {
                dragOffset = new Point(x, y);
                Mouse.capture(component);
            } else {
                Bounds resizeHandleBounds = resizeHandle.getBounds();

                if (resizable && resizeHandleBounds.contains(x, y)) {
                    resizeOffset = new Point(getWidth() - x, getHeight() - y);
                    Mouse.capture(component);
                }
            }
        }
View Full Code Here

            && !menuPopup.isOpen()) {
            // Size and position the popup
            Display display = menuItem.getDisplay();
            Dimensions displaySize = display.getSize();

            Point location = menuItem.mapPointToAncestor(display, getWidth(), 0);
            menuPopup.setLocation(location.x, location.y);

            int width = getWidth();

            // If the popup extends over the right edge of the display,
View Full Code Here

TOP

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

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.