本文整理汇总了Java中org.fit.layout.model.Area.getBoxes方法的典型用法代码示例。如果您正苦于以下问题:Java Area.getBoxes方法的具体用法?Java Area.getBoxes怎么用?Java Area.getBoxes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fit.layout.model.Area
的用法示例。
在下文中一共展示了Area.getBoxes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAverageBoxColorLuminosity
import org.fit.layout.model.Area; //导入方法依赖的package包/类
public double getAverageBoxColorLuminosity(Area area)
{
if (area.getBoxes().isEmpty())
return 0;
else
{
double sum = 0;
int len = 0;
for (Box box : area.getBoxes())
{
int l = box.getText().length();
sum += colorLuminosity(box.getColor()) * l;
len += l;
}
return sum / len;
}
}
示例2: computeRootStatistics
import org.fit.layout.model.Area; //导入方法依赖的package包/类
/**
* Recursively computes the statistics of the individual colors in a subtree.
* @param root the root of the subtree
*/
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.getChildArea(i));
}
示例3: getColorPercentage
import org.fit.layout.model.Area; //导入方法依赖的package包/类
/**
* Obtains the average percentage of all the text that has the given color.
* @param color the color to be tested.
* @return the percentage (0..1)
*/
public double getColorPercentage(Area node)
{
int tlen = 0;
double sum = 0;
for (Box box : node.getBoxes())
{
int len = letterLength(box.getText());
if (len > 0)
{
sum += getColorPercentage(box.getColor()) * len;
tlen += len;
}
}
for (int i = 0; i < node.getChildCount(); i++)
{
Area child = node.getChildArea(i);
int nlen = letterLength(child.getText());
tlen += nlen;
sum += getColorPercentage(child) * nlen;
}
if (tlen == 0)
return 0;
else
return sum / tlen;
}