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

The following are Jave code examples for showing how to use setHeight() 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: cuba   File: CubaFileDownloaderConnector.java   Source Code and License Vote up 6 votes
public void downloadFileById(String resourceId) {
    final String url = getResourceUrl(resourceId);
    if (url != null && !url.isEmpty()) {
        final IFrameElement iframe = Document.get().createIFrameElement();

        Style style = iframe.getStyle();
        style.setVisibility(Style.Visibility.HIDDEN);
        style.setHeight(0, Style.Unit.PX);
        style.setWidth(0, Style.Unit.PX);

        iframe.setFrameBorder(0);
        iframe.setTabIndex(-1);
        iframe.setSrc(url);
        RootPanel.getBodyElement().appendChild(iframe);

        Timer removeTimer = new Timer() {
            @Override
            public void run() {
                iframe.removeFromParent();
            }
        };
        removeTimer.schedule(60 * 1000);
    }
}
 
Example 3
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 4
Project: blogwt   File: MapHelper.java   Source Code and License Vote up 6 votes
/**
 * @param element
 * @param lines
 * @param params
 */
public static void showMap (Element element, List<String> lines,
		Map<String, String> params) {
	Style s = element.getStyle();

	float width = floatParam(params, "width", 100);
	Unit widthUnits = unitParam(params, "widthUnits", Unit.PCT);
	s.setWidth(width, widthUnits);

	float height = floatParam(params, "height", 200);
	Unit heightUnits = unitParam(params, "heightUnits", Unit.PT);
	s.setHeight(height, heightUnits);

	float lat = floatParam(params, "lat", -34.397f);
	float lng = floatParam(params, "lng", 150.644f);

	int zoom = intParam(params, "zoom", 8);

	String markerName = params.get("markerName");

	showMap(element, lat, lng, zoom, markerName);
}
 
Example 5
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 6
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 7
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 8
Project: cuba   File: CubaFileUploadProgressWindow.java   Source Code and License Vote up 5 votes
private void fixIE8FocusCaptureIssue() {
    Element e = DOM.createInputText();
    Style elemStyle = e.getStyle();
    elemStyle.setPosition(Style.Position.ABSOLUTE);
    elemStyle.setTop(-10, Style.Unit.PX);
    elemStyle.setWidth(0, Style.Unit.PX);
    elemStyle.setHeight(0, Style.Unit.PX);

    contentPanel.getElement().appendChild(e);
    e.focus();
    contentPanel.getElement().removeChild(e);
}
 
Example 9
Project: Wiab.pro   File: ImageThumbnailWidget.java   Source Code and License Vote up 5 votes
private void setImageSize() {
  int width = isFullSize?attachmentWidth:thumbnailWidth;
  int height = isFullSize?attachmentHeight:thumbnailHeight;
  image.setPixelSize(width, height);
  //TODO(user,danilatos): Whinge about how declarative UI doesn't let us avoid this hack:
  Style pstyle = image.getElement().getParentElement().getParentElement().getStyle();
  if (width == 0) {
    image.setWidth("");
    pstyle.clearWidth();
  } else {
    pstyle.setWidth(width, Unit.PX);
  }
  if (height == 0) {
    image.setHeight("");
    pstyle.clearHeight();
  } else {
    pstyle.setHeight(height, Unit.PX);
  }

  String url = isFullSize?attachmentUrl:thumbnailUrl;
  if (url != null) {
    if (doubleBufferLoader == null) {
      doubleBufferLoader = new DoubleBufferImage(spin, errorLabel, image);
    }
    doubleBufferLoader.loadImage(url);
    DOM.setStyleAttribute(image.getElement(), "visibility", "");
  }

  // NOTE(user): IE requires that the imageCaptionContainer element has a width
  //   in order to correctly center the caption.
  if (DO_FRAME_WIDTH_UPDATE) {
    captionPanel.getElement().getStyle().setWidth(width, Unit.PX);
  }
}
 
Example 10
Project: kie-docker-ci   File: NavigationItemViewBuilder.java   Source Code and License Vote up 5 votes
public static NavigationDateItemView buildDateItemView(final DateNavigationItem item, final NavigationItemSelectedEventHandler handler) {
    final NavigationDateItemView navigationItemView = GWT.create(NavigationDateItemView.class);
    navigationItemView.setEmptyText(Constants.INSTANCE.newLiteral(), Constants.INSTANCE.createNewForThisType());
    final Style style = navigationItemView.getElement().getStyle();
    style.setWidth(200, Style.Unit.PX);
    style.setHeight(200, Style.Unit.PX);
    navigationItemView.addNavigationItemSelectedEventHandler(handler);
    navigationItemView.show(item);
    return navigationItemView;
}
 
Example 11
Project: kie-docker-ci   File: NavigationItemViewBuilder.java   Source Code and License Vote up 5 votes
public static NavigationItemView buildDefaultItemView(final DefaultNavigationItem item, final NavigationItemSelectedEventHandler handler) {
    final NavigationItemView navigationItemView = GWT.create(NavigationItemView.class);
    navigationItemView.setEmptyText(Constants.INSTANCE.newLiteral(), Constants.INSTANCE.createNewForThisType());
    final Style style = navigationItemView.getElement().getStyle();
    style.setWidth(200, Style.Unit.PX);
    style.setHeight(200, Style.Unit.PX);
    navigationItemView.setImageSizePx(150);
    navigationItemView.addNavigationItemSelectedEventHandler(handler);
    navigationItemView.show(item);
    return navigationItemView;
}
 
Example 12
Project: forplay   File: HtmlImageLayerDom.java   Source Code and License Vote up 5 votes
private void applySize() {
  Style style = element().getStyle();
  style.setWidth(widthSet ? width : htmlImage.img.getWidth(), Unit.PX);
  style.setHeight(heightSet ? height : htmlImage.img.getHeight(), Unit.PX);
  if (sourceRectSet) {
    applyBackgroundSize();
  }
}
 
Example 13
Project: che   File: EditorMultiPartStackViewImpl.java   Source Code and License Vote up 5 votes
@Override
protected void onAttach() {
  super.onAttach();

  Style style = getElement().getParentElement().getStyle();
  style.setHeight(100, PCT);
  style.setWidth(100, PCT);
}
 
Example 14
Project: che   File: EditorPartStackView.java   Source Code and License Vote up 5 votes
/** {@inheritDoc} */
@Override
protected void onAttach() {
  super.onAttach();

  Style style = getElement().getParentElement().getStyle();
  style.setHeight(100, PCT);
  style.setWidth(100, PCT);
}
 
Example 15
Project: minus   File: LightBox.java   Source Code and License Vote up 5 votes
private void addColumnElem(int i, Element elem, int elemWidth, int elemHeight, int rowspan) {
  ImageSize newSize = fitWidth(elemWidth, elemHeight, 1 + Math.abs(rowspan));
  newSize.height_ -= (columnsHeight_[i] + newSize.height_ + margin_) % DELTA;

  Style elemStyle = elem.getStyle();
  elemStyle.setMarginLeft(
      extraMargin_ + margin_ + (columnsWidth_ + margin_) * (i + (rowspan == -1 ? -1 : 0)),
      Style.Unit.PX);
  elemStyle.setMarginTop(columnsHeight_[i], Style.Unit.PX);
  elemStyle.setWidth(newSize.width_, Style.Unit.PX);
  elemStyle.setHeight(newSize.height_, Style.Unit.PX);

  int nextHeight = columnsHeight_[i] + newSize.height_ + margin_;
  columnsHeight_[i + rowspan] = columnsHeight_[i] = nextHeight;
}
 
Example 16
Project: djvu-html5   File: TextLayer.java   Source Code and License Vote up 5 votes
TextLine(int minY, int maxY, int prevY, TextPage parent, List<Zone> lineTokens) {
	Style style = getElement().getStyle();
	double marginTop = round((prevY - maxY) * 100.0 / parent.width, PCT_ACCURACY);
	if (parent.getWidgetCount() == 0) {
		style.setPaddingTop(marginTop, Unit.PCT);
	} else {
		style.setMarginTop(marginTop, Unit.PCT);
	}
	style.setHeight(round((maxY - minY) * 100.0 / parent.height, PCT_ACCURACY), Unit.PCT);
	
	Token lastToken = null;
	int prevXmax = 0;
	for (Zone zone : lineTokens) {
		Token token = new Token(zone, prevXmax, parent);
		if (token.text.isEmpty()) {
			if (lastToken != null)
				lastToken.setText(lastToken.getText() + token.getText());
			continue;
		}
		add(token);
		lastToken = token;
		if (token.text.length() > 1 || lineTokens.size() == 1) {
			tokens.add(token);
		}
		prevXmax = zone.xmax;
	}

	parent.textLines.add(this);
	parent.add(this);
}
 
Example 17
Project: appformer   File: ResizableMovableHeader.java   Source Code and License Vote up 5 votes
private static void setLine(final Style style,
                            final int width,
                            final int top,
                            final int height,
                            final String color) {
    style.setPosition(Position.ABSOLUTE);
    style.setTop(top,
                 PX);
    style.setHeight(height,
                    PX);
    style.setWidth(width,
                   PX);
    style.setBackgroundColor(color);
    style.setZIndex(Integer.MAX_VALUE);
}
 
Example 18
Project: appformer   File: TextBoxDOMElement.java   Source Code and License Vote up 5 votes
public TextBoxDOMElement(final TextBox widget,
                         final GridLayer gridLayer,
                         final GridWidget gridWidget) {
    super(widget,
          gridLayer,
          gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setWidth(100,
                   Style.Unit.PCT);
    style.setHeight(HEIGHT,
                    Style.Unit.PX);
    style.setPaddingLeft(2,
                         Style.Unit.PX);
    style.setPaddingRight(2,
                          Style.Unit.PX);
    style.setFontSize(10,
                      Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0,
                        Style.Unit.PX);
    style.setPaddingBottom(0,
                           Style.Unit.PX);
    style.setProperty("WebkitBoxSizing",
                      "border-box");
    style.setProperty("MozBoxSizing",
                      "border-box");
    style.setProperty("boxSizing",
                      "border-box");
    style.setProperty("lineHeight",
                      "normal");
    // --- End workaround ---

    getContainer().getElement().getStyle().setPaddingLeft(5,
                                                          Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingRight(5,
                                                           Style.Unit.PX);
    getContainer().setWidget(widget);
}
 
Example 19
Project: appformer   File: CheckBoxDOMElement.java   Source Code and License Vote up 5 votes
public CheckBoxDOMElement(final CheckBox widget,
                          final GridLayer gridLayer,
                          final GridWidget gridWidget) {
    super(widget,
          gridLayer,
          gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setMarginTop(0,
                       Style.Unit.PX);
    style.setMarginLeft(2,
                        Style.Unit.PX);
    style.setWidth(SIZE,
                   Style.Unit.PX);
    style.setHeight(SIZE,
                    Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0,
                        Style.Unit.PX);
    style.setPaddingBottom(0,
                           Style.Unit.PX);
    style.setProperty("WebkitBoxSizing",
                      "border-box");
    style.setProperty("MozBoxSizing",
                      "border-box");
    style.setProperty("boxSizing",
                      "border-box");
    style.setProperty("lineHeight",
                      "normal");
    // --- End workaround ---

    getContainer().setWidget(widget);
}
 
Example 20
Project: appformer   File: ListBoxDOMElement.java   Source Code and License Vote up 5 votes
public ListBoxDOMElement(final ListBox widget,
                         final GridLayer gridLayer,
                         final GridWidget gridWidget) {
    super(widget,
          gridLayer,
          gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setWidth(100,
                   Style.Unit.PCT);
    style.setHeight(HEIGHT,
                    Style.Unit.PX);
    style.setPaddingLeft(2,
                         Style.Unit.PX);
    style.setPaddingRight(2,
                          Style.Unit.PX);
    style.setFontSize(10,
                      Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0,
                        Style.Unit.PX);
    style.setPaddingBottom(0,
                           Style.Unit.PX);
    style.setProperty("WebkitBoxSizing",
                      "border-box");
    style.setProperty("MozBoxSizing",
                      "border-box");
    style.setProperty("boxSizing",
                      "border-box");
    style.setProperty("lineHeight",
                      "normal");
    // --- End workaround ---

    getContainer().getElement().getStyle().setPaddingLeft(5,
                                                          Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingRight(5,
                                                           Style.Unit.PX);
    getContainer().setWidget(widget);
}
 
Example 21
Project: appformer   File: WorkbenchSplitLayoutPanel.java   Source Code and License Vote up 5 votes
@Override
protected void setUpHoverStyle(final Style style,
                               int size) {
    style.setHeight(size,
                    Unit.PX);
    style.setMarginTop(-(size / 2),
                       Unit.PX);
}
 
Example 22
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 23
Project: cuba   File: CubaFieldGroupLayoutComponentSlot.java   Source Code and License Vote up 4 votes
@Override
public void positionVertically(double currentLocation, double allocatedSpace, double marginBottom) {
    if (!isCaptionInline()) {
        super.positionVertically(currentLocation, allocatedSpace, marginBottom);
        return;
    }

    // CAUTION copied from VLayoutSlot.positionVertically(~)
    Style style = wrapper.getStyle();

    double contentHeight = allocatedSpace;

    int captionHeight;
    VCaption caption = getCaption();
    if (caption == null || caption.shouldBePlacedAfterComponent() || isCaptionInline()) {
        style.clearPaddingTop();
        captionHeight = 0;
    } else {
        captionHeight = getCaptionHeight();
        contentHeight -= captionHeight;
        if (contentHeight < 0) {
            contentHeight = 0;
        }
        style.setPaddingTop(captionHeight, Style.Unit.PX);
    }

    if (marginBottom > 0) {
        style.setMarginBottom(marginBottom, Style.Unit.PX);
    } else {
        style.clearMarginBottom();
    }

    if (isRelativeHeight()) {
        style.setHeight(contentHeight, Style.Unit.PX);
    } else {
        style.clearHeight();
    }

    double allocatedContentHeight = 0;
    if (isRelativeHeight()) {
        String height = getWidget().getElement().getStyle().getHeight();
        double percentage = parsePercent(height);
        allocatedContentHeight = contentHeight * (percentage / 100);
        reportActualRelativeHeight(Math
                .round((float) allocatedContentHeight));
    }

    AlignmentInfo alignment = getAlignment();
    if (!alignment.isTop()) {
        double usedHeight;
        if (isRelativeHeight()) {
            if (isCaptionInline()) {
                usedHeight = allocatedContentHeight;
            } else {
                usedHeight = captionHeight + allocatedContentHeight;
            }
        } else {
            usedHeight = getUsedHeight();
        }
        if (alignment.isVerticalCenter()) {
            currentLocation += (allocatedSpace - usedHeight) / 2d;
        } else {
            currentLocation += (allocatedSpace - usedHeight);
        }
    }

    style.setTop(currentLocation, Style.Unit.PX);
}