home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / 1&1 / java.z / java_301 / java / awt / GridBagLayout.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-10-20  |  12.7 KB  |  703 lines

  1. package java.awt;
  2.  
  3. import java.util.Hashtable;
  4.  
  5. public class GridBagLayout implements LayoutManager {
  6.    protected static final int MAXGRIDSIZE = 128;
  7.    protected static final int MINSIZE = 1;
  8.    protected static final int PREFERREDSIZE = 2;
  9.    protected Hashtable comptable = new Hashtable();
  10.    protected GridBagConstraints defaultConstraints = new GridBagConstraints();
  11.    protected GridBagLayoutInfo layoutInfo;
  12.    public int[] columnWidths;
  13.    public int[] rowHeights;
  14.    public double[] columnWeights;
  15.    public double[] rowWeights;
  16.  
  17.    public void setConstraints(Component comp, GridBagConstraints constraints) {
  18.       this.comptable.put(comp, constraints.clone());
  19.    }
  20.  
  21.    public GridBagConstraints getConstraints(Component comp) {
  22.       GridBagConstraints constraints = (GridBagConstraints)this.comptable.get(comp);
  23.       if (constraints == null) {
  24.          this.setConstraints(comp, this.defaultConstraints);
  25.          constraints = (GridBagConstraints)this.comptable.get(comp);
  26.       }
  27.  
  28.       return (GridBagConstraints)constraints.clone();
  29.    }
  30.  
  31.    protected GridBagConstraints lookupConstraints(Component comp) {
  32.       GridBagConstraints constraints = (GridBagConstraints)this.comptable.get(comp);
  33.       if (constraints == null) {
  34.          this.setConstraints(comp, this.defaultConstraints);
  35.          constraints = (GridBagConstraints)this.comptable.get(comp);
  36.       }
  37.  
  38.       return constraints;
  39.    }
  40.  
  41.    public Point getLayoutOrigin() {
  42.       Point origin = new Point(0, 0);
  43.       if (this.layoutInfo != null) {
  44.          origin.x = this.layoutInfo.startx;
  45.          origin.y = this.layoutInfo.starty;
  46.       }
  47.  
  48.       return origin;
  49.    }
  50.  
  51.    public int[][] getLayoutDimensions() {
  52.       if (this.layoutInfo == null) {
  53.          return new int[2][0];
  54.       } else {
  55.          int[][] dim = new int[2][];
  56.          dim[0] = new int[this.layoutInfo.width];
  57.          dim[1] = new int[this.layoutInfo.height];
  58.          System.arraycopy(this.layoutInfo.minWidth, 0, dim[0], 0, this.layoutInfo.width);
  59.          System.arraycopy(this.layoutInfo.minHeight, 0, dim[1], 0, this.layoutInfo.height);
  60.          return dim;
  61.       }
  62.    }
  63.  
  64.    public double[][] getLayoutWeights() {
  65.       if (this.layoutInfo == null) {
  66.          return new double[2][0];
  67.       } else {
  68.          double[][] weights = new double[2][];
  69.          weights[0] = new double[this.layoutInfo.width];
  70.          weights[1] = new double[this.layoutInfo.height];
  71.          System.arraycopy(this.layoutInfo.weightX, 0, weights[0], 0, this.layoutInfo.width);
  72.          System.arraycopy(this.layoutInfo.weightY, 0, weights[1], 0, this.layoutInfo.height);
  73.          return weights;
  74.       }
  75.    }
  76.  
  77.    public Point location(int x, int y) {
  78.       Point loc = new Point(0, 0);
  79.       if (this.layoutInfo == null) {
  80.          return loc;
  81.       } else {
  82.          int d = this.layoutInfo.startx;
  83.  
  84.          int i;
  85.          for(i = 0; i < this.layoutInfo.width; ++i) {
  86.             d += this.layoutInfo.minWidth[i];
  87.             if (d > x) {
  88.                break;
  89.             }
  90.          }
  91.  
  92.          loc.x = i;
  93.          d = this.layoutInfo.starty;
  94.  
  95.          for(i = 0; i < this.layoutInfo.height; ++i) {
  96.             d += this.layoutInfo.minHeight[i];
  97.             if (d > y) {
  98.                break;
  99.             }
  100.          }
  101.  
  102.          loc.y = i;
  103.          return loc;
  104.       }
  105.    }
  106.  
  107.    public void addLayoutComponent(String name, Component comp) {
  108.    }
  109.  
  110.    public void removeLayoutComponent(Component comp) {
  111.    }
  112.  
  113.    public Dimension preferredLayoutSize(Container parent) {
  114.       GridBagLayoutInfo info = this.GetLayoutInfo(parent, 2);
  115.       return this.GetMinSize(parent, info);
  116.    }
  117.  
  118.    public Dimension minimumLayoutSize(Container parent) {
  119.       GridBagLayoutInfo info = this.GetLayoutInfo(parent, 1);
  120.       return this.GetMinSize(parent, info);
  121.    }
  122.  
  123.    public void layoutContainer(Container parent) {
  124.       this.ArrangeGrid(parent);
  125.    }
  126.  
  127.    public String toString() {
  128.       return this.getClass().getName();
  129.    }
  130.  
  131.    protected void DumpLayoutInfo(GridBagLayoutInfo s) {
  132.       System.out.println("Col\tWidth\tWeight");
  133.  
  134.       for(int x = 0; x < s.width; ++x) {
  135.          System.out.println(x + "\t" + s.minWidth[x] + "\t" + s.weightX[x]);
  136.       }
  137.  
  138.       System.out.println("Row\tHeight\tWeight");
  139.  
  140.       for(int var3 = 0; var3 < s.height; ++var3) {
  141.          System.out.println(var3 + "\t" + s.minHeight[var3] + "\t" + s.weightY[var3]);
  142.       }
  143.  
  144.    }
  145.  
  146.    protected void DumpConstraints(GridBagConstraints constraints) {
  147.       System.out.println("wt " + constraints.weightx + " " + constraints.weighty + ", " + "box " + constraints.gridx + " " + constraints.gridy + " " + constraints.gridwidth + " " + constraints.gridheight + ", " + "min " + constraints.minWidth + " " + constraints.minHeight + ", " + "pad " + constraints.insets.bottom + " " + constraints.insets.left + " " + constraints.insets.right + " " + constraints.insets.top + " " + constraints.ipadx + " " + constraints.ipady);
  148.    }
  149.  
  150.    protected GridBagLayoutInfo GetLayoutInfo(Container parent, int sizeflag) {
  151.       GridBagLayoutInfo r = new GridBagLayoutInfo();
  152.       int ncomponents = parent.countComponents();
  153.       r.width = r.height = 0;
  154.       int curCol = -1;
  155.       int curRow = -1;
  156.       int[] xMax = new int[128];
  157.       int[] yMax = new int[128];
  158.  
  159.       for(int compindex = 0; compindex < ncomponents; ++compindex) {
  160.          Component comp = parent.getComponent(compindex);
  161.          GridBagConstraints constraints = this.lookupConstraints(comp);
  162.          int curX = constraints.gridx;
  163.          int curY = constraints.gridy;
  164.          int curWidth = constraints.gridwidth;
  165.          if (curWidth <= 0) {
  166.             curWidth = 1;
  167.          }
  168.  
  169.          int curHeight = constraints.gridheight;
  170.          if (curHeight <= 0) {
  171.             curHeight = 1;
  172.          }
  173.  
  174.          if (curX < 0 && curY < 0) {
  175.             if (curRow >= 0) {
  176.                curY = curRow;
  177.             } else if (curCol >= 0) {
  178.                curX = curCol;
  179.             } else {
  180.                curY = 0;
  181.             }
  182.          }
  183.  
  184.          if (curX < 0) {
  185.             int px = 0;
  186.  
  187.             for(int i = curY; i < curY + curHeight; ++i) {
  188.                px = Math.max(px, xMax[i]);
  189.             }
  190.  
  191.             curX = px - curX - 1;
  192.             if (curX < 0) {
  193.                curX = 0;
  194.             }
  195.          } else if (curY < 0) {
  196.             int py = 0;
  197.  
  198.             for(int i = curX; i < curX + curWidth; ++i) {
  199.                py = Math.max(py, yMax[i]);
  200.             }
  201.  
  202.             curY = py - curY - 1;
  203.             if (curY < 0) {
  204.                curY = 0;
  205.             }
  206.          }
  207.  
  208.          int px;
  209.          for(px = curX + curWidth; r.width < px; ++r.width) {
  210.          }
  211.  
  212.          int py;
  213.          for(py = curY + curHeight; r.height < py; ++r.height) {
  214.          }
  215.  
  216.          for(int i = curX; i < curX + curWidth; ++i) {
  217.             yMax[i] = py;
  218.          }
  219.  
  220.          for(int i = curY; i < curY + curHeight; ++i) {
  221.             xMax[i] = px;
  222.          }
  223.  
  224.          Dimension d;
  225.          if (sizeflag == 2) {
  226.             d = comp.preferredSize();
  227.          } else {
  228.             d = comp.minimumSize();
  229.          }
  230.  
  231.          constraints.minWidth = d.width;
  232.          constraints.minHeight = d.height;
  233.          if (constraints.gridheight == 0 && constraints.gridwidth == 0) {
  234.             curCol = -1;
  235.             curRow = -1;
  236.          }
  237.  
  238.          if (constraints.gridheight == 0 && curRow < 0) {
  239.             curCol = curX + curWidth;
  240.          } else if (constraints.gridwidth == 0 && curCol < 0) {
  241.             curRow = curY + curHeight;
  242.          }
  243.       }
  244.  
  245.       if (this.columnWidths != null && r.width < this.columnWidths.length) {
  246.          r.width = this.columnWidths.length;
  247.       }
  248.  
  249.       if (this.rowHeights != null && r.height < this.rowHeights.length) {
  250.          r.height = this.rowHeights.length;
  251.       }
  252.  
  253.       curCol = -1;
  254.       curRow = -1;
  255.       xMax = new int[128];
  256.       yMax = new int[128];
  257.  
  258.       for(int var35 = 0; var35 < ncomponents; ++var35) {
  259.          Component comp = parent.getComponent(var35);
  260.          GridBagConstraints constraints = this.lookupConstraints(comp);
  261.          int curX = constraints.gridx;
  262.          int curY = constraints.gridy;
  263.          int curWidth = constraints.gridwidth;
  264.          int curHeight = constraints.gridheight;
  265.          if (curX < 0 && curY < 0) {
  266.             if (curRow >= 0) {
  267.                curY = curRow;
  268.             } else if (curCol >= 0) {
  269.                curX = curCol;
  270.             } else {
  271.                curY = 0;
  272.             }
  273.          }
  274.  
  275.          if (curX < 0) {
  276.             if (curHeight <= 0) {
  277.                curHeight += r.height - curY;
  278.                if (curHeight < 1) {
  279.                   curHeight = 1;
  280.                }
  281.             }
  282.  
  283.             int px = 0;
  284.  
  285.             for(int i = curY; i < curY + curHeight; ++i) {
  286.                px = Math.max(px, xMax[i]);
  287.             }
  288.  
  289.             curX = px - curX - 1;
  290.             if (curX < 0) {
  291.                curX = 0;
  292.             }
  293.          } else if (curY < 0) {
  294.             if (curWidth <= 0) {
  295.                curWidth += r.width - curX;
  296.                if (curWidth < 1) {
  297.                   curWidth = 1;
  298.                }
  299.             }
  300.  
  301.             int py = 0;
  302.  
  303.             for(int i = curX; i < curX + curWidth; ++i) {
  304.                py = Math.max(py, yMax[i]);
  305.             }
  306.  
  307.             curY = py - curY - 1;
  308.             if (curY < 0) {
  309.                curY = 0;
  310.             }
  311.          }
  312.  
  313.          if (curWidth <= 0) {
  314.             curWidth += r.width - curX;
  315.             if (curWidth < 1) {
  316.                curWidth = 1;
  317.             }
  318.          }
  319.  
  320.          if (curHeight <= 0) {
  321.             curHeight += r.height - curY;
  322.             if (curHeight < 1) {
  323.                curHeight = 1;
  324.             }
  325.          }
  326.  
  327.          int px = curX + curWidth;
  328.          int py = curY + curHeight;
  329.  
  330.          for(int i = curX; i < curX + curWidth; ++i) {
  331.             yMax[i] = py;
  332.          }
  333.  
  334.          for(int var43 = curY; var43 < curY + curHeight; ++var43) {
  335.             xMax[var43] = px;
  336.          }
  337.  
  338.          if (constraints.gridheight == 0 && constraints.gridwidth == 0) {
  339.             curCol = -1;
  340.             curRow = -1;
  341.          }
  342.  
  343.          if (constraints.gridheight == 0 && curRow < 0) {
  344.             curCol = curX + curWidth;
  345.          } else if (constraints.gridwidth == 0 && curCol < 0) {
  346.             curRow = curY + curHeight;
  347.          }
  348.  
  349.          constraints.tempX = curX;
  350.          constraints.tempY = curY;
  351.          constraints.tempWidth = curWidth;
  352.          constraints.tempHeight = curHeight;
  353.       }
  354.  
  355.       int nextSize = Integer.MAX_VALUE;
  356.  
  357.       for(int i = 1; i != Integer.MAX_VALUE; nextSize = Integer.MAX_VALUE) {
  358.          for(int var36 = 0; var36 < ncomponents; ++var36) {
  359.             Component comp = parent.getComponent(var36);
  360.             GridBagConstraints constraints = this.lookupConstraints(comp);
  361.             if (constraints.tempWidth != i) {
  362.                if (constraints.tempWidth > i && constraints.tempWidth < nextSize) {
  363.                   nextSize = constraints.tempWidth;
  364.                }
  365.             } else {
  366.                int px = constraints.tempX + constraints.tempWidth;
  367.                double weight_diff = constraints.weightx;
  368.  
  369.                for(int k = constraints.tempX; k < px; ++k) {
  370.                   weight_diff -= r.weightX[k];
  371.                }
  372.  
  373.                if (weight_diff > (double)0.0F) {
  374.                   double weight = (double)0.0F;
  375.  
  376.                   for(int var49 = constraints.tempX; var49 < px; ++var49) {
  377.                      weight += r.weightX[var49];
  378.                   }
  379.  
  380.                   for(int var50 = constraints.tempX; weight > (double)0.0F; ++var50) {
  381.                      double wt = r.weightX[var50];
  382.                      double dx = wt * weight_diff / weight;
  383.                      double[] var10000 = r.weightX;
  384.                      var10000[var50] += dx;
  385.                      weight_diff -= dx;
  386.                      weight -= wt;
  387.                   }
  388.  
  389.                   double[] var87 = r.weightX;
  390.                   var87[px - 1] += weight_diff;
  391.                }
  392.  
  393.                int pixels_diff = constraints.minWidth + constraints.ipadx + constraints.insets.left + constraints.insets.right;
  394.  
  395.                for(int var51 = constraints.tempX; var51 < px; ++var51) {
  396.                   pixels_diff -= r.minWidth[var51];
  397.                }
  398.  
  399.                if (pixels_diff > 0) {
  400.                   double weight = (double)0.0F;
  401.  
  402.                   for(int var52 = constraints.tempX; var52 < px; ++var52) {
  403.                      weight += r.weightX[var52];
  404.                   }
  405.  
  406.                   for(int var53 = constraints.tempX; weight > (double)0.0F; ++var53) {
  407.                      double wt = r.weightX[var53];
  408.                      int dx = (int)(wt * (double)pixels_diff / weight);
  409.                      int[] var88 = r.minWidth;
  410.                      var88[var53] += dx;
  411.                      pixels_diff -= dx;
  412.                      weight -= wt;
  413.                   }
  414.  
  415.                   int[] var89 = r.minWidth;
  416.                   var89[px - 1] += pixels_diff;
  417.                }
  418.             }
  419.  
  420.             if (constraints.tempHeight != i) {
  421.                if (constraints.tempHeight > i && constraints.tempHeight < nextSize) {
  422.                   nextSize = constraints.tempHeight;
  423.                }
  424.             } else {
  425.                int py = constraints.tempY + constraints.tempHeight;
  426.                double weight_diff = constraints.weighty;
  427.  
  428.                for(int k = constraints.tempY; k < py; ++k) {
  429.                   weight_diff -= r.weightY[k];
  430.                }
  431.  
  432.                if (weight_diff > (double)0.0F) {
  433.                   double weight = (double)0.0F;
  434.  
  435.                   for(int var55 = constraints.tempY; var55 < py; ++var55) {
  436.                      weight += r.weightY[var55];
  437.                   }
  438.  
  439.                   for(int var56 = constraints.tempY; weight > (double)0.0F; ++var56) {
  440.                      double wt = r.weightY[var56];
  441.                      double dy = wt * weight_diff / weight;
  442.                      double[] var90 = r.weightY;
  443.                      var90[var56] += dy;
  444.                      weight_diff -= dy;
  445.                      weight -= wt;
  446.                   }
  447.  
  448.                   double[] var91 = r.weightY;
  449.                   var91[py - 1] += weight_diff;
  450.                }
  451.  
  452.                int pixels_diff = constraints.minHeight + constraints.ipady + constraints.insets.top + constraints.insets.bottom;
  453.  
  454.                for(int var57 = constraints.tempY; var57 < py; ++var57) {
  455.                   pixels_diff -= r.minHeight[var57];
  456.                }
  457.  
  458.                if (pixels_diff > 0) {
  459.                   double weight = (double)0.0F;
  460.  
  461.                   for(int var58 = constraints.tempY; var58 < py; ++var58) {
  462.                      weight += r.weightY[var58];
  463.                   }
  464.  
  465.                   for(int var59 = constraints.tempY; weight > (double)0.0F; ++var59) {
  466.                      double wt = r.weightY[var59];
  467.                      int dy = (int)(wt * (double)pixels_diff / weight);
  468.                      int[] var92 = r.minHeight;
  469.                      var92[var59] += dy;
  470.                      pixels_diff -= dy;
  471.                      weight -= wt;
  472.                   }
  473.  
  474.                   int[] var93 = r.minHeight;
  475.                   var93[py - 1] += pixels_diff;
  476.                }
  477.             }
  478.          }
  479.  
  480.          i = nextSize;
  481.       }
  482.  
  483.       if (this.columnWidths != null) {
  484.          for(int var45 = 0; var45 < this.columnWidths.length; ++var45) {
  485.             if (r.minWidth[var45] < this.columnWidths[var45]) {
  486.                r.minWidth[var45] = this.columnWidths[var45];
  487.             }
  488.          }
  489.       }
  490.  
  491.       if (this.rowHeights != null) {
  492.          for(int var46 = 0; var46 < this.rowHeights.length; ++var46) {
  493.             if (r.minHeight[var46] < this.rowHeights[var46]) {
  494.                r.minHeight[var46] = this.rowHeights[var46];
  495.             }
  496.          }
  497.       }
  498.  
  499.       if (this.columnWeights != null) {
  500.          for(int var47 = 0; var47 < r.width && var47 < this.columnWeights.length; ++var47) {
  501.             if (r.weightX[var47] < this.columnWeights[var47]) {
  502.                r.weightX[var47] = this.columnWeights[var47];
  503.             }
  504.          }
  505.       }
  506.  
  507.       if (this.rowWeights != null) {
  508.          for(int var48 = 0; var48 < r.height && var48 < this.rowWeights.length; ++var48) {
  509.             if (r.weightY[var48] < this.rowWeights[var48]) {
  510.                r.weightY[var48] = this.rowWeights[var48];
  511.             }
  512.          }
  513.       }
  514.  
  515.       return r;
  516.    }
  517.  
  518.    protected void AdjustForGravity(GridBagConstraints constraints, Rectangle r) {
  519.       r.x += constraints.insets.left;
  520.       r.width -= constraints.insets.left + constraints.insets.right;
  521.       r.y += constraints.insets.top;
  522.       r.height -= constraints.insets.top + constraints.insets.bottom;
  523.       int diffx = 0;
  524.       if (constraints.fill != 2 && constraints.fill != 1 && r.width > constraints.minWidth + constraints.ipadx) {
  525.          diffx = r.width - (constraints.minWidth + constraints.ipadx);
  526.          r.width = constraints.minWidth + constraints.ipadx;
  527.       }
  528.  
  529.       int diffy = 0;
  530.       if (constraints.fill != 3 && constraints.fill != 1 && r.height > constraints.minHeight + constraints.ipady) {
  531.          diffy = r.height - (constraints.minHeight + constraints.ipady);
  532.          r.height = constraints.minHeight + constraints.ipady;
  533.       }
  534.  
  535.       switch (constraints.anchor) {
  536.          case 10:
  537.             r.x += diffx / 2;
  538.             r.y += diffy / 2;
  539.             return;
  540.          case 11:
  541.             r.x += diffx / 2;
  542.             return;
  543.          case 12:
  544.             r.x += diffx;
  545.             return;
  546.          case 13:
  547.             r.x += diffx;
  548.             r.y += diffy / 2;
  549.             return;
  550.          case 14:
  551.             r.x += diffx;
  552.             r.y += diffy;
  553.             return;
  554.          case 15:
  555.             r.x += diffx / 2;
  556.             r.y += diffy;
  557.             return;
  558.          case 16:
  559.             r.y += diffy;
  560.             return;
  561.          case 17:
  562.             r.y += diffy / 2;
  563.             return;
  564.          case 18:
  565.             return;
  566.          default:
  567.             throw new IllegalArgumentException("illegal anchor value");
  568.       }
  569.    }
  570.  
  571.    protected Dimension GetMinSize(Container parent, GridBagLayoutInfo info) {
  572.       Dimension d = new Dimension();
  573.       Insets insets = parent.insets();
  574.       int t = 0;
  575.  
  576.       for(int i = 0; i < info.width; ++i) {
  577.          t += info.minWidth[i];
  578.       }
  579.  
  580.       d.width = t + insets.left + insets.right;
  581.       t = 0;
  582.  
  583.       for(int var7 = 0; var7 < info.height; ++var7) {
  584.          t += info.minHeight[var7];
  585.       }
  586.  
  587.       d.height = t + insets.top + insets.bottom;
  588.       return d;
  589.    }
  590.  
  591.    protected void ArrangeGrid(Container parent) {
  592.       Insets insets = parent.insets();
  593.       int ncomponents = parent.countComponents();
  594.       Rectangle r = new Rectangle();
  595.       if (ncomponents != 0 || this.columnWidths != null && this.columnWidths.length != 0 || this.rowHeights != null && this.rowHeights.length != 0) {
  596.          GridBagLayoutInfo info = this.GetLayoutInfo(parent, 2);
  597.          Dimension d = this.GetMinSize(parent, info);
  598.          if (d.width < parent.width || d.height < parent.height) {
  599.             info = this.GetLayoutInfo(parent, 1);
  600.             d = this.GetMinSize(parent, info);
  601.          }
  602.  
  603.          this.layoutInfo = info;
  604.          r.width = d.width;
  605.          r.height = d.height;
  606.          int diffw = parent.width - r.width;
  607.          if (diffw != 0) {
  608.             double weight = (double)0.0F;
  609.  
  610.             for(int i = 0; i < info.width; ++i) {
  611.                weight += info.weightX[i];
  612.             }
  613.  
  614.             if (weight > (double)0.0F) {
  615.                for(int i = 0; i < info.width; ++i) {
  616.                   int dx = (int)((double)diffw * info.weightX[i] / weight);
  617.                   int[] var10000 = info.minWidth;
  618.                   var10000[i] += dx;
  619.                   r.width += dx;
  620.                   if (info.minWidth[i] < 0) {
  621.                      r.width -= info.minWidth[i];
  622.                      info.minWidth[i] = 0;
  623.                   }
  624.                }
  625.             }
  626.  
  627.             diffw = parent.width - r.width;
  628.          } else {
  629.             diffw = 0;
  630.          }
  631.  
  632.          int diffh = parent.height - r.height;
  633.          if (diffh != 0) {
  634.             double weight = (double)0.0F;
  635.  
  636.             for(int i = 0; i < info.height; ++i) {
  637.                weight += info.weightY[i];
  638.             }
  639.  
  640.             if (weight > (double)0.0F) {
  641.                for(int var18 = 0; var18 < info.height; ++var18) {
  642.                   int dy = (int)((double)diffh * info.weightY[var18] / weight);
  643.                   int[] var27 = info.minHeight;
  644.                   var27[var18] += dy;
  645.                   r.height += dy;
  646.                   if (info.minHeight[var18] < 0) {
  647.                      r.height -= info.minHeight[var18];
  648.                      info.minHeight[var18] = 0;
  649.                   }
  650.                }
  651.             }
  652.  
  653.             diffh = parent.height - r.height;
  654.          } else {
  655.             diffh = 0;
  656.          }
  657.  
  658.          info.startx = diffw / 2 + insets.left;
  659.          info.starty = diffh / 2 + insets.top;
  660.  
  661.          for(int compindex = 0; compindex < ncomponents; ++compindex) {
  662.             Component comp = parent.getComponent(compindex);
  663.             GridBagConstraints constraints = this.lookupConstraints(comp);
  664.             r.x = info.startx;
  665.  
  666.             for(int i = 0; i < constraints.tempX; ++i) {
  667.                r.x += info.minWidth[i];
  668.             }
  669.  
  670.             r.y = info.starty;
  671.  
  672.             for(int var20 = 0; var20 < constraints.tempY; ++var20) {
  673.                r.y += info.minHeight[var20];
  674.             }
  675.  
  676.             r.width = 0;
  677.  
  678.             for(int var21 = constraints.tempX; var21 < constraints.tempX + constraints.tempWidth; ++var21) {
  679.                r.width += info.minWidth[var21];
  680.             }
  681.  
  682.             r.height = 0;
  683.  
  684.             for(int var22 = constraints.tempY; var22 < constraints.tempY + constraints.tempHeight; ++var22) {
  685.                r.height += info.minHeight[var22];
  686.             }
  687.  
  688.             this.AdjustForGravity(constraints, r);
  689.             if (r.width > 0 && r.height > 0) {
  690.                if (comp.x != r.x || comp.y != r.y || comp.width != r.width || comp.height != r.height) {
  691.                   comp.reshape(r.x, r.y, r.width, r.height);
  692.                }
  693.  
  694.                comp.show();
  695.             } else {
  696.                comp.hide();
  697.             }
  698.          }
  699.  
  700.       }
  701.    }
  702. }
  703.