CompositeAdapter parent = (CompositeAdapter) WidgetAdapter.getWidgetAdapter(container);
Insets insets = container.getInsets();
WidgetAdapter dropAdapter = tracingAdapter;
JComponent drop = (JComponent)dropAdapter.getParentContainer();
Point hot = dropAdapter.getHotspotPoint();
Constraints cons = adapter.getLastConstraints();
Alignment horizontal = cons.getHorizontal();
Alignment vertical = cons.getVertical();
Point ltp = parent.getMascotLocation();
int x = ltp.x - hot.x;
int y = ltp.y - hot.y;
int width = drop.getWidth();
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 Leading(x - insets.left, width, spring);
else if (horizontal instanceof Bilateral)
horizontal = new Leading(x - insets.left, 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.createRightAxis(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 Leading(x - insets.left, width, spring);
else if (horizontal instanceof Bilateral)
horizontal = new Leading(x - insets.left, 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);
last_point = null;
return true;
}