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


Java Area.getParentArea方法代码示例

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


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

示例1: areaFontSize

import org.fit.layout.model.Area; //导入方法依赖的package包/类
private float areaFontSize(Area area)
{
    Area cur = area;
    float ret = cur.getFontSize();
    while (ret == 0.0f && cur.getParentArea() != null)
    {
        cur = cur.getParentArea();
        ret = cur.getFontSize();
    }
    return ret;
}
 
开发者ID:FitLayout,项目名称:PDFAnalyzer,代码行数:12,代码来源:RemapSeparatorsOperator.java

示例2: findCommonParent

import org.fit.layout.model.Area; //导入方法依赖的package包/类
private Area findCommonParent(Area a1, Area a2)
{
    if (a1.getParentArea() == a2.getParentArea())
        return a1.getParentArea();
    else
        return null;
}
 
开发者ID:FitLayout,项目名称:PDFAnalyzer,代码行数:8,代码来源:SeparatorPairsOperator.java

示例3: getEffectiveBackgroundColor

import org.fit.layout.model.Area; //导入方法依赖的package包/类
/**
 * Computes the effective (visible) background color of an area considering
 * transparency and parent areas.
 * @param area The area
 * @return the visible background color
 */
public static Color getEffectiveBackgroundColor(Area area)
{
    if (area.getBackgroundColor() != null)
        return area.getBackgroundColor();
    else
    {
        if (area.getParentArea() != null)
            return getEffectiveBackgroundColor(area.getParentArea());
        else
            return Color.WHITE; //use white as the default root color
    }
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:19,代码来源:BackgroundColorAnalyzer.java

示例4: countAreasAbove

import org.fit.layout.model.Area; //导入方法依赖的package包/类
private int countAreasAbove(Area a)
{
    Area parent = a.getParentArea();
    if (parent != null)
    {
        Rectangular gp = parent.getTopology().getPosition(a);
        Rectangular r = new Rectangular(gp.getX1(), 0, gp.getX2(), gp.getY1() - 1);
        return countAreas(parent, r);
    }
    else
        return 0;
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:13,代码来源:ArticleFeatureExtractor.java

示例5: countAreasBelow

import org.fit.layout.model.Area; //导入方法依赖的package包/类
private int countAreasBelow(Area a)
{
    Area parent = a.getParentArea();
    if (parent != null)
    {
        Rectangular gp = parent.getTopology().getPosition(a);
        Rectangular r = new Rectangular(gp.getX1(), gp.getY2()+1, gp.getX2(), Integer.MAX_VALUE);
        return countAreas(parent, r);
    }
    else
        return 0;
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:13,代码来源:ArticleFeatureExtractor.java

示例6: countAreasLeft

import org.fit.layout.model.Area; //导入方法依赖的package包/类
private int countAreasLeft(Area a)
{
    Area parent = a.getParentArea();
    if (parent != null)
    {
        Rectangular gp = parent.getTopology().getPosition(a);
        Rectangular r = new Rectangular(0, gp.getY1(), gp.getX1() - 1, gp.getY2());
        return countAreas(parent, r);
    }
    else
        return 0;
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:13,代码来源:ArticleFeatureExtractor.java

示例7: countAreasRight

import org.fit.layout.model.Area; //导入方法依赖的package包/类
private int countAreasRight(Area a)
{
    Area parent = a.getParentArea();
    if (parent != null)
    {
        Rectangular gp = parent.getTopology().getPosition(a);
        Rectangular r = new Rectangular(gp.getX2()+1, gp.getY1(), Integer.MAX_VALUE, gp.getY2());
        return countAreas(parent, r);
    }
    else
        return 0;
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:13,代码来源:ArticleFeatureExtractor.java

示例8: removeSeparator

import org.fit.layout.model.Area; //导入方法依赖的package包/类
private void removeSeparator(Area sep)
{
    final Area parent = sep.getParentArea();
    if (parent != null)
        parent.removeChild(sep);
}
 
开发者ID:FitLayout,项目名称:PDFAnalyzer,代码行数:7,代码来源:RemapSeparatorsOperator.java

示例9: isCentered

import org.fit.layout.model.Area; //导入方法依赖的package包/类
/**
 * Tries to guess whether the area is horizontally centered within its parent area 
 * @param askBefore may we compare the alignment with the preceding siblings?
 * @param askAfter may we compare the alignment with the following siblings?
 * @return 0 when certailny not centered, 1 when certainly centered, 2 when not sure (nothing to compare with and no margins around)
 */
private int isCentered(Area area, boolean askBefore, boolean askAfter)
{
    Area parent = area.getParentArea();
    if (parent != null)
    {
        int left = area.getX1() - parent.getX1();
        int right = parent.getX2() - area.getX2();
        int limit = (int) (((left + right) / 2.0) * CENTERING_THRESHOLD);
        if (limit == 0) limit = 1; //we always allow +-1px
        //System.out.println(this + " left=" + left + " right=" + right + " limit=" + limit);
        boolean middle = Math.abs(left - right) <= limit; //first guess - check if it is placed in the middle
        boolean fullwidth = left == 0 && right == 0; //centered because of full width
        
        if (!middle && !fullwidth) //not full width and certainly not in the middle
        {
            return 0; 
        }
        else //may be centered - check the alignment
        {
            //compare the alignent with the previous and/or the next child
            Area prev = null;
            Area next = null;
            int pc = 2; //previous centered?
            int nc = 2; //next cenrered?
            if (askBefore || askAfter)
            {
                if (askBefore)
                {
                    prev = area.getPreviousSibling();
                    while (prev != null && (pc = isCentered(prev, true, false)) == 2)
                        prev = prev.getPreviousSibling();
                }
                if (askAfter)
                {
                    next = area.getNextSibling();
                    while (next != null && (nc = isCentered(next, false, true)) == 2)
                        next = next.getNextSibling();
                }
            }
            
            if (pc != 2 || nc != 2) //we have something for comparison
            {
                if (fullwidth) //cannot guess, compare with others
                {
                    if (pc != 0 && nc != 0) //something around is centered - probably centered
                        return 1;
                    else
                        return 0;
                }
                else //probably centered, if it is not left- or right-aligned with something around
                {
                    if (prev != null && lrAligned(area, prev) == 1 ||
                        next != null && lrAligned(area, next) == 1)
                        return 0; //aligned, not centered
                    else
                        return 1; //probably centered
                }
            }
            else //nothing to compare, just guess
            {
                if (fullwidth)
                    return 2; //cannot guess from anything
                else
                    return (middle ? 1 : 0); //nothing to compare with - guess from the position
            }
        }
    }
    else
        return 2; //no parent - we don't know
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:77,代码来源:ArticleFeatureExtractor.java


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