final CommandFactory cmdFactory = CommandFactory.getInstance();
MfRecord mf;
while ((mf = readNextRecord()) != null)
{
final MfCmd cmd = cmdFactory.getCommand(mf.getType());
if (cmd == null)
{
logger.info("Failed to parse record " + mf.getType());
}
else
{
cmd.setRecord(mf);
if (cmd.getFunction() == MfType.SET_WINDOW_ORG)
{
final MfCmdSetWindowOrg worg = (MfCmdSetWindowOrg) cmd;
final Point p = worg.getTarget();
minX = Math.min(p.x, minX);
minY = Math.min(p.y, minY);
}
else if (cmd.getFunction() == MfType.SET_WINDOW_EXT)
{
final MfCmdSetWindowExt worg = (MfCmdSetWindowExt) cmd;
final Dimension d = worg.getDimension();
maxWidth = Math.max(maxWidth, d.width);
maxHeight = Math.max(maxHeight, d.height);