// get the trigger point from the trigger
TriggerPoint position = resolveStyle(pop.trigger, TRIGGER_POINT);
// get the origin point from the menu
BoxPoint origin = resolveStyle(pop.trigger, POPUP_ORIGIN);
// get the desired position, may be relative to trigger or pointer
Point tpos = position.getLocation(pop.trigger, pop.pointer);
Point mpos = origin.resolve(0, 0, width, height, new Point());
// figure out the best place to put the menu, in screen coordinates; starting with
// the requested popup position
Rectangle bounds = new Rectangle(tpos.x - mpos.x, tpos.y - mpos.y, width, height);