frame.setStyleNameReference(cell.getStyleNameReference());
frame.copyBox(cell.getLineBox());
for (Iterator it = cell.getChildren().iterator(); it.hasNext();)
{
JRChild child = (JRChild) it.next();
if (child instanceof JRElement)
{
JRElement element = (JRElement) child;
// clone the element in order to set the frame as group
element = (JRElement) element.clone(frame);
if (width != originalWidth)
{
scaleCellElement(element, originalWidth, width);
if (element instanceof JRElementGroup)//i.e. frame
{
JRElementGroup elementGroup = (JRElementGroup) element;
for (JRElement subelement : elementGroup.getElements())
{
scaleCellElement(subelement, originalWidth, width);
}
}
}
frame.addElement(element);
}
else if (child instanceof JRElementGroup)
{
JRElementGroup elementGroup = (JRElementGroup) child;
// clone the elements in order to set the frame as group
elementGroup = (JRElementGroup) elementGroup.clone(frame);
frame.addElementGroup(elementGroup);
if (width != originalWidth)
{
for (JRElement element : elementGroup.getElements())
{
scaleCellElement(element, originalWidth, width);
}
}
}
else
{
throw new JRRuntimeException("Unknown JRChild type " + child.getClass().getName());
}
}
return frame;
}