Example usage for com.google.gwt.user.client.ui Widget getAbsoluteLeft

List of usage examples for com.google.gwt.user.client.ui Widget getAbsoluteLeft

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Widget getAbsoluteLeft.

Prototype

public int getAbsoluteLeft() 

Source Link

Document

Gets the object's absolute left position in pixels, as measured from the browser window's client area.

Usage

From source file:com.mvp4g.example.client.views.desktop.shortcuts.ShortcutsView.java

License:Apache License

@Override
public void showContactPopup(String name, String email, IsWidget widget) {
    ContactPopup popup = new ContactPopup(name, email);
    Widget w = widget.asWidget();
    popup.setPopupPosition(w.getAbsoluteLeft() + 14, w.getAbsoluteTop() + 14);
    popup.show();// w w w. jav  a2 s.co  m
}

From source file:com.objetdirect.tatami.demo.client.GfxDemo.java

License:Open Source License

/**
 * shows a popup to scale a graphical Object
 **///from www .j av  a2 s. co  m
private void showPopupScaler(Widget sender) {
    if (current != null) {
        scaleFactor = 1;
        final PopupPanel popupScaler = new PopupPanel(true);
        popupScaler.addStyleName("GfxDemo-popup");
        final Slider scaler = new Slider(Slider.HORIZONTAL, -10, 10, 1, true);
        scaler.setRuleMarkBottom(6, "3px");
        HorizontalPanel scalePanel = new HorizontalPanel();
        scalePanel.setSpacing(5);

        final Label labelScaler = new Label();
        scalePanel.add(scaler);
        scalePanel.add(labelScaler);

        labelScaler.setText("x" + scaleFactor);

        ChangeListener scaleChange = new ChangeListener() {
            public void onChange(Widget sender) {
                int value = scaler.getValue();
                if (current != null && value != 0) {
                    if (value < 0) {
                        final float minus = (scaler.getMinimum() - value) * (-1);
                        float factor = (minus / (float) scaler.getMaximum()) / scaleFactor;
                        if (current.getGroup() != null) {
                            current.getGroup().scale(factor);
                        } else {
                            current.scale(factor);
                        }
                        scaleFactor = (minus / (float) scaler.getMaximum());

                    } else {
                        float factor = (float) value / scaleFactor;
                        if (current.getGroup() != null) {
                            current.getGroup().scale(factor);
                        } else {
                            current.scale(factor);
                        }
                        scaleFactor = (float) value;
                    }

                }
                labelScaler.setText("x" + scaleFactor);
            }
        };
        scaler.addChangeListener(scaleChange);
        popupScaler.add(scalePanel);
        popupScaler.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop());
        popupScaler.show();
    }
}

From source file:com.objetdirect.tatami.demo.client.GfxDemo.java

License:Open Source License

/**
 * Show a popup with a <code>Slider</code> to
 * perform some rotation of the current <code>GraphicObject</code>
 *
 *///  ww  w  .  j av  a2 s  .c o m
private void showPopupRotate(Widget sender) {
    if (current != null) {
        rotateDegree = 0;
        final PopupPanel popupRotate = new PopupPanel(true);
        popupRotate.addStyleName("GfxDemo-popup");
        final Slider rotate = new Slider(Slider.HORIZONTAL, 0, 360, 0, true);
        HorizontalPanel rotatePanel = new HorizontalPanel();
        rotatePanel.setSpacing(5);

        final Label label = new Label();
        rotatePanel.add(rotate);
        rotatePanel.add(label);
        label.setText("" + rotateDegree);
        ChangeListener rotateChange = new ChangeListener() {
            public void onChange(Widget sender) {
                int value = rotate.getValue();
                if (current != null && value != 0) {
                    int degree = value - rotateDegree;

                    if (current.getGroup() != null) {
                        current.getGroup().rotate(degree);
                    } else {
                        current.rotate(degree);
                    }

                    rotateDegree = value;
                }
                label.setText(rotateDegree + "");

            }
        };
        rotate.addChangeListener(rotateChange);
        popupRotate.add(rotatePanel);
        popupRotate.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop());
        popupRotate.show();
    }
}

From source file:com.objetdirect.tatami.demo.client.GfxDemo.java

License:Open Source License

/**
 * Shows a popup to select a color for the background or the stroke.
 * The popup contains a TabPanel with 3 tab, a <code>ColorChooser</code>,
 *  a <code>Slider</code> to change the opacity of the <code>Color</code>,
 *  some <code>Pattern</code> to apply
 *//*from   www  . j a  va  2  s  . c  om*/
private void showPopupColor(Widget sender) {

    final PopupPanel popupColor = new PopupPanel(true);
    popupColor.addStyleName("GfxDemo-popupColor");
    TabPanel tabPanel = new TabPanel();
    FlowPanel colPanel = new FlowPanel();

    final CheckBox checkFill = new CheckBox("Background");
    checkFill.setChecked(true);
    colPanel.add(checkFill);

    final ColorChooser colorChooser = new ColorChooser();

    colPanel.add(colorChooser);

    tabPanel.add(colPanel, new Label("Color"));

    ChangeListener colorChange = new ChangeListener() {
        public void onChange(Widget sender) {
            String color = colorChooser.getColor();
            Color colorSelected = Color.getColor(color);
            if (checkFill.isChecked()) {
                currentFillColor = colorSelected;
                DOM.setStyleAttribute(fill.getElement(), "backgroundColor", color);
                //currentFillColor.setAlpha(opacity.getValue());
                if (current != null) {
                    current.setFillColor(currentFillColor);
                }
            } else {
                currentStrokeColor = colorSelected;
                lastStrokeColor = currentStrokeColor;
                DOM.setStyleAttribute(fill.getElement(), "borderColor", color);
                if (current != null) {

                    current.setStroke(currentStrokeColor, 1);
                }
            }
        }
    };
    colorChooser.addChangeListener(colorChange);

    FlowPanel patternContainer = new FlowPanel();

    patternContainer.add(createImagePattern("gfx/none.gif"));
    patternContainer.add(createImagePattern("littleNero.png"));
    patternContainer.add(createImagePattern("littleTrajan.png"));
    patternContainer.add(createImagePattern("cubic.jpg"));
    patternContainer.add(createImagePattern("logo_ft.gif"));
    patternContainer.add(createImagePattern("od-logo.jpg"));
    tabPanel.add(patternContainer, new Label("Pattern"));
    tabPanel.add(this.opacity, new Label("Opacity"));

    tabPanel.selectTab(0);
    popupColor.add(tabPanel);
    popupColor.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop());
    popupColor.show();
}

From source file:com.openkm.extension.frontend.client.widget.dropbox.Status.java

License:Open Source License

/**
 * Refreshing the panel//  www .j a  v  a  2s.com
 */
public void refresh() {
    if (flag_exporting || flag_importing || flag_search || flag_getChildren) {
        Widget widgetBaseToCenter = Main.get().mainPanel;
        if (flag_getChildren && widget != null) {
            widgetBaseToCenter = widget;
        }

        int left = widgetBaseToCenter.getAbsoluteLeft() + (widgetBaseToCenter.getOffsetWidth() - 200) / 2;
        int top = widgetBaseToCenter.getAbsoluteTop() + (widgetBaseToCenter.getOffsetHeight() - 40) / 2;

        if (left > 0 && top > 0) {
            setPopupPosition(left, top);
            super.show();
        }
    } else {
        super.hide();
    }
}

From source file:com.ponysdk.ui.terminal.ui.PTWidget.java

License:Apache License

protected void triggerOnClick(final PTInstruction addHandler, final Widget widget, final int domHandlerType,
        final UIService uiService, final ClickEvent event) {
    final PTInstruction eventInstruction = buildEventInstruction(addHandler, domHandlerType);
    eventInstruction.put(PROPERTY.CLIENT_X, event.getClientX());
    eventInstruction.put(PROPERTY.CLIENT_Y, event.getClientY());
    eventInstruction.put(PROPERTY.SOURCE_ABSOLUTE_LEFT, widget.getAbsoluteLeft());
    eventInstruction.put(PROPERTY.SOURCE_ABSOLUTE_TOP, widget.getAbsoluteTop());
    eventInstruction.put(PROPERTY.SOURCE_OFFSET_HEIGHT, widget.getOffsetHeight());
    eventInstruction.put(PROPERTY.SOURCE_OFFSET_WIDTH, widget.getOffsetWidth());
    uiService.triggerEvent(eventInstruction);
}

From source file:com.preferanser.client.geom.Point.java

License:Open Source License

public static Point FromWidgetLeftTop(Widget widget) {
    return new Point(widget.getAbsoluteLeft(), widget.getAbsoluteTop());
}

From source file:com.preferanser.client.geom.Point.java

License:Open Source License

public static Point FromWidgetRightBottom(Widget widget) {
    return new Point(widget.getAbsoluteLeft() + widget.getOffsetWidth(),
            widget.getAbsoluteTop() + widget.getOffsetHeight());
}

From source file:com.seanchenxi.gwt.serenity.client.widget.PopupLabelBox.java

License:Apache License

public void showRelativeTo(Widget w) {
    show();/*w w  w.  j a v  a  2  s  .co  m*/
    int top = w.getAbsoluteTop() - 20;
    int left = w.getAbsoluteLeft() + w.getOffsetWidth();
    setPopupPosition(left, top);
}

From source file:com.threerings.gwt.ui.fx.MoveAnimation.java

License:Open Source License

protected MoveAnimation(Widget target) {
    _fromLeft = _toLeft = target.getAbsoluteLeft();
    _fromTop = _toTop = target.getAbsoluteTop();
}