Package edu.mit.blocks.renderable

Examples of edu.mit.blocks.renderable.RenderableBlock


            if (pageChild.getNodeName().equals("PageBlocks")) {
                NodeList blocks = pageChild.getChildNodes();
                Node blockNode;
                for (int j = 0; j < blocks.getLength(); j++) {
                    blockNode = blocks.item(j);
                    RenderableBlock rb = RenderableBlock.loadBlockNode(workspace, blockNode, this, idMapping);
                    // save the loaded blocks to add later
                    loadedBlocks.add(rb);
                }
                break//should only have one set of page blocks
            }
View Full Code Here


                this.removeBlock(toBeRemovedBlock);
            }
            //Finally, add all the remaining blocks that weren't there before
            ArrayList<RenderableBlock> blocksToAdd = new ArrayList<RenderableBlock>();
            for (Long newBlockID : unloadedRenderableBlockStates) {
                RenderableBlock newBlock = new RenderableBlock(workspace, this, newBlockID);
                newBlock.loadState(renderableBlockStates.get(newBlockID));
                blocksToAdd.add(newBlock);
            }
            this.addBlocks(blocksToAdd);
            this.pageJComponent.repaint();
        }
View Full Code Here

        socket blocks.  If stacks were dropped top-first, this would check the
        blocks up the stack rather than down the stack. TODO - this doesn't
        always work, because there can be multiple "branches" that might get
        dropped on different places.  Need to find a way to drop according the
        widget of the top block of the stack...*/
        RenderableBlock socketBlock;
        for (BlockConnector con : (workspace.getEnv().getBlock(block.getBlockID()).getSockets())) {
            socketBlock = block.getWorkspace().getEnv().getRenderableBlock(con.getBlockID());
            if (socketBlock != null) {
                w = socketBlock.getParentWidget();
            }
        }
        w.blockDropped(block);
        this.repaint();
    }
View Full Code Here

        //Do not delete null block references.  Otherwise, get Block and RenderableBlock instances.
        if (isNullBlockInstance(focusManager.getFocusBlockID())) {
            throw new RuntimeException("TypeBlockManager: deleting a null block references.");
        }
        Block block = workspace.getEnv().getBlock(focusManager.getFocusBlockID());
        RenderableBlock renderable = workspace.getEnv().getRenderableBlock(block.getBlockID());

        //get workspace widget associated with current focus
        WorkspaceWidget widget = renderable.getParentWidget();
        //do not delete block instances in null widgets
        if (widget == null) {
            throw new RuntimeException("TypeBlockManager: do not delete blocks with no parent widget.");
            //return;
        }
        //get parent container of this graphical representation
        Container container = renderable.getParent();
        //do not delete block instances in null parents
        if (container == null) {
            throw new RuntimeException("TypeBlockManager: do not delete blocks with no parent container.");
            //return;
        }
View Full Code Here

        //Workspace.getInstance().notifyListeners(new WorkspaceEvent(widget, renderable.getBlockID(), WorkspaceEvent.BLOCK_REMOVED));
        for (BlockConnector child : workspace.getEnv().getBlock(renderable.getBlockID()).getSockets()) {
            if (child == null || child.getBlockID().equals(Block.NULL)) {
                continue;
            }
            RenderableBlock childRenderable = workspace.getEnv().getRenderableBlock(child.getBlockID());
            if (childRenderable == null) {
                continue;
            }
            removeBlock(childRenderable, widget, container);
        }
View Full Code Here

        //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);
        }
View Full Code Here

            return;
        }

        link.disconnect();

        RenderableBlock parentRenderable = workspace.getEnv().getRenderableBlock(parentBlock.getBlockID());
        if (parentRenderable == null) {
            throw new RuntimeException("INCONSISTANCY VIOLATION: "
                    + "parent block was valid, non-null, and existed.\n\tBut yet, when we get it's renderable"
                    + "representation, we recieve a null instance.\n\tIf the Block instance of an ID is non-null"
                    + "then its graphical RenderableBlock should be non-null as well");
        }
        parentRenderable.blockDisconnected(parentSocket);
        workspace.notifyListeners(new WorkspaceEvent(workspace, widget, link, WorkspaceEvent.BLOCKS_DISCONNECTED));
    }
View Full Code Here

            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);
            }
View Full Code Here

            } else if (dir == Direction.LEFT) {
                focusManager.focusPrevBlock();
            } else if (dir == Direction.RIGHT) {
                focusManager.focusNextBlock();
            } else if (dir == Direction.ESCAPE) {
                RenderableBlock block = workspace.getEnv().getRenderableBlock(
                        focusManager.getFocusBlockID());
                Point location = SwingUtilities.convertPoint(block, new Point(0, 0), this.blockCanvas.getCanvas());
                this.focusManager.setFocus(location, Block.NULL);
                this.blockCanvas.getCanvas().requestFocus();
            } else if (dir == Direction.ENTER) {
View Full Code Here

            autoCompletePanel.setVisible(true);
            autoCompletePanel.requestFocus();
        } else {
            //renderableblock has focus
            this.blockCanvas.getCanvas().add(autoCompletePanel, JLayeredPane.DRAG_LAYER);
            RenderableBlock block = workspace.getEnv().getRenderableBlock(focusManager.getFocusBlockID());
            Point location = SwingUtilities.convertPoint(
                    block,
                    this.focusManager.getBlockPoint(),
                    this.blockCanvas.getCanvas());
            location.translate(10, 10);
View Full Code Here

TOP

Related Classes of edu.mit.blocks.renderable.RenderableBlock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.