SegmentGridInstance segmentGridContext =
(SegmentGridInstance) instance;
// Initialise the attributes.
SegmentGridAttributes attributes =
segmentGridContext.getAttributes();
String value;
int ivalue;
value = (String) grid.getAttribute(
FormatConstants.BORDER_WIDTH_ATTRIBUTE);
try {
ivalue = Integer.parseInt(value);
} catch (NumberFormatException nfe) {
ivalue = 0;
}
attributes.setBorderWidth(ivalue);
value = (String) grid.getAttribute(
FormatConstants.BORDER_COLOUR_ATTRIBUTE);
attributes.setBorderColor(value);
value = (String) grid.getAttribute(
FormatConstants.FRAME_BORDER_ATTRIBUTE);
attributes.setFrameBorder("true".equalsIgnoreCase(value));
value = (String) grid.getAttribute(
FormatConstants.FRAME_SPACING_ATTRIBUTE);
try {
ivalue = Integer.parseInt(value);
} catch (NumberFormatException nfe) {
ivalue = 0;
}
attributes.setFrameSpacing(ivalue);
// Make column width array
int columns = grid.getColumns();
int columnWidths [] = new int[columns];
String columnWidthUnits [] = new String[columns];
for (int i = 0; i < columnWidths.length; i += 1) {
Column column = grid.getColumn(i);
String width = column.getWidth();
if (width != null) {
columnWidths[i] = Integer.parseInt(width);
} else {
columnWidths[i] = -1;
}
columnWidthUnits[i] = column.getWidthUnits();
}
if (columnWidths.length > 0) {
attributes.setColumnWidths(columnWidths);
attributes.setColumnWidthUnits(columnWidthUnits);
}
// Make row height array
int rows = grid.getRows();
int rowHeights [] = new int[rows];
String rowHeightUnits [] = new String[rows];
for (int i = 0; i < rowHeights.length; i += 1) {
Row row = grid.getRow(i);
String height = row.getHeight();
if (height != null) {
rowHeights[i] = Integer.parseInt(height);
} else {
rowHeights[i] = -1;
}
rowHeightUnits[i] = row.getHeightUnits();
}
if (rowHeights.length > 0) {
attributes.setRowHeights(rowHeights);
attributes.setRowHeightUnits(rowHeightUnits);
}
// Get the module.
LayoutModule module = context.getLayoutModule();