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

The following are Jave code examples for showing how to use setWidth() 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.
+ Save this method
Example 1
Project: wbi   File: MaterialItem.java   View Source Code 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: PanelCache.java   View Source Code 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 3
Project: empiria.player   File: MultiPageView.java   View Source Code 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 4
Project: cuba   File: CubaFileDownloaderConnector.java   View Source Code 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 5
Project: wbi   File: MaterialButton.java   View Source Code 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 6
Project: blogwt   File: MapHelper.java   View Source Code 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 7
Project: appformer   File: ResizableMovableHeader.java   View Source Code 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 8
Project: appformer   File: WorkbenchLayoutImpl.java   View Source Code 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 9
Project: Mindustry   File: HtmlLauncher.java   View Source Code Vote up 5 votes
@Override
   public PreloaderCallback getPreloaderCallback () {
	final Panel preloaderPanel = new VerticalPanel();
	preloaderPanel.setStyleName("gdx-preloader");
	final Image logo = new Image(GWT.getModuleBaseURL() + "logo.png");
	logo.setStyleName("logo");		
	preloaderPanel.add(logo);
	final Panel meterPanel = new SimplePanel();
	meterPanel.setStyleName("gdx-meter");
	meterPanel.addStyleName("red");
	final InlineHTML meter = new InlineHTML();
	final Style meterStyle = meter.getElement().getStyle();
	meterStyle.setWidth(0, Unit.PCT);
	meterPanel.add(meter);
	preloaderPanel.add(meterPanel);
	getRootPanel().add(preloaderPanel);
	return new PreloaderCallback() {

		@Override
		public void error (String file) {
			System.out.println("error: " + file);
		}
		
		@Override
		public void update (PreloaderState state) {
			meterStyle.setWidth(100f * state.getProgress(), Unit.PCT);
		}			
		
	};
}
 
Example 10
Project: empiria.player   File: VideoFullScreenHelper.java   View Source Code 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 11
Project: empiria.player   File: MediaProgressBarImpl.java   View Source Code Vote up 5 votes
private void setAfterButtonPositionAndStyle(final int leftOffsetForProgressButton) {
    Style afterButtonStyle = afterButton.getElement().getStyle();

    double percentWidth = positionCalculator.getPercentWidth(leftOffsetForProgressButton);
    afterButtonStyle.setWidth(100 - percentWidth, Unit.PCT);

    afterButtonStyle.setProperty(positionCalculator.getPositionPropertyForAfterProgressElement(), "0px");
}
 
Example 12
Project: empiria.player   File: MediaProgressBarImpl.java   View Source Code Vote up 5 votes
private void setBeforeButtonPositionAndStyle(final int leftOffsetForProgressButton) {
    Style beforeButtonStyle = beforeButton.getElement().getStyle();

    double percentWidth = positionCalculator.getPercentWidth(leftOffsetForProgressButton);
    beforeButtonStyle.setWidth(percentWidth, Unit.PCT);

    beforeButtonStyle.setProperty(positionCalculator.getPositionPropertyForBeforeProgressElement(), "0px");
}
 
Example 13
Project: odb-artax   File: HtmlLauncher.java   View Source Code Vote up 5 votes
@Override
public Preloader.PreloaderCallback getPreloaderCallback() {
    final VerticalPanel preloaderPanel = new VerticalPanel();
    preloaderPanel.setStyleName("gdx-preloader");
    preloaderPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    final Image logo = new Image(GWT.getModuleBaseURL() + "logo.gif");
    logo.setStyleName("logo");
    preloaderPanel.add(logo);
    final Panel meterPanel = new SimplePanel();
    meterPanel.setStyleName("gdx-meter");
    meterPanel.addStyleName("red");
    final InlineHTML meter = new InlineHTML();
    final Style meterStyle = meter.getElement().getStyle();
    meterStyle.setWidth(0, Style.Unit.PCT);
    meterPanel.add(meter);
    preloaderPanel.add(meterPanel);
    getRootPanel().add(preloaderPanel);
    return new Preloader.PreloaderCallback() {
        @Override
        public void error(String file) {
            System.out.println("error: " + file);
        }

        @Override
        public void update(Preloader.PreloaderState state) {
            meterStyle.setWidth(100f * state.getProgress(), Style.Unit.PCT);
        }

    };
}
 
Example 14
Project: odb-little-fortune-planet   File: HtmlLauncher.java   View Source Code Vote up 5 votes
@Override
public Preloader.PreloaderCallback getPreloaderCallback() {
    final VerticalPanel preloaderPanel = new VerticalPanel();
    preloaderPanel.setStyleName("gdx-preloader");
    preloaderPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    final Image logo = new Image(GWT.getModuleBaseURL() + "logo.gif");
    logo.setStyleName("logo");
    preloaderPanel.add(logo);
    final Panel meterPanel = new SimplePanel();
    meterPanel.setStyleName("gdx-meter");
    meterPanel.addStyleName("red");
    final InlineHTML meter = new InlineHTML();
    final Style meterStyle = meter.getElement().getStyle();
    meterStyle.setWidth(0, Style.Unit.PCT);
    meterPanel.add(meter);
    preloaderPanel.add(meterPanel);
    getRootPanel().add(preloaderPanel);
    return new Preloader.PreloaderCallback() {
        @Override
        public void error(String file) {
            System.out.println("error: " + file);
        }

        @Override
        public void update(Preloader.PreloaderState state) {
            meterStyle.setWidth(100f * state.getProgress(), Style.Unit.PCT);
        }

    };
}
 
Example 15
Project: cuba   File: CubaFileUploadProgressWindow.java   View Source Code 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 16
Project: Wiab.pro   File: ImageThumbnailWidget.java   View Source Code 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 17
Project: kie-docker-ci   File: NavigationItemViewBuilder.java   View Source Code 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 18
Project: kie-docker-ci   File: NavigationItemViewBuilder.java   View Source Code 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 19
Project: forplay   File: HtmlImageLayerDom.java   View Source Code 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 20
Project: che   File: EditorMultiPartStackViewImpl.java   View Source Code Vote up 5 votes
@Override
protected void onAttach() {
  super.onAttach();

  Style style = getElement().getParentElement().getStyle();
  style.setHeight(100, PCT);
  style.setWidth(100, PCT);
}
 
Example 21
Project: che   File: EditorPartStackView.java   View Source Code 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 22
Project: minus   File: LightBox.java   View Source Code 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 23
Project: appformer   File: ResizableMovableHeader.java   View Source Code 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 24
Project: appformer   File: TextBoxDOMElement.java   View Source Code 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 25
Project: appformer   File: CheckBoxDOMElement.java   View Source Code 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 26
Project: appformer   File: ListBoxDOMElement.java   View Source Code 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 27
Project: appformer   File: WorkbenchSplitLayoutPanel.java   View Source Code Vote up 5 votes
@Override
protected void setUpHoverStyle(final Style style,
                               int size) {
    style.setWidth(size,
                   Unit.PX);
    style.setMarginLeft(-(size / 2),
                        Unit.PX);
}
 
Example 28
Project: appformer   File: Layouts.java   View Source Code 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);
}