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

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

Introduction

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

Prototype

@Override
    public int getOffsetWidth() 

Source Link

Usage

From source file:org.bonitasoft.console.client.view.processes.ProcessMouseHandler.java

License:Open Source License

public void onMouseOver(MouseOverEvent anEvent) {
    // Reposition the popup relative to the button
    Widget source = (Widget) anEvent.getSource();
    int left = source.getAbsoluteLeft() + source.getOffsetWidth() + 1;
    int top = source.getAbsoluteTop();
    myPopup.setPopupPosition(left, top);

    // Show the popup
    myPopup.show();//w w w  .  j  av a2s. c  o m
}

From source file:org.cruxframework.crux.widgets.client.slider.TouchSlider.java

License:Apache License

@Override
public void onTouchMove(TouchMoveEvent event) {
    if (this.isSliding) {
        return;/*  w  w w  .  ja  va2 s .  com*/
    }
    int clientX = event.getTouches().get(0).getClientX();
    int diff = clientX - startTouchPosition;

    boolean hasNextPanel = hasNextWidget();
    boolean hasPreviousPanel = hasPreviousWidget();

    if ((diff < 0 && hasNextPanel) || (diff > 0 && hasPreviousPanel)) {
        currentTouchPosition = clientX;
        Transition.translateX(getCurrentPanel(), diff, null);
        if (hasPreviousPanel) {
            Widget previousPanel = getPreviousPanel();
            Transition.translateX(previousPanel, diff - previousPanel.getOffsetWidth(), null);
        }
        if (hasNextPanel) {
            Widget nextPanel = getNextPanel();
            Transition.translateX(nextPanel, diff + nextPanel.getOffsetWidth(), null);
        }
    }
    if (!didMove && (Math.abs(diff) > TAP_EVENT_THRESHOLD)) {
        didMove = true;
    }
}

From source file:org.cruxframework.crux.widgets.client.slider.TouchSlider.java

License:Apache License

@Override
public void onOrientationChange() {
    if (getWidgetCount() > 0) {
        boolean hasNextPanel = hasNextWidget();
        boolean hasPreviousPanel = hasPreviousWidget();

        if (hasNextPanel || hasPreviousPanel) {
            Transition.translateX(getCurrentPanel(), 0, null);
            if (hasPreviousPanel) {
                Widget previousPanel = getPreviousPanel();
                Transition.translateX(previousPanel, -previousPanel.getOffsetWidth(), null);
            }//from   www  . j av a  2  s  .  c  o m
            if (hasNextPanel) {
                Widget nextPanel = getNextPanel();
                Transition.translateX(nextPanel, nextPanel.getOffsetWidth(), null);
            }
        }
    }
}

From source file:org.cruxframework.crux.widgets.client.slider.TouchSlider.java

License:Apache License

/**
 * //from   w ww .j a v a2s  .  c  o  m
 * @param slideBy
 */
private void slide(final int slideBy, boolean fireSlidingStartEvent) {
    isSliding = true;
    if (fireSlidingStartEvent) {
        SlidingEvent.fire(this, true);
    }
    Transition.translateX(getCurrentPanel(), slideBy, slideTransitionDuration, new Callback() {
        @Override
        public void onTransitionCompleted() {
            int nextIndex = getNextIndexAfterSlide(slideBy);
            isSliding = false;
            setCurrentWidget(nextIndex);
            SlidingEvent.fire(TouchSlider.this, false);
        }
    });
    if (hasPreviousWidget()) {
        Widget previousPanel = getPreviousPanel();
        Transition.translateX(previousPanel, slideBy - previousPanel.getOffsetWidth(), slideTransitionDuration,
                null);
    }
    if (hasNextWidget()) {
        Widget nextPanel = getNextPanel();
        Transition.translateX(nextPanel, slideBy + nextPanel.getOffsetWidth(), slideTransitionDuration, null);
    }
}

From source file:org.cruxframework.crux.widgets.client.slider.TouchSlider.java

License:Apache License

private void configureHiddenPanel(Widget panel, boolean forward) {
    panel.setVisible(false);//from   w w w.ja  v a  2  s .  co m
    int width = panel.getOffsetWidth();
    Transition.translateX(panel, forward ? width : -width, null);
}

From source file:org.cruxframework.crux.widgets.client.slideshow.SlideshowBaseController.java

License:Apache License

/**
 * //from  w ww  . j a  v  a2s  .co m
 * @param referencePanel
 * @param photo
 * @param image
 */
protected void adjustImageSize(final Widget referencePanel, final Photo photo, final Image image) {
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
        @Override
        public boolean execute() {
            //Wait for panel to be at DOM
            if (referencePanel.getOffsetHeight() == 0) {
                return true;
            }

            if (photo.getWidth() == 0 || photo.getWidth() == 0) {
                return false;
            }

            if (SCALE_IMAGES) {
                double scaleWidth = referencePanel.getOffsetWidth() / ((double) photo.getWidth());
                double scaleHeight = referencePanel.getOffsetHeight() / ((double) photo.getHeight());
                double scale = Math.min(scaleWidth, scaleHeight);
                if (scale > 0) {
                    image.setWidth(Math.round(photo.getWidth() * scale) + "px");
                    image.setHeight(Math.round(photo.getHeight() * scale) + "px");
                }
            } else {
                image.setWidth(photo.getWidth() + "px");
                image.setHeight(photo.getHeight() + "px");
            }

            return false;
        }
    }, 100);
}

From source file:org.drools.workbench.screens.scenariosimulation.client.editor.ScenarioSimulationViewImpl.java

License:Apache License

@Override
public void onResize() {
    final Widget parent = getParent();
    if (parent != null) {
        final double w = parent.getOffsetWidth();
        final double h = parent.getOffsetHeight();
        setPixelSize((int) w, (int) h);
    }/*from  w  w w  .ja  v a2s.com*/
    scenarioGridPanel.onResize();
}

From source file:org.eclipse.swt.widgets.Control.java

License:Open Source License

/**
 * Returns a point describing the receiver's size. The x coordinate of the
 * result is the width of the receiver. The y coordinate of the result is
 * the height of the receiver.// w w  w  . ja  va2s . co m
 * 
 * @return the receiver's size
 * 
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been
 *                disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the receiver</li>
 *                </ul>
 */
public Point getSize() {
    com.google.gwt.user.client.ui.Widget gwtWidget = getGwtWidget();
    int offsetWidth = gwtWidget.getOffsetWidth();
    int offsetHeight = gwtWidget.getOffsetHeight();
    return new Point(offsetWidth, offsetHeight);

}

From source file:org.ednovo.gooru.client.mvp.profilepage.ProfilePageView.java

License:Open Source License

public void setMetaDataContainerWidth() {
    int gradeContainerWidth = userGradeList.getOffsetWidth();
    //      int courseContainerWidth = userCourseList.getOffsetWidth();
    //      int metaDataContainerWidth = metaDataContainer.getOffsetWidth();
    boolean isValue = true;
    List<String> moreGradeCourseLbls = new ArrayList<String>();

    int gradeWidth = 0;
    Iterator<Widget> gradeWidgets = userGradeList.iterator();
    while (gradeWidgets.hasNext()) {
        Widget widget = gradeWidgets.next();
        if (widget instanceof Label) {
            if ((gradeContainerWidth - gradeWidth) > widget.getOffsetWidth()) {
                if (isValue) {
                    gradeWidth = gradeWidth + widget.getOffsetWidth() + RENDER_MARGIN_WIDTH;
                } else {
                    isValue = false;/*from  w  ww  . j a v  a 2 s. c  o m*/
                    moreGradeCourseLbls.add(((Label) widget).getText());
                }
            } else {
                isValue = false;
                moreGradeCourseLbls.add(((Label) widget).getText());
            }
        }
    }
    renderExtraGradeCourse(moreGradeCourseLbls);
}

From source file:org.gems.ajax.client.connection.RectilinearConnection.java

License:Open Source License

public void updateDecorations() {
    if (segments_ != null) {
        for (ConnectionDecoration d : getConnectionDecorations()) {
            if (d.getLocation() instanceof BasicConnectionLocation) {
                BasicConnectionLocation bcl = (BasicConnectionLocation) d.getLocation();

                int direction = LEFT;
                Segment s = null;
                Segment s2 = null;

                if (bcl.getLocation() == START) {
                    s = segments_.get(0);
                    s2 = segments_.get(segments_.size() - 1);
                } else if (bcl.getLocation() == END) {
                    s = segments_.get(segments_.size() - 1);
                    s2 = segments_.get(0);
                } else if (bcl.getLocation() == MIDDLE) {
                    s = segments_.get(2);
                    s2 = segments_.get(0);
                }//  ww w  .  ja v  a 2 s  .co m

                if (s.isHorizontal()) {
                    direction = (s.getAbsoluteLeft() - s2.getAbsoluteLeft() < 0) ? LEFT : RIGHT;
                } else {
                    direction = (s.getAbsoluteTop() - s2.getAbsoluteTop() < 0) ? UP : DOWN;
                }

                d.setDirection(direction);

                Widget w = d.getWidget();

                int x = 0;
                int y = 0;
                Point p = Util.getDiagramLocation(s);
                if (direction == UP) {
                    x = Util.half(Util.getOffsetWidth(s)) + p.x - Util.half(w.getOffsetWidth());
                    y = p.y - 3;
                } else if (direction == DOWN) {
                    x = Util.half(Util.getOffsetWidth(s)) + p.x - Util.half(w.getOffsetWidth());
                    y = 3 + p.y + s.getLength() - w.getOffsetHeight();
                } else if (direction == LEFT) {
                    y = Util.half(Util.getOffsetHeight(s)) + p.y - Util.half(w.getOffsetHeight());
                    x = p.x - 3;
                } else if (direction == RIGHT) {
                    y = Util.half(Util.getOffsetHeight(s)) + p.y - Util.half(w.getOffsetHeight());
                    x = 3 + p.x + s.getLength() - w.getOffsetWidth();
                }

                x = adjustXOffset(bcl, s, w, x, direction);
                y = adjustYOffset(bcl, s, w, y, direction);

                AbsolutePanel cp = getConnectionLayer().getConnectionPanel();
                if (w.getParent() != cp) {
                    w.removeFromParent();
                    cp.add(w, x, y);
                } else {
                    cp.setWidgetPosition(w, x, y);
                }

                d.update();
            }
        }
    }
}