List of usage examples for com.google.gwt.dom.client NodeList getLength
public int getLength()
From source file:com.sciencegadgets.client.algebra.EquationHTML.java
License:Open Source License
private void addChildrenIfInline(Element curEl, LinkedList<Element> childrenInline, TypeSGET curType) { switch (curType) { case Exponential: // Only the base of an exponent is considered inline childrenInline.add((Element) curEl.getChild(0)); break;//from www. java 2 s . com case Fraction: break; case Equation: case Sum: case Term: case Trig: case Log: NodeList<Node> children = curEl.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { childrenInline.add((Element) children.getItem(i)); } break; } }
From source file:com.sciencegadgets.client.algebra.EquationTree.java
License:Open Source License
public void setDisplay(EquationHTML equationHTML) { for (Wrapper w : wrappers) { if (w instanceof EditWrapper) { ((EditWrapper) w).onUnload(); } else if (w instanceof AlgebaWrapper) { ((AlgebaWrapper) w).onUnload(); }/* w w w.j a va2s .c o m*/ w.getElement().removeFromParent(); } wrappers.clear(); idHTMLMap.clear(); this.eqHTML = equationHTML; NodeList<Element> allElements = eqHTML.getElement().getElementsByTagName("*"); for (int i = 0; i < allElements.getLength(); i++) { Element el = (Element) allElements.getItem(i); String elId = el.getAttribute(MathAttribute.ID.getAttributeName()); if (elId.contains(UnitHTML.UNIT_NODE_DELIMITER)) { String parentElId = elId.split(UnitHTML.UNIT_NODE_DELIMITER)[1]; idUnitHTMLMap.put(el, parentElId); } else { idHTMLMap.put(elId, el); } el.removeAttribute(MathAttribute.ID.getAttributeName()); } }
From source file:com.sciencegadgets.client.algebra.EquationTree.java
License:Open Source License
public EquationNode newNode(Element xmlNode) { EquationNode newNode = new EquationNode(xmlNode); addToMaps(newNode);// w w w . j av a2 s.com NodeList<Element> descendants = xmlNode.getElementsByTagName("*"); for (int i = 0; i < descendants.getLength(); i++) { Element descendantEl = descendants.getItem(i); addToMaps(new EquationNode(descendantEl)); } return newNode; }
From source file:com.sciencegadgets.client.algebra.EquationTree.java
License:Open Source License
/** * Gets all nodes in the parent by specified type.</br>Use type == null for * all nodes within this node.</br>Use {@link #getNodesByType(TypeSGET type)} * for all nodes by type.</br>Use {@link #getNodes()} for all nodes in the * tree including the root/*from w ww . j a v a 2 s .c om*/ * * @param type */ public LinkedList<EquationNode> getNodesByType(TypeSGET type, EquationNode parent) { LinkedList<EquationNode> nodes = new LinkedList<EquationNode>(); String tag = "*"; if (type != null) { tag = type.getTag(); } NodeList<Element> elements = parent.getXMLNode().getElementsByTagName(tag); for (int i = 0; i < elements.getLength(); i++) { String id = elements.getItem(i).getAttribute(MathAttribute.ID.getAttributeName()); nodes.add(idMap.get(id)); } return nodes; }
From source file:com.sciencegadgets.client.algebra.EquationTree.java
License:Open Source License
private EquationNode bindXMLtoNodeRecursive(Element equationXMLNode) { EquationNode eqNode = new EquationNode(equationXMLNode); String id = eqNode.getId();/* w w w . ja va2s . c o m*/ idMap.put(id, eqNode); idMLMap.put(id, equationXMLNode); NodeList<Node> equationXMLNodeChildren = equationXMLNode.getChildNodes(); for (int i = 0; i < equationXMLNodeChildren.getLength(); i++) { Element currentNode = (Element) equationXMLNodeChildren.getItem(i); if (currentNode.getNodeType() == Node.ELEMENT_NODE) { bindXMLtoNodeRecursive((Element) currentNode); } } return eqNode; }
From source file:com.sciencegadgets.client.conversion.ConversionActivity.java
License:Open Source License
public void reloadEquation() { // Make and add entire equation before moving left dimensionalAnalysisArea.clear();//w w w. java 2 s . c om EquationHTML eqHTML = mTree.reloadDisplay(false, false); // Unit font wrapperArea.addStyleName(CSS.UNIT); NodeList<Element> elements = eqHTML.getElement().getElementsByTagName("*"); for (int i = 0; i < elements.getLength(); i++) { elements.getItem(i).addClassName(CSS.UNIT); } // Recreate wrappers placeWrappers(); // Place entire equation in history area first eqHTML.autoFillParent = true; dimensionalAnalysisArea.add(eqHTML); // No need for equals sign mTree.getEquals().getHTML(true, true).removeFromParent(); // Move left side of equation into wrapper area Element newWorkingHTML = mTree.getLeftSide().getHTML(false, false); if (workingHTML == null) { wrapperArea.getElement().appendChild(newWorkingHTML); } else { wrapperArea.getElement().replaceChild(newWorkingHTML, workingHTML); } workingHTML = newWorkingHTML; // Resize working area double widthRatio = (double) wrapperArea.getOffsetWidth() / workingHTML.getOffsetWidth(); double heightRatio = (double) wrapperArea.getOffsetHeight() / workingHTML.getOffsetHeight(); double smallerRatio = (widthRatio > heightRatio) ? heightRatio : widthRatio; double fontPercent = smallerRatio * 95;// *95 for looser fit workingHTML.getStyle().setFontSize(fontPercent, com.google.gwt.dom.client.Style.Unit.PCT); // HashMap<Parameter, String> parameterMap = new HashMap<Parameter, // String>(); // parameterMap // .put(Parameter.activity, ActivityType.conversion.toString()); // parameterMap.put(Parameter.equation, mTree.getMathXMLString()); // URLParameters.setParameters(parameterMap, false); }
From source file:com.seanchenxi.gwt.serenity.client.SerenityUtil.java
License:Apache License
public static String getWpNaming() { Element el = Document.get().getElementsByTagName(HeadElement.TAG).getItem(0); NodeList<Element> els = el.getElementsByTagName(MetaElement.TAG); for (int i = 0; i < els.getLength(); i++) { if (SerenityResources.GENERATOR.equalsIgnoreCase(els.getItem(i).getAttribute(SerenityResources.NAME))) { return els.getItem(i).getAttribute(SerenityResources.CONTENT); }/*from www .j a va2s . co m*/ } return SerenityResources.MSG.wordpress_Name(); }
From source file:com.seanchenxi.gwt.serenity.client.SerenityUtil.java
License:Apache License
public static String getWpBaseUrl() { Element el = Document.get().getElementsByTagName(HeadElement.TAG).getItem(0); NodeList<Element> els = el.getElementsByTagName(MetaElement.TAG); for (int i = 0; i < els.getLength(); i++) { if (SerenityResources.URL.equalsIgnoreCase(els.getItem(i).getAttribute(SerenityResources.NAME))) { return els.getItem(i).getAttribute(SerenityResources.CONTENT); }/* ww w.ja v a2s.co m*/ } return StringPool.SLASH; }
From source file:com.sencha.gxt.core.client.dom.XElement.java
License:sencha.com license
/** * Inserts the elements before this element. * /*from ww w. ja v a 2 s .c om*/ * @param elements the elements to insert */ public final void insertBefore(NodeList<Element> elements) { Element parent = getParentElement(); assert parent != null : "cannot insertBefore with null parent"; for (int i = 0, len = elements.getLength(); i < len; i++) { parent.insertBefore(elements.getItem(0), this); } }
From source file:com.sencha.gxt.core.client.dom.XElement.java
License:sencha.com license
/** * Replace one class name with another./*from ww w. j a v a 2 s .co m*/ * * @param oldClassName the class name to be replaced * @param newClassName the class name to replace it * @param deep true to class names on child elements */ public final void replaceClassName(String oldClassName, String newClassName, boolean deep) { removeClassName(oldClassName); addClassName(newClassName); NodeList<Element> nodes = select("." + oldClassName); for (int i = 0; i < nodes.getLength(); i++) { nodes.getItem(i).replaceClassName(oldClassName, newClassName); } }