Package com.volantis.mcs.runtime.layouts.styling

Examples of com.volantis.mcs.runtime.layouts.styling.FormatStylingEngine


        if (styleClass == null) {
            styleClass = "fraglinks";
        }

        // Get the styles associated with the fragment.
        FormatStylingEngine formatStylingEngine =
                formatRendererContext.getFormatStylingEngine();
        Styles styles = formatStylingEngine.startStyleable(source, styleClass);
        a.setStyles(styles);

        if (pageContext.getPageTagId() != null) {
            a.setId(pageContext.getPageTagId());
        }
        a.setName(fragmentName);

        final OutputBuffer linkBuffer = getLinkBuffer(destination, toEnclosing);

        a.setLinkText(linkBuffer);

        VolantisProtocol protocol = pageContext.getProtocol();
        try {
            protocol.writeFragmentLink(a);
        } catch (ProtocolException pe) {
            throw new RendererException(
                    exceptionLocalizer.format("renderer-error", destination),
                    pe);
        }
   
        formatStylingEngine.endStyleable(source);
    }
View Full Code Here


        GridAttributes attributes = gridInstance.getAttributes();

        TableLayers layers = new TableLayers();

        // Style the grid, and then style all of its columns.
        FormatStylingEngine formatStylingEngine =
                context.getFormatStylingEngine();
        Styles formatStyles = formatStylingEngine.startStyleable(
                grid, grid.getStyleClass());
        layers.setLayer(TableLayers.TABLE, formatStyles);

        attributes.setStyles(formatStyles);
        attributes.setLayers(layers);

        // Style the columns so that we can pick up the height and any
        // other properties associated with the column's style class
        // if any.

        // Style the group of columns. This is to simply group the grid columns
        // together within a single element to simplify the use of those
        // selectors that rely on the position of an element within its parent,
        // e.g. nth-child().
        Styles columnGroupStyles = formatStylingEngine.startStyleable(
                SyntheticStyleableFormat.GRID_COLUMNS,
                null);
        layers.setLayer(TableLayers.COLUMN_GROUP, columnGroupStyles);

        Styles[] columnStyles = getColumnStyles(grid, formatStylingEngine,
                requiredColumns);

        formatStylingEngine.endStyleable(
                SyntheticStyleableFormat.GRID_COLUMNS);

        if (logger.isDebugEnabled()) {
            logger.debug("Grid.writeOutput()");
        }

        attributes.setColumns(columns);

        // Should the order of the columns be reversed,
        // false = 0...n, true = n...0
        boolean reversed =
                DirectionHelper.isDirectionReversed(grid, formatStyles);

        // Open the grid, even if no rows are written
        attributes.setFormat(grid);
        module.writeOpenGrid(attributes);

        // Style the group of rows. See the comment in getColumnStyles().
        Styles bodyStyles = formatStylingEngine.startStyleable(
                SyntheticStyleableFormat.GRID_BODY, null);
        layers.setLayer(TableLayers.ROW_GROUP, bodyStyles);

        // Write out children
        for (int r = 0; r < grid.getRows(); r++) {

            // If the row is completely empty then ignore it.
            if (requiredRows[r]) {
                writeRow(r, context, reversed, columnStyles, gridInstance,
                        requiredColumns, module, columns, layers);
            } else if (logger.isDebugEnabled()) {
                logger.debug("Output not required for row " + r);
            }

        }

        formatStylingEngine.endStyleable(
                SyntheticStyleableFormat.GRID_BODY);

        module.writeCloseGrid(attributes);
        formatStylingEngine.endStyleable(grid);
    }
View Full Code Here

        Grid grid = (Grid) gridInstance.getFormat();

        Row row = grid.getRow(rowPosition);

        FormatStylingEngine formatStylingEngine =
                context.getFormatStylingEngine();
        Styles rowStyles = formatStylingEngine.startStyleable(
                row, row.getStyleClass());
        layers.setLayer(TableLayers.ROW, rowStyles);

        GridRowAttributes rowAttributes = gridInstance.getRowAttributes();

        rowAttributes.resetAttributes();
        rowAttributes.setStyles(rowStyles);
        rowAttributes.setFormat(grid);
        rowAttributes.setColumns(columns);
        rowAttributes.setRow(rowPosition);
        rowAttributes.setLayers(layers);

        module.writeOpenGridRow(rowAttributes);

        writeSubRow(context, gridInstance, rightToLeft, rowPosition,
                columnStyles,
                requiredColumns, columns, module, layers);

        module.writeCloseGridRow(rowAttributes);

        formatStylingEngine.endStyleable(row);
    }
View Full Code Here

            GridInstance gridInstance, Styles[] columnStyles, int column,
            int row, int columns, GridFormatModule module,
            TableLayers layers)
            throws RendererException {

        FormatStylingEngine formatStylingEngine =
                context.getFormatStylingEngine();

        layers.setLayer(TableLayers.COLUMN, columnStyles[column]);

        // Get the styles for the child.
        Styles childStyles = formatStylingEngine.startStyleable(
                SyntheticStyleableFormat.GRID_CELL, null);
        layers.setLayer(TableLayers.CELL, childStyles);

        layers.mergeColumnStylesIntoCellStyles(
                childStyles, row == 0, column == 0);

        Grid grid = (Grid) gridInstance.getFormat();

        GridChildAttributes childAttributes =
                gridInstance.getChildAttributes();

        childAttributes.resetAttributes();

        childAttributes.setRow(row);
        childAttributes.setColumn(column);
        childAttributes.setStyles(childStyles);
        childAttributes.setFormat(grid);
        childAttributes.setColumns(columns);
        childAttributes.setLayers(layers);

        // Write out the per-child preamble, even if the child
        // is null because otherwise the grid will be
        // misaligned.

        module.writeOpenGridChild(childAttributes);

        Format child = grid.getChildAt(row, column);

        if (child != null) {
            FormatInstance childInstance =
                    context.getFormatInstance(
                            child, gridInstance.getIndex());

            // Now render the child
            context.renderFormat(childInstance);
        }

        module.writeCloseGridChild(childAttributes);

        formatStylingEngine.endStyleable(
                SyntheticStyleableFormat.GRID_CELL);
    }
View Full Code Here

    // Javadoc inherited.
    public void pushDeviceLayoutContext(DeviceLayoutContext context) {
        ImmutablePropertyValues propertyValues =
                context.getInheritableStyleValues();
        FormatStylingEngine stylingEngine = getFormatStylingEngine();
        stylingEngine.pushPropertyValues(propertyValues);

        pageContext.pushDeviceLayoutContext(context);
    }
View Full Code Here

    public void popDeviceLayoutContext() {
        DeviceLayoutContext context = pageContext.popDeviceLayoutContext();

        ImmutablePropertyValues propertyValues =
                context.getInheritableStyleValues();
        FormatStylingEngine stylingEngine = getFormatStylingEngine();
        stylingEngine.popPropertyValues(propertyValues);
    }
View Full Code Here

                // Initialise the attributes.
                PaneAttributes attributes = paneInstance.getAttributes();

                // Style the format.
                String styleClass = paneInstance.getStyleClass();
                FormatStylingEngine formatStylingEngine =
                        context.getFormatStylingEngine();
                Styles formatStyles = formatStylingEngine.startStyleable(
                        pane, styleClass);
                attributes.setStyles(formatStyles);
                attributes.setPane(pane);

                renderPaneInstance(context, paneInstance);

                // Finished styling the pane and its contents.
                formatStylingEngine.endStyleable(pane);
            }
        } catch (IOException e) {
            throw new RendererException(exceptionLocalizer.format(
                    "renderer-error",
                    instance.getFormat()), e);
View Full Code Here

        SpatialFormatIterator spatial = (SpatialFormatIterator)
                instance.getFormat();

        // Start styling
        FormatStylingEngine formatStylingEngine =
                context.getFormatStylingEngine();
        Styles formatStyles = formatStylingEngine.startStyleable(
                spatial, spatial.getStyleClass());

        CoordinateConverter converter = chooseCoordinateConverter(
                context, instance, spatial, formatStyles);

        render(context, instance, formatStyles, converter);

        formatStylingEngine.endStyleable(spatial);
    }
View Full Code Here

    // javadoc inherited
    public void render()
            throws RendererException {

        // Start styling
        FormatStylingEngine formatStylingEngine =
                context.getFormatStylingEngine();

        // Now render the spatial iterator and its grid children as an
        // integrated grid (and ensure the child children's content is
        // also rendered)

        EndlessStringArray rowStyleClasses = spatial.getRowStyleClasses();
        EndlessStringArray columnStyleClasses = spatial.getColumnStyleClasses();

        NDimensionalIndex childIndex =
                formatInstance.getIndex().addDimension();

        // Retrieve the number of rows and columns.
        int rows = converter.getRows();
        //        assert rows > 0;
        int columns = converter.getColumns();
        //        assert columns > 0;

        // Open the spatial format iterator.
        module.writeOpenSpatialFormatIterator(spatialAttributes);

        // Get the styles for the spatial iterator columns. Do these up front
        // as they will be merged into the styles for the cells later on.

        // Style the group of columns. This simply groups the spatial columns
        // together within a single element to simplify the use of those
        // selectors that rely on the position of an element within its parent,
        // e.g. nth-child().
        Styles groupStyles = formatStylingEngine.startStyleable(
                SyntheticStyleableFormat.SPATIAL_COLUMNS,
                null);
        setDisplayStyle(groupStyles, DisplayKeywords.TABLE_ROW_GROUP);
        spatialLayers.setLayer(TableLayers.COLUMN_GROUP, groupStyles);

        Styles[] columnStyles = getColumnStyles(
                formatStylingEngine, columns, requiredSlices,
                columnStyleClasses);

        formatStylingEngine.endStyleable(
                SyntheticStyleableFormat.SPATIAL_COLUMNS);

        // Style the group of rows. See the comment in getColumnStyles().
        Styles spatialBodyStyles = formatStylingEngine.startStyleable(
                SyntheticStyleableFormat.SPATIAL_BODY,
                null);
        setDisplayStyle(spatialBodyStyles, DisplayKeywords.TABLE_ROW_GROUP);
        spatialLayers.setLayer(TableLayers.ROW_GROUP, spatialBodyStyles);

        for (int row = 0; row < rows; row++) {
            if (!requiredSlices.isSpatialRowRequired(row)) {
                continue;
            }

            Styles rowStyles = formatStylingEngine.startStyleable(
                    SyntheticStyleableFormat.SPATIAL_ROW,
                    rowStyleClasses.get(row));

            // Make sure that the row has the correct display.
            setDisplayStyle(rowStyles, DisplayKeywords.TABLE_ROW);
            spatialLayers.setLayer(TableLayers.ROW, rowStyles);

            openSpatialRow(rowStyles);

            for (int column = 0; column < columns; column++) {
                if (!requiredSlices.isSpatialColumnRequired(column)) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("No spatial cell required at [" +
                                column + "," + row + "]");
                    }
                    continue;
                }

                spatialLayers.setLayer(TableLayers.COLUMN,
                        columnStyles[column]);

                Styles cellStyles = formatStylingEngine.startStyleable(
                        SyntheticStyleableFormat.SPATIAL_CELL, null);

                // Make sure that the cell has the correct display.
                setDisplayStyle(cellStyles, DisplayKeywords.TABLE_CELL);

                spatialLayers.setLayer(TableLayers.CELL, cellStyles);

                openSpatialCell(cellStyles, row, column);

                // Map the 2D (row, col) coordinates down onto the
                // 1D sequence of instances.
                int position = converter.getPosition(column, row);

                // Set and store the new child index.
                childIndex = childIndex.setCurrentFormatIndex(position);
                context.setCurrentFormatIndex(childIndex);

                writeChild(childIndex, row, column);

                closeSpatialCell();

                formatStylingEngine.endStyleable(
                        SyntheticStyleableFormat.SPATIAL_CELL);
            }

            closeSpatialRow();

            formatStylingEngine.endStyleable(
                    SyntheticStyleableFormat.SPATIAL_ROW);
        }

        formatStylingEngine.endStyleable(
                SyntheticStyleableFormat.SPATIAL_BODY);

        // Handle the spatial processing postamble
        module.writeCloseSpatialFormatIterator(spatialAttributes);
View Full Code Here

        RuntimeDeviceLayout runtimeDeviceLayout = context.getDeviceLayout();
        CompiledStyleSheet layoutStyleSheet =
                runtimeDeviceLayout.getCompiledStyleSheet();

        // Set up the styling engine with the applicable style sheets.
        FormatStylingEngine formatStylingEngine =
                formatRendererContext.getFormatStylingEngine();
        // First add the layout style sheet into the styling engine.
        formatStylingEngine.pushStyleSheet(layoutStyleSheet);
        // Then add the theme style sheet(s) into the styling engine.
        CompiledStyleSheetCollection themeStyleSheets =
                context.getThemeStyleSheets();
        if (themeStyleSheets != null) {
            themeStyleSheets.pushAll(formatStylingEngine);
        }
        // else, allow tests to run without doing the above. Dodgy.

        // Process a nested inclusion, this is done after the page context has been
        // updated in order to make sure that the nesting depth is correct.
        boolean inclusion = (context.getIncludingDeviceLayoutContext() != null);

        if (inclusion) {
            module.beginNestedInclusion();
        }

        module.writeOpenLayout(attributes);

        Fragment fragment = formatRendererContext.getCurrentFragment();
        if (fragment == null) {
            if (logger.isDebugEnabled()) {
                String name =
                        deviceLayout != null ? deviceLayout.getName():null;
                logger.debug("Writing out the Layout named "
                             + name + " to the page");

                // Write the format tree

            }
            Format root = deviceLayout.getRootFormat();
            if (root != null) {
                FormatInstance rootInstance =
                        formatRendererContext.getFormatInstance(
                                root, index);
                formatRendererContext.renderFormat(rootInstance);
            } else {
                if (logger.isDebugEnabled()) {
                    logger.debug("Empty layout");
                }
            }

        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("Writing out the fragment named "
                             + fragment.getName() + " to the page");
            }
            // Write out the fragment and the fragment link list which contains
            // links to the fragment's parent and peer fragments.
            if (!module.getSupportsFragmentLinkListTargetting()) {
                // Write out parent/peer fragment link list *after* the fragment.
                // This is necessary as the fragment link list is being appended to
                // the existing content and must therefore come after it.

                // First, write out the fragment itself
                FormatInstance fragmentInstance =
                        formatRendererContext.getFormatInstance(
                                fragment, index);
                formatRendererContext.renderFormat(fragmentInstance);

                // Then, write out the parent/peer fragment link list.
                writeFragmentLinkList(fragment, formatRendererContext);
            } else {
                // Write out parent/peer fragment link list *before* the fragment.
                // This is necessary as the fragment link list is going into it's
                // own pane which would be empty if we tried to render it before
                // creating them.

                // First, write out parent/peer fragment link list.
                writeFragmentLinkList(fragment, formatRendererContext);
                // Then, write out the fragment itself.
                FormatInstance fragmentInstance =
                        formatRendererContext.getFormatInstance(
                                fragment, index);

                formatRendererContext.renderFormat(fragmentInstance);
            }

        }

        // Write the link to the default segment if necessary.
        SegmentLinkWriter segmentLinkWriter =
                formatRendererContext.getSegmentLinkWriter();
        segmentLinkWriter.writeDefaultSegmentLink();

        module.writeCloseLayout(attributes);

        // Finish processing the nested inclusion.
        if (inclusion) {
            module.endNestedInclusion();
        }

        // Clean up the styling information we added to the styling engine.
        // This should be done in reverse order.
        // First we remove the theme style sheet(s).
        if (themeStyleSheets != null) {
            themeStyleSheets.popAll(formatStylingEngine);
        }
        // else, allow tests to run without the above. Dodgy.

        // Then we remove the layout style sheet.
        formatStylingEngine.popStyleSheet(layoutStyleSheet);

        // Restore the old DeviceLayoutContext.
        formatRendererContext.popDeviceLayoutContext();
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.runtime.layouts.styling.FormatStylingEngine

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.