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

The following examples show how to use com.google.gwt.dom.client.Style#setProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeywordsWidget.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Draws a tag cloud
 */
private void drawTagCloud(Collection<String> keywords) {
	// Deletes all tag clouds keys
	keywordsCloud.clear();
	keywordsCloud.setMinFrequency(Main.get().mainPanel.dashboard.keyMapDashboard.getTotalMinFrequency());
	keywordsCloud.setMaxFrequency(Main.get().mainPanel.dashboard.keyMapDashboard.getTotalMaxFrequency());

	for (Iterator<String> it = keywords.iterator(); it.hasNext(); ) {
		String keyword = it.next();
		HTML tagKey = new HTML(keyword);
		tagKey.setStyleName("okm-cloudTags");
		Style linkStyle = tagKey.getElement().getStyle();
		int fontSize = keywordsCloud.getLabelSize(Main.get().mainPanel.dashboard.keyMapDashboard.getKeywordRate(keyword));
		linkStyle.setProperty("fontSize", fontSize + "pt");
		linkStyle.setProperty("color", keywordsCloud.getColor(fontSize));
		if (fontSize > 0) {
			linkStyle.setProperty("top", (keywordsCloud.getMaxFontSize() - fontSize) / 2 + "px");
		}
		keywordsCloud.add(tagKey);
	}
}
 
Example 2
Source File: WidgetUtil.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Draws a tag cloud
 */
public static void drawTagCloud(final TagCloud keywordsCloud, Collection<String> keywords) {
	// Deletes all tag clouds keys
	keywordsCloud.clear();
	keywordsCloud.setMinFrequency(Main.get().mainPanel.dashboard.keyMapDashboard.getTotalMinFrequency());
	keywordsCloud.setMaxFrequency(Main.get().mainPanel.dashboard.keyMapDashboard.getTotalMaxFrequency());

	for (Iterator<String> it = keywords.iterator(); it.hasNext(); ) {
		String keyword = it.next();
		HTML tagKey = new HTML(keyword);
		tagKey.setStyleName("okm-cloudTags");
		Style linkStyle = tagKey.getElement().getStyle();
		int fontSize = keywordsCloud.getLabelSize(Main.get().mainPanel.dashboard.keyMapDashboard.getKeywordRate(keyword));
		linkStyle.setProperty("fontSize", fontSize + "pt");
		linkStyle.setProperty("color", keywordsCloud.getColor(fontSize));
		if (fontSize > 0) {
			linkStyle.setProperty("top", (keywordsCloud.getMaxFontSize() - fontSize) / 2 + "px");
		}
		keywordsCloud.add(tagKey);
	}
}
 
Example 3
Source File: BaseCellMapper.java    From jetpad-projectional-open-source with Apache License 2.0 6 votes vote down vote up
private void applyBackground(String color, String underline) {
  Style style = getTarget().getStyle();
  if (color == null) {
    if (underline == null) {
      style.clearProperty(BACKGROUND);
    } else {
      style.setProperty(BACKGROUND, underline + UNDERLINE_SUFFIX);
    }
  } else {
    if (underline == null) {
      style.setProperty(BACKGROUND, color);
    } else {
      style.setProperty(BACKGROUND, underline + UNDERLINE_SUFFIX + " " + color);
    }
  }
}
 
Example 4
Source File: MockForm.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
private static int getVerticalScrollbarWidth() {
  // We only calculate the vertical scroll bar width once, then we store it in the static field
  // verticalScrollbarWidth. If the field is non-zero, we don't need to calculate it again.
  if (verticalScrollbarWidth == 0) {
    // The following code will calculate (on the fly) the width of a vertical scroll bar.
    // We'll create two divs, one inside the other and add the outer div to the document body,
    // but off-screen where the user won't see it.
    // We'll measure the width of the inner div twice: (first) when the outer div's vertical
    // scrollbar is hidden and (second) when the outer div's vertical scrollbar is visible.
    // The width of inner div will be smaller when outer div's vertical scrollbar is visible.
    // By subtracting the two measurements, we can calculate the width of the vertical scrollbar.

    // I used code from the following websites as reference material:
    // http://jdsharp.us/jQuery/minute/calculate-scrollbar-width.php
    // http://www.fleegix.org/articles/2006-05-30-getting-the-scrollbar-width-in-pixels

    Document document = Document.get();

    // Create an outer div.
    DivElement outerDiv = document.createDivElement();
    Style outerDivStyle = outerDiv.getStyle();
    // Use absolute positioning and set the top/left so that it is off-screen.
    // We don't want the user to see anything while we do this calculation.
    outerDivStyle.setProperty("position", "absolute");
    outerDivStyle.setProperty("top", "-1000px");
    outerDivStyle.setProperty("left", "-1000px");
    // Set the width and height of the outer div to a fixed size in pixels.
    outerDivStyle.setProperty("width", "100px");
    outerDivStyle.setProperty("height", "50px");
    // Hide the outer div's scrollbar by setting the "overflow" property to "hidden".
    outerDivStyle.setProperty("overflow", "hidden");

    // Create an inner div and put it inside the outer div.
    DivElement innerDiv = document.createDivElement();
    Style innerDivStyle = innerDiv.getStyle();
    // Set the height of the inner div to be 4 times the height of the outer div so that a
    // vertical scrollbar will be necessary (but hidden for now) on the outer div.
    innerDivStyle.setProperty("height", "200px");
    outerDiv.appendChild(innerDiv);

    // Temporarily add the outer div to the document body. It's off-screen so the user won't
    // actually see anything.
    Element bodyElement = document.getElementsByTagName("body").getItem(0);
    bodyElement.appendChild(outerDiv);

    // Get the width of the inner div while the outer div's vertical scrollbar is hidden.
    int widthWithoutScrollbar = innerDiv.getOffsetWidth();
    // Show the outer div's vertical scrollbar by setting the "overflow" property to "auto".
    outerDivStyle.setProperty("overflow", "auto");
    // Now, get the width of the inner div while the vertical scrollbar is visible.
    int widthWithScrollbar = innerDiv.getOffsetWidth();

    // Remove the outer div from the document body.
    bodyElement.removeChild(outerDiv);

    // Calculate the width of the vertical scrollbar by subtracting the two widths.
    verticalScrollbarWidth = widthWithoutScrollbar - widthWithScrollbar;
  }

  return verticalScrollbarWidth;
}
 
Example 5
Source File: TableWidgetDelegate.java    From cuba with Apache License 2.0 5 votes vote down vote up
public void updateHeaderCellWidth(VScrollTable.HeaderCell hCell, int minWidth, double realColWidth) {
    if (realColWidth > minWidth) {
        Style hStyle = hCell.getElement().getStyle();
        hStyle.setProperty("width", realColWidth + "px");
        hStyle.setProperty("minWidth", realColWidth + "px");
        hStyle.setProperty("maxWidth", realColWidth + "px");
    }
}
 
Example 6
Source File: MaterialCutOut.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
protected void setCutOutStyle() {
    Style style = getElement().getStyle();
    style.setWidth(100, Unit.PCT);
    style.setHeight(100, Unit.PCT);
    style.setPosition(Position.FIXED);
    style.setTop(0, Unit.PX);
    style.setLeft(0, Unit.PX);
    style.setZIndex(10000);

    focusElement.setClassName(AddinsCssName.MATERIAL_CUTOUT_FOCUS);
    style = focusElement.getStyle();
    style.setProperty("content", "\'\'");
    style.setPosition(Position.ABSOLUTE);
    style.setZIndex(-1);
}
 
Example 7
Source File: GwtEditorSegmentBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void add(String key, String value, String tooltip, int severity, int flag) {
  highlightFlags = BitUtil.set(highlightFlags, flag, true);

  Integer oldSeverity = mySeverityMap == null ? null : mySeverityMap.get(key);
  if (oldSeverity != null && severity <= oldSeverity) {
    return;
  }

  if (severity != 0) {
    if (mySeverityMap == null) {
      mySeverityMap = new HashMap<String, Integer>();
    }

    mySeverityMap.put(key, severity);
  }

  if (myStyles == null) {
    myStyles = new ArrayList<StyleInfo>();
  }
  myStyles.add(new StyleInfo(key, value, tooltip, flag));

  Style style = getElement().getStyle();
  if (key.equals("textDecoration")) {
    String oldValue = style.getProperty(key);
    if (oldValue != null) {
      style.setProperty(key, oldValue + " " + value);
      return;
    }
  }

  style.setProperty(key, value);
}
 
Example 8
Source File: GwtEditorSegmentBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void removeByFlag(int flag) {
  if (BitUtil.isSet(highlightFlags, flag)) {
    highlightFlags = BitUtil.set(highlightFlags, flag, false);

    if (myStyles == null) {
      return;
    }

    StyleInfo[] styleInfos = myStyles.toArray(new StyleInfo[myStyles.size()]);
    for (StyleInfo styleInfo : styleInfos) {
      if (mySeverityMap != null) {
        mySeverityMap.remove(styleInfo.key);
      }

      if (styleInfo.flag == flag) {
        myStyles.remove(styleInfo);

        Style style = getElement().getStyle();
        if (styleInfo.key.equals("textDecoration")) {
          String oldValue = style.getProperty(styleInfo.key);
          if (oldValue == null) {
            continue;
          }

          // it mixin - need removed only our value
          if (oldValue.contains(" ")) {
            oldValue = oldValue.replace(" " + styleInfo.value, "");
            style.setProperty(styleInfo.key, oldValue);
            continue;
          }
        }

        style.setProperty(styleInfo.key, null);
      }
    }
  }
}
 
Example 9
Source File: ScrollCellMapper.java    From jetpad-projectional-open-source with Apache License 2.0 5 votes vote down vote up
@Override
public void refreshProperties() {
  super.refreshProperties();

  Style style = getTarget().getStyle();
  Vector maxDim = getSource().maxDimension().get();
  style.setProperty("maxWidth", maxDim.x + "px");
  style.setProperty("maxHeight", maxDim.y + "px");

  style.setOverflowY(getSource().scroll().get() ? Style.Overflow.SCROLL : Style.Overflow.HIDDEN);
}
 
Example 10
Source File: MaterialCutOut.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
/**
 * Opens the dialog cut out taking all the screen. The target element should
 * be set before calling this method.
 *
 * @throws IllegalStateException if the target element is <code>null</code>
 * @see #setTarget(Widget)
 */
public void open() {
    setCutOutStyle();

    if (targetElement == null) {
        throw new IllegalStateException("The target element should be set before calling open().");
    }
    targetElement.scrollIntoView();

    if (computedBackgroundColor == null) {
        setupComputedBackgroundColor();
    }

    //temporarily disables scrolling by setting the overflow of the page to hidden
    Style docStyle = Document.get().getDocumentElement().getStyle();
    viewportOverflow = docStyle.getOverflow();
    docStyle.setProperty("overflow", "hidden");

    if (backgroundSize == null) {
        backgroundSize = body().width() + 300 + "px";
    }

    setupTransition();
    if (animated) {
        focusElement.getStyle().setProperty("boxShadow", "0px 0px 0px 0rem " + computedBackgroundColor);

        //the animation will take place after the boxshadow is set by the deferred command
        Scheduler.get().scheduleDeferred(() -> {
            focusElement.getStyle().setProperty("boxShadow", "0px 0px 0px " + backgroundSize + " " + computedBackgroundColor);
        });
    } else {
        focusElement.getStyle().setProperty("boxShadow", "0px 0px 0px " + backgroundSize + " " + computedBackgroundColor);
    }
    
    if (circle) {
        focusElement.getStyle().setProperty("WebkitBorderRadius", "50%");
        focusElement.getStyle().setProperty("borderRadius", "50%");
        // Temporary fixed for the IOS Issue on recalculation of the border radius
        focusElement.getStyle().setProperty("webkitBorderTopLeftRadius", "49.9%");
        focusElement.getStyle().setProperty("borderTopLeftRadius", "49.9%");
    } else {
        focusElement.getStyle().clearProperty("WebkitBorderRadius");
        focusElement.getStyle().clearProperty("borderRadius");
        focusElement.getStyle().clearProperty("webkitBorderTopLeftRadius");
        focusElement.getStyle().clearProperty("borderTopLeftRadius");
    }
    setupCutOutPosition(focusElement, targetElement, cutOutPadding, circle);

    setupWindowHandlers();
    getElement().getStyle().clearDisplay();

    // verify if the component is added to the document (via UiBinder for
    // instance)
    if (getParent() == null) {
        autoAddedToDocument = true;
        RootPanel.get().add(this);
    }
    OpenEvent.fire(this, this);
}
 
Example 11
Source File: Geometry.java    From gwt-traction with Apache License 2.0 4 votes vote down vote up
public static final void setInvisibleToMeasure(Element e) {
    Style s = e.getStyle();
    s.setProperty("visibility", "hidden");
    s.setProperty("display", "block");
}
 
Example 12
Source File: Geometry.java    From gwt-traction with Apache License 2.0 4 votes vote down vote up
public static final void unsetInvisibleToMeasure(Element e) {
    Style s = e.getStyle();
    s.setProperty("display", "none");
    s.setProperty("visibility", "");
}