• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BlockStub类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: makeNodeWithChildren

import edu.mit.blocks.codeblocks.BlockStub; //导入依赖的package包/类
public static BlockNode makeNodeWithChildren(Workspace workspace, Long blockID) {
    if (isNullBlockInstance(workspace, blockID)) {
        return null;
    }
    Block block = workspace.getEnv().getBlock(blockID);
    String genus = block.getGenusName();
    String parentGenus = block instanceof BlockStub ? ((BlockStub) block).getParentGenus() : null;
    String label;
    if (!block.labelMustBeUnique() || block instanceof BlockStub) {
        label = block.getBlockLabel();
    } else {
        label = null;
    }
    BlockNode node = new BlockNode(genus, parentGenus, label);
    for (BlockConnector socket : block.getSockets()) {
        if (socket.hasBlock()) {
            node.addChild(makeNodeWithStack(workspace, socket.getBlockID()));
        }
    }
    return node;
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:22,代码来源:BlockUtilities.java


示例2: makeNodeWithStack

import edu.mit.blocks.codeblocks.BlockStub; //导入依赖的package包/类
public static BlockNode makeNodeWithStack(Workspace workspace, Long blockID) {
    if (isNullBlockInstance(workspace, blockID)) {
        return null;
    }
    Block block = workspace.getEnv().getBlock(blockID);
    String genus = block.getGenusName();
    String parentGenus = block instanceof BlockStub ? ((BlockStub) block).getParentGenus() : null;
    String label;
    if (!block.labelMustBeUnique() || block instanceof BlockStub) {
        label = block.getBlockLabel();
    } else {
        label = null;
    }
    BlockNode node = new BlockNode(genus, parentGenus, label);
    for (BlockConnector socket : block.getSockets()) {
        if (socket.hasBlock()) {
            node.addChild(makeNodeWithStack(workspace, socket.getBlockID()));
        }
    }
    if (block.hasAfterConnector()) {
        node.setAfter(makeNodeWithStack(workspace, block.getAfterBlockID()));
    }
    return node;
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:25,代码来源:BlockUtilities.java


示例3: revertPoly

import edu.mit.blocks.codeblocks.BlockStub; //导入依赖的package包/类
/**
    * The initiation step. We first check that the initial connector (the connector that was disconnected)
    * is POLY and can be reverted. If we pass the check, we set the initial connector to its INITIAL TYPE.
    * If the block is PROC-RELATED, we stop the recursion. Otherwise, we use the initial connector as the
    * SETTER CONN to revert the other POLY connectors. Then we call recursion on connected blocks, with the
    * newly reverted POLY CONNs as SETTER CONNs.
    * 
    * (See "Reverting type specifics: " for details on why we need an initial round before recursion.)
    * 
 * @param polyBlock is the block containing the initial connector
 * @param polyConn is the initial connector
 */
private void revertPoly(Block polyBlock, BlockConnector polyConn) {
	// Check that we can revert the initial connector.
	if (!(isInitPoly(polyConn) && canRevertPolyConnectors(polyBlock, Block.NULL)))
		return;
	// Revert the initial to its INITIAL TYPE
	polyConn.setKind(polyConn.initKind());
	// Stop recursion if block is PROC-RELATED
    if (isProcRelated(polyBlock.getBlockID())) {
        polyBlock.notifyRenderable();
        if(polyBlock.hasStubs())
        	BlockStub.parentConnectorsChanged(workspace, polyBlock.getBlockID());
    }
    // Otherwise set all POLY connectors in the block and begin recursion
    else {
    	for (BlockConnector nextConn : getPolyConnectors(polyBlock)) {
    		revertPolyKind(nextConn,polyConn);
    		// Excludes initial connector, which doesn't have a connected block
    		if (nextConn.hasBlock())
    			revertPolyConnectors(nextConn,polyBlock.getBlockID());
    	}
    	polyBlock.notifyRenderable();
    }    
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:36,代码来源:PolyRule.java


示例4: staticdrawer

import edu.mit.blocks.codeblocks.BlockStub; //导入依赖的package包/类
private String staticdrawer(BlockStub stub) {
   for (FactoryCanvas canvas : this.staticCanvases) {
   	for (RenderableBlock bl : canvas.getBlocks()) {
   		if (bl.getGenus().equals(stub.getParentGenus())) {
   			return canvas.getName();
   		}
   	}
   }
return null;
  }
 
开发者ID:heqichen,项目名称:openblocks,代码行数:11,代码来源:FactoryManager.java


示例5: textChanged

import edu.mit.blocks.codeblocks.BlockStub; //导入依赖的package包/类
protected void textChanged(String text) {
    if ((this.labelType.equals(BlockLabel.Type.NAME_LABEL) || this.labelType.equals(BlockLabel.Type.PORT_LABEL))
            && workspace.getEnv().getBlock(blockID).isLabelEditable()) {
        if (this.labelType.equals(BlockLabel.Type.NAME_LABEL)) {
            workspace.getEnv().getBlock(blockID).setBlockLabel(text);
        }
        BlockConnector plug = workspace.getEnv().getBlock(blockID).getPlug();
        // Check if we're connected to a block. If we are and the the block we're connected to
        // has stubs, update them.
        if (plug != null && plug.getBlockID() != Block.NULL) {
            if (workspace.getEnv().getBlock(plug.getBlockID()) != null) {
                if (workspace.getEnv().getBlock(plug.getBlockID()).isProcedureDeclBlock()
                        && workspace.getEnv().getBlock(plug.getBlockID()).hasStubs()) {
                    // Blocks already store their socket names when saved so it is not necessary
                    // nor desired to call the connectors changed event again.
                    if (workspace.getEnv().getRenderableBlock(plug.getBlockID()).isLoading()) {
                        BlockStub.parentConnectorsChanged(workspace, plug.getBlockID());
                    }
                }
            }
        }
        RenderableBlock rb = workspace.getEnv().getRenderableBlock(blockID);
        if (rb != null) {
            workspace.notifyListeners(new WorkspaceEvent(workspace, rb.getParentWidget(), blockID, WorkspaceEvent.BLOCK_RENAMED));
        }
    }
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:28,代码来源:BlockLabel.java


示例6: finishLoad

import edu.mit.blocks.codeblocks.BlockStub; //导入依赖的package包/类
/**
   * After loading canvas, does a final sweep of all procedures to update
   * myProcInfo. It does this by going through each output block and seeing
   * if that output contributes any information to a procedure.
   * Then it updates the procedure's stubs if the procedure type changes.
   * 
   * Called after regular loading is finished (WorkspaceController.LoadSaveString()).
   * 
   * Updating myProcInfo depends on one crucial assumption:
   * The types of all outputs should be consistent because they were handled
   * prior to the original saving with the POM (so the loaded version is correct).
* Therefore, we DO NOT need to:
* 		change the types of empty output sockets
*		revert the types of incorrect output sockets
*		disconnect incorrect output types
   */
  public static void finishLoad() {
  	
  	// Create new output info for each procedure on the canvas.
  	for(Block p : workspace.getBlocksFromGenus("procedure")) {
  		myProcInfo.put(p.getBlockID(), new OutputInfo());
  	}
  	
  	// Update myProcInfo by checking each output.
  	for(Block b : workspace.getBlocksFromGenus("return")) {
  		// Only handle the output blocks that are connected to a procedure.
  		Long top = getTopBlockID(b.getBlockID());
  		if (top != null && workspace.getEnv().getBlock(top).isProcedureDeclBlock()) {
  			//System.out.println("procedure (top) number "+top);
  			OutputInfo info = myProcInfo.get(top);
  			
  			// Check that the output hasn't already been visited (shouldn't have but just to be safe...)
		if (!info.outputs.contains(b)) {
			
			// Change the procedure type if it has not been set and is not of the generic type poly.
  				if (info.type == null && !b.getSocketAt(0).getKind().equals("poly")) {
  					info.type = b.getSocketAt(0).getKind();
  					// Update stubs due to change in type
  					BlockStub.parentPlugChanged(workspace, top, info.type);
  				}
  				
  				// Increase the number of typed outputs (aka connected outputs without empty sockets).
  				if (b.getSocketAt(0).getBlockID() != -1) {
  					info.numTyped++;
  				}
  				
  				// Add all outputs that have not already been added (regardless of type or empty/nonempty sockets).
 					info.outputs.add(b.getBlockID());
 					
  			}
  			//System.out.println("numtyped "+info.numTyped+" type "+info.type);
  		}
  	}
  }
 
开发者ID:heqichen,项目名称:openblocks,代码行数:55,代码来源:ProcedureOutputManager.java


示例7: blocksDisconnected

import edu.mit.blocks.codeblocks.BlockStub; //导入依赖的package包/类
/**
 * When blocks are disconnected, update the proc stack and revert any
 * affected output blocks/callers.
 */
private static void blocksDisconnected(WorkspaceWidget w, Long socket, Long plug) {
    // Don't do anything if we're not in a procedure stack.
    Long top = getTopBlockID(socket);
    if (top == null || !workspace.getEnv().getBlock(top).isProcedureDeclBlock()) return;
    
    // Revert any output blocks in the disconnected stack. 
    OutputInfo info = myProcInfo.get(top);

    if (isOutput(workspace.getEnv().getBlock(socket)) && info.type != null) {
        // PolyRule reverts this to "poly" so we have to change it 
        // back to whatever type it should be.

        info.numTyped--;
        workspace.getEnv().getBlock(socket).getSocketAt(0).setKind(info.type);
        workspace.getEnv().getBlock(socket).notifyRenderable();
    }
    else
        revertType(workspace.getEnv().getBlock(plug), info, true);        
    
    // If there are no more connected blocks in this procedure, remove
    // the type and revert current output blocks.
    if (info.numTyped == 0) {
        info.type = null;
        revertType(workspace.getEnv().getBlock(top), info, false);
        BlockStub.parentPlugChanged(workspace, top, null);
    }
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:32,代码来源:ProcedureOutputManager.java


示例8: getParent

import edu.mit.blocks.codeblocks.BlockStub; //导入依赖的package包/类
/** Returns parent of stub, or null if parent does not exist or if b is not a stub. */
public static Block getParent(Block b) {
    if (b instanceof BlockStub) {
        Block parent = ((BlockStub) b).getParent();
        if (parent != null && 
        		workspace.getEnv().getRenderableBlock(parent.getBlockID()).getParentWidget() != null) 
        {
            return parent;
        }
    }
        
    return null;
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:14,代码来源:SLBlockProperties.java


示例9: getBlock

import edu.mit.blocks.codeblocks.BlockStub; //导入依赖的package包/类
/**
     * Returns a new RenderableBlock instance with the matching genusName.
     * New block will also have matching label is label is not-null. May return null.
     *
     * @param workspace The workspace to use
     * @param genusName
     * @param label
     *
     * @requires if block associated with genusName has a non editable
     * 			 or unique block label, then "label" MUST BE NULL.
     * @return  A new RenderableBlock with matching genusName and label (if label is not-null).
     * 			If no matching blocks were found, return null.
     */
    public static RenderableBlock getBlock(Workspace workspace, String genusName, String label) {
        if (genusName == null) {
            return null;
        }

//		find all blocks on the page and look for any match
        for (Block block : workspace.getBlocks()) {
            //make sure we're not dealing with null blocks
            if (block == null || block.getBlockID() == null || block.getBlockID().equals(Block.NULL)) {
                continue;
            }
            //find the block with matching genus and either a matching label or an editable label
            if (block.getGenusName().equals(genusName) && (block.isLabelEditable() || block.getBlockLabel().equals(label)
                    || block.isInfix())) {
                //for block stubs, need to make sure that the label matches because stubs of the same kind
                //(i.e. global var getters, agent var setters, etc.) have the same genusName
                //but stubs of different parents do not share the same label
                if (block instanceof BlockStub && !block.getBlockLabel().equals(label)) {
                    continue;
                }
                //create new renderable block instance
                RenderableBlock renderable = BlockUtilities.cloneBlock(block);
                //make sure renderable block is not a null instance of a block
                if (renderable == null || renderable.getBlockID().equals(Block.NULL)) {
                    throw new RuntimeException("Invariant Violated: a valid non null blockID just"
                            + "returned a null instance of RenderableBlock");
                    //please throw an exception here because it wouldn't make any sense
                    //if the Block is valid but it's associated RenderableBlock is not
                }
                //do not drop down default arguments
                renderable.ignoreDefaultArguments();
                //get corresponding block
                Block newblock = workspace.getEnv().getBlock(renderable.getBlockID());
                //make sure corresponding block is not a null instance of block
                if (newblock == null || newblock.getBlockID().equals(Block.NULL)) {
                    throw new RuntimeException("Invariant Violated: a valid non null blockID just"
                            + "returned a null instance of Block");
                    //please throw an exception here because it wouldn't make any sense
                    //if the Block is valid but it's associated RenderableBlock is not
                }
                //attempt to set the label text if possible as defined by the specs
                //should not set the labels of block stubs because their labels are determined by their parent
                if ((block.isLabelEditable() || block.getBlockLabel().equals(label))) {
                    if (label != null && !(block instanceof BlockStub)) {
                        if (newblock.isLabelEditable() && !newblock.labelMustBeUnique()) {
                            newblock.setBlockLabel(label);
                        }
                    }
                }
                //return renderable block
                return renderable;
            }



            /////////////////////////////////////
            //TODO: Add code here for nicknames//
            /////////////////////////////////////



        }
        //TODO: the part below is a hack. If there are other types of blocks, we need to account for them
        return null;
    }
 
开发者ID:heqichen,项目名称:openblocks,代码行数:79,代码来源:BlockUtilities.java


示例10: blocksConnected

import edu.mit.blocks.codeblocks.BlockStub; //导入依赖的package包/类
/**
 * When blocks are connected, check to see whether we are in a proc
 * stack. If so, check to see whether we should update the output type,
 * and if any existing blocks are affected by this change. 
 */
private static void blocksConnected(WorkspaceWidget w, Long socket, Long plug) {
    // Don't do anything if we're not in a procedure stack.
    Long top = getTopBlockID(socket);

    if (top == null || !workspace.getEnv().getBlock(top).isProcedureDeclBlock()) return;

    // If the proc stack already has a type, change all outputs in the
    // new part to that type and disconnect anything that doesn't fit.
    OutputInfo info = myProcInfo.get(top);
    List<WorkspaceEvent> events = new ArrayList<WorkspaceEvent>();
    Block b = workspace.getEnv().getBlock(socket);

    // If the block was added to an output block,
    // then b is the parent block (socket = output) and add is false.
    // else b is the current block (plug) and add is true.
    // in changeType, we check if b is type output before proceeding.
    boolean add = true;
    if (isOutput(b))
        add = false;    // don't add the output twice to the list
    else 
        b = workspace.getEnv().getBlock(plug);
    
    if (info.type != null)
        changeType(add, b, info.type, info, w, events);
    else {
        // Examine the type. If there is a type in the new portion of
        // the stack, reset all the previous output blocks to that type.
        examineType(add, b, info);
        if (info.type != null) {
            changeType(info, w, events);
            BlockStub.parentPlugChanged(workspace, top, info.type);
        }
    }
    
    // Fire events.
    if (!events.isEmpty()) {
        //WorkspaceController.getInstance().notifyListeners(events);
        for (WorkspaceEvent e : events) {
            workspace.notifyListeners(e);
        }
    }
    	
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:49,代码来源:ProcedureOutputManager.java


示例11: isProcedureCall

import edu.mit.blocks.codeblocks.BlockStub; //导入依赖的package包/类
/** returns true if "vm-command-name" property = "eval-procedure" */
public static boolean isProcedureCall(Block b) {
    return b != null && 
           CMD_EVAL_PROCEDURE.equals(b.getProperty(VM_COMMAND_NAME)) &&
           b instanceof BlockStub;
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:7,代码来源:SLBlockProperties.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GradientPanel类代码示例发布时间:2022-05-16
下一篇:
Java AuthenticationType类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap