本文整理汇总了Java中org.eclipse.draw2d.geometry.PrecisionRectangle.setPreciseWidth方法的典型用法代码示例。如果您正苦于以下问题:Java PrecisionRectangle.setPreciseWidth方法的具体用法?Java PrecisionRectangle.setPreciseWidth怎么用?Java PrecisionRectangle.setPreciseWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.geometry.PrecisionRectangle
的用法示例。
在下文中一共展示了PrecisionRectangle.setPreciseWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: snapRectangle
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入方法依赖的package包/类
/**
* @see SnapToHelper#snapRectangle(Request, int, PrecisionRectangle,
* PrecisionRectangle)
*/
public int snapRectangle(Request request, int snapLocations,
PrecisionRectangle rect, PrecisionRectangle result) {
rect = rect.getPreciseCopy();
makeRelative(container.getContentPane(), rect);
PrecisionRectangle correction = new PrecisionRectangle();
makeRelative(container.getContentPane(), correction);
if (gridX > 0 && (snapLocations & EAST) != 0) {
correction.setPreciseWidth(correction.preciseWidth()
- localIEEEremainder(rect.preciseRight() - origin.x - 1,
gridX));
snapLocations &= ~EAST;
}
if ((snapLocations & (WEST | HORIZONTAL)) != 0 && gridX > 0) {
double leftCorrection = localIEEEremainder(rect.preciseX()
- origin.x, gridX);
correction.setPreciseX(correction.preciseX() - leftCorrection);
if ((snapLocations & HORIZONTAL) == 0) {
correction.setPreciseWidth(correction.preciseWidth()
+ leftCorrection);
}
snapLocations &= ~(WEST | HORIZONTAL);
}
if ((snapLocations & SOUTH) != 0 && gridY > 0) {
correction.setPreciseHeight(correction.preciseHeight()
- localIEEEremainder(rect.preciseBottom() - origin.y - 1,
gridY));
snapLocations &= ~SOUTH;
}
if ((snapLocations & (NORTH | VERTICAL)) != 0 && gridY > 0) {
double topCorrection = localIEEEremainder(rect.preciseY()
- origin.y, gridY);
correction.setPreciseY(correction.preciseY() - topCorrection);
if ((snapLocations & VERTICAL) == 0) {
correction.setPreciseHeight(correction.preciseHeight()
+ topCorrection);
}
snapLocations &= ~(NORTH | VERTICAL);
}
makeAbsolute(container.getContentPane(), correction);
result.setPreciseX(result.preciseX() + correction.preciseX());
result.setPreciseY(result.preciseY() + correction.preciseY());
result.setPreciseWidth(result.preciseWidth()
+ correction.preciseWidth());
result.setPreciseHeight(result.preciseHeight()
+ correction.preciseHeight());
return snapLocations;
}