Package edu.mit.blocks.workspace

Examples of edu.mit.blocks.workspace.Workspace


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


     */
    private static void dropBlock(RenderableBlock block) {
        if (block == null) {
            throw new RuntimeException("Invariant Violated: child block was null");
        }
        Workspace workspace = block.getWorkspace();
        Page p = workspace.getCurrentPage(block);
        if (p == null) {
            throw new RuntimeException("Invariant Violated: child block was located on a null widget");
        }
        //add this block to that page.
        p.blockDropped(block);
View Full Code Here

    public static boolean isLabelValid(Block block, String label) {
        if (block == null || label == null) {
            return false;
        } else if (block.labelMustBeUnique()) {
            Workspace workspace = block.getWorkspace();
            //search through the current block instances active in the workspace
            for (RenderableBlock rb : workspace.getRenderableBlocksFromGenus(block.getGenusName())) {
                if (label.equals(rb.getBlock().getBlockLabel())) {
                    return false;
                }
            }
        }
View Full Code Here

            parent.remove(block);
            parent.validate();
        }

        block.setParentWidget(null);
        Workspace workspace = block.getWorkspace();
        workspace.notifyListeners(new WorkspaceEvent(workspace, widget, block.getBlockID(), WorkspaceEvent.BLOCK_REMOVED));

    }
View Full Code Here

    }

    public static RenderableBlock cloneBlock(Block myblock) {
        String mygenusname = myblock.getGenusName();
        String label = myblock.getBlockLabel();
        final Workspace workspace = myblock.getWorkspace();

        //sometimes the factory block will have an assigned label different
        //from its genus label.
        if (!myblock.getInitialLabel().equals(myblock.getBlockLabel())) {
            //acquire prefix and suffix length from myblock label
View Full Code Here

     * Constructs a WorkspaceController instance that manages the
     * interaction with the codeblocks.Workspace
     *
     */
    public WorkspaceController() {
        this.workspace = new Workspace();
    }
View Full Code Here

      e.printStackTrace();
      workspaceController.loadFreshWorkspace();
    }
        */
   
    Workspace workspace = workspaceController.getWorkspace();
    Page page = workspace.getPageNamed("Main");
   
    FactoryManager manager = workspace.getFactoryManager();
    Block newBlock;
        newBlock = new Block(workspace, "loop", false);
        FactoryRenderableBlock factoryRenderableBlock = new FactoryRenderableBlock(workspace, manager, newBlock.getBlockID());
        RenderableBlock renderableBlock = factoryRenderableBlock.createNewInstance();
        renderableBlock.setLocation(100, 100);
View Full Code Here

    /*
    WorkspaceController workspaceController = context.getWorkspaceController();
    JComponent workspaceComponent = workspaceController.getWorkspacePanel();
    */
   
    final Workspace workspace = context.getWorkspace();
   
    // WTF I can't add worksapcelistener by workspace contrller
    workspace.addWorkspaceListener(new ArdublockWorkspaceListener(this));
   
    JPanel buttons = new JPanel();
    buttons.setLayout(new FlowLayout());
    JButton newButton = new JButton(uiMessageBundle.getString("ardublock.ui.new"));
    newButton.addActionListener(new NewButtonListener(this));
    JButton saveButton = new JButton(uiMessageBundle.getString("ardublock.ui.save"));
    saveButton.addActionListener(new SaveButtonListener(this));
    JButton saveAsButton = new JButton(uiMessageBundle.getString("ardublock.ui.saveAs"));
    saveAsButton.addActionListener(new SaveAsButtonListener(this));
    JButton openButton = new JButton(uiMessageBundle.getString("ardublock.ui.load"));
    openButton.addActionListener(new OpenButtonListener(this));
    JButton generateButton = new JButton(uiMessageBundle.getString("ardublock.ui.upload"));
    generateButton.addActionListener(new GenerateCodeButtonListener(this, context));
    JButton serialMonitorButton = new JButton(uiMessageBundle.getString("ardublock.ui.serialMonitor"));
    serialMonitorButton.addActionListener(new ActionListener () {
      public void actionPerformed(ActionEvent e) {
        context.getEditor().handleSerial();
      }
    });
    JButton saveImageButton = new JButton(uiMessageBundle.getString("ardublock.ui.saveImage"));
    saveImageButton.addActionListener(new ActionListener () {
      public void actionPerformed(ActionEvent e) {
        Dimension size = workspace.getCanvasSize();
        System.out.println("size: " + size);
        BufferedImage bi = new BufferedImage(2560, 2560, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = (Graphics2D)bi.createGraphics();
        double theScaleFactor = (300d/72d)
        g.scale(theScaleFactor,theScaleFactor);
       
        workspace.getBlockCanvas().getPageAt(0).getJComponent().paint(g);
        try{
          final JFileChooser fc = new JFileChooser();
          fc.setSelectedFile(new File("ardublock.png"));
          int returnVal = fc.showSaveDialog(workspace.getBlockCanvas().getJComponent());
              if (returnVal == JFileChooser.APPROVE_OPTION) {
                  File file = fc.getSelectedFile();
            ImageIO.write(bi,"png",file);
              }
        } catch (Exception e1) {
View Full Code Here

TOP

Related Classes of edu.mit.blocks.workspace.Workspace

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.