本文整理汇总了Java中edu.mit.blocks.codeblocks.rendering.BlockShapeUtil类的典型用法代码示例。如果您正苦于以下问题:Java BlockShapeUtil类的具体用法?Java BlockShapeUtil怎么用?Java BlockShapeUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockShapeUtil类属于edu.mit.blocks.codeblocks.rendering包,在下文中一共展示了BlockShapeUtil类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeBottomSide
import edu.mit.blocks.codeblocks.rendering.BlockShapeUtil; //导入依赖的package包/类
protected void makeBottomSide() {
//start bottom-right
setEndPoint(gpBottom, botLeftCorner, topLeftCorner, true);
//curve down and right
BlockShapeUtil.cornerTo(gpBottom, botLeftCorner, botRightCorner, blockCornerRadius);
/// CONTROL CONNECTOR
// Removing the isCommandBlock requirement for now because procedure block has an after connector
//if (block.isCommandBlock() && block.hasAfterConnector()) {
if (block.hasAfterConnector() && !rb.isCollapsed()) {
//control connector if necessary
// Trying left-aligned ports
Point2D p = BCS.addControlConnectorShape(gpBottom, (float) COMMAND_PORT_OFFSET + blockCornerRadius, true);
rb.updateSocketPoint(block.getAfterConnector(), p);
}
//curve right and up
BlockShapeUtil.cornerTo(gpBottom, botRightCorner, topRightCorner, blockCornerRadius);
//end bottom
setEndPoint(gpBottom, botRightCorner, topRightCorner, false);
}
示例2: makeTopSide
import edu.mit.blocks.codeblocks.rendering.BlockShapeUtil; //导入依赖的package包/类
protected void makeTopSide() {
//starting point of the block
//gpTop.moveTo((float) topLeftCorner.getX(), (float) topLeftCorner.getY() + blockCornerRadius);
setEndPoint(gpTop, topLeftCorner, botLeftCorner, true);
//curve up and right
BlockShapeUtil.cornerTo(gpTop, topLeftCorner, topRightCorner, blockCornerRadius);
//command socket if necessary
if (block.isCommandBlock() && block.hasBeforeConnector()) {
//params: path, distance to center of block, going right
// Old center-aligned ports
//Point2D p = BCS.addControlConnectorShape(gpTop, (float) topLeftCorner.distance(topRightCorner) / 2 - blockCornerRadius, true);
// Trying left-aligned ports for now
Point2D p = BCS.addControlConnectorShape(gpTop, (float) COMMAND_PORT_OFFSET + blockCornerRadius, true);
rb.updateSocketPoint(block.getBeforeConnector(), p);
}
//curve down
BlockShapeUtil.cornerTo(gpTop, topRightCorner, botRightCorner, blockCornerRadius);
//end topside
//gpTop.lineTo(blockBody.x + blockBody.width, blockBody.y + blockCornerRadius);
//gpTop.lineTo((float) topRightCorner.getX(), (float) topRightCorner.getY() + blockCornerRadius);
setEndPoint(gpTop, topRightCorner, botRightCorner, false);
}
示例3: 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);
}
示例4: 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;
}
示例5: updateBuffImg
import edu.mit.blocks.codeblocks.rendering.BlockShapeUtil; //导入依赖的package包/类
/**
* Redraws the entire buffer on a Graphics2D, called by paintCompnent() only
* if the buffer has been cleared.
*/
private void updateBuffImg() {
if (GraphicsEnvironment.isHeadless()) {
return;
}
// if label text has changed, then resync labels/sockets and reform
// shape
if (!synchronizeLabelsAndSockets()) {
reformBlockShape();// if updateLabels is true, we don't need to
// reform AGAIN
}
// create image
// note: need to add twice the highlight stroke width so that the
// highlight does not get cut off
GraphicsManager.recycleGCCompatibleImage(buffImg);
buffImg = GraphicsManager.getGCCompatibleImage(
blockArea.getBounds().width, blockArea.getBounds().height);
Graphics2D buffImgG2 = (Graphics2D) buffImg.getGraphics();
// update bounds of this renderableBlock as bounds of the shape
Dimension updatedDimensionRect = new Dimension(blockArea.getBounds()
.getSize());
// get size of block to determine size needed for bevel image
Image bevelImage = BlockShapeUtil.getBevelImage(
updatedDimensionRect.width, updatedDimensionRect.height,
blockArea);
// need antialiasing to remove color fill artifacts outside the bevel
buffImgG2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
// ADD BLOCK COLOR
Color blockColor = this.getBLockColor();
buffImgG2.setColor(blockColor);
buffImgG2.fill(blockArea);
// draw the bevel on the shape -- comment this line to not apply
// beveling
buffImgG2.drawImage(bevelImage, 0, 0, null);
// DRAW BLOCK IMAGES
repositionBlockImages(blockArea.getBounds().width,
blockArea.getBounds().height);
}
示例6: reformArea
import edu.mit.blocks.codeblocks.rendering.BlockShapeUtil; //导入依赖的package包/类
/**
* Reform the BlockShape area. This is the major procedure that makes all of the sides
* combines them in their correct directions, and connects them so they are all one direction.
* @return reformed Area of the BlockShape
*/
public Area reformArea() {
//hopefully reseting is less costly than creating new ones
gpTop.reset();
gpRight.reset();
gpBottom.reset();
gpLeft.reset();
setupDimensions();
//make all of the sides
makeTopSide();
makeRightSide();
makeBottomSide();
makeLeftSide();
//corrected (clockwise) left and bottom
gpBottomClockwise = new GeneralPath();
gpLeftClockwise = new GeneralPath();
gpBottomClockwise.moveTo((float) gpBottom.getCurrentPoint().getX(),
(float) gpBottom.getCurrentPoint().getY());
gpLeftClockwise.moveTo((float) gpLeft.getCurrentPoint().getX(),
(float) gpLeft.getCurrentPoint().getY());
BlockShapeUtil.appendPath(gpBottomClockwise, gpBottom, true);
BlockShapeUtil.appendPath(gpLeftClockwise, gpLeft, true);
//create direction specific paths
GeneralPath gpClockwise = new GeneralPath();
GeneralPath gpCounterClockwise = new GeneralPath();
//add to the direction specific paths
gpCounterClockwise.append(gpLeft, true);
gpCounterClockwise.append(gpBottom, true);
gpClockwise.append(gpTop, true);
gpClockwise.append(gpRight, true);
//connect so gpCounterClockwise is the full path
//it must be counter-clockwise for the bevel to be able to use it
BlockShapeUtil.appendPath(gpCounterClockwise, gpClockwise, true);
//convert it to an area
blockArea = new Area(gpCounterClockwise);
return blockArea;
}