public DefaultPageGrid(final PageDefinition pageDefinition)
{
final Rectangle2D[] pagePositions = pageDefinition.getPagePositions();
final TreeSet horizontalPositions = new TreeSet();
final TreeSet verticalPositions = new TreeSet();
final int pagePosCount = pagePositions.length;
for (int i = 0; i < pagePosCount; i++)
{
final Rectangle2D pagePosition = pagePositions[i];
final double minX = pagePosition.getMinX();
final double maxX = pagePosition.getMaxX();
final double minY = pagePosition.getMinY();
final double maxY = pagePosition.getMaxY();
if (minX == maxX || maxY == minY)
{
throw new IllegalArgumentException("This page format is invalid, it has no imageable area.");
}
horizontalPositions.add(new Double(minX));
horizontalPositions.add(new Double(maxX));
verticalPositions.add(new Double(minY));
verticalPositions.add(new Double(maxY));
}
horizontalBreaksFull = new long[horizontalPositions.size()];
int pos = 0;
for (Iterator iterator = horizontalPositions.iterator(); iterator.hasNext();)
{
final Double value = (Double) iterator.next();
horizontalBreaksFull[pos] = StrictGeomUtility.toInternalValue(value.doubleValue());
pos += 1;
}
verticalBreaksFull = new long[verticalPositions.size()];
pos = 0;
for (Iterator iterator = verticalPositions.iterator(); iterator.hasNext();)
{
final Double value = (Double) iterator.next();
verticalBreaksFull[pos] = StrictGeomUtility.toInternalValue(value.doubleValue());
pos += 1;
}
horizontalPositions.remove(new Double(0));
verticalPositions.remove(new Double(0));
horizontalBreaks = new long[horizontalPositions.size()];
pos = 0;
for (Iterator iterator = horizontalPositions.iterator(); iterator.hasNext();)
{
final Double value = (Double) iterator.next();
horizontalBreaks[pos] = StrictGeomUtility.toInternalValue(value.doubleValue());
pos += 1;
}
verticalBreaks = new long[verticalPositions.size()];
pos = 0;
for (Iterator iterator = verticalPositions.iterator(); iterator.hasNext();)
{
final Double value = (Double) iterator.next();
verticalBreaks[pos] = StrictGeomUtility.toInternalValue(value.doubleValue());
pos += 1;
}