Package com.volantis.mcs.layouts

Examples of com.volantis.mcs.layouts.SegmentGrid


            if (!instance.isEmpty()) {
                if (logger.isDebugEnabled()) {
                    logger.debug("SegmentGridRenderer.render");
                }

                SegmentGrid grid = (SegmentGrid)instance.getFormat();

                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();

                module.writeOpenSegmentGrid(attributes);

                // Write out children
                int index;
                for (int r = 0; r < rows; r += 1) {
                    for (int c = 0; c < columns; c += 1) {
                        index = r * columns + c;
                        Format child = grid.getChildAt(index);
                        if (child != null) {
                            FormatInstance childInstance =
                                    context.getFormatInstance(child,
                                            instance.getIndex());
                            context.renderFormat(childInstance);
View Full Code Here

TOP

Related Classes of com.volantis.mcs.layouts.SegmentGrid

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.