Example #1
0
    @Override
    public void mouseClicked(MouseEvent e) {

      if ((!Page.this.hideMinimize)) {
        if (fullview) {
          this.setBounds(0, 0, COLLAPSED_WIDTH, charSet.length * (FONT_SIZE + 3) + COLLAPSED_WIDTH);
        } else {
          this.setBounds(0, 0, COLLAPSED_WIDTH, COLLAPSED_WIDTH);
        }
        fullview = !fullview;
        pageJComponent.setFullView(fullview);
        PageChangeEventManager.notifyListeners();
      }
    }
Example #2
0
  /**
   * @param newName - the new name of this page.
   * @requires newName != null
   * @modifies this.name
   * @effects sets the name of this page to be newName.
   */
  public void setPageName(String newName) {
    if (pageDrawer.equals(this.pageJComponent.getName())) {
      pageDrawer = newName;
    }

    this.pageJComponent.setName(newName);
    this.collapse.setText(newName);

    // iterate through blocks and update the ones that are page label enabled
    for (RenderableBlock block : this.getBlocks()) {
      if (workspace.getEnv().getBlock(block.getBlockID()).isPageLabelSetByPage()) {
        workspace.getEnv().getBlock(block.getBlockID()).setPageLabel(this.getPageName());
        block.repaintBlock();
      }
    }

    PageChangeEventManager.notifyListeners();
  }
Example #3
0
  /**
   * @param block - the new block being added whose position must be revalidated
   * @requires block != null
   * @modifies block.location or this page's abstract width
   * @effects shifts this block into the page or increases the width of this page to fit the new
   *     block. It must then notify listeners that the page's size may have changed
   */
  public void reformBlockPosition(RenderableBlock block) {
    // move blocks in
    Point p =
        SwingUtilities.convertPoint(block.getParent(), block.getLocation(), this.pageJComponent);
    if (p.x < block.getHighlightStrokeWidth() / 2 + 1) {
      block.setLocation(block.getHighlightStrokeWidth() / 2 + 1, p.y);
      block.moveConnectedBlocks();
      // the block has moved, so update p
      p = SwingUtilities.convertPoint(block.getParent(), block.getLocation(), this.pageJComponent);
    } else if (p.x + block.getWidth() + block.getHighlightStrokeWidth() / 2 + 1
        > this.pageJComponent.getWidth()) {
      this.setPixelWidth(p.x + block.getWidth() + block.getHighlightStrokeWidth() / 2 + 1);
    }

    if (p.y < block.getHighlightStrokeWidth() / 2 + 1) {
      block.setLocation(p.x, block.getHighlightStrokeWidth() / 2 + 1);
      block.moveConnectedBlocks();
    } else if (p.y + block.getStackBounds().height + block.getHighlightStrokeWidth() / 2 + 1
        > this.pageJComponent.getHeight()) {
      block.setLocation(
          p.x,
          this.pageJComponent.getHeight()
              - block.getStackBounds().height
              - block.getHighlightStrokeWidth() / 2
              + 1);
      block.moveConnectedBlocks();
    }

    if (block.hasComment()) {
      // p = SwingUtilities.convertPoint(block.getComment().getParent(),
      // block.getComment().getLocation(), this.pageJComponent);
      p = block.getComment().getLocation();
      if (p.x + block.getComment().getWidth() + 1 > this.pageJComponent.getWidth()) {
        this.setPixelWidth(p.x + block.getComment().getWidth() + 1);
      }
    }

    // repaint all pages
    PageChangeEventManager.notifyListeners();
  }