private void scrollSelectedItemIntoView() { NodeList<Node> items = getSuggestionMenu().getElement().getChild(1).getChild(0).getChildNodes(); for (int i = 0; i < items.getLength(); i++) { Element element = (Element) items.getItem(i); if (((Element) element.getChild(0)).getClassName().equals("item item-selected")) { element.scrollIntoView(); break; } } } }
private void checkAnchorPanel() { if (anchorPanel == null) { anchorPanel = new CustomFlowPanel(anchor); int anchorIdx = -1; Node parent = anchor.getParentNode(); if (parent != null && parent == getElement()) { for (int i = 0; i < parent.getChildCount(); i++) { if (parent.getChild(i) == anchor) { anchorIdx = i; break; } } } if (anchorIdx >= 0) insert(anchorPanel, anchorIdx); else add(anchorPanel); } if (controlGroupRoot != null && controlGroupRoot.getParent() != anchorPanel) { anchorPanel.add(controlGroupRoot); } }
@Override public Node get(int index) { return n.getChild(index); }
private void checkAnchorPanel() { if (anchorPanel == null) { anchorPanel = new CustomFlowPanel(anchor); int anchorIdx = -1; Node parent = anchor.getParentNode(); if (parent != null && parent == getElement()) { for (int i = 0; i < parent.getChildCount(); i++) { if (parent.getChild(i) == anchor) { anchorIdx = i; break; } } } if (anchorIdx >= 0) insert(anchorPanel, anchorIdx); else add(anchorPanel); } if (controlGroupRoot != null && controlGroupRoot.getParent() != anchorPanel) { anchorPanel.add(controlGroupRoot); } }
private Content getChildContent(Node root, String... path) { Node target = root; for ( String pathElement : path ) { Node child = target.getChild(pathElement); if ( child == null ) return null; // or whatever you should do target = child; } return target.getContent(); }
private void checkAnchorPanel() { if (anchorPanel == null) { anchorPanel = new CustomFlowPanel(anchor); int anchorIdx = -1; Node parent = anchor.getParentNode(); if (parent != null && parent == getElement()) { for (int i = 0; i < parent.getChildCount(); i++) { if (parent.getChild(i) == anchor) { anchorIdx = i; break; } } } if (anchorIdx >= 0) insert(anchorPanel, anchorIdx); else add(anchorPanel); } if (controlGroupRoot != null && controlGroupRoot.getParent() != anchorPanel) { anchorPanel.add(controlGroupRoot); } }
@Override public Node remove(int index) { Node child = n.getChild(index); n.removeChild(child); return child; }
private void moveTosCopyRight() { // move the ToS and copyright to the top // create a div group in the graphics context if (tosGroup == null) { String graphicsId = map.getVectorContext().getId(); Element graphics = DOM.getElementById(graphicsId); tosGroup = DOM.createDiv(); tosGroup.setId(map.getID() + "-googleAddon"); tosGroup.getStyle().setBottom(VERTICAL_MARGIN, Unit.PX); graphics.appendChild(tosGroup); UIObject.setVisible(tosGroup, visible); } String mapsId = map.getRasterContext().getId(this); Element gmap = DOM.getElementById(mapsId); if (gmap.getChildCount() > 0) { Node baseMap = gmap.getChild(0); if (baseMap.getChildCount() > 2) { Node copyright = baseMap.getChild(1); Node tos = baseMap.getChild(2); tosGroup.appendChild(copyright); tosGroup.appendChild(tos); } } }
public static final void findCounts(String input, HashMap<Character,Node> sequences) { int n = input.length(); for (int i=0; i<n; i++) { char root = input.charAt(i); Node sequence = sequences.get(root); int j = -1; int c = 1; while (((i+c) < n) && ((j = sequence.hasChild(input.charAt(i+c))) != -1)) { sequence = sequence.getChild(j); c++; } sequence.count++; } }
Node currentNode = rootNode; for (String s : singleNodes) { if( currentNode.hasChild(s) ) currentNode = currentNode.getChild(s); else currentNode = currentNode.createChild(s); }
public void depthFirst(Node node, int op){ if (op == 1) operationsNoTrim(node); //child generator method else if (op == 2) operationsWithTrim(node); //child generator method else if (op == 3) operationsWithTrimNSecure(node); //child generator method for(int i = 0; i < node.getTotalChild(); i++){ depthFirst(node.getChild(i), op); } }
Node root = new Node("root"); Reader r = new InputStreamReader(new BufferedInputStream(...)); String line; while ((line = r.readLine) != null) { String[] colunms = line.split("\\s*"); // Read in the data in tabular form // Build a tree structure of Node objects // NOTE: This could be optimized quite a bit to take // advantage of the sorted input. Node curr = null; Node prev = root; for (int i = 0; i < columns.length; i++) { curr = prev.getChild(columns[i]); // If this node has not been seen yet, create it if (curr == null) { curr = new Node(columns[i]); prev.addChild(curr); } prev = curr; } }
private Element getFilpElement() { return (Element) getElement().getChild(2).getChild(0); }
public void breadthFirst(ArrayList<Node> nodes, int op) { ArrayList<Node> children = new ArrayList<>(); // nodes contain the nodes on the previous (or parent) level for(int i = 0; i < nodes.size(); ++i) { Node node = nodes.get(i); if (op == 1) operationsNoTrim(node); //child generator method else if (op == 2) operationsWithTrim(node); //child generator method else if (op == 3) operationsWithTrimNSecure(node); //child generator method for(int i = 0; i < node.getTotalChild(); ++i) { children.add(node.getChild(i)); } } // children contain the nodes on the current level // all the nodes have been created, but not processed yet // now process this level recursively... breadthFirst(children, op); }
@Override public void add(int index, Node element) { if (element.getParentElement() != null) { throw new IllegalStateException(); } if (index == 0) { n.insertFirst(element); } else { Node prev = n.getChild(index - 1); n.insertAfter(element, prev); } }
public VDDTabSheet() { super(); newTab.setClassName(CLASSNAME_NEW_TAB); // Get the tabBar tabBar = (ComplexPanel) getChildren().get(0); // Get the content tabPanel = (VTabsheetPanel) getChildren().get(1); // Get the spacer Element tBody = tabBar.getElement(); spacer = tBody.getChild(tBody.getChildCount() - 1).getChild(0) .getChild(0).cast(); }
public VDDTabSheet() { super(); newTab.setClassName(CLASSNAME_NEW_TAB); // Get the tabBar tabBar = (ComplexPanel) getChildren().get(0); // Get the content tabPanel = (VTabsheetPanel) getChildren().get(1); // Get the spacer Element tBody = tabBar.getElement(); spacer = tBody.getChild(tBody.getChildCount() - 1).getChild(0) .getChild(0).cast(); }
public class Bits { public static void main(String[] args) { int[] ints = new int[] {1, 0, 1, 0, 1, 0}; Node parent = new Node(ints[0]); Node root = parent; for (int i = 1; i < ints.length; i++) { Node child = new Node(ints[i]); parent.setChild(child); parent = child; } long value = computeValue(0, root); System.out.println(); System.out.println("value = " + value); } private static long computeValue(long parentValue, Node node) { if (node == null) { return parentValue; } // only to print the current digit System.out.print(node.getDigit()); long value = (parentValue << 1) + node.getDigit(); return computeValue(value, node.getChild()); } }
public void show(final int mx, final int my, int columnIndex, int rowIndex, String group, boolean asProperty) { super.show(mx, my, columnIndex, group, asProperty); columnContextLIElement .getChild(1) // a element .getChild(3) // span element .getFirstChild() // b element .getChild(0) // text .setNodeValue(group); mapEvent(insertRowAboveLIElement, new InsertRowEvent(rowIndex)); mapEvent(insertRowBelowLIElement, new InsertRowEvent(rowIndex + 1)); mapEvent(duplicateRowLIElement, new DuplicateRowEvent(rowIndex)); mapEvent(deleteRowLIElement, new DeleteRowEvent(rowIndex)); } }