GWTFontMetrics getFontMetrics(Font font) { GWTFontMetrics metrics = fontMetrics.get(font); if (metrics == null) { measureElement.getStyle().setFontSize(font.size, Unit.PX); measureElement.getStyle().setFontWeight(Style.FontWeight.NORMAL); measureElement.getStyle().setFontStyle(Style.FontStyle.NORMAL); measureElement.getStyle().setProperty("fontFamily", font.name); measureElement.setInnerText(HEIGHT_TEXT); switch (font.style) { case BOLD: measureElement.getStyle().setFontWeight(Style.FontWeight.BOLD); break; case ITALIC: measureElement.getStyle().setFontStyle(Style.FontStyle.ITALIC); break; case BOLD_ITALIC: measureElement.getStyle().setFontWeight(Style.FontWeight.BOLD); measureElement.getStyle().setFontStyle(Style.FontStyle.ITALIC); break; default: break; } float height = measureElement.getOffsetHeight(); measureElement.setInnerText(EMWIDTH_TEXT); float emwidth = measureElement.getOffsetWidth(); metrics = new GWTFontMetrics(font, height, emwidth); fontMetrics.put(font, metrics); } return metrics; }
@Override public void reset() { Preconditions.checkState(this.listener != null); this.listener = null; avatar.setSrc(null); name.setInnerText(null); address.setInnerText(null); for (Widget child : self.getChildren()) { child.removeFromParent(); } }
@Override public void setBeaconData(Beacon beacon) { Element username = DOM.getElementById("username"); username.setInnerText(beacon.getName()); Element tags = DOM.getElementById("tags"); String stags = "Empty"; boolean first = true; for (String t : beacon.getTags()) { if (first) { stags = t; } else { stags = stags + "," + t; } } tags.setInnerText(stags); Element uuid = DOM.getElementById("uuid"); uuid.setInnerText(beacon.getProximityUUID()); Element bcolor = DOM.getElementById("bcolor"); bcolor.setInnerText(beacon.getBeaconColor()); Element bmac = DOM.getElementById("bmac"); bmac.setInnerText(beacon.getMacAddress()); Element major = DOM.getElementById("major"); major.setInnerText(String.valueOf(beacon.getMajor())); Element minor = DOM.getElementById("minor"); minor.setInnerText(String.valueOf(beacon.getMinor())); Element secureuuid = DOM.getElementById("secureuuid"); minor.setInnerText(String.valueOf(beacon.getSecureUUID())); }
public void addTab(String text) { Element button = DOM.createDiv(); button.setClassName(getStylePrimaryName() + "-Item"); button.setInnerText(text); getElement().insertBefore(button, clear); }
/** Utility method to show a loading element if there is no one in hosting page. */ public static void startLoading() { Element l = DOM.getElementById("loading"); if (l == null) { l = DOM.createDiv(); l.setAttribute( "style", "position:fixed;top:0px;left:0px;width:100%;text-align:center;font-family:arial;font-size:24px;color:#4285f4;"); l.setId("loading"); l.setInnerText("loading" + "..."); Document.get().getBody().appendChild(l); } }
private void printParts(Label label, double val, boolean degrees) { if (degrees) { label.setText(kernel.formatAngle(val, StringTemplate.defaultTemplate, true).toString()); return; } parts = StringTemplate.printLimitedWidth(val, kernel, parts); if (parts[1] == null) { label.setText(parts[0]); } else { label.setText(parts[0] + "\u00D7 10"); Element exponent = DOM.createElement("sup"); exponent.setInnerText(parts[1]); label.getElement().appendChild(exponent); } }
private void displayReport() { errorText.setInnerText(""); purposeText.setText(report.getPurpose()); notesText.setText(report.getNotes()); String department = report.getDepartment(); departmentList.setSelectedIndex(0); for (int i = 0; i < Expenses.DEPARTMENTS.length; i++) { if (Expenses.DEPARTMENTS[i].equals(department)) { departmentList.setSelectedIndex(i); } } Date d = report.getCreated(); showCreationDate(d); }
private Element createElement(String image, String text, String link) { Element e = DOM.createElement("li"); Element l = DOM.createAnchor(); l.setAttribute("href", link); l.setAttribute("style", "padding-bottom: 8px; padding-top: 8px;"); if (image != null) { Element i = DOM.createImg(); i.setAttribute("src", image); i.setAttribute("style", "margin-top: 2px; float: left;"); l.appendChild(i); } Element lb = DOM.createSpan(); lb.setInnerText(text); lb.setAttribute("style", "margin-left: 5px;"); l.appendChild(lb); e.appendChild(l); return e; }
@Test public void clone_NotDeep() { // Arrange Element e = n.cast(); e.setInnerText("text"); e.getStyle().setBackgroundColor("black"); AnchorElement child = Document.get().createAnchorElement(); child.setInnerText("child inner text"); n.appendChild(child); // Act DivElement newNode = n.cloneNode(false).cast(); // Assert assertEquals(Node.ELEMENT_NODE, newNode.getNodeType()); assertTrue(e.getStyle() != newNode.getStyle()); assertEquals("black", newNode.getStyle().getBackgroundColor()); assertEquals("text", newNode.getInnerText()); assertNull(newNode.getParentNode()); assertEquals(2, n.getChildNodes().getLength()); assertEquals(1, newNode.getChildNodes().getLength()); }
public void setTabText(int index, String text) { Element tab = getTab(index); if (tab == null) return; tab.setInnerText(text); }
/** Sets the text to the pretty-date, once, and never again. */ public static void makePretty(Date date, String prefix, Element element) { element.setInnerText(prefix + getPrettyText(date)); }
public void setSender(String s) { sender.setInnerText(s); }
public void setSubject(String s) { subject.setInnerText(s); }
/** * Add description to radio button title. * * @param radioItem radio button * @param description description to add */ private void addDescription(RadioButton radioItem, String description) { Element descElement = DOM.createSpan(); descElement.setInnerText(description); descElement.getStyle().setColor("#888"); radioItem.getElement().appendChild(descElement); }
@Override public void visitStringNode(Text string) { Element parent = getParent(string.getParent()); parent.setInnerText(string.getText()); }
public SpanPanel(String text) { Element span = DOM.createSpan(); span.setInnerText(text); setElement(span); }