void (Rectangle src, Rectangle dst, int w, int h, int cw, int ch, IdeBackgroundUtil.Fill fillType) { if (fillType == IdeBackgroundUtil.Fill.SCALE) { boolean useWidth = cw * h > ch * w; int sw = useWidth ? w : cw * h / ch; int sh = useWidth ? ch * w / cw : h; src.setBounds(0, 0, sw, sh); dst.setBounds(0, 0, cw, ch); } else if (fillType == IdeBackgroundUtil.Fill.TILE) { int dw = cw < w ? w : ((cw / w + 1) / 2 * 2 + 1) * w; int dh = ch < h ? h : ((ch / h + 1) / 2 * 2 + 1) * h; // tile rectangles are not clipped for proper anchor support src.setBounds(0, 0, w, h); dst.setBounds(0, 0, dw, dh); } else { src.setBounds(0, 0, Math.min(w, cw), Math.min(h, ch)); dst.setBounds(src); } }