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


Java Area.getX2方法代码示例

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


在下文中一共展示了Area.getX2方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getRelX

import org.fit.layout.model.Area; //导入方法依赖的package包/类
private double getRelX(Area a)
{
    int objx1 = a.getX1();
    if (objx1 < 0) objx1 = 0;
    int objx2 = a.getX2();
    if (objx2 < 0) objx2 = 0;
    
    int topx1 = root.getX1();
    if (topx1 < 0) topx1 = 0;
    int topx2 = root.getX2();
    if (topx2 < 0) topx2 = 0;
    
    double midw = (objx2 - objx1) / 2.0;
    double topx = topx1 + midw; //zacatek oblasti, kde lze objektem posunovat
    double midx = (objx1 + objx2) / 2.0 - topx; //stred objektu v ramci teto oblasti
    double topw = (topx2 - topx1) - (objx2 - objx1); //sirka, kam lze stredem posunovat
    return midx / topw;
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:19,代码来源:ArticleFeatureExtractor.java

示例3: lrAligned

import org.fit.layout.model.Area; //导入方法依赖的package包/类
/**
 * Checks if the areas are left- or right-aligned.
 * @return 0 if not, 1 if yes, 2 if both left and right
 */
private int lrAligned(Area a1, Area a2)
{
    if (a1.getX1() == a2.getX1())
        return (a1.getX2() == a2.getX2()) ? 2 : 1;
    else if (a1.getX2() == a2.getX2())
        return 1;
    else
        return 0;
}
 
开发者ID:FitLayout,项目名称:classify,代码行数:14,代码来源:ArticleFeatureExtractor.java

示例4: 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.getX2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。