int hmargin = height / 2;
double scalefactor = Math.min(winSizeX / (2.0 * wmargin + width),
winSizeY / (2.0 * hmargin + height));
PCamera lc = canvas.getCamera();
lc.scaleView(scalefactor / lc.getViewScale());
lc.animateViewToPanToBounds(new Rectangle(x1 - hmargin, y1 - hmargin,
2 * wmargin + width,
2 * hmargin + height), 0);
}
}