当前位置: 首页>>代码示例>>Java>>正文


Java DOM.setStyleAttribute方法代码示例

本文整理汇总了Java中com.google.gwt.user.client.DOM.setStyleAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java DOM.setStyleAttribute方法的具体用法?Java DOM.setStyleAttribute怎么用?Java DOM.setStyleAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.user.client.DOM的用法示例。


在下文中一共展示了DOM.setStyleAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setBackgroundImageProperty

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
/**
 * Sets the canvas's BackgroundImage property to a new value.
 */
private void setBackgroundImageProperty(String text) {
  String url = convertImagePropertyValueToUrl(text);

  // We tell the layout (which is a MockCanvasLayout) that there is (or is not) a background
  // image so it can adjust the "layout width/height". The "layout width/height" is used when the
  // preferred width/height of a MockContainer is requested. See MockContainer.getPreferredWidth
  // and getPreferredHeight, as well as MockLayout.getPreferredWidth and getPreferredHeight.
  if (url == null) {
    // text was not recognized as an asset.
    ((MockCanvasLayout) layout).setBackgroundImageUrl("");
    url = "images/canvas.png";
    // We set the background image of the canvasWidget so it displays the image. We do it inside
    // the if because we need to override the background-size property only for this case
    MockComponentsUtil.setWidgetBackgroundImage(this, canvasWidget, url);
    DOM.setStyleAttribute(canvasWidget.getElement(), "backgroundSize", "");
  } else {
    ((MockCanvasLayout) layout).setBackgroundImageUrl(url);
    // We set the background image of the canvasWidget so it displays the image.
    MockComponentsUtil.setWidgetBackgroundImage(this, canvasWidget, url);
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:25,代码来源:MockCanvas.java

示例2: setWidgetFontTypeface

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
/**
 * Sets the font typeface for the given widget.
 *
 * @param widget  widget to change font typeface for
 * @param typeface  "0" for normal, "1" for sans serif, "2" for serif and
 *                  "3" for monospace
 */
static void setWidgetFontTypeface(Widget widget, String typeface) {
  switch (Integer.parseInt(typeface)) {
    default:
      // This should never happen
      throw new IllegalArgumentException("Typeface:" + typeface);

    case 0:
    case 1:
      typeface = "sans-serif";
      break;

    case 2:
      typeface = "serif";
      break;

    case 3:
      typeface = "monospace";
      break;
  }
  DOM.setStyleAttribute(widget.getElement(), "fontFamily", typeface);
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:29,代码来源:MockComponentsUtil.java

示例3: setWidgetTextAlign

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
/**
 * Sets the text alignment for the given widget.
 *
 * @param widget  widget to change text alignment for
 * @param align  one of "0" for left, "1" for center or "2" for right
 */
static void setWidgetTextAlign(Widget widget, String align) {
  switch (Integer.parseInt(align)) {
    default:
      // This should never happen
      throw new IllegalArgumentException("align:" + align);

    case 0:
      align = "left";
      break;

    case 1:
      align = "center";
      break;

    case 2:
      align = "right";
      break;
  }
  DOM.setStyleAttribute(widget.getElement(), "textAlign", align);
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:27,代码来源:MockComponentsUtil.java

示例4: MiniProgressBar

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
/**
 * Create a progress bar within the given range starting at the specified
 * progress amount.
 *
 * @param minProgress the minimum progress
 * @param maxProgress the maximum progress
 * @param curProgress the current progress
 * @param textFormatter the text formatter
 */
public MiniProgressBar(double minProgress, double maxProgress,
  double curProgress, TextFormatter textFormatter) {
  this.minProgress = minProgress;
  this.maxProgress = maxProgress;
  this.curProgress = curProgress;
  setTextFormatter(textFormatter);

  // Create the outer shell
  setElement(DOM.createDiv());
  DOM.setStyleAttribute(getElement(), "position", "relative");
  setStyleName("gwt-ProgressBar-shell");

  // Create the bar element
  barElement = DOM.createDiv();
  DOM.appendChild(getElement(), barElement);
  DOM.setStyleAttribute(barElement, "height", "100%");
  setBarStyleName("gwt-ProgressBar-bar");

  // Create the text element
  textElement = DOM.createDiv();
  DOM.appendChild(getElement(), textElement);
  DOM.setStyleAttribute(textElement, "position", "absolute");
  DOM.setStyleAttribute(textElement, "top", "0px");

  //Set the current progress
  setProgress(curProgress);
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:37,代码来源:MiniProgressBar.java

示例5: setProgress

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
/**
 * Set the current progress.
 *
 * @param curProgress the current progress
 */
public void setProgress(double curProgress) {
  this.curProgress = Math.max(minProgress, Math.min(maxProgress, curProgress));

  // Calculate percent complete
  int percent = (int) (100 * getPercent());
  DOM.setStyleAttribute(barElement, "width", percent + "%");
  DOM.setElementProperty(textElement, "innerHTML", generateText(curProgress));
  updateTextStyle(percent);

  // Realign the text
  redraw();
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:18,代码来源:MiniProgressBar.java

示例6: onLoad

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
/**
 * This method is called immediately after a widget becomes attached to the
 * browser's document.
 */
@Override
protected void onLoad() {
  // Reset the position attribute of the parent element
  DOM.setStyleAttribute(getElement(), "position", "relative");
  ResizableWidgetCollection.get().add(this);
  redraw();
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:12,代码来源:MiniProgressBar.java

示例7: configureDragWidgetToAppearWithCursorAt

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
/**
 * Configures the specified drag-widget (that will be returned by
 * {@link DragSource#createDragWidget(int, int)}) so that the cursor's hot spot
 * will appear at the point (x,y) in the widget's coordinate system.
 */
public static void configureDragWidgetToAppearWithCursorAt(Widget w, int x, int y) {
  Element e = w.getElement();
  DOM.setStyleAttribute(e, "position", "absolute");
  DOM.setStyleAttribute(e, "left", -x + "px");
  DOM.setStyleAttribute(e, "top", -y + "px");
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:12,代码来源:DragSourceSupport.java

示例8: ensureDropTargetArea

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
private void ensureDropTargetArea() {
  if (dropTargetArea == null) {
    dropTargetArea = DOM.createDiv();
    setDropTargetAreaVisible(false);
    DOM.setStyleAttribute(dropTargetArea, "border", "2px solid " + DROP_TARGET_AREA_COLOR);
    DOM.appendChild(container.getRootPanel().getElement(), dropTargetArea);
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:9,代码来源:MockTableLayout.java

示例9: setDividerBoundsAndShow

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
private void setDividerBoundsAndShow(int x, int y, int width, int height) {
  DOM.setStyleAttribute(dividerElement, "position", "absolute");
  DOM.setStyleAttribute(dividerElement, "left", x + "px");
  DOM.setStyleAttribute(dividerElement, "top", y + "px");
  DOM.setStyleAttribute(dividerElement, "width", width + "px");
  DOM.setStyleAttribute(dividerElement, "height", height + "px");
  setDividerVisible(true);
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:9,代码来源:MockHVLayoutBase.java

示例10: setWidgetBackgroundColor

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
/**
 * Sets the background color for the given widget.
 *
 * @param widget  widget to change background color for
 * @param color  new color (RGB value)
 */
static void setWidgetBackgroundColor(Widget widget, String color) {
  if (isNoneColor(color)) {
    DOM.setStyleAttribute(widget.getElement(), "backgroundColor", "transparent");
  } else {
    DOM.setStyleAttribute(widget.getElement(), "backgroundColor", "#" + getHexString(color, 6));
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:14,代码来源:MockComponentsUtil.java

示例11: setWidgetBackgroundImage

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
/**
 * Sets the background image for the given widget.
 *
 * @param widget  widget to change background image for
 * @param image  URL
 */
static void setWidgetBackgroundImage(Widget widget, String image) {
  DOM.setStyleAttribute(widget.getElement(), "backgroundImage", "url(" + image + ')');
  DOM.setStyleAttribute(widget.getElement(), "backgroundRepeat", "no-repeat");
  DOM.setStyleAttribute(widget.getElement(), "backgroundPosition", "center");
  DOM.setStyleAttribute(widget.getElement(), "backgroundSize", "100% 100%");
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:13,代码来源:MockComponentsUtil.java

示例12: setWidgetTextColor

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
/**
 * Sets the text color for the given widget.
 *
 * @param widget  widget to change text color for
 * @param color  new color (RGB value)
 */
static void setWidgetTextColor(Widget widget, String color) {
  if (isNoneColor(color)) {
    DOM.setStyleAttribute(widget.getElement(), "color", "transparent");
  } else {
    DOM.setStyleAttribute(widget.getElement(), "color", "#" + getHexString(color, 6));
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:14,代码来源:MockComponentsUtil.java

示例13: setShapeProperty

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
private void setShapeProperty(String text) {
  shape = Integer.parseInt(text);
  // Android Buttons with images take the shape of the image and do not
  // use one of the defined Shapes.
  if (hasImage) {
    return;
  }
  switch(shape) {
    case 0:
      // Default Button
      DOM.setStyleAttribute(buttonWidget.getElement(), "borderRadius", "0px");
      break;
    case 1:
      // Rounded Button.
      // The corners of the Button are rounded by 10 px.
      // The value 10 px was chosen strictly for style.
      // 10 px is the same as ROUNDED_CORNERS_RADIUS defined in
      // com.google.appinventor.components.runtime.ButtonBase.
      DOM.setStyleAttribute(buttonWidget.getElement(), "borderRadius", "10px");
      break;
    case 2:
      // Rectangular Button
      DOM.setStyleAttribute(buttonWidget.getElement(), "borderRadius", "0px");
      break;
    case 3:
      // Oval Button
      String height = DOM.getStyleAttribute(buttonWidget.getElement(), "height");
      DOM.setStyleAttribute(buttonWidget.getElement(), "borderRadius", height);
      break;
    default:
      // This should never happen
      throw new IllegalArgumentException("shape:" + shape);
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:35,代码来源:MockButtonBase.java

示例14: clearSizeStyle

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
static String[] clearSizeStyle(Widget w) {
  Element element = w.getElement();
  String widthStyle = DOM.getStyleAttribute(element, "width");
  String heightStyle = DOM.getStyleAttribute(element, "height");
  if (widthStyle != null) {
    DOM.setStyleAttribute(element, "width", null);
  }
  if (heightStyle != null) {
    DOM.setStyleAttribute(element, "height", null);
  }
  return new String[] { widthStyle, heightStyle };
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:13,代码来源:MockComponentsUtil.java

示例15: restoreSizeStyle

import com.google.gwt.user.client.DOM; //导入方法依赖的package包/类
static void restoreSizeStyle(Widget w, String[] style) {
  Element element = w.getElement();
  if (style[0] != null) {
    DOM.setStyleAttribute(element, "width", style[0]);
  }
  if (style[1] != null) {
    DOM.setStyleAttribute(element, "height", style[1]);
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:10,代码来源:MockComponentsUtil.java


注:本文中的com.google.gwt.user.client.DOM.setStyleAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。