diff --git a/src/main/java/edu/mit/blocks/codeblocks/InfixBlockShape.java b/src/main/java/edu/mit/blocks/codeblocks/InfixBlockShape.java index a849561a97b37ff5fc1d00212d3e546208499d08..77c09da0b18977319eb41387d4378aa9bee7f6d2 100644 --- a/src/main/java/edu/mit/blocks/codeblocks/InfixBlockShape.java +++ b/src/main/java/edu/mit/blocks/codeblocks/InfixBlockShape.java @@ -43,13 +43,19 @@ public class InfixBlockShape extends BlockShape { //curve down and right BlockShapeUtil.cornerTo(gpBottom, botLeftCorner, botRightCorner, blockCornerRadius); - + //added by letsgoING for new setVariableBlock test + 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); + } /// BOTTOM SOCKETS //for each socket in the iterator int socketCounter = 0; //need to use this to determine which socket we're on for (BlockConnector curSocket : block.getSockets()) { - + //if bottom socket if (curSocket.getPositionType() == BlockConnector.PositionType.BOTTOM) { @@ -58,17 +64,22 @@ public class InfixBlockShape extends BlockShape { gpBottom.lineTo( (float) gpBottom.getCurrentPoint().getX() + BOTTOM_SOCKET_MIDDLE_SPACER, (float) gpBottom.getCurrentPoint().getY()); - } else { + } else if(block.isCommandBlock()) { //TODO: check //added by letsgoING for new setVariableBlock test gpBottom.lineTo( (float) gpBottom.getCurrentPoint().getX() + BOTTOM_SOCKET_SIDE_SPACER, (float) gpBottom.getCurrentPoint().getY()); + } else { + gpBottom.lineTo( + (float) gpBottom.getCurrentPoint().getX() + BOTTOM_SOCKET_SIDE_SPACER , + (float) gpBottom.getCurrentPoint().getY()); } - + //move down so bevel doesn't screw up from connecting infinitely sharp corner // as occurs from a curved port BlockShapeUtil.lineToRelative(gpBottom, 0, -0.1f); + ////////////////////// //begin drawing socket ////////////////////// @@ -232,27 +243,46 @@ public class InfixBlockShape extends BlockShape { //System.out.println("determining block width"); int width = super.determineBlockWidth(); - - //if the sum of bottom sockets is greater than the calculated width, then use it + int bottomSocketWidth = 0; - for (BlockConnector socket : block.getSockets()) { - if (socket.getPositionType() == BlockConnector.PositionType.BOTTOM) { - if (socket.getBlockID() == Block.NULL) { - //3 socket spacers = left of socket, between connectors, right of socket - bottomSocketWidth += BOTTOM_SOCKET_SIDE_SPACER; - } else { //a block is connected to socket - //TODO get their assigned width from rb - if (rb.getSocketSpaceDimension(socket) != null) { - bottomSocketWidth += rb.getSocketSpaceDimension(socket).width; - } - bottomSocketWidth -= BlockConnectorShape.NORMAL_DATA_PLUG_WIDTH; - // if it's a mirror plug, subtract for the other side, too. - if (rb.getWorkspace().getEnv().getBlock(socket.getBlockID()).getPlug().getPositionType() == BlockConnector.PositionType.MIRROR) { - bottomSocketWidth -= BlockConnectorShape.NORMAL_DATA_PLUG_WIDTH; + + //added by letsgoING for new setVariableBlock test + if (block.isCommandBlock()) { + for (BlockConnector socket : block.getSockets()) { + if (socket.getPositionType() == BlockConnector.PositionType.BOTTOM) { + if (socket.getBlockID() == Block.NULL) { + //3 socket spacers = left of socket, between connectors, right of socket + bottomSocketWidth += BOTTOM_SOCKET_SIDE_SPACER + BOTTOM_SOCKET_MIDDLE_SPACER; + } else { //a block is connected to socket + //TODO get their assigned width from rb + if (rb.getSocketSpaceDimension(socket) != null) { + bottomSocketWidth += rb.getSocketSpaceDimension(socket).width; + } } } } } + //if the sum of bottom sockets is greater than the calculated width, then use it + else { + for (BlockConnector socket : block.getSockets()) { + if (socket.getPositionType() == BlockConnector.PositionType.BOTTOM) { + if (socket.getBlockID() == Block.NULL) { + //3 socket spacers = left of socket, between connectors, right of socket + bottomSocketWidth += BOTTOM_SOCKET_SIDE_SPACER; + } else { //a block is connected to socket + //TODO get their assigned width from rb + if (rb.getSocketSpaceDimension(socket) != null) { + bottomSocketWidth += rb.getSocketSpaceDimension(socket).width; + } + bottomSocketWidth -= BlockConnectorShape.NORMAL_DATA_PLUG_WIDTH; + // if it's a mirror plug, subtract for the other side, too. + if (rb.getWorkspace().getEnv().getBlock(socket.getBlockID()).getPlug().getPositionType() == BlockConnector.PositionType.MIRROR) { + bottomSocketWidth -= BlockConnectorShape.NORMAL_DATA_PLUG_WIDTH; + } + } + } + } + } bottomSocketWidth += 2 * BOTTOM_SOCKET_MIDDLE_SPACER; //TODO need to decide for a size of the middle spacer and how to place them diff --git a/src/main/java/edu/mit/blocks/renderable/NameLabel.java b/src/main/java/edu/mit/blocks/renderable/NameLabel.java index 75ca66dbfd98b5225222330937e7407da569346f..6b4f14b34d85e496273fed921f87ec410ca86afa 100644 --- a/src/main/java/edu/mit/blocks/renderable/NameLabel.java +++ b/src/main/java/edu/mit/blocks/renderable/NameLabel.java @@ -34,11 +34,20 @@ class NameLabel extends BlockLabel { x += 4 + BlockConnectorShape.getConnectorDimensions(rb.getBlock().getPlug()).width; } if (rb.getBlock().isInfix()) { - if (!rb.getBlock().getSocketAt(0).hasBlock()) { - x += 30; - } else { - x += rb.getSocketSpaceDimension(rb.getBlock().getSocketAt(0)).width; - } + //added by letsgoING for new setVariableBlock test + if(rb.getBlock().isCommandBlock()) { + if (!rb.getBlock().getSocketAt(0).hasBlock()) { + x += 60; + } else { + x += rb.getSocketSpaceDimension(rb.getBlock().getSocketAt(0)).width+30; + } + }else { + if (!rb.getBlock().getSocketAt(0).hasBlock()) { + x += 30; + } else { + x += rb.getSocketSpaceDimension(rb.getBlock().getSocketAt(0)).width; + } + } } if (rb.getBlockWidget() == null) {