1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| protected Rectangle positionBlock(String position, Rectangle pageRect, int width, int height)
{
float pageHeight = pageRect.getHeight();
float pageWidth = pageRect.getWidth();
Rectangle r = null;
//Rectangle constructor(float llx, float lly, float urx, float ury)
if (position.equals(POSITION_BOTTOMLEFT))
{
r = new Rectangle(0, height, width, 0);
}
else if (position.equals(POSITION_BOTTOMCENTER))
{
r = new Rectangle(width, height, (pageWidth - width), 0);
}
else if (position.equals(POSITION_BOTTOMRIGHT))
{
r = new Rectangle((pageWidth - (width / 2)), height, pageWidth, 0);
}
else if (position.equals(POSITION_TOPLEFT))
{
r = new Rectangle(0, pageHeight, width, (pageHeight - height));
}
else if (position.equals(POSITION_TOPCENTER))
{
r = new Rectangle(width, pageHeight, (pageWidth - width), (pageHeight - height));
}
else if (position.equals(POSITION_TOPRIGHT))
{
r = new Rectangle((pageWidth - (width / 2)), pageHeight, pageWidth, (pageHeight - height));
}
else if (position.equals(POSITION_CENTERLEFT))
{
r = new Rectangle(0, ((pageHeight / 2) + height), width, (pageHeight / 2));
}
else if (position.equals(POSITION_CENTER))
{
r = new Rectangle(width, ((pageHeight / 2) + height), (pageWidth - width), (pageHeight / 2));
}
else if (position.equals(POSITION_CENTERRIGHT))
{
r = new Rectangle((pageWidth - (width / 2)), ((pageHeight / 2) + height), pageWidth, (pageHeight / 2));
}
return r;
} |
Partager