本文整理汇总了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;
}
示例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;
}
示例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
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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
}