本文整理汇总了Java中edu.mit.blocks.codeblocks.rendering.BlockShapeUtil.lineToRelative方法的典型用法代码示例。如果您正苦于以下问题:Java BlockShapeUtil.lineToRelative方法的具体用法?Java BlockShapeUtil.lineToRelative怎么用?Java BlockShapeUtil.lineToRelative使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.mit.blocks.codeblocks.rendering.BlockShapeUtil
的用法示例。
在下文中一共展示了BlockShapeUtil.lineToRelative方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendConnectorOffset
import edu.mit.blocks.codeblocks.rendering.BlockShapeUtil; //导入方法依赖的package包/类
/**
* Appends an offset to a general path that makes up the side of a block.
*/
private void appendConnectorOffset(GeneralPath gp, Point2D topPoint, Point2D botPoint,
BlockConnector blockConnector, boolean aboveConnector) {
//if top and bottom are equal, then no offset necessary
if (topPoint.getX() == botPoint.getX()) {
return;
}
//if top further right than bottom, then Xdiff is positive
double Xdiff = topPoint.getX() - botPoint.getX();
//absolute distance
double Ydiff = Math.abs(topPoint.getY() - botPoint.getY());
//check to only offset correctly above or below the connector:
//offset only above connectors on right slanting sides
if (Xdiff > 0 && !aboveConnector) {
return;
}
//offset only below connectors on left slanting sides
if (Xdiff < 0 && aboveConnector) {
return;
}
//get fraction by dividing connector height by total height of the side
double fraction = BlockConnectorShape.getConnectorDimensions(blockConnector).getHeight() / Ydiff;
double insetDist = Xdiff * fraction;
//if top further out, then inset left - else move right
BlockShapeUtil.lineToRelative(gp, (float) -insetDist, 0);
}
示例2: addCommandSocket
import edu.mit.blocks.codeblocks.rendering.BlockShapeUtil; //导入方法依赖的package包/类
public Point2D addCommandSocket(GeneralPath blockPath, int commandSocketHeight) {
//draw bar
BlockShapeUtil.lineToRelative(blockPath, COMMAND_INPUT_BAR_WIDTH, 0);
BlockShapeUtil.lineToRelative(blockPath, 0, COMMAND_INPUT_BAR_HEIGHT);
Point2D socketPoint = addControlConnectorShape(blockPath, false);
//first corner inside command input
BlockShapeUtil.cornerTo(blockPath,
new Point2D.Float(
(float) blockPath.getCurrentPoint().getX() - COMMAND_INPUT_BAR_WIDTH + BlockShape.CORNER_RADIUS,
(float) blockPath.getCurrentPoint().getY()),
new Point2D.Float(
(float) blockPath.getCurrentPoint().getX() - COMMAND_INPUT_BAR_WIDTH + BlockShape.CORNER_RADIUS,
(float) blockPath.getCurrentPoint().getY() + BlockShape.CORNER_RADIUS),
BlockShape.CORNER_RADIUS);
//insert dynamic command input height between these two methods
BlockShapeUtil.lineToRelative(blockPath, 0, commandSocketHeight);
//second corner at bottom of command input
BlockShapeUtil.cornerTo(blockPath,
new Point2D.Float(
(float) blockPath.getCurrentPoint().getX(),
(float) blockPath.getCurrentPoint().getY() + BlockShape.CORNER_RADIUS),
new Point2D.Float(
(float) blockPath.getCurrentPoint().getX() + BlockShape.CORNER_RADIUS,
(float) blockPath.getCurrentPoint().getY() + BlockShape.CORNER_RADIUS),
BlockShape.CORNER_RADIUS);
//extend left to match y coordinate of initial point
BlockShapeUtil.lineToRelative(blockPath, CONTROL_PLUG_WIDTH / 2, 0);
return socketPoint;
}