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


Java BlockNode类代码示例

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


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

示例1: pasteStack

import edu.mit.blocks.renderable.BlockNode; //导入依赖的package包/类
private void pasteStack(BlockNode node) {
//		====================>>>>>>>>>>>>>>>>>>>>>>>>>
//		====================focus coming in>>>>>>>>>> TODO
//		====================>>>>>>>>>>>>>>>>>>>>>>>>>
        if (node == null) {
            return;
        }
        WorkspaceWidget widget = null;
        Iterable<WorkspaceWidget> widgets = null;
        Point spot = null;
        if (invalidBlockID(focusManager.getFocusBlockID())) {
            //canvas has focus
            Point location = SwingUtilities.convertPoint(
                    this.blockCanvas.getCanvas(),
                    this.focusManager.getCanvasPoint(),
                    workspace);
            widget = workspace.getWidgetAt(location);
            spot = SwingUtilities.convertPoint(
                    this.blockCanvas.getCanvas(),
                    this.focusManager.getCanvasPoint(),
                    widget.getJComponent());
        } else {
            RenderableBlock focusRenderable = workspace.getEnv().getRenderableBlock(focusManager.getFocusBlockID());
            widget = focusRenderable.getParentWidget();
            spot = focusRenderable.getLocation();
        }

        if (widget == null) {
            // TODO: To be examined and fixed, occurs on macs
            JOptionPane.showMessageDialog(frame, "Please click somewhere on the canvas first.",
                    "Error", JOptionPane.PLAIN_MESSAGE);
            //throw new RuntimeException("Why are we adding a block to a null widget?");
        } else {
            // checks to see if the copied block still exists
            if (BlockUtilities.blockExists(workspace, node)) {
                //create mirror block and mirror childrens
                spot.translate(10, 10);
                RenderableBlock mirror = BlockUtilities.makeRenderable(workspace, node, widget);
                mirror.setLocation(spot);
                mirror.moveConnectedBlocks(); // make sure the childrens are placed correctly
            } else {
                //TODO: future version, allow them to paste
                JOptionPane.showMessageDialog(frame, "You cannot paste blocks that are currently NOT on the canvas."
                        + "\nThis function will be available in a future version.\n", "Error", JOptionPane.PLAIN_MESSAGE);
            }

        }
    }
 
开发者ID:heqichen,项目名称:openblocks,代码行数:49,代码来源:TypeBlockManager.java


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