int height = drop.getHeight();
Spring spring = new Spring(10, 10);// TODO should be replaced by a
// container gap.
if (pair == null) {
if (horizontal instanceof Leading)
horizontal = new Leading(x - insets.left, width, spring);
else if (horizontal instanceof Trailing)
horizontal = new Trailing(container.getWidth() - x - width - insets.right, width, spring);
else if (horizontal instanceof Bilateral)
horizontal = new Trailing(container.getWidth() - x - width - insets.right, width, spring);
if (vertical instanceof Leading)
vertical = new Leading(y - insets.top, height, spring);
else if (vertical instanceof Trailing)
vertical = new Leading(y - insets.top, height, spring);
else if (vertical instanceof Bilateral)
vertical = new Leading(y - insets.top, height, spring);
} else {
if (pair.vQuart != null) {
horizontal = pair.vQuart.anchor.createLeftAxis(drop, new Rectangle(x, y, width, height), horizontal);
} else {
if (horizontal instanceof Leading)
horizontal = new Leading(x - insets.left, width, spring);
else if (horizontal instanceof Trailing)
horizontal = new Trailing(container.getWidth() - x - width - insets.right, width, spring);
else if (horizontal instanceof Bilateral)
horizontal = new Trailing(container.getWidth() - x - width - insets.right, width, spring);
}
if (pair.hQuart != null) {
vertical = pair.hQuart.anchor.createBottomAxis(drop, new Rectangle(x, y, width, height), vertical);
} else {
if (vertical instanceof Leading)
vertical = new Leading(y - insets.top, height, spring);
else if (vertical instanceof Trailing)
vertical = new Leading(y - insets.top, height, spring);
else if (vertical instanceof Bilateral)
vertical = new Leading(y - insets.top, height, spring);
}
}
assert horizontal != null && vertical != null;
Constraints constraints = new Constraints(horizontal, vertical);
container.add(drop, constraints);