/** Constrains a point to the current grid. */ protected Point constrainPoint(Point p) { // constrain to view size Dimension size = getSize(); // p.x = Math.min(size.width, Math.max(1, p.x)); // p.y = Math.min(size.height, Math.max(1, p.y)); p.x = Geom.range(1, size.width, p.x); p.y = Geom.range(1, size.height, p.y); if (fConstrainer != null) { return fConstrainer.constrainPoint(p); } return p; }
/** * Internal MDI frames have offsets where a popup menu should be shown (in JDK 1.2). This method * sums up iteratively all x and y offsets of all parent compontents until the top parent * component is reached. */ private void adjustOffsets(Component comp, Point offsetPoint) { if (comp != null) { Point compLocation = comp.getLocation(); offsetPoint.translate(compLocation.x, compLocation.y); adjustOffsets(comp.getParent(), offsetPoint); } }