/**
     * Calculates the maximum size dimensions for the specified panal given the components in the
     * specified parent container.
     */
    public Dimension maximumLayoutSize(Container target) {
      synchronized (target.getTreeLock()) {
        Dimension dim = new Dimension(0, 0);
        int size = actions.size();
        if ((grip != null) && grip.isVisible()) {
          Dimension d = grip.getPreferredSize();
          dim.width += d.width;
          dim.width += hgap;
        }
        Component last = null;
        for (int i = 0; i < size; i++) {
          Component comp = (Component) actions.elementAt(i);
          if (comp.isVisible()) {
            Dimension d = comp.getPreferredSize();
            dim.width += d.width;
            dim.height = Math.max(dim.height, d.height);
            dim.width += hgap;
            last = comp;
          }
        }
        if (last != null) {
          Dimension prefSize = last.getPreferredSize();
          Dimension maxSize = last.getMaximumSize();
          if (prefSize != maxSize) {
            dim.width = dim.width - prefSize.width + maxSize.width;
            dim.height = Math.max(dim.height, maxSize.height);
          }
        }
        Insets insets = target.getInsets();
        dim.width += insets.left + insets.right;
        dim.height += insets.top + insets.bottom;

        return dim;
      }
    }
  @Override
  public Dimension preferredLayoutSize(final Container parent) {
    synchronized (parent.getTreeLock()) {
      final Insets in = parent.getInsets();
      final int nr = parent.getComponentCount();

      int maxW = 0;
      int maxH = 0;
      for (int i = 0; i < cols; ++i) {
        posX[i] = maxW;
        final int w = maxW;
        int h = 0;

        for (int j = 0; j < rows; ++j) {
          final int n = j * cols + i;
          if (n >= nr) break;

          final Component c = parent.getComponent(n);
          final Dimension d = c.getPreferredSize();
          if (maxW < w + d.width) maxW = w + d.width;
          if (posY[j] < h) posY[j] = h;
          else h = posY[j];
          h += d.height;
        }
        if (maxH < h) maxH = h;
      }
      width = in.left + maxW + (cols - 1) * insetX + in.right;
      height = in.top + maxH + (rows - 1) * insetY + in.bottom;

      return new Dimension(width, height);
    }
  }
  /*--------------------------------------------------------------------------*/
  public Dimension preferredLayoutSize(Container target) {
    synchronized (target.getTreeLock()) {
      Dimension dim = new Dimension(0, 0);
      int nmembers = target.getComponentCount();
      boolean firstVisibleComponent = true;

      for (int i = 0; i < nmembers; i++) {
        Component m = target.getComponent(i);
        if (m.isVisible()) {
          Dimension d = m.getPreferredSize();
          dim.height = Math.max(dim.height, d.height);
          if (firstVisibleComponent) {
            firstVisibleComponent = false;
          } else {
            dim.width += hgap;
          }
          dim.width += d.width;
        }
      }

      Insets insets = target.getInsets();
      dim.width += insets.left + insets.right + hgap * 2;
      dim.height += insets.top + insets.bottom + vgap * 2;

      return (dim);
    }
  }
Example #4
0
    @Override
    public java.awt.Dimension preferredLayoutSize(java.awt.Container parent) {
      synchronized (parent.getTreeLock()) {
        org.lgna.croquet.CardOwnerComposite cardOwner =
            (org.lgna.croquet.CardOwnerComposite) getComposite();

        int widthMax = 0;
        int heightMax = 0;

        for (org.lgna.croquet.Composite<?> card : cardOwner.getCards()) {
          if (cardOwner.isCardAccountedForInPreferredSizeCalculation(card)) {
            java.awt.Component awtChild = card.getRootComponent().getAwtComponent();
            java.awt.Dimension awtChildPreferredSize = awtChild.getPreferredSize();
            widthMax = Math.max(widthMax, awtChildPreferredSize.width);
            heightMax = Math.max(heightMax, awtChildPreferredSize.height);
          }
        }
        java.awt.Insets insets = parent.getInsets();
        int hgap = this.getHgap();
        int vgap = this.getVgap();
        return new java.awt.Dimension(
            hgap + insets.left + widthMax + insets.right + hgap,
            vgap + insets.top + heightMax + insets.bottom + vgap);
      }
    }
  /**
   * Calculates the preferred size dimensions for the specified panel given the components in the
   * specified parent container.
   *
   * @param target The component to be laid out.
   * @return A size deemed suitable for laying out the container.
   * @see #minimumLayoutSize
   */
  public Dimension preferredLayoutSize(Container target) {
    int count;
    Component component;
    Dimension dimension;
    Insets insets;
    Dimension ret;

    synchronized (target.getTreeLock()) {
      // get the the total height and maximum width component
      ret = new Dimension(0, 0);
      count = target.getComponentCount();
      for (int i = 0; i < count; i++) {
        component = target.getComponent(i);
        if (component.isVisible()) {
          dimension = component.getPreferredSize();
          ret.width = Math.max(ret.width, dimension.width);
          ret.height += dimension.height;
        }
      }
      insets = target.getInsets();
      ret.width += insets.left + insets.right;
      ret.height += insets.top + insets.bottom;
    }

    return (ret);
  }
  /**
   * Lays out the container in the specified container.
   *
   * @param parent the component which needs to be laid out
   */
  public void layoutContainer(Container parent) {
    synchronized (parent.getTreeLock()) {
      Insets insets = parent.getInsets();
      int ncomponents = parent.getComponentCount();

      if (ncomponents == 0) {
        return;
      }

      // Total parent dimensions
      Dimension size = parent.getSize();
      int totalW = size.width - (insets.left + insets.right);
      int totalH = size.height - (insets.top + insets.bottom);

      // Cell dimensions, including padding
      int totalCellW = totalW / gridSize.width;
      int totalCellH = totalH / gridSize.height;

      // Cell dimensions, without padding
      int cellW = (totalW - ((gridSize.width + 1) * hgap)) / gridSize.width;
      int cellH = (totalH - ((gridSize.height + 1) * vgap)) / gridSize.height;

      for (int i = 0; i < ncomponents; i++) {
        Component c = parent.getComponent(i);
        Rectangle rect = (Rectangle) compTable.get(c);
        if (rect != null) {
          int x = insets.left + (totalCellW * rect.x) + hgap;
          int y = insets.top + (totalCellH * rect.y) + vgap;
          int w = (cellW * rect.width) - hgap;
          int h = (cellH * rect.height) - vgap;
          c.setBounds(x, y, w, h);
        }
      }
    }
  }
Example #7
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());

    }
  }
    /** Lays out the container in the specified panel. */
    public void layoutContainer(Container target) {
      synchronized (target.getTreeLock()) {
        Insets insets = target.getInsets();
        Dimension dim = target.getSize();

        int fullHeight = dim.height;
        int bottom = dim.height - insets.bottom - 1;
        int top = 0 + insets.top;
        int left = insets.left;
        int maxPosition = dim.width - (insets.left + insets.right) - hgap;
        int right = dim.width - insets.right;
        maxPosition = right;
        int height = bottom - top;
        int size = actions.size();
        int w, h;
        if ((grip != null) && grip.isVisible()) {
          Dimension d = grip.getPreferredSize();
          grip.setBounds(left, top + vgap, d.width, bottom - top - 2 * vgap);
          left += d.width;
          left += hgap;
        }
        for (int i = 0; i < size; i++) {
          left += hgap;
          Component comp = (Component) actions.elementAt(i);
          Dimension d;
          Dimension minSize = comp.getMinimumSize();

          if (i == size - 1) d = comp.getMaximumSize();
          else d = comp.getPreferredSize();
          w = d.width;
          h = Math.min(height, d.height);
          if ((left < maxPosition) && (left + w > maxPosition)) {
            if (maxPosition - left >= minSize.width) w = maxPosition - left;
          }

          comp.setBounds(left, (fullHeight - d.height) / 2, w, h);

          //  	  if (i == size - 1)
          //  	    d = comp.getMaximumSize();
          //  	  else
          //  	    d = comp.getPreferredSize();
          //  	  if ((left + d.width) > right)
          //  	    w = right - left;
          //  	  else
          //  	    w = d.width;
          //  	  h = Math.min (height, d.height);
          //  	  comp.setBounds (left, (fullHeight - d.height)/2, w, h);

          left += d.width;
        }
      }
    }
Example #9
0
  /** {@inheritDoc} */
  public void layoutContainer(final Container parent) {
    synchronized (parent.getTreeLock()) {
      int width = parent.getWidth();
      int height = parent.getHeight();

      Rectangle bounds = new Rectangle(0, 0, width, height);

      int componentsCount = components.size();

      for (int i = 0; i < componentsCount; i++) {
        Component comp = components.get(i);
        comp.setBounds(bounds);
        parent.setComponentZOrder(comp, componentsCount - i - 1);
      }
    }
  }
Example #10
0
  /**
   * Lays out the container.
   *
   * @param target The container which needs to be laid out.
   */
  public void layoutContainer(Container target) {
    int count;
    Component component;
    Dimension dimension;

    synchronized (target.getTreeLock()) {
      count = target.getComponentCount();
      for (int i = 0; i < count; i++) {
        component = target.getComponent(i);
        if (component.isVisible()) {
          dimension = component.getPreferredSize();
          component.setSize(dimension.width, dimension.height);
        }
      }
    }
  }
Example #11
0
    public void layoutContainer(Container target) {
      /*
       * Algorithm is as follows: - the "left-hand" components take 33% of
       * horizontal space - scrollPane takes the remaining space
       */
      synchronized (target.getTreeLock()) {
        if (pane == null || spane == null) return;
        Dimension dim = target.getSize();
        if (dim.height < 20) return;

        spane.setBounds(new Rectangle(0, 0, dim.width, dim.height));
        // Dimension dim0 = new Dimension(dim.width-2, dim.height-2);
        // pane.setPreferredSize(dim0);
        // JViewport viewPort = spane.getViewport();
        // viewPort.setViewSize(dim0);
        // paramsLayout.setReferenceSize(dim0.width, dim0.height);
      }
    }
Example #12
0
  /** {@inheritDoc} */
  public Dimension minimumLayoutSize(final Container parent) {
    synchronized (parent.getTreeLock()) {
      int width = 0;
      int height = 0;

      for (Component comp : components) {
        Dimension size = comp.getMinimumSize();
        width = Math.max(size.width, width);
        height = Math.max(size.height, height);
      }

      Insets insets = parent.getInsets();
      width += insets.left + insets.right;
      height += insets.top + insets.bottom;

      return new Dimension(width, height);
    }
  }
Example #13
0
  @Override
  public void layoutContainer(Container target) {

    synchronized (target.getTreeLock()) {
      Insets insets = target.getInsets();

      int top = insets.top;

      int bottom = target.getHeight() - insets.bottom;

      int left = insets.left;

      int right = target.getWidth() - insets.right;

      northHeight = getPreferredDimension(north).height;

      southHeight = getPreferredDimension(south).height;

      eastWidth = getPreferredDimension(east).width;

      westWidth = getPreferredDimension(west).width;

      placeComponents(target, north, left, top, right - left, northHeight, TOP);

      top += (northHeight + getVgap());

      placeComponents(target, south, left, bottom - southHeight, right - left, southHeight, BOTTOM);

      bottom -= (southHeight + getVgap());

      placeComponents(target, east, right - eastWidth, top, eastWidth, bottom - top, RIGHT);

      right -= (eastWidth + getHgap());

      placeComponents(target, west, left, top, westWidth, bottom - top, LEFT);

      left += (westWidth + getHgap());

      if (center != null) {

        center.setBounds(left, top, right - left, bottom - top);
      }
    }
  }
  /*--------------------------------------------------------------------------*/
  private void moveComponents(
      Container target,
      int x,
      int y,
      int width,
      int height,
      int rowStart,
      int rowEnd,
      boolean ltr) {
    synchronized (target.getTreeLock()) {
      switch (newAlign) {
        case LEFT:
          x += ltr ? 0 : width;
          break;
        case CENTER:
          x += width / 2;
          break;
        case RIGHT:
          x += ltr ? width : 0;
          break;
        case LEADING:
          break;
        case TRAILING:
          x += width;
          break;
      }

      for (int i = rowStart; i < rowEnd; i++) {
        Component m = target.getComponent(i);

        if (m.isVisible()) {
          if (ltr) {
            m.setLocation(x, y + (height - m.getSize().height) / 2);
          } else {
            m.setLocation(
                target.getSize().width - x - m.getSize().width,
                y + (height - m.getSize().height) / 2);
          }

          x += m.getSize().width + hgap;
        }
      }
    }
  }
 @Override
 public java.awt.Dimension preferredLayoutSize(java.awt.Container target) {
   synchronized (target.getTreeLock()) {
     java.awt.Dimension dim = new java.awt.Dimension(0, 0);
     if (this.mainComponent != null) {
       java.awt.Dimension d = this.mainComponent.getPreferredSize();
       dim.width = Math.max(d.width, dim.width);
       dim.height += d.height + vGap;
     }
     if (this.bottomComponent != null) {
       java.awt.Dimension d = this.bottomComponent.getPreferredSize();
       dim.width = Math.max(d.width, dim.width);
       dim.height += d.height + vGap;
     }
     addInsets(dim, target);
     // edu.cmu.cs.dennisc.java.util.logging.Logger.outln( "preferredLayoutSize", dim, target );
     return dim;
   }
 }
 @Override
 public void layoutContainer(final Container p) {
   preferredLayoutSize(p);
   synchronized (p.getTreeLock()) {
     final Insets in = p.getInsets();
     final int nr = p.getComponentCount();
     for (int j = 0; j < rows; ++j) {
       for (int i = 0; i < cols; ++i) {
         final int n = j * cols + i;
         if (n >= nr) return;
         final Dimension cs = p.getComponent(n).getPreferredSize();
         final int x = in.left + posX[i] + i * insetX;
         final int y = in.top + posY[j] + j * insetY;
         final int w = cs.width > 0 ? cs.width : width - in.left - in.right;
         final int h = cs.height > 0 ? cs.height : height - in.top - in.bottom;
         p.getComponent(n).setBounds(x, y, w, h);
       }
     }
   }
 }
Example #17
0
    public void layoutContainer(Container parent) {
      synchronized (parent.getTreeLock()) {
        Insets margin = parent.getInsets();
        int x = margin.left;
        int y = margin.top;
        int w = parent.getWidth() - (margin.left + margin.right);
        int h = parent.getHeight() - (margin.top + margin.bottom);
        Component header = findHeader(parent.getComponents());
        if (header != null && header.isVisible()) {
          Dimension dim = header.getPreferredSize();
          header.setBounds(x, y, w, dim.height);
          y += dim.height;
          h -= dim.height;
        }

        Component body = findBody(parent.getComponents());
        if (body != null && body.isVisible()) {
          body.setBounds(x, y, w, h);
        }
      }
    }
Example #18
0
  /**
   * Lays out the container argument using this border layout.
   *
   * <p>This method actually reshapes the components in the specified container in order to satisfy
   * the constraints of this <code>BorderLayout</code> object. The <code>NORTH</code> and <code>
   * SOUTH</code> components, if any, are placed at the top and bottom of the container,
   * respectively. The <code>WEST</code> and <code>EAST</code> components are then placed on the
   * left and right, respectively. Finally, the <code>CENTER</code> object is placed in any
   * remaining space in the middle.
   *
   * <p>Most applications do not call this method directly. This method is called when a container
   * calls its <code>doLayout</code> method.
   *
   * @param target the container in which to do the layout.
   * @see java.awt.Container
   * @see java.awt.Container#doLayout()
   */
  public void layoutContainer(Container target) {
    synchronized (target.getTreeLock()) {
      Insets insets = target.getInsets();
      int top = insets.top;
      int bottom = target.getHeight() - insets.bottom;
      int left = insets.left;
      int right = target.getWidth() - insets.right;

      boolean ltr = target.getComponentOrientation().isLeftToRight();
      Component c = null;

      if ((c = getChild(NORTH, ltr)) != null) {
        c.setSize(right - left, c.getHeight());
        Dimension d = c.getPreferredSize();
        c.setBounds(left, top, right - left, d.height);
        top += d.height + vgap;
      }
      if ((c = getChild(SOUTH, ltr)) != null) {
        c.setSize(right - left, c.getHeight());
        Dimension d = c.getPreferredSize();
        c.setBounds(left, bottom - d.height, right - left, d.height);
        bottom -= d.height + vgap;
      }
      if ((c = getChild(EAST, ltr)) != null) {
        c.setSize(c.getWidth(), bottom - top);
        Dimension d = c.getPreferredSize();
        c.setBounds(right - d.width, top, d.width, bottom - top);
        right -= d.width + hgap;
      }
      if ((c = getChild(WEST, ltr)) != null) {
        c.setSize(c.getWidth(), bottom - top);
        Dimension d = c.getPreferredSize();
        c.setBounds(left, top, d.width, bottom - top);
        left += d.width + hgap;
      }
      if ((c = getChild(CENTER, ltr)) != null) {
        c.setBounds(left, top, right - left, bottom - top);
      }
    }
  }
Example #19
0
  /**
   * Determines the preferred size of the <code>target</code> container using this layout manager,
   * based on the components in the container.
   *
   * <p>Most applications do not call this method directly. This method is called when a container
   * calls its <code>getPreferredSize</code> method.
   *
   * @param target the container in which to do the layout.
   * @return the preferred dimensions to lay out the subcomponents of the specified container.
   * @see java.awt.Container
   * @see java.awt.BorderLayout#minimumLayoutSize
   * @see java.awt.Container#getPreferredSize()
   */
  public Dimension preferredLayoutSize(Container target) {
    synchronized (target.getTreeLock()) {
      Dimension dim = new Dimension(0, 0);

      boolean ltr = target.getComponentOrientation().isLeftToRight();
      Component c = null;

      if ((c = getChild(EAST, ltr)) != null) {
        Dimension d = c.getPreferredSize();
        dim.width += d.width + hgap;
        dim.height = Math.max(d.height, dim.height);
      }
      if ((c = getChild(WEST, ltr)) != null) {
        Dimension d = c.getPreferredSize();
        dim.width += d.width + hgap;
        dim.height = Math.max(d.height, dim.height);
      }
      if ((c = getChild(CENTER, ltr)) != null) {
        Dimension d = c.getPreferredSize();
        dim.width += d.width;
        dim.height = Math.max(d.height, dim.height);
      }
      if ((c = getChild(NORTH, ltr)) != null) {
        Dimension d = c.getPreferredSize();
        dim.width = Math.max(d.width, dim.width);
        dim.height += d.height + vgap;
      }
      if ((c = getChild(SOUTH, ltr)) != null) {
        Dimension d = c.getPreferredSize();
        dim.width = Math.max(d.width, dim.width);
        dim.height += d.height + vgap;
      }

      Insets insets = target.getInsets();
      dim.width += insets.left + insets.right;
      dim.height += insets.top + insets.bottom;

      return dim;
    }
  }
Example #20
0
  /**
   * Calculates the preferred size dimensions for the specified panel given the components in the
   * specified parent container.
   *
   * @see #minimumLayoutSize
   * @param target The component to be laid out.
   * @return A size deemed suitable for laying out the container.
   */
  public Dimension preferredLayoutSize(Container target) {
    int count;
    Container parent;
    Component component;
    Point point;
    Dimension dimension;
    Insets insets;
    Dimension ret;

    synchronized (target.getTreeLock()) {
      count = target.getComponentCount();
      if (0 == count) {
        // be the same size unless we have a parent
        ret = target.getSize();
        parent = target.getParent();
        if (null != parent) {
          insets = parent.getInsets();
          ret = parent.getSize();
          ret.setSize(
              ret.width - insets.left - insets.right, ret.height - insets.top - insets.bottom);
        }
      } else {
        ret = new Dimension(0, 0);
        for (int i = 0; i < count; i++) {
          component = target.getComponent(i);
          if (component.isVisible()) {
            point = component.getLocation();
            dimension = component.getPreferredSize();
            ret.width = Math.max(ret.width, point.x + dimension.width);
            ret.height = Math.max(ret.height, point.y + dimension.height);
          }
        }
        insets = target.getInsets();
        ret.width += insets.left + insets.right;
        ret.height += insets.top + insets.bottom;
      }
    }

    return (ret);
  }
  @Override
  public void layoutContainer(java.awt.Container target) {
    synchronized (target.getTreeLock()) {
      java.awt.Insets insets = target.getInsets();
      int top = insets.top;
      int left = insets.left;
      int bottom = target.getHeight() - insets.bottom;
      int right = target.getWidth() - insets.right;

      int width = right - left;
      int bottomHeight;
      if (bottomComponent != null) {
        bottomComponent.setSize(width, bottomComponent.getHeight());
        java.awt.Dimension d = bottomComponent.getPreferredSize();
        bottomHeight = d.height;
      } else {
        bottomHeight = 0;
      }

      if (this.mainComponent != null) {
        this.mainComponent.setSize(width, this.mainComponent.getHeight());
        java.awt.Dimension d = this.mainComponent.getPreferredSize();
        if (this.mainComponent instanceof javax.swing.JScrollPane) {
          javax.swing.JScrollPane jScrollPane = (javax.swing.JScrollPane) this.mainComponent;
          if (d.width > (right - left)) {
            d.height += jScrollPane.getHorizontalScrollBar().getPreferredSize().height;
          }
        }

        d.height = Math.min(d.height, bottom - top - bottomHeight);

        this.mainComponent.setBounds(left, top, width, d.height);
        top += d.height + vGap;
      }
      if (bottomComponent != null) {
        bottomComponent.setBounds(left, top, width, bottomHeight);
      }
    }
  }
 private void setComponentConstraintsImpl(
     Component paramComponent, Object paramObject, boolean paramBoolean) {
   Container localContainer = paramComponent.getParent();
   synchronized (localContainer != null ? localContainer.getTreeLock() : new Object()) {
     if ((!paramBoolean) && (!this.scrConstrMap.containsKey(paramComponent)))
       throw new IllegalArgumentException("Component must already be added to parent!");
     SwingComponentWrapper localSwingComponentWrapper = new SwingComponentWrapper(paramComponent);
     if ((paramObject == null) || ((paramObject instanceof String))) {
       String str = ConstraintParser.prepare((String) paramObject);
       this.scrConstrMap.put(paramComponent, paramObject);
       this.ccMap.put(localSwingComponentWrapper, ConstraintParser.parseComponentConstraint(str));
     } else if ((paramObject instanceof CC)) {
       this.scrConstrMap.put(paramComponent, paramObject);
       this.ccMap.put(localSwingComponentWrapper, (CC) paramObject);
     } else {
       throw new IllegalArgumentException(
           "Constraint must be String or ComponentConstraint: "
               + paramObject.getClass().toString());
     }
     this.dirty = true;
   }
 }
Example #23
0
    @Override
    public Dimension preferredLayoutSize(Container target) {
      synchronized (target.getTreeLock()) {
        Dimension dim = new Dimension(0, 0);
        int nmembers = target.getComponentCount();

        Insets insets = target.getInsets();
        // Provide a default if the panel has not been displayed yet (i.e. in a dialog)
        int targetWidth = target.getWidth() == 0 ? 400 : target.getWidth();
        int maxwidth = targetWidth - (insets.left + insets.right + getHgap() * 2);
        int width = 0;
        int height = 0;
        int component = 0;
        for (int i = 0; i < nmembers; i++, component++) {
          Component m = target.getComponent(i);
          if (m.isVisible()) {
            Dimension d = m.getPreferredSize();
            if (component > 0) {
              if (width + d.width > maxwidth) {
                dim.width = Math.max(dim.width, width);
                dim.height += height + getVgap();
                width = 0;
                height = 0;
                component = 0;
              }
              width += getHgap();
            }
            height = Math.max(height, d.height);
            width += d.width;
          }
        }
        dim.width = Math.max(dim.width, width);
        dim.height += height;

        dim.width += insets.left + insets.right + getHgap() * 2;
        dim.height += insets.top + insets.bottom + getVgap() * 2;
        return dim;
      }
    }
  /*--------------------------------------------------------------------------*/
  public void layoutContainer(Container target) {
    synchronized (target.getTreeLock()) {
      Insets insets = target.getInsets();
      int maxWidth = target.getSize().width - (insets.left + insets.right + hgap * 2);
      int nMembers = target.getComponentCount();
      int x = 0;
      int y = insets.top + vgap;
      int rowh = 0;
      int start = 0;

      boolean ltr = target.getComponentOrientation().isLeftToRight();

      for (int i = 0; i < nMembers; i++) {
        Component m = target.getComponent(i);

        if (m.isVisible()) {
          Dimension d = m.getPreferredSize();
          m.setSize(d.width, d.height);

          if ((x == 0) || ((x + d.width) <= maxWidth)) {
            if (x > 0) {
              x += hgap;
            }
            x += d.width;
            rowh = Math.max(rowh, d.height);
          } else {
            moveComponents(target, insets.left, y, maxWidth - x, rowh, start, i, ltr);
            x = d.width;
            y += vgap + rowh;
            rowh = d.height;
            start = i;
          }
        }
      }

      moveComponents(target, insets.left, y, maxWidth - x, rowh, start, nMembers, ltr);
    }
  }
Example #25
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);
    }
  }
 public void layoutContainer(Container paramContainer) {
   synchronized (paramContainer.getTreeLock()) {
     checkCache(paramContainer);
     Insets localInsets = paramContainer.getInsets();
     int[] arrayOfInt = {
       localInsets.left,
       localInsets.top,
       paramContainer.getWidth() - localInsets.left - localInsets.right,
       paramContainer.getHeight() - localInsets.top - localInsets.bottom
     };
     if (this.grid.layout(
         arrayOfInt, this.lc.getAlignX(), this.lc.getAlignY(), getDebug(), true)) {
       this.grid = null;
       checkCache(paramContainer);
       this.grid.layout(arrayOfInt, this.lc.getAlignX(), this.lc.getAlignY(), getDebug(), false);
     }
     long l = this.grid.getHeight()[1] + (this.grid.getWidth()[1] << 32);
     if (this.lastSize != l) {
       this.lastSize = l;
       ContainerWrapper localContainerWrapper = checkParent(paramContainer);
       Window localWindow =
           (Window)
               SwingUtilities.getAncestorOfClass(
                   Window.class, (Component) localContainerWrapper.getComponent());
       if (localWindow != null)
         if (localWindow.isVisible())
           SwingUtilities.invokeLater(
               new Runnable(localContainerWrapper) {
                 public void run() {
                   MigLayout.this.adjustWindowSize(this.val$containerWrapper);
                 }
               });
         else adjustWindowSize(localContainerWrapper);
     }
     this.lastInvalidSize = null;
   }
 }
Example #27
0
    @Override
    public Dimension minimumLayoutSize(Container target) {
      synchronized (target.getTreeLock()) {
        Dimension dim = new Dimension(0, 0);
        int nmembers = target.getComponentCount();

        Insets insets = target.getInsets();
        int maxwidth = target.getWidth() - (insets.left + insets.right + getHgap() * 2);
        int width = 0;
        int height = 0;
        int component = 0;
        for (int i = 0; i < nmembers; i++, component++) {
          Component m = target.getComponent(i);
          if (m.isVisible()) {
            Dimension d = m.getMinimumSize();
            if (component > 0) {
              if (width + d.width > maxwidth) {
                dim.width = Math.max(dim.width, width);
                dim.height += height + getVgap();
                width = 0;
                height = 0;
                component = 0;
              }
              width += getHgap();
            }
            height = Math.max(height, d.height);
            width += d.width;
          }
        }
        dim.width = Math.max(dim.width, width);
        dim.height += height;

        dim.width += insets.left + insets.right + getHgap() * 2;
        dim.height += insets.top + insets.bottom + getVgap() * 2;
        return dim;
      }
    }
  /*--------------------------------------------------------------------------*/
  public Dimension minimumLayoutSize(Container target) {
    synchronized (target.getTreeLock()) {
      Dimension dim = new Dimension(0, 0);
      int nmembers = target.getComponentCount();

      for (int i = 0; i < nmembers; i++) {
        Component m = target.getComponent(i);
        if (m.isVisible()) {
          Dimension d = m.getMinimumSize();
          dim.height = Math.max(dim.height, d.height);
          if (i > 0) {
            dim.width += hgap;
          }
          dim.width += d.width;
        }
      }

      Insets insets = target.getInsets();
      dim.width += insets.left + insets.right + hgap * 2;
      dim.height += insets.top + insets.bottom + vgap * 2;

      return (dim);
    }
  }
  /**
   * Lays out the container.
   *
   * @param target The container which needs to be laid out.
   */
  public void layoutContainer(Container target) {
    Insets insets;
    int x;
    int y;
    int count;
    int width;
    Component component;
    Dimension dimension;

    synchronized (target.getTreeLock()) {
      insets = target.getInsets();
      x = insets.left;
      y = insets.top;
      count = target.getComponentCount();
      width = 0;
      for (int i = 0; i < count; i++) {
        component = target.getComponent(i);
        if (component.isVisible()) {
          dimension = component.getPreferredSize();
          width = Math.max(width, dimension.width);
          component.setSize(dimension.width, dimension.height);
          component.setLocation(x, y);
          y += dimension.height;
        }
      }
      // now set them all to the same width
      for (int i = 0; i < count; i++) {
        component = target.getComponent(i);
        if (component.isVisible()) {
          dimension = component.getSize();
          dimension.width = width;
          component.setSize(dimension.width, dimension.height);
        }
      }
    }
  }
Example #30
0
    Dimension getLayoutSize(Container parent) {
      synchronized (parent.getTreeLock()) {
        Component[] comps = parent.getComponents();
        int width = 0;
        int height = 0;
        Component header = findHeader(comps);
        if (header != null && header.isVisible()) {
          Dimension dim = header.getPreferredSize();
          width = dim.width;
          height = dim.height;
        }

        Component body = findBody(comps);
        if (body != null && body.isVisible()) {
          Dimension dim = body.getPreferredSize();
          height += dim.height;
        }

        Insets margin = parent.getInsets();
        width += (margin.left + margin.right);
        height += (margin.top + margin.bottom);
        return new Dimension(width, height);
      }
    }