List of usage examples for com.google.gwt.dom.client Style clearFontWeight
public void clearFontWeight()
From source file:com.sciencegadgets.client.ui.LinkPrompt.java
License:Open Source License
public void setColor(String hexColor) { Style labelStyle = colorLabel.getElement().getStyle(); if (hexColor == null || hexColor.length() != 6) { if ("".equals(hexColor)) { labelStyle.clearColor();//from www. jav a 2s. co m labelStyle.clearFontWeight(); } else { labelStyle.setColor("red"); labelStyle.setFontWeight(FontWeight.BOLD); } HashMap<Parameter, String> pMap = setMapParameters(); pMap.remove(Parameter.color); updateLinks(pMap); return; } try { Integer.valueOf(hexColor.substring(0, 2), 16); Integer.valueOf(hexColor.substring(2, 4), 16); Integer.valueOf(hexColor.substring(4, 6), 16); } catch (NumberFormatException e) { labelStyle.setColor("red"); labelStyle.setFontWeight(FontWeight.BOLD); return; } labelStyle.clearColor(); labelStyle.setFontWeight(FontWeight.BOLD); // HashMap<Parameter, String> algActivityMap = URLParameters // .getParameterMap(); // algActivityMap.put(Parameter.themecolor, hexColor); // URLParameters.setParameters(algActivityMap, false); URLParameters.addParameter(Parameter.color, hexColor, true); initialColor = hexColor; HashMap<Parameter, String> pMap = setMapParameters(); pMap.put(Parameter.color, hexColor); updateLinks(pMap); }
From source file:com.sciencegadgets.client.ui.LinkPrompt.java
License:Open Source License
boolean isValidSpec(Label label, TextBox textBox, ValueListBox<String> listBox) { Style labelStyle = label.getElement().getStyle(); if ("".equals(textBox.getValue()) && listBox.getValue() == null) { labelStyle.clearColor();//from ww w.j a v a 2 s .c om labelStyle.clearFontWeight(); return false; } boolean isValid; try { Double value = Double.parseDouble(textBox.getValue()); if (value > 0 && listBox.getValue() != null) { isValid = true; } else { isValid = false; } } catch (NumberFormatException e) { isValid = false; } if (isValid) { labelStyle.clearColor(); labelStyle.setFontWeight(FontWeight.BOLD); } else { labelStyle.setColor("red"); labelStyle.setFontWeight(FontWeight.BOLD); } return isValid; }
From source file:com.sencha.gxt.chart.client.draw.engine.VML.java
License:sencha.com license
/** * Applies the attributes of the passed {@link TextSprite} to its VML element. * /* w w w . j a v a2s . c om*/ * @param sprite the sprite whose attributes to use */ private void setTextAttributes(TextSprite sprite, XElement element) { Element textPath = element.childElement("textPath").cast(); Style textStyle = textPath.getStyle(); textBBoxCache.remove(sprite); if (sprite.isFontSizeDirty() || ignoreOptimizations) { if (sprite.getFontSize() > 0) { textStyle.setFontSize(sprite.getFontSize(), Unit.PX); } else { textStyle.clearFontSize(); } } if (sprite.isFontStyleDirty() || ignoreOptimizations) { if (sprite.getFontStyle() != null) { textStyle.setFontStyle(sprite.getFontStyle()); } else { textStyle.clearFontStyle(); } } if (sprite.isFontWeightDirty() || ignoreOptimizations) { if (sprite.getFontWeight() != null) { textStyle.setFontWeight(sprite.getFontWeight()); } else { textStyle.clearFontWeight(); } } if (sprite.isFontDirty() || ignoreOptimizations) { if (sprite.getFont() != null) { textStyle.setProperty("fontFamily", sprite.getFont()); } else { textStyle.clearProperty("fontFamily"); } } // text-anchor emulation if (sprite.isTextAnchorDirty() || ignoreOptimizations) { if (sprite.getTextAnchor() == TextAnchor.MIDDLE) { setTextAlign(textStyle, "center"); } else if (sprite.getTextAnchor() == TextAnchor.END) { setTextAlign(textStyle, "right"); } else { setTextAlign(textStyle, "left"); } } if (sprite.isTextDirty() || ignoreOptimizations) { if (sprite.getText() != null) { textPath.setPropertyString("string", sprite.getText()); } else { textPath.setPropertyString("string", ""); } } if (sprite.isTextBaselineDirty() || sprite.isXDirty() || sprite.isYDirty() || ignoreOptimizations) { double height = sprite.getFontSize(); if (sprite.getTextBaseline() == TextBaseline.MIDDLE) { height = 0; } else if (sprite.getTextBaseline() == TextBaseline.BOTTOM) { height *= -1; } Element path = element.childElement("path").cast(); path.setPropertyString("v", new StringBuilder().append("m").append(Math.round(sprite.getX() * zoom)).append(",") .append(Math.round((sprite.getY() + (height / 2.0)) * zoom)).append(" l") .append(Math.round(sprite.getX() * zoom) + 1).append(",") .append(Math.round((sprite.getY() + (height / 2.0)) * zoom)).toString()); textRenderedPoints.put(sprite, new PrecisePoint(sprite.getX(), sprite.getY())); textRenderedBaseline.put(sprite, sprite.getTextBaseline()); } }
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;/*from w w w .j av a2 s . c o m*/ } //// 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(); } } }