当前位置: 首页>>代码示例>>Java>>正文


Java PositionType类代码示例

本文整理汇总了Java中edu.mit.blocks.codeblocks.BlockConnector.PositionType的典型用法代码示例。如果您正苦于以下问题:Java PositionType类的具体用法?Java PositionType怎么用?Java PositionType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PositionType类属于edu.mit.blocks.codeblocks.BlockConnector包,在下文中一共展示了PositionType类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateConnectors

import edu.mit.blocks.codeblocks.BlockConnector.PositionType; //导入依赖的package包/类
/**
 * Updates the conenctors of this stub according to its parent.
 * For now only caller stubs should update their connector information after 
 * being created.  
 */
private void updateConnectors() {
    Block parent = getParent();
    if (parent != null) {
        //retrieve sockets from parent and set sockets accordingly
        Iterator<BlockConnector> parentSockets = parent.getSockets().iterator();
        int i; //socket index
        //clear all sockets TODO temporary solution
        for (BlockConnector socket : getSockets()) {
            removeSocket(socket);
        }
        //add parent sockets
        for (i = 0; parentSockets.hasNext(); i++) {
            BlockConnector parentSocket = parentSockets.next();
            if (parentSocket.getBlockID() != Block.NULL) {
                //may need to add more sockets if parent has > 1 sockets
                if (i > this.getNumSockets() - 1) {
                    //socket labels should correspond with the socket blocks of parent
                    if (parentSocket.getBlockID() != Block.NULL) {
                        addSocket(parentSocket.getKind(), BlockConnector.PositionType.SINGLE, workspace.getEnv().getBlock(parentSocket.getBlockID()).getBlockLabel(), false, false, Block.NULL);
                    }
                } else {
                    BlockConnector con = getSocketAt(i);
                    this.setSocketAt(i, parentSocket.getKind(), con.getPositionType(), workspace.getEnv().getBlock(parentSocket.getBlockID()).getBlockLabel(), con.isLabelEditable(),
                            con.isExpandable(), con.getBlockID());
                }
            }
        }
    }
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:35,代码来源:BlockStub.java

示例2: updatePlug

import edu.mit.blocks.codeblocks.BlockConnector.PositionType; //导入依赖的package包/类
/**
 * Updates the plug type. Disconnects any invalid blocks. Only caller
 * stubs should use this method.
 * @param kind must not be null
 */
private void updatePlug(String kind) {
    if (hasPlug() && getPlugKind().equals(kind)) {
        return;
    }

    // We have to check for a before and after block.
    Long id = getBeforeBlockID();
    if (id != null && !id.equals(Block.NULL)) {
        disconnectBlock(id);
    }

    id = getAfterBlockID();
    if (id != null && !id.equals(Block.NULL)) {
        disconnectBlock(id);
    }

    // We also need to check the plug, because it may be connected to
    // the wrong type.
    id = getPlugBlockID();
    if (id != null && !id.equals(Block.NULL)) {
        disconnectBlock(id);
    }

    // Always synchronize! We can't have both a plug and a before.
    removeBeforeAndAfter();
    setPlug(kind, PositionType.SINGLE, kind, false, Block.NULL);
    workspace.getEnv().getRenderableBlock(getBlockID()).updateConnectors();
    notifyRenderable();
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:35,代码来源:BlockStub.java

示例3: setSocketAt

import edu.mit.blocks.codeblocks.BlockConnector.PositionType; //导入依赖的package包/类
/**
   * Replaces the socket at the specified index with the new specified parameters
   * @param index of the BlockConnector to replace
* @param isLabelEditable is true iff this BlockConnector can have its labels edited.
   * @return true if socket successfully replaced
   */
  public boolean setSocketAt(int index, String kind, PositionType pos, String label, boolean isLabelEditable, boolean isExpandable, Long blockID) {
      return sockets.set(index, new BlockConnector(workspace, kind, pos, label, isLabelEditable, isExpandable, blockID)) != null;
  }
 
开发者ID:heqichen,项目名称:openblocks,代码行数:10,代码来源:Block.java

示例4: addSocket

import edu.mit.blocks.codeblocks.BlockConnector.PositionType; //导入依赖的package包/类
/**
   * Adds another socket to this.  Socket is added to the "end" of socket list.
   * @param kind the socket kind of new socket
   * @param label the label of the new socket
   * @param positionType the BlockConnector.PositionType of the new connector
* @param isLabelEditable is true iff this BlockConnector can have its labels edited.
   * @param isExpandable true iff this connector can expand to another connector
   * @param blockID the block id of the block attached to new socket
   */
  public void addSocket(String kind, PositionType positionType, String label, boolean isLabelEditable, boolean isExpandable, Long blockID) {
      BlockConnector newSocket = new BlockConnector(workspace, kind, positionType, label, isLabelEditable, isExpandable, blockID);
      sockets.add(newSocket);
  }
 
开发者ID:heqichen,项目名称:openblocks,代码行数:14,代码来源:Block.java

示例5: setPlug

import edu.mit.blocks.codeblocks.BlockConnector.PositionType; //导入依赖的package包/类
/**
   * Sets the plug of this.
   * @param kind the socket kind of plug
   * @param label the label of the plug
   * @param positionType the BlockConnector.PositionType of this plug
* @param isLabelEditable is true iff this BlockConnector can have its labels edited.
   * @param blockID the block id of the block attached to plug
   */
  public void setPlug(String kind, PositionType positionType, String label, boolean isLabelEditable, Long blockID) {
      plug = new BlockConnector(workspace, kind, positionType, label, isLabelEditable, false, blockID);
  }
 
开发者ID:heqichen,项目名称:openblocks,代码行数:12,代码来源:Block.java


注:本文中的edu.mit.blocks.codeblocks.BlockConnector.PositionType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。