List of usage examples for com.google.gwt.dom.client Style setProperty
public void setProperty(String name, String value)
From source file:org.waveprotocol.wave.client.editor.content.paragraph.DefaultParagraphHtmlRenderer.java
License:Apache License
@Override public void updateRendering(HasImplNodelets element, String type, String listStyle, int indent, Alignment alignment, Direction direction) { Element implNodelet = element.getImplNodelet(); ParagraphBehaviour behaviour = ParagraphBehaviour.of(type); boolean toListItem = behaviour == ParagraphBehaviour.LIST; boolean isListItem = implNodelet.getTagName().equalsIgnoreCase(LIST_IMPL_TAGNAME); if (isListItem != toListItem) { Element newNodelet = createNodeletInner(toListItem); DomHelper.replaceElement(implNodelet, newNodelet); element.setBothNodelets(newNodelet); // Ideally onRepair shouldn't require a ContentElement ParagraphHelper.INSTANCE.onRepair((ContentElement) element); implNodelet = newNodelet;// ww w .j a va 2 s . c om } //// Type logic //// double fontSize = -1; FontWeight fontWeight = null; implNodelet.removeClassName(NUMBERED_CLASSNAME); switch (behaviour) { case LIST: if (Paragraph.LIST_STYLE_DECIMAL.equals(listStyle)) { implNodelet.addClassName(NUMBERED_CLASSNAME); } break; case HEADING: fontWeight = FontWeight.BOLD; double headingNum = Integer.parseInt(type.substring(1)); // Do this with CSS instead. // h1 -> 1.75, h4 -> 1, others linearly in between. double factor = 1 - (headingNum - 1) / (Paragraph.NUM_HEADING_SIZES - 1); fontSize = MIN_HEADING_SIZE_EM + factor * (MAX_HEADING_SIZE_EM - MIN_HEADING_SIZE_EM); break; } //// Indent logic //// for (String bulletType : BULLET_CLASSNAMES) { implNodelet.removeClassName(bulletType); } if (behaviour == ParagraphBehaviour.LIST) { if (listStyle == null) { implNodelet.addClassName(bulletClassName(indent)); } indent++; } int margin = indent * INDENT_UNIT_SIZE_PX; //// Update actual values //// // NOTE(danilatos): For these, it might be more efficient to check that the // value has changed before changing it. This is not currently known. Style style = implNodelet.getStyle(); if (fontSize != -1) { style.setFontSize(fontSize, Unit.EM); } else { style.clearFontSize(); } if (fontWeight != null) { style.setFontWeight(fontWeight); } else { style.clearFontWeight(); } if (alignment != null) { style.setProperty("textAlign", alignment.cssValue()); } else { style.clearProperty("textAlign"); } if (direction != null) { style.setProperty("direction", direction.cssValue()); } else { style.clearProperty("direction"); } if (margin == 0) { style.clearMarginLeft(); style.clearMarginRight(); } else { if (direction == Direction.RTL) { style.setMarginRight(margin, Unit.PX); style.clearMarginLeft(); } else { style.setMarginLeft(margin, Unit.PX); style.clearMarginRight(); } } }
From source file:playn.html.HtmlImageLayerDom.java
License:Apache License
private void applyBackgroundSize() { Style style = element().getStyle(); // Set background-repeat to get the right repeating behavior. String repeat;// ww w .j a v a 2s . c om if (repeatX) { if (repeatY) { repeat = "repeat"; } else { repeat = "repeat-x"; } } else if (repeatY) { repeat = "repeat-y"; } else { repeat = "no-repeat"; } style.setProperty("backgroundRepeat", repeat); // Set background-size to get the right pinning behavior. if (sourceRectSet) { float wratio = widthSet ? (width / sw) : (image().width() / sw); float hratio = heightSet ? (height / sh) : (image().height() / sh); if (wratio == 0) { wratio = 1; } if (hratio == 0) { hratio = 1; } float backWidth = image().width() * wratio; float backHeight = image().height() * hratio; style.setProperty("backgroundSize", backWidth + "px " + backHeight + "px"); style.setProperty("backgroundPosition", (-sx * wratio) + "px " + (-sy * hratio) + "px"); } else { String size = repeatX ? image().width() + "px " : "100% "; size += repeatY ? image().height() + "px" : "100%"; style.setProperty("backgroundSize", size); style.clearProperty("backgroundPosition"); } }
From source file:scrum.client.calendar.DayListWidget.java
License:Open Source License
private void formatRow(FlexTable table, int row) { String border = "1px solid #EEE"; for (int i = 0; i <= 4; i++) { Element element = table.getCellFormatter().getElement(row, i); Style style = element.getStyle(); style.setProperty("borderBottom", border); if (row == 0) style.setProperty("borderTop", border); if (i < 3 || i == 4) style.setProperty("borderLeft", border); if (i == 4) style.setProperty("borderRight", border); }// w ww . ja v a2s . co m }
From source file:viewer.FixedWidth.java
License:Open Source License
public FixedWidth(final String text) { super(text);/*from w ww . j a va 2 s . c o m*/ final Style style = super.getElement().getStyle(); style.setProperty("fontFamily", "monospace"); style.setProperty("whiteSpace", "pre-wrap"); }