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


Java BlockLinkChecker.getSocketEquivalents方法代码示例

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


在下文中一共展示了BlockLinkChecker.getSocketEquivalents方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeBlock

import edu.mit.blocks.codeblocks.BlockLinkChecker; //导入方法依赖的package包/类
/**
 *
 * @param renderable
 * @param widget
 * @param container
 *
 * @requires renderable != null && renderable.blockID != null && renderable.blockID != Block.NULL
 * 			 && widget != null && container != null
 * @modifies renderable && children blocks connected to renderable
 * @effects removes renderable from container and widget and re-renders
 * 			renderable block, widget, and container appropriately.
 * 			Repeats for all of renderable's children.
 */
private void removeBlock(RenderableBlock renderable, WorkspaceWidget widget, Container container) {
    widget.removeBlock(renderable);
    container.remove(renderable);
    container.validate();
    container.repaint();
    renderable.setParentWidget(null);
    //Workspace.getInstance().notifyListeners(new WorkspaceEvent(widget, renderable.getBlockID(), WorkspaceEvent.BLOCK_REMOVED));
    for (BlockConnector child : BlockLinkChecker.getSocketEquivalents(workspace.getEnv().getBlock(renderable.getBlockID()))) {
        if (child == null || child.getBlockID().equals(Block.NULL)) {
            continue;
        }
        RenderableBlock childRenderable = workspace.getEnv().getRenderableBlock(child.getBlockID());
        if (childRenderable == null) {
            continue;
        }
        removeBlock(childRenderable, widget, container);
    }
    if (renderable.hasComment()) {
        renderable.removeComment();
    }
    workspace.notifyListeners(new WorkspaceEvent(workspace, widget, renderable.getBlockID(), WorkspaceEvent.BLOCK_REMOVED));
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:36,代码来源:TypeBlockManager.java

示例2: startDragging

import edu.mit.blocks.codeblocks.BlockLinkChecker; //导入方法依赖的package包/类
private void startDragging(RenderableBlock renderable,
		WorkspaceWidget widget) {
	renderable.pickedUp = true;
	renderable.lastDragWidget = widget;
	if (renderable.hasComment()) {
		renderable.comment.setConstrainComment(false);
	}
	Component oldParent = renderable.getParent();
	Workspace workspace = renderable.getWorkspace();
	workspace.addToBlockLayer(renderable);
	renderable.setLocation(SwingUtilities.convertPoint(oldParent,
			renderable.getLocation(), workspace));
	renderable.setHighlightParent(workspace);
	for (BlockConnector socket : BlockLinkChecker
			.getSocketEquivalents(workspace.getEnv().getBlock(
					renderable.blockID))) {
		if (socket.hasBlock()) {
			startDragging(
					workspace.getEnv().getRenderableBlock(
							socket.getBlockID()), widget);
		}
	}
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:24,代码来源:RenderableBlock.java

示例3: findStackType

import edu.mit.blocks.codeblocks.BlockLinkChecker; //导入方法依赖的package包/类
private String findStackType(Long topID, Long startID, String currentType) {
	if (startID == Block.NULL)
		return "";
	topBlock.put(startID, topID);
	Block b = workspace.getEnv().getBlock(startID);
	String type = b.getProperty("stack-type");
	if (type != null && type.length() > currentType.length())
		currentType = type;
	BlockConnector inlineSocket = getInlineStackSocket(b);
	for (BlockConnector socket : BlockLinkChecker.getSocketEquivalents(b)) {
		if (socket == inlineSocket && socket.hasBlock()) {
			long blockID = socket.getBlockID();
			stackType.put(blockID, findStackType(blockID, blockID, b.getProperty("inline-stack-type")));
		}
		else {
			type = findStackType(topID, socket.getBlockID(), currentType);
			if (type.length() > currentType.length())
				currentType = type;
		}
	}
	return currentType;
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:23,代码来源:StackRule.java

示例4: redrawFromTop

import edu.mit.blocks.codeblocks.BlockLinkChecker; //导入方法依赖的package包/类
/**
 * Redraws this RenderableBlock along with the RenderableBlocks after it,
 * which include after and socket blocks. In other words, this method
 * redraws the stack of blocks that begin with this. NOTE: this is
 * inefficient, should only use this if needed NOTE: Must call this after
 * loading of blocks to update the socket dimensions of this and set the
 * isLoading flag to false
 */
public void redrawFromTop() {
	if (GraphicsEnvironment.isHeadless()) {
		return;
	}

	isLoading = false;
	for (BlockConnector socket : BlockLinkChecker
			.getSocketEquivalents(getBlock())) {

		if (socket.hasBlock()) {
			// loop through all the afters of the connected block
			long curBlockID = socket.getBlockID();
			// TODO: this is a patch, but we need to fix the root of the
			// problem!
			if (workspace.getEnv().getRenderableBlock(curBlockID) == null) {
				System.out.println("does not exist yet, block: "
						+ curBlockID);
				continue;
			}

			workspace.getEnv().getRenderableBlock(curBlockID)
					.redrawFromTop();

			// add dimension to the mapping
			this.getConnectorTag(socket).setDimension(
					calcDimensionOfSocket(socket));
		} else {
			this.getConnectorTag(socket).setDimension(null);
		}
	}

	// reform shape with new socket dimension
	reformBlockShape();
	// next time, redraw with new positions and moving children blocks
	clearBufferedImage();
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:45,代码来源:RenderableBlock.java

示例5: stopDragging

import edu.mit.blocks.codeblocks.BlockLinkChecker; //导入方法依赖的package包/类
/**
 * This method is called when this RenderableBlock is plugged into another
 * RenderableBlock that has finished dragging.
 * 
 * @param widget
 *            the WorkspaceWidget where this RenderableBlock is being
 *            dropped.
 */
public static void stopDragging(RenderableBlock renderable,
		WorkspaceWidget widget) {
	if (!renderable.dragging) {
		throw new RuntimeException("dropping without prior dragging?");
	}
	// notify children
	for (BlockConnector socket : BlockLinkChecker
			.getSocketEquivalents(renderable.getBlock())) {
		if (socket.hasBlock()) {
			stopDragging(renderable.getWorkspace().getEnv()
					.getRenderableBlock(socket.getBlockID()), widget);
		}
	}
	// drop this block on its widget (if w is null it'll throw an exception)
	widget.blockDropped(renderable);
	// stop rendering as transparent
	renderable.dragging = false;
	// move comment
	if (renderable.hasComment()) {
		if (renderable.getParentWidget() != null) {
			renderable.comment.setParent(renderable.getParentWidget()
					.getJComponent(), 0);
		} else {
			renderable.comment.setParent(null, renderable.getBounds());
		}

		renderable.comment.setConstrainComment(true);
		renderable.comment.setLocation(renderable.comment.getLocation());
		renderable.comment.getArrow().updateArrow();
	}
// When dragging, Child blocks can become mis-aligned to their Parent Block which is very annoying
// I can't stop this happening, nor work out why it happens.
// This is just a quick 'fix' to stop things looking too bad
renderable.moveConnectedBlocks();
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:44,代码来源:RenderableBlock.java

示例6: drag

import edu.mit.blocks.codeblocks.BlockLinkChecker; //导入方法依赖的package包/类
private void drag(RenderableBlock renderable, int dx, int dy,
		WorkspaceWidget widget, boolean isTopLevelBlock) {
	if (!renderable.pickedUp) {
		throw new RuntimeException("dragging without prior pickup");
	}
	// mark this as being dragged
	renderable.dragging = true;
	// move the block by drag amount
	if (!isTopLevelBlock) {
		renderable.setLocation(renderable.getX() + dx, renderable.getY()
				+ dy);
	}
	// send blockEntered/blockExited/blogDragged as appropriate
	if (widget != null) {
		if (!widget.equals(renderable.lastDragWidget)) {
			widget.blockEntered(renderable);
			if (renderable.lastDragWidget != null) {
				renderable.lastDragWidget.blockExited(renderable);
			}
		}
		widget.blockDragged(renderable);
		renderable.lastDragWidget = widget;
	}

	// translate highlight along with the block - this would happen
	// automatically,
	// but putting the call here takes out any lag.
	renderable.highlighter.repaint();
	// Propagate the drag event to anything plugged into this block
	for (BlockConnector socket : BlockLinkChecker
			.getSocketEquivalents(renderable.getBlock())) {
		if (socket.hasBlock()) {
			drag(workspace.getEnv().getRenderableBlock(socket.getBlockID()),
					dx, dy, widget, false);
		}
	}
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:38,代码来源:RenderableBlock.java

示例7: moveConnectedBlocks

import edu.mit.blocks.codeblocks.BlockLinkChecker; //导入方法依赖的package包/类
/**
 * Aligns all RenderableBlocks plugged into this one with the current
 * location of this RenderableBlock. These RenderableBlocks to move include
 * blocks connected at sockets and the after connector.
 */
public void moveConnectedBlocks() {
	if (DEBUG) {
		System.out.println("move connected blocks of this: " + this);
	}

	// if this hasn't been added anywhere, asking its location will break
	// stuff
	if (getParent() == null) {
		return;
	}

	Block b = workspace.getEnv().getBlock(blockID);
	Point socketLocation;
	Point plugLocation;
	RenderableBlock rb;
	Point myScreenOffset = getLocation();
	Point otherScreenOffset;
	for (BlockConnector socket : BlockLinkChecker.getSocketEquivalents(b)) {
		socketLocation = getSocketPixelPoint(socket);
		if (socket.hasBlock()) {
			rb = workspace.getEnv().getRenderableBlock(socket.getBlockID());

			// TODO: djwendel - this is a patch, but the root of the problem
			// needs to be found and fixed!!
			if (rb == null) {
				System.out.println("Block doesn't exist yet: "
						+ socket.getBlockID());
				continue;
			}

			plugLocation = rb.getSocketPixelPoint(BlockLinkChecker
					.getPlugEquivalent(workspace.getEnv().getBlock(
							socket.getBlockID())));
			otherScreenOffset = SwingUtilities.convertPoint(rb.getParent(),
					rb.getLocation(), getParent());
			otherScreenOffset.translate(-rb.getX(), -rb.getY());
			rb.setLocation(
					(int) Math.round((float) myScreenOffset.getX()
							+ socketLocation.getX()
							- (float) otherScreenOffset.getX()
							- plugLocation.getX()),
					(int) Math.round((float) myScreenOffset.getY()
							+ socketLocation.getY()
							- (float) otherScreenOffset.getY()
							- plugLocation.getY()));

			rb.moveConnectedBlocks();
		}
	}
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:56,代码来源:RenderableBlock.java


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