本文整理汇总了Java中org.eclipse.draw2d.geometry.PrecisionRectangle.setPreciseX方法的典型用法代码示例。如果您正苦于以下问题:Java PrecisionRectangle.setPreciseX方法的具体用法?Java PrecisionRectangle.setPreciseX怎么用?Java PrecisionRectangle.setPreciseX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.geometry.PrecisionRectangle
的用法示例。
在下文中一共展示了PrecisionRectangle.setPreciseX方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doPrecisionAlignment
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入方法依赖的package包/类
private void doPrecisionAlignment(PrecisionRectangle result,
PrecisionRectangle reference) {
switch (alignment) {
case PositionConstants.LEFT:
result.setPreciseX(reference.preciseX());
break;
case PositionConstants.RIGHT:
result.setPreciseX(reference.preciseX() + reference.preciseWidth()
- result.preciseWidth());
break;
case PositionConstants.TOP:
result.setPreciseY(reference.preciseY());
break;
case PositionConstants.BOTTOM:
result.setPreciseY(reference.preciseY() + reference.preciseHeight()
- result.preciseHeight());
break;
case PositionConstants.CENTER:
result.setPreciseX(reference.preciseX()
+ (reference.preciseWidth() / 2)
- (result.preciseWidth() / 2));
break;
case PositionConstants.MIDDLE:
result.setPreciseY(reference.preciseY()
+ (reference.preciseHeight() / 2)
- (result.preciseHeight() / 2));
break;
}
}
示例2: 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;
}
示例3: snapPoint
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入方法依赖的package包/类
/**
* Applies a snapping correction to the given result. Snapping can occur in
* the four primary directions: NORTH, SOUTH, EAST, WEST, as defined on
* {@link PositionConstants}. By default a Point is treated as an empty
* Rectangle. Only NORTH and WEST should be used in general. But SOUTH and
* EAST may also be used. Similarly, VERTICAL and HORIZONTAL may be used to
* allow a point to snap to the "center" or "middle" as defined by the
* concrete subclass.
* <P>
* The returned value should be a subset of the given snapDirections based
* on what correction was applied to the result. e.g., if the <b>x</b> value
* was adjusted, the returned value should not contain WEST, EAST, or
* HORIZONTAL.
* <P>
* All coordinate information received and returned by this method should be
* in absolute coordinates.
*
* @param request
* a request or <code>null</code>
* @param snapDirections
* the directions in which snapping should occur.
* @param where
* the rectangle used to determine snapping
* @param result
* the result
* @return the remaining snap locations
*/
public int snapPoint(Request request, int snapDirections,
PrecisionPoint where, PrecisionPoint result) {
PrecisionRectangle rect = new PrecisionRectangle();
PrecisionRectangle resultRect = new PrecisionRectangle();
rect.setPreciseX(where.preciseX());
rect.setPreciseY(where.preciseY());
snapDirections = snapRectangle(request, snapDirections, rect,
resultRect);
result.setPreciseX(result.preciseX() + resultRect.preciseX());
result.setPreciseY(result.preciseY() + resultRect.preciseY());
return snapDirections;
}