void doZoom() { if (owner == null) { return; } owner.pack(); Dimension screenSize = owner.getToolkit().getScreenSize(); Dimension windowSize = owner.getPreferredSize(); Point windowLoc = owner.getLocation(); boolean locChanged = false; boolean sizeChanged = false; if (windowLoc.x + windowSize.width > screenSize.width) { windowLoc.x = Math.max(0, screenSize.width - windowSize.width); locChanged = true; if (windowLoc.x + windowSize.width > screenSize.width) { windowSize.width = screenSize.width - windowLoc.x; sizeChanged = true; } } if (windowLoc.y + windowSize.height > screenSize.height) { windowLoc.y = Math.max(0, screenSize.height - windowSize.height); locChanged = true; if (windowLoc.y + windowSize.height > screenSize.height) { windowSize.height = screenSize.height - windowLoc.y; sizeChanged = true; } } if (locChanged) { owner.setLocation(windowLoc); } if (sizeChanged) { owner.setSize(windowSize); } }
@Override public boolean contains(Location loc, boolean assumeFilled) { Object type = getPaintType(); if (assumeFilled && type == DrawAttr.PAINT_STROKE) { type = DrawAttr.PAINT_STROKE_FILL; } if (type != DrawAttr.PAINT_FILL) { int stroke = getStrokeWidth(); double[] q = toArray(loc); double[] p0 = toArray(this.p0); double[] p1 = toArray(this.p1); double[] p2 = toArray(this.p2); double[] p = CurveUtil.findNearestPoint(q, p0, p1, p2); if (p == null) { return false; } int thr; if (type == DrawAttr.PAINT_STROKE) { thr = Math.max(Line.ON_LINE_THRESH, stroke / 2); } else { thr = stroke / 2; } if (LineUtil.distanceSquared(p[0], p[1], q[0], q[1]) < thr * thr) { return true; } } if (type != DrawAttr.PAINT_STROKE) { QuadCurve2D curve = getCurve(null); if (curve.contains(loc.getX(), loc.getY())) { return true; } } return false; }