Recursively computes the statistics of the individual colors in a subtree.
@param root the root of the subtree
514669
private void computeRootStatistics(Area root)
    {
    	for (Box box : root.getBoxes())
    	{
    		int len = letterLength(box.getText());
    		if (len > 0)
    		{
    			int key = colorKey(box.getColor());
    			Integer val = colors.get(key);
    			if (val == null) val = 0;
    			val += len;
    			colors.put(key, val);
    		}
    	}
        for (int i = 0; i < root.getChildCount(); i++)
            computeRootStatistics(root.getChildAt(i));
    }
    
    private int letterLength(String s)
    {
        int len = 0;
        for (int i = 0; i < s.length(); i++)
            if (Character.getType(s.charAt(i)) != Character.SPACE_SEPARATOR)
                len++;
        return len;
    }

    /**
     * Converts a color to a number, 4 bits per color channel so that similar colors have similar numbers.
     */
    private int colorKey(Color color)
    {
        return (color.getRed() / 16) * 256 + (color.getGreen() / 16) * 16 + (color.getBlue() / 16);
    }

}
1050608
public void setRoots(java.util.Collection<Root> roots) {
        if (roots == null) {
            this.roots = null;
            return;
        }

        this.roots = new java.util.ArrayList<Root>(roots);
    }
1200723
def set_root(self, root):
        
        if root is None:
            return
        for plot in self.traverse(lambda x: x):
            plot._root = root
1081396
public void setSiteRoot(String root) {

        // site roots must never end with a "/"
        if (root.endsWith("/")) {
            m_siteRoot = root.substring(0, root.length() - 1);
        } else {
            m_siteRoot = root;
        }
    }
1073616
function ( root ) {
    var walker = new TreeWalker( root, SHOW_TEXT, function () {
            return true;
        }, false ),
        parent, node, index;
    while ( node = walker.nextNode() ) {
        while ( ( index = node.data.indexOf( ZWS ) ) > -1 ) {
            if ( node.length === 1 ) {
                do {
                    parent = node.parentNode;
                    parent.removeChild( node );
                    node = parent;
                    walker.currentNode = parent;
                } while ( isInline( node ) && !getLength( node ) );
                break;
            } else {
                node.deleteData( index, 1 );
            }
        }
    }
}
397657
private void handleAllRoots() {
		int totalFound = 0;
		double r = 1;
		int iter = 0;

		// increase the search region centered around 0 until at least one root has been found
		while( iter++ < maxBoundIterations && (totalFound=sturm.countRealRoots(-r,r)) <= 0 ) {
			r = 2*r*r;
		}
		if( Double.isInfinite(r) )
			throw new RuntimeException("r is infinite");
		if( iter >= maxBoundIterations)
			throw new RuntimeException("Too many iterations when searching center region");

		boundEachRoot(-r,r,0,totalFound);

		int target;
		// search for roots below the center bound
		if( totalFound < numRoots && (target = sturm.countRealRoots(Double.NEGATIVE_INFINITY,-r)) > 0 ) {
			double upper = -r;
			double width = r;

			iter = 0;
			while( iter < maxBoundIterations && target > 0 ) {
				int N = sturm.countRealRoots(upper-width,upper);
				if( N != 0 ) {
					boundEachRoot(upper-width,upper,totalFound,N);
					target -= N;
					totalFound += N;
				}
				upper -= width;
				width = 2*width*width;
			}
			if( iter >= maxBoundIterations)
				throw new RuntimeException("Too many iterations when searching lower region");
		}

		if( totalFound < numRoots && (target = sturm.countRealRoots(r,Double.POSITIVE_INFINITY)) > 0 ) {
			double lower = r;
			double width = r;

			iter = 0;
			while( iter < maxBoundIterations && target > 0 ) {
				int N = sturm.countRealRoots(lower,lower+width);
				if( N != 0 ) {
					boundEachRoot(lower,lower+width,totalFound,N);
					target -= N;
					totalFound += N;
				}
				lower += width;
				width = 2*width*width;
			}
			if( iter >= maxBoundIterations)
				throw new RuntimeException("Too many iterations when searching upper region");
		}
	}
1081922
boolean treeFinished(treeNode root){
		return (root.parent == null && root.lc == null && root.rc == null);
	}
936746
private void transform(JSONArray root) {
        for (int i = 0, size = root.size(); i < size; i++)
        {
            Object target = root.get(i);
            if (target instanceof JSONObject)
                this.transform((JSONObject)target);
        }
    }
836485
public void removeEmptySubtrees(CmsTreeNode<I_CmsContextMenuItem> root) {

        List<CmsTreeNode<I_CmsContextMenuItem>> children = root.getChildren();
        if ((root.getData() != null) && root.getData().isLeafItem()) {
            children.clear();
        } else {
            Iterator<CmsTreeNode<I_CmsContextMenuItem>> iter = children.iterator();
            while (iter.hasNext()) {
                CmsTreeNode<I_CmsContextMenuItem> node = iter.next();
                removeEmptySubtrees(node);
                if ((node.getData() != null) && !node.getData().isLeafItem() && (node.getChildren().size() == 0)) {
                    iter.remove();
                }
            }
        }
    }
172525
public void setColor(final Color COLOR) {
        if (null == color) {
            _color = COLOR;
        } else {
            color.set(COLOR);
        }
    }
1357045
private final void parseSettings (final Element root) {

        if (root == null) { throw new NullPointerException(); }

        clear();
        parseGlobalSettings(root);
        parseTargetSpecificSettings(root);
    }
1265244
protected void initTree(CmsResource rootRes) throws CmsException {

        m_currentRoot = rootRes;
        m_treeContainer.removeAllComponents();
        showHeader();
        CmsSitemapTreeController controller = new CmsSitemapTreeController(
            A_CmsUI.getCmsObject(),
            rootRes,
            this,
            m_treeContainer);

        // no need to escape a structure id
        JavaScript.eval(CmsGwtConstants.VAR_LOCALE_ROOT + "='" + rootRes.getStructureId() + "'");

        CmsSitemapUI ui = (CmsSitemapUI)(A_CmsUI.get());
        ui.getSitemapExtension().setSitemapTreeController(controller);
        CmsSitemapTreeNode root1 = controller.createRootNode();
        controller.initEventHandlers(root1);
        m_treeContainer.addComponent(root1);
        controller.onClickOpen(root1);
    }
870938
public void setAnchorColor(int index, Color color) {
        if (index <= 0) {
            if (startColor == null) {
                startColor = new RGBColor(0.0, 0.0, 0.0);
            }
            setGradation(true);
            this.startColor = color;
        } else if (index >= 1) {
            if (endColor == null) {
                endColor = new RGBColor(0.0, 0.0, 0.0);
            }
            setGradation(true);
            this.endColor = color;
        }
    }
1097591
public static BufferedImage recolorImage (
        BufferedImage image, Color rootColor, float[] dists, float[] offsets)
    {
        return recolorImage(image, new Colorization[] {
            new Colorization(-1, rootColor, dists, offsets) });
    }
1265470
private static void displayInventoryTree(AdUnit root, Map<String, List<AdUnit>> treeMap) {
    displayInventoryTreeHelper(root, treeMap, 0);
  }
913280
protected JsTreeNodeData populateTreeNodeData(FileObject root, FileObject file) throws FileSystemException {
		boolean noChild = true;
		FileType type = file.getType();
		if (type.equals(FileType.FOLDER) || type.equals(FileType.FILE_OR_FOLDER)){
			noChild = file.getChildren().length == 0;
		}
		String relativePath = root.getName().getRelativeName(file.getName());
		return populateTreeNodeData(file, noChild, relativePath);
	}
174824
public void setAverageColor(final Color COLOR) {
        if (null == averageColor) {
            _averageColor = COLOR;
            fireUpdateEvent(REDRAW_EVENT);
        } else {
            averageColor.set(COLOR);
        }
    }