예제 #1
0
    /**
     * 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;
      }
    }
예제 #2
0
  public void enableControlPanel() {
    boolean bVisible = false;

    int nmembers = buttonPane.getComponentCount();
    for (int k = 0; k < nmembers; k++) {
      Component comp = buttonPane.getComponent(k);
      if (comp != null) {
        if (comp.isVisible() || comp.isEnabled()) {
          bVisible = true;
          break;
        }
      }
    }

    if (bVisible && !buttonPane.isVisible()) {
      Dimension dim = getSize();
      Dimension dim1 = buttonPane.getPreferredSize();
      int w = dim.width;
      int h = dim.height + dim1.height;
      if (dim1.width > w) w = dim1.width;
      if (w < 300) w = 300;
      if (h < 200) h = 200;
      setSize(w, h);
    }
    buttonPane.setVisible(bVisible);
  }
예제 #3
0
  private boolean is(boolean first) {
    Container parent = getParent();
    if (parent == null) return false;

    int max = first ? Integer.MAX_VALUE : 0;
    ToolWindowAnchor anchor = getAnchor();
    Component c = null;
    int count = parent.getComponentCount();
    for (int i = 0; i < count; i++) {
      Component component = parent.getComponent(i);
      if (!component.isVisible()) continue;
      Rectangle r = component.getBounds();
      if (anchor == ToolWindowAnchor.LEFT || anchor == ToolWindowAnchor.RIGHT) {
        if (first && (max > r.y) || (!first && max < r.y)) {
          max = r.y;
          c = component;
        }
      } else {
        if (first && (max > r.x) || (!first && max < r.x)) {
          max = r.x;
          c = component;
        }
      }
    }

    return c == this;
  }
예제 #4
0
 public Dimension preferredLayoutSize(Container target) {
   Insets insets = target.getInsets();
   Dimension compMax = new Dimension(0, 0);
   int maxheight = target.getBounds().height - (insets.top + insets.bottom + vgap * 2);
   int nmembers = target.getComponentCount();
   int visiblecount = 0;
   for (int i = 0; i < nmembers; i++) {
     Component m = target.getComponent(i);
     if (m.isVisible()) {
       ++visiblecount;
       Dimension d = m.getPreferredSize();
       compMax.width = Math.max(compMax.width, d.width);
       compMax.height = Math.max(compMax.height, d.height);
     }
   }
   if (visiblecount > 0) {
     int nrows = Math.max(1, (maxheight + compMax.height / 4) / compMax.height);
     int ncols = (visiblecount + nrows - 1) / nrows;
     compMax.height = compMax.height * nrows + vgap * (nrows - 1);
     compMax.width = compMax.width * ncols + hgap * (ncols - 1);
   }
   compMax.height += insets.top + insets.bottom + vgap * 2;
   compMax.width += insets.left + insets.right + hgap * 2;
   return compMax;
 }
예제 #5
0
 private void hideDropDownButton() {
   for (Component component : this.getComponents()) {
     if (component instanceof AbstractButton && component.isVisible()) {
       component.setVisible(false);
       this.revalidate();
     }
   }
 }
예제 #6
0
  public void layoutContainer(Container target) {
    Insets insets = target.getInsets();
    Dimension size = target.getSize();
    Dimension compMax = new Dimension(0, 0);
    int maxheight = size.height - (insets.top + insets.bottom + vgap * 2);
    int nmembers = target.getComponentCount();
    int visiblecount = 0;
    for (int i = 0; i < nmembers; i++) {
      Component m = target.getComponent(i);
      if (m.isVisible()) {
        ++visiblecount;
        Dimension d = m.getPreferredSize();
        compMax.width = Math.max(compMax.width, d.width);
        compMax.height = Math.max(compMax.height, d.height);
      }
    }
    if (visiblecount > 0) {
      int nrows = Math.max(1, (maxheight + compMax.height / 4) / compMax.height);
      int ncols = (visiblecount + nrows - 1) / nrows;
      int row = 0, col = 0, currComp = 0;

      for (int i = 0; i < nmembers; i++) {
        Component m = target.getComponent(i);
        if (m.isVisible()) {
          Dimension d = m.getPreferredSize();
          int x = insets.left + hgap + col * (compMax.width + hgap);
          int y = insets.top + vgap + row * (compMax.height + vgap);

          m.setBounds(x, y, d.width, d.height);

          // move index to next component
          ++currComp;
          if (++row >= nrows) {
            row = 0;
            ++col;
          }
        }
      }
    }
    repaint();
  }
예제 #7
0
    /** 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;
        }
      }
    }
예제 #8
0
  public void layoutContainer(Container parent) {
    Insets insets = parent.getInsets();

    Component c;
    c = parent.getComponent(0);
    if (c.isVisible()) {
      c.setBounds(insets.left + 152, insets.top + 64, 176, 24);
    }
    c = parent.getComponent(1);
    if (c.isVisible()) {
      c.setBounds(insets.left + 152, insets.top + 96, 176, 24);
    }
    c = parent.getComponent(2);
    if (c.isVisible()) {
      c.setBounds(insets.left + 72, insets.top + 8, 184, 32);
    }
    c = parent.getComponent(3);
    if (c.isVisible()) {
      c.setBounds(insets.left + 16, insets.top + 64, 128, 24);
    }
    c = parent.getComponent(4);
    if (c.isVisible()) {
      c.setBounds(insets.left + 16, insets.top + 96, 128, 24);
    }
    c = parent.getComponent(5);
    if (c.isVisible()) {
      c.setBounds(insets.left + 56, insets.top + 176, 96, 32);
    }
    c = parent.getComponent(6);
    if (c.isVisible()) {
      c.setBounds(insets.left + 176, insets.top + 176, 96, 32);
    }
    c = parent.getComponent(7);
    if (c.isVisible()) {
      c.setBounds(insets.left + 152, insets.top + 128, 176, 24);
    }
    c = parent.getComponent(8);
    if (c.isVisible()) {
      c.setBounds(insets.left + 16, insets.top + 128, 128, 24);
    }
  }
예제 #9
0
  /**
   * Sets a specified <code>Component</code> to be the glass pane for this root pane. The glass pane
   * should normally be a lightweight, transparent component, because it will be made visible when
   * ever the root pane needs to grab input events.
   *
   * <p>The new glass pane's visibility is changed to match that of the current glass pane. An
   * implication of this is that care must be taken when you want to replace the glass pane and make
   * it visible. Either of the following will work:
   *
   * <pre>
   *   root.setGlassPane(newGlassPane);
   *   newGlassPane.setVisible(true);
   * </pre>
   *
   * or:
   *
   * <pre>
   *   root.getGlassPane().setVisible(true);
   *   root.setGlassPane(newGlassPane);
   * </pre>
   *
   * @param glass the <code>Component</code> to use as the glass pane for this <code>JRootPane
   *     </code>
   * @exception NullPointerException if the <code>glass</code> parameter is <code>null</code>
   */
  public void setGlassPane(Component glass) {
    if (glass == null) {
      throw new NullPointerException("glassPane cannot be set to null.");
    }

    AWTAccessor.getComponentAccessor().setMixingCutoutShape(glass, new Rectangle());

    boolean visible = false;
    if (glassPane != null && glassPane.getParent() == this) {
      this.remove(glassPane);
      visible = glassPane.isVisible();
    }

    glass.setVisible(visible);
    glassPane = glass;
    this.add(glassPane, 0);
    if (visible) {
      repaint();
    }
  }
예제 #10
0
 /**
  * The <code>glassPane</code> and <code>contentPane</code> have the same bounds, which means
  * <code>JRootPane</code> does not tiles its children and this should return false. On the other
  * hand, the <code>glassPane</code> is normally not visible, and so this can return true if the
  * <code>glassPane</code> isn't visible. Therefore, the return value here depends upon the
  * visibility of the <code>glassPane</code>.
  *
  * @return true if this component's children don't overlap
  */
 public boolean isOptimizedDrawingEnabled() {
   return !glassPane.isVisible();
 }