Java Code Examples for com.google.gwt.dom.client.Style.setLeft()

The following are Jave code examples for showing how to use setLeft() of the com.google.gwt.dom.client.Style class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: wbi   File: MaterialItem.java   Source Code and License Vote up 8 votes
@Override
public void onClick(ClickEvent event) {
    if (animationEnabled) {
        Element inkElement = ink.getElement();

        inkElement.removeClassName(Class.ANIMATE.getName());

        Style style = inkElement.getStyle();
        int size = panel.getOffsetWidth();

        style.setWidth(size, Style.Unit.PX);
        style.setHeight(size, Style.Unit.PX);
        style.setMarginLeft(-size / 2, Style.Unit.PX);
        style.setMarginTop(-size / 2, Style.Unit.PX);

        style.setLeft(event.getX(), Style.Unit.PX);
        style.setTop(event.getY(), Style.Unit.PX);

        inkElement.addClassName(Class.ANIMATE.getName());
    }
}
 
Example 2
Project: empiria.player   File: LabelledImgContent.java   Source Code and License Vote up 6 votes
private void alignWidget(Widget widget, Point anchorPoint, String horizontalAlign, String verticalAlign) {
    Style style = widget.getElement().getStyle();
    double xPos = anchorPoint.getX();
    double yPos = anchorPoint.getY();

    if ("center".equals(horizontalAlign)) {
        xPos -= widget.getOffsetWidth() / 2;
    } else if ("right".equals(horizontalAlign)) {
        xPos -= widget.getOffsetWidth();
    }

    if ("center".equals(verticalAlign)) {
        yPos -= widget.getOffsetHeight() / 2;
    } else if ("bottom".equals(verticalAlign)) {
        yPos -= widget.getOffsetHeight();
    }

    style.setPosition(Position.ABSOLUTE);
    style.setTop(yPos, Unit.PX);
    style.setLeft(xPos, Unit.PX);
}
 
Example 3
Project: empiria.player   File: PanelCache.java   Source Code and License Vote up 6 votes
@Override
protected KeyValue<FlowPanel, FlowPanel> getElement(Integer index) {
    parent = panelFactory.getFlowPanel();
    FlowPanel childPanel = panelFactory.getFlowPanel();

    Style style = parent.getElement().getStyle();
    parent.getElement().setId(styleNames.QP_PAGE() + index.intValue());

    if (swipeType != SwipeType.DISABLED) {
        style.setPosition(Position.ABSOLUTE);
        style.setTop(0, Unit.PX);
        style.setLeft(WIDTH * index, Unit.PCT);
        style.setWidth(WIDTH, Unit.PCT);
    }

    childPanel.setHeight("100%");
    childPanel.setWidth("100%");
    parent.add(childPanel);
    return new KeyValue<FlowPanel, FlowPanel>(parent, childPanel);
}
 
Example 4
Project: empiria.player   File: MultiPageView.java   Source Code and License Vote up 6 votes
public void setSwipeDisabled(boolean swipeDisabled) {
    Style style = controller.getStyle();
    Style elementStyle = getElement().getStyle();

    style.setWidth(controller.getWidth(), Unit.PCT);

    if (swipeDisabled) {
        style.clearPosition();
        style.clearTop();
        style.clearLeft();
        elementStyle.clearPosition();
    } else {
        style.setPosition(Position.ABSOLUTE);
        style.setTop(0, Unit.PX);
        style.setLeft(0, Unit.PX);
        elementStyle.setPosition(Position.RELATIVE);
    }

    setSwipeLength();
}
 
Example 5
Project: empiria.player   File: MultiPageController.java   Source Code and License Vote up 6 votes
@Override
public void move(boolean swipeRight, float length) {
    if (!focusDropped && UserAgentChecker.isStackAndroidBrowser()) {
        dropFocus();
    }
    if (swipeRight) {
        showProgressBarForPage(currentVisiblePage + 1);
    } else {
        showProgressBarForPage(currentVisiblePage - 1);
    }
    Style style = getStyle();
    float position = getPositionLeft();
    if (swipeRight) {
        style.setLeft(position - length, Unit.PCT);
    } else {
        style.setLeft(position + length, Unit.PCT);
    }
}
 
Example 6
Project: djvu-html5   File: Scrollbar.java   Source Code and License Vote up 6 votes
public void setThumb(double center, double width) {
	Style style = getElement().getStyle();
	if (width >= 1) {
		style.setVisibility(Visibility.HIDDEN);
		return;
	} else {
		style.setVisibility(Visibility.VISIBLE);
	}
	if (isHorizontal) {
		style.setLeft(100 * (center - width / 2), Unit.PCT);
		style.setRight(100 * (1 - center - width / 2), Unit.PCT);
	} else {
		style.setTop(100.0 * (center - width / 2), Unit.PCT);
		style.setBottom(100 * (1 - center - width / 2), Unit.PCT);
	}
}
 
Example 7
Project: wbi   File: MaterialButton.java   Source Code and License Vote up 6 votes
@Override
public void onClick(ClickEvent event) {
    if (animationEnabled) {
        ink.removeClassName(Class.ANIMATE.getName());

        Style style = ink.getStyle();
        int size = anchor.getOffsetWidth();

        style.setWidth(size, Style.Unit.PX);
        style.setHeight(size, Style.Unit.PX);
        style.setMarginLeft(-size / 2, Style.Unit.PX);
        style.setMarginTop(-size / 2, Style.Unit.PX);

        style.setLeft(event.getX(), Style.Unit.PX);
        style.setTop(event.getY(), Style.Unit.PX);

        ink.addClassName(Class.ANIMATE.getName());
    }
}
 
Example 8
Project: appformer   File: ResizableMovableHeader.java   Source Code and License Vote up 6 votes
private SpanElement createSpanElement(final Cursor cursor,
                                      final double left,
                                      final double width) {
    final SpanElement span = document.createSpanElement();
    span.setAttribute("title",
                      title);
    final Style style = span.getStyle();
    style.setCursor(cursor);
    style.setPosition(Position.ABSOLUTE);
    style.setBottom(0,
                    PX);
    style.setHeight(source.getOffsetHeight(),
                    PX);
    style.setTop(source.getOffsetTop(),
                 PX);
    style.setWidth(width,
                   PX);
    style.setLeft(left,
                  PX);
    return span;
}
 
Example 9
Project: appformer   File: WorkbenchLayoutImpl.java   Source Code and License Vote up 6 votes
private void updateMaximizedPanelSizes() {
    for (Widget w : maximizedWidgetOriginalStyles.keySet()) {
        Style style = w.getElement().getStyle();
        style.setTop(perspectiveRootContainer.getAbsoluteTop(),
                     Unit.PX);
        style.setLeft(perspectiveRootContainer.getAbsoluteLeft(),
                      Unit.PX);
        style.setWidth(perspectiveRootContainer.getOffsetWidth(),
                       Unit.PX);
        style.setHeight(perspectiveRootContainer.getOffsetHeight(),
                        Unit.PX);

        if (w instanceof RequiresResize) {
            ((RequiresResize) w).onResize();
        }
    }
}
 
Example 10
Project: empiria.player   File: MathModule.java   Source Code and License Vote up 5 votes
private void placeGaps() {
    for (MathGap gap : getMathGaps()) {
        Widget gapContainer = gap.getContainer();
        Style gapStyle = gapContainer.getElement().getStyle();

        gapStyle.setTop(0, Unit.PX);
        gapStyle.setLeft(0, Unit.PX);
        gapStyle.setPosition(Position.ABSOLUTE);
    }
}
 
Example 11
Project: empiria.player   File: MathModule.java   Source Code and License Vote up 5 votes
private void initializePanels() {
    applyIdAndClassToView(mainPanel);

    outerPanel.getElement().getStyle().setOverflow(Overflow.VISIBLE);
    gapsPanel.getElement().getStyle().setOverflow(Overflow.VISIBLE);

    Style mainPanelStyle = mainPanel.getElement().getStyle();
    mainPanelStyle.setPosition(Position.ABSOLUTE);
    mainPanelStyle.setTop(0, Unit.PX);
    mainPanelStyle.setLeft(0, Unit.PX);
}
 
Example 12
Project: empiria.player   File: VideoFullScreenHelper.java   Source Code and License Vote up 5 votes
protected void resizeToFullScreen(Widget widget, Position position) {
    Style style = widget.getElement().getStyle();
    style.setPosition(position);
    style.setTop(0, Unit.PX);
    style.setLeft(0, Unit.PX);
    style.setWidth(100, Unit.PCT);
    style.setHeight(100, Unit.PCT);
}
 
Example 13
Project: Wiab.pro   File: InteractiveSuggestionsManager.java   Source Code and License Vote up 5 votes
@Override
public void setPopupPositionAndMakeVisible(Element reference, final Element popup) {
  Style popupStyle = popup.getStyle();

  // TODO(danilatos): Do something more intelligent than arbitrary constants (which might be
  // susceptible to font size changes, etc)
  popupStyle.setLeft(popupAnchor.getAbsoluteLeft() - popup.getOffsetWidth() + 26, Unit.PX);
  popupStyle.setTop(popupAnchor.getAbsoluteBottom() + 5, Unit.PX);

  popupStyle.setVisibility(Visibility.VISIBLE);
}
 
Example 14
Project: Wiab.pro   File: DomUtil.java   Source Code and License Vote up 5 votes
/**
 * Puts cover element on the covered element.
 * The cover and covered elements have the same position and size.
 * 
 * @param cover the cover element
 * @param covered the covered element
 */
public static void putCover(Element cover, Element covered) {
    Element parent = covered.getParentElement();
    Rect coveredRect = DomUtil.getElementAbsoluteRect(covered);
    Rect parentRect = DomUtil.getElementAbsoluteRect(parent);
    Style coverStyle = cover.getStyle();
    coverStyle.setPosition(Style.Position.ABSOLUTE);      
    coverStyle.setTop(coveredRect.getTop() - parentRect.getTop(), Style.Unit.PX);
    coverStyle.setLeft(coveredRect.getLeft() - parentRect.getLeft(), Style.Unit.PX);
    coverStyle.setRight(parentRect.getRight() - coveredRect.getRight(), Style.Unit.PX);
    coverStyle.setBottom(parentRect.getBottom() - coveredRect.getBottom(), Style.Unit.PX);      
    parent.appendChild(cover);    
}
 
Example 15
Project: che   File: SpeedSearch.java   Source Code and License Vote up 5 votes
private void initSearchPopUp() {
  this.searchPopUp = new SearchPopUp();
  Style style = this.searchPopUp.getElement().getStyle();

  style.setBackgroundColor("grey");
  style.setBorderStyle(Style.BorderStyle.SOLID);
  style.setBorderColor("#dbdbdb");
  style.setBorderWidth(1, Style.Unit.PX);
  style.setPadding(2, Style.Unit.PX);
  style.setPosition(Style.Position.FIXED);
  style.setTop(100, Style.Unit.PX);
  style.setLeft(20, Style.Unit.PX);
}
 
Example 16
Project: gerrit   File: InsertCommentBubble.java   Source Code and License Vote up 5 votes
void position(Rect r) {
  Style s = getElement().getStyle();
  int top = (int) (r.top() - (getOffsetHeight() - 8));
  if (top < 0) {
    s.setTop(-3, Unit.PX);
    s.setLeft(r.right() + 2, Unit.PX);
  } else {
    s.setTop(top, Unit.PX);
    s.setLeft((int) (r.right() - 14), Unit.PX);
  }
}
 
Example 17
Project: appformer   File: CheckBoxDOMElement.java   Source Code and License Vote up 5 votes
@Override
public void initialise(final GridBodyCellRenderContext context) {
    final Style style = widget.getElement().getStyle();
    style.setLeft((context.getCellWidth() - SIZE) / 2,
                  Style.Unit.PX);
    style.setTop((context.getCellHeight() - SIZE) / 2,
                 Style.Unit.PX);
    transform(context);
}
 
Example 18
Project: appformer   File: StencilPaletteBuilder.java   Source Code and License Vote up 5 votes
private void setDragProxyPosition(final LienzoPanel dragProxyParentPanel,
                                  final LienzoPanel dragProxyPanel,
                                  final double proxyWidth,
                                  final double proxyHeight,
                                  final NodeMouseDownEvent event) {
    Style style = dragProxyPanel.getElement().getStyle();
    style.setPosition(Style.Position.ABSOLUTE);
    style.setLeft(dragProxyParentPanel.getAbsoluteLeft() + event.getX() - (proxyWidth / 2),
                  Style.Unit.PX);
    style.setTop(dragProxyParentPanel.getAbsoluteTop() + event.getY() - (proxyHeight / 2),
                 Style.Unit.PX);
    style.setZIndex(ZINDEX);
}
 
Example 19
Project: appformer   File: Layouts.java   Source Code and License Vote up 5 votes
/**
 * Sets the CSS on the given widget so it automatically fills the available space, rather than being sized based on
 * the amount of space required by its contents. This tends to be useful when building a UI that always fills the
 * available space on the screen, as most desktop application windows do.
 * <p>
 * To achieve this, the element is given relative positioning with top and left set to 0px and width and height set
 * to 100%. This makes the widget fill its nearest ancestor which has relative or absolute positioning. This
 * technique is compatible with GWT's LayoutPanel system. Note that, like LayoutPanels, this only works if the host
 * page is in standards mode (has a {@code <!DOCTYPE html>} header).
 * @param w the widget that should always fill its available space, rather than being sized to fit its contents.
 */
public static void setToFillParent(Widget w) {
    Element e = w.getElement();
    Style s = e.getStyle();
    s.setPosition(Position.RELATIVE);
    s.setTop(0.0,
             Unit.PX);
    s.setLeft(0.0,
              Unit.PX);
    s.setWidth(100.0,
               Unit.PCT);
    s.setHeight(100.0,
                Unit.PCT);
}
 
Example 20
Project: empiria.player   File: LabellingChildViewImpl.java   Source Code and License Vote up 4 votes
@Override
public void setPosition(int left, int top) {
    Style style = container.getElement().getStyle();
    style.setLeft(left, Unit.PX);
    style.setTop(top, Unit.PX);
}
 
Example 21
Project: empiria.player   File: StickieView.java   Source Code and License Vote up 4 votes
@Override
public final void setPosition(int left, int top) {
    Style elementStyle = getElement().getStyle();
    elementStyle.setLeft(left, Unit.PX);
    elementStyle.setTop(top, Unit.PX);
}