@Override
	public void layout() {

		Container parent = getParent();
		for (GUIElement child : parent.getChildren()) {

			List<Anchor> anchorList = constraints.get(child);
			if (anchorList == null)
				continue;
			Rectangle rect = new Rectangle(child.getPreferredSize());

			for (Anchor anchor : anchorList) {

				int start = getSideValue(anchor.start, anchor.startSide);
				int end = getSideValue(anchor.end, anchor.endSide);
				int position = (int) ((end - start) * anchor.percent + start);

				switch (anchor.moveSide) {
					case TOP:
						rect.y = position;
						break;
					case BOTTOM:
						rect.height = position - rect.y;
						break;
					case LEFT:
						rect.x = position;
						break;
					case RIGHT:
						rect.width = position - rect.x;
						break;
				}
			}
			child.setBounds(rect);
			child.setPreferredSize(rect.getSize());
		}
	}