// Returns a point whose x and y fields represent the required pages wide // and tall, respectively private Point estimatePagesRequired(int width, int height) { if (width <= 0 || height <= 0) return new Point(0, 0); Point pref = target.preferredSize(); Point prefPages = new Point(pref.x / width, pref.y / height); Point min = target.minimumSize(); // Adding width-1 rounds up page count w/out floating point op // Same goes for adding height-1 Point minPages = new Point( Math.max((min.x + width - 1) / width, 1), Math.max((min.y + height - 1) / height, 1)); return new Point(Math.max(prefPages.x, minPages.x), Math.max(prefPages.y, minPages.y)); }
public Point preferredSize() { return target.preferredSize(); }
public boolean hasNext() { return currentPiece != null || target.hasNext(); }
public Point minimumSize() { return target.minimumSize(); }