private void layoutComponents()

in src/main/java/org/jetbrains/plugins/spotbugs/gui/common/NDockLayout.java [164:246]


	private void layoutComponents(final Container target, final ArrayList<Component> components, int x, int y, final int w, final int h, final int orientation) {
		int offset = 0;
		Component component = null;

		if (orientation == TOP || orientation == BOTTOM) {

			offset = x;

			int totalWidth = 0;
			int cwidth = 0;
			final int num = components.size();

			for (int i = 0; i < num; i++) {
				component = components.get(i);
				flipSeparators(component, SwingConstants.VERTICAL);
				final int widthSwap = totalWidth;
				final int cwidthSwap = cwidth;
				cwidth = component.getPreferredSize().width;
				totalWidth += cwidth;
				if (w < totalWidth && i != 0) {
					final Component c0 = components.get(i - 1);
					final Rectangle rec = c0.getBounds();
					c0.setBounds(rec.x, rec.y, w - widthSwap + cwidthSwap, rec.height);
					offset = x;
					if (orientation == TOP) {
						y += h;
						_northHeight += h;
					} else if (orientation == BOTTOM) {
						_southHeight += h;
						y -= h;
					}
					totalWidth = cwidth;
				}
				if (i + 1 == num) {
					component.setBounds(x + offset, y, w - totalWidth + cwidth, h);
				} else {
					component.setBounds(x + offset, y, cwidth, h);
					offset += cwidth;
				}
			}

			flipSeparators(component, SwingConstants.VERTICAL);

		} else {
			int totalHeight = 0;
			int cheight = 0;
			final int num = components.size();

			for (int i = 0; i < num; i++) {
				component = components.get(i);
				flipSeparators(component, SwingConstants.HORIZONTAL);
				final int heightSwap = totalHeight;
				final int cheightSwap = cheight;
				cheight = component.getPreferredSize().height;
				totalHeight += cheight;
				if (h < totalHeight && i != 0) {
					final Component c0 = components.get(i - 1);
					final Rectangle rec = c0.getBounds();
					c0.setBounds(rec.x, rec.y, rec.width, h - heightSwap + cheightSwap);
					//offset = y;
					if (orientation == LEFT) {
						x += w;
						_westWidth += w;
					} else if (orientation == RIGHT) {
						_eastWidth += w;
						x -= w;
					}
					totalHeight = cheight;
					offset = 0;
				}

				if (i + 1 == num) {
					component.setBounds(x, y + offset, w, h - totalHeight + cheight);
				} else {
					component.setBounds(x, y + offset, w, cheight);
					offset += cheight;
				}

			}

			flipSeparators(component, SwingConstants.HORIZONTAL);
		}
	}