当前位置: 首页>>代码示例>>Java>>正文


Java Area类代码示例

本文整理汇总了Java中org.fit.layout.model.Area的典型用法代码示例。如果您正苦于以下问题:Java Area类的具体用法?Java Area怎么用?Java Area使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Area类属于org.fit.layout.model包,在下文中一共展示了Area类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isJoinable

import org.fit.layout.model.Area; //导入依赖的package包/类
private boolean isJoinable(Area sep1, Area sep2, boolean horizontal)
{
    if (sep1.isLeaf() && sep2.isLeaf())
    {
        if (horizontal)
        {
            return sep1.getY1() == sep2.getY1()
                    && sep1.getY2() == sep2.getY2()
                    && sep2.getX1() >= sep1.getX1()
                    && sep2.getX1() <= sep1.getX2() + 1;
        }
        else
        {
            return sep1.getX1() == sep2.getX1()
                    && sep1.getX2() == sep2.getX2()
                    && sep2.getY1() >= sep1.getY1()
                    && sep2.getY1() <= sep1.getY2() + 1;
        }
    }
    else
        return false;
}
 
开发者ID:FitLayout,项目名称:PDFAnalyzer,代码行数:23,代码来源:NormalizeSeparatorsOperator.java

示例2: findSeparatorsAround

import org.fit.layout.model.Area; //导入依赖的package包/类
private Neighborhood findSeparatorsAround(AreaImpl area)
{
    Neighborhood ret = new Neighborhood(area);
    
    Area cand;
    cand = findNeigborTop(area);
    if (cand != null && cand.isHorizontalSeparator())
        ret.neighbors[TOP] = cand;
    cand = findNeigborRight(area);
    if (cand != null && cand.isVerticalSeparator())
        ret.neighbors[RIGHT] = cand;
    cand = findNeigborBottom(area);
    if (cand != null && cand.isHorizontalSeparator())
        ret.neighbors[BOTTOM] = cand;
    cand = findNeigborLeft(area);
    if (cand != null && cand.isVerticalSeparator())
        ret.neighbors[LEFT] = cand;
    
    return ret;
}
 
开发者ID:FitLayout,项目名称:PDFAnalyzer,代码行数:21,代码来源:RemapSeparatorsOperator.java

示例3: findNeigborLeft

import org.fit.layout.model.Area; //导入依赖的package包/类
private Area findNeigborLeft(AreaImpl area)
{
    final AreaGrid grid = ((AreaImpl) area.getParentArea()).getGrid();
    final int spos = grid.getColOfs(area.getGridPosition().getX1());
    int y = area.getGridPosition().midY();
    int x = area.getGridPosition().getX1() - 1;
    while (x >= 0)
    {
        final int epos = grid.getColOfs(x);
        if (spos - epos > maxEmDistX * areaFontSize(area))
            break; //distance limit exceeded
        final Area cand = grid.getAreaAt(x, y);
        if (cand != null)
            return cand;
        x--;
    }
    return null;
}
 
开发者ID:FitLayout,项目名称:PDFAnalyzer,代码行数:19,代码来源:RemapSeparatorsOperator.java

示例4: findNeigborRight

import org.fit.layout.model.Area; //导入依赖的package包/类
private Area findNeigborRight(AreaImpl area)
{
    final AreaGrid grid = ((AreaImpl) area.getParentArea()).getGrid();
    int y = area.getGridPosition().midY();
    int x = area.getGridPosition().getX2() + 1;
    final int spos = grid.getColOfs(x);
    while (x < grid.getWidth())
    {
        final int epos = grid.getColOfs(x);
        if (epos - spos > maxEmDistX * areaFontSize(area))
            break; //distance limit exceeded
        final Area cand = grid.getAreaAt(x, y);
        if (cand != null)
            return cand;
        x++;
    }
    return null;
}
 
开发者ID:FitLayout,项目名称:PDFAnalyzer,代码行数:19,代码来源:RemapSeparatorsOperator.java

示例5: findNeigborTop

import org.fit.layout.model.Area; //导入依赖的package包/类
private Area findNeigborTop(AreaImpl area)
{
    final AreaGrid grid = ((AreaImpl) area.getParentArea()).getGrid();
    final int spos = grid.getRowOfs(area.getGridPosition().getY1());
    int x = area.getGridPosition().midX();
    int y = area.getGridPosition().getY1() - 1;
    while (y >= 0)
    {
        final int epos = grid.getRowOfs(y);
        if (spos - epos > maxEmDistY * areaFontSize(area))
            break; //distance limit exceeded
        final Area cand = grid.getAreaAt(x, y);
        if (cand != null)
            return cand;
        y--;
    }
    return null;
}
 
开发者ID:FitLayout,项目名称:PDFAnalyzer,代码行数:19,代码来源:RemapSeparatorsOperator.java

示例6: findNeigborBottom

import org.fit.layout.model.Area; //导入依赖的package包/类
private Area findNeigborBottom(AreaImpl area)
{
    final AreaGrid grid = ((AreaImpl) area.getParentArea()).getGrid();
    int x = area.getGridPosition().midX();
    int y = area.getGridPosition().getY2() + 1;
    final int spos = grid.getRowOfs(y);
    while (y < grid.getHeight())
    {
        final int epos = grid.getRowOfs(y);
        if (epos - spos > maxEmDistY * areaFontSize(area))
            break; //distance limit exceeded
        final Area cand = grid.getAreaAt(x, y);
        if (cand != null)
            return cand;
        y++;
    }
    return null;
}
 
开发者ID:FitLayout,项目名称:PDFAnalyzer,代码行数:19,代码来源:RemapSeparatorsOperator.java

示例7: recursivelyFindPairs

import org.fit.layout.model.Area; //导入依赖的package包/类
private void recursivelyFindPairs(Area root, List<SepPair> pairs)
{
    if (root.isSeparator())
    {
        //try to complete an existing pair
        final List<SepPair> expairs = findPairsFor(root, pairs);
        for (SepPair expair : expairs)
        {
            //expair.addPair(root);
            SepPair copy = new SepPair(expair.s1);
            copy.addPair(root);
            pairs.add(copy);
        }
        //and create a new one
        pairs.add(new SepPair(root));
    }
    for (int i = 0; i < root.getChildCount(); i++)
        recursivelyFindPairs(root.getChildArea(i), pairs);
}
 
开发者ID:FitLayout,项目名称:PDFAnalyzer,代码行数:20,代码来源:SeparatorPairsOperator.java

示例8: findJoinableAreas

import org.fit.layout.model.Area; //导入依赖的package包/类
/**
 * Tries to find non-separated neighboring areas that may be joined
 * and joins them.
 * @param areas The list of areas to process.
 * @return {@code true} when some change has been performed
 */
private boolean findJoinableAreas(List<Area> areas)
{
    final int[] dirs = { RIGHT, BOTTOM };
    for (Area curArea : areas)
    {
        List<Area> siblings = curArea.getParentArea().getChildAreas();
        for (int di = 0; di < 2; di++)
        {
            Area cand = findNeighbor(curArea, siblings, dirs[di], 0);
            if (cand == null)
                cand = findNeighbor(curArea, siblings, dirs[di], 1);
            if (cand != null && !cand.isSeparator() && areas.contains(cand)) //candidate found: join
            {
                //join the areas
                curArea.getBounds().expandToEnclose(cand.getBounds());
                curArea.appendChildren(cand.getChildAreas());
                cand.getParentArea().removeChild(cand);
                areas.remove(cand);
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:FitLayout,项目名称:PDFAnalyzer,代码行数:31,代码来源:SeparatorPairsOperator.java

示例9: computeIndentation

import org.fit.layout.model.Area; //导入依赖的package包/类
private double computeIndentation(Area area)
{
    /* TODO this must be completely rewritten for the new API
    final double max_levels = 3;
    final AreaTopology topo = area.getTopology();
    
    if (topo.getPreviousOnLine() != null)
        return computeIndentation(topo.getPreviousOnLine()); //use the indentation of the first one on the line
    else
    {
        double ind = max_levels;
        if (!node.isCentered() && area.getParentArea() != null)
            ind = ind - (topo.getPosition().getX1() - area.getParentArea().getTopology().getMinIndent());
        if (ind < 0) ind = 0;
        return ind / max_levels;
    }*/
    return 0;
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:19,代码来源:NodeStyle.java

示例10: 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)
{
    if (root.isBackgroundSeparated())
    {
        Color color = root.getBackgroundColor();

        if (color != null)
        {
            int key = colorKey(color);
            Integer val = colors.get(key);
            if (val == null) val = 0;
            val += root.getBounds().getArea();
            colors.put(key, val);
        }
    }
    
    for (int i = 0; i < root.getChildCount(); i++)
        computeRootStatistics(root.getChildArea(i));
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:24,代码来源:BackgroundColorAnalyzer.java

示例11: recursiveCheckAreas

import org.fit.layout.model.Area; //导入依赖的package包/类
private void recursiveCheckAreas(Area root)
{
    Set<String> names = new HashSet<String>();
    for (Tag tag : root.getTags().keySet())
    {
        if (srcType.equals(tag.getType()) || destType.equals(tag.getType()))
            names.add(tag.getValue());
    }
    for (String name : names)
    {
        checkTag(root, name);
    }
    
    for (int i = 0; i < root.getChildCount(); i++)
        recursiveCheckAreas(root.getChildArea(i));
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:17,代码来源:CompareTagsOperator.java

示例12: checkTag

import org.fit.layout.model.Area; //导入依赖的package包/类
private void checkTag(Area a, String name)
{
    Tag tsrc = new DefaultTag(srcType, name);
    Tag tdest = new DefaultTag(destType, name);
    boolean hasSrc = a.hasTag(tsrc);
    boolean hasDest = a.hasTag(tdest);
    if (hasSrc || hasDest)
        System.out.println("TAG;;" + a.getText() + ";;" + name );
    if (hasDest)
    {
        if (hasSrc) tp++; //true positive
        else fp++; //false positive
    }
    else
    {
        if (hasSrc) fn++; //false negative
        else tn++; //true negative
    }
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:20,代码来源:CompareTagsOperator.java

示例13: getMarkedness

import org.fit.layout.model.Area; //导入依赖的package包/类
/**
 * Computes the markedness of the area. The markedness generally describes the visual importance of the area based on different criteria.
 * @return the computed expressiveness
 */
public double getMarkedness(Area node)
{
    double fsz = node.getFontSize() / avgfont; //use relative font size, 0 is the normal font
    double fwt = node.getFontWeight();
    double fst = node.getFontStyle();
    double ind = getIndentation(node);
    double cen = isCentered(node) ? 1.0 : 0.0;
    double contrast = getContrast(node);
    double cp = 1.0 - ca.getColorPercentage(node);
    double bcp = bca.getColorPercentage(node);
    bcp = (bcp < 0.0) ? 0.0 : (1.0 - bcp);
    
    //weighting
    double exp = weights[WFSZ] * fsz 
                  + weights[WFWT] * fwt 
                  + weights[WFST] * fst 
                  + weights[WIND] * ind
                  + weights[WCON] * contrast
                  + weights[WCEN] * cen
                  + weights[WCP] * cp
                  + weights[WBCP] * bcp;
    
    return exp;
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:29,代码来源:ArticleFeatureExtractor.java

示例14: getIndentation

import org.fit.layout.model.Area; //导入依赖的package包/类
/**
 * Computes the indentation metric.
 * @return the indentation metric (0..1) where 1 is for the non-indented areas, 0 for the most indented areas.
 */
public double getIndentation(Area node)
{
    //TODO this must be completely rewritten for the new API
    /*
    final double max_levels = 3;
    
    if (node.getTopology().getPreviousOnLine() != null)
        return getIndentation(node.getTopology().getPreviousOnLine()); //use the indentation of the first one on the line
    else
    {
        double ind = max_levels;
        if (!isCentered(node) && node.getParentArea() != null)
            ind = ind - (node.getTopology().getPosition().getX1() - node.getParentArea().getTopology().getMinIndent());
        if (ind < 0) ind = 0;
        return ind / max_levels;
    }*/
    return 0;
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:23,代码来源:ArticleFeatureExtractor.java

示例15: 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;
    }
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:18,代码来源:ArticleFeatureExtractor.java


注:本文中的org.fit.layout.model.Area类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。