예제 #1
0
  public void layoutContainer(Container parent) {
    synchronized (parent.getTreeLock()) {
      DiagramView diagramView = (DiagramView) parent;
      DesignView designView = diagramView.getDesignView();

      double k = designView.getCorrectedZoom();

      FBounds bounds = diagramView.getContentSize();

      int offsetX = (int) Math.round((diagramView.getWidth() - bounds.width * k) / 2.0);
      int offsetY = (int) Math.round((diagramView.getHeight() - bounds.height * k) / 2.0);

      diagramView.setOffsets(offsetX, offsetY);

      if (parent.getComponentCount() > 0) {
        repositionDecorations(parent);
      }

      //            Component component = parent.getComponent(0);
      //            if (!(component instanceof NavigationTools)) {
      //                return;
      //            }
      //            component.setBounds(0, 0, parent.getWidth(), parent.getHeight());

    }
  }
예제 #2
0
  public Dimension preferredLayoutSize(Container parent) {
    synchronized (parent.getTreeLock()) {
      DiagramView diagramView = (DiagramView) parent;
      DesignView designView = diagramView.getDesignView();

      int w = 0;
      int h = 0;

      double k = designView.getCorrectedZoom();

      FBounds bounds = diagramView.getContentSize();

      w = (int) Math.round(k * bounds.width + MARGIN_LEFT + MARGIN_RIGHT);
      h = (int) Math.round(k * bounds.height + MARGIN_TOP + MARGIN_BOTTOM);

      if (parent instanceof ProcessView) {
        //                int count = diagramView.getComponentCount();
        //                for (int i = 0; i < count; i++) {
        //                    Component c = diagramView.getComponent(i);
        //                    if (c instanceof NavigationTools) {
        //                        continue;
        //                    }
        //
        //                    w = Math.max(w, c.getX() + c.getWidth() + MARGIN_RIGHT);
        //                    h = Math.max(h, c.getY() + c.getHeight() + MARGIN_BOTTOM);
        //                }

        TriScrollPane scrollPane = designView.getScrollPane();
        int leftWidth = scrollPane.getLeftPreferredWidth();
        int rightWidth = scrollPane.getRightPreferredWidth();

        w += leftWidth + rightWidth;
      }

      return new Dimension(w, h);
    }
  }