Package com.volantis.mcs.runtime.policies

Examples of com.volantis.mcs.runtime.policies.SelectedVariant


        // TODO: factor together with AbstractImageElement
        MarinerPageContext pageContext = protocol.getMarinerPageContext();

        AssetResolver resolver = pageContext.getAssetResolver();

        SelectedVariant selectedVariant =
                resolver.selectBestVariant(reference, null);

        String url = resolver.retrieveVariantURLAsString(selectedVariant);
        if (url == null) {
            return;
        }

        url = resolver.rewriteURLWithPageURLRewriter(url, PageURLType.IMAGE);

        ImageAttributes imageAttributes = new ImageAttributes();

        BaseLocation location = resolver.getBaseLocation(selectedVariant);
        imageAttributes.setLocalSrc(location == BaseLocation.DEVICE);

        Variant variant = selectedVariant.getVariant();
        ImageMetaData image = (ImageMetaData) variant.getMetaData();
        // Make a note of whether this image is a convertible
        // image asset
        if (image.getConversionMode() == ImageConversionMode.ALWAYS_CONVERT) {
            imageAttributes.setConvertibleImageAsset(true);
View Full Code Here


        }

        // Cache selection.
        final InternalDevice device = context.getDevice();
        Object key = new DeviceSpecificKey(device.getName(), requiredEncodings);
        SelectedVariant selected;
        synchronized (policy) {
            selected = policy.getSelected(key);
            if (selected == null) {
                selected = selectBest(context, policy, requiredEncodings);
                policy.putSelected(key, selected);
View Full Code Here

    private SelectedVariant selectBest(
            SelectionContext context,
            ActivatedVariablePolicy policy,
            EncodingCollection requiredEncodings) {

        SelectedVariant selection = policyVariantSelector.selectVariant(
                context, policy, requiredEncodings);

        if (selection == null) {

            // Try fallback.
            PolicyType policyType = policy.getPolicyType();
            RuntimePolicyReference fallbackReference = (RuntimePolicyReference)
                    policy.getAlternatePolicy(policyType);
            if (fallbackReference != null) {
                PolicyFetcher fetcher = context.getPolicyFetcher();
                policy = (ActivatedVariablePolicy)
                        fetcher.fetchPolicy(fallbackReference);
                if (policy == null) {
                    selection = POLICY_NOT_FOUND;
                } else {
                    return selectBest(context, policy, requiredEncodings);
                }
            }
        } else {
            Variant variant = selection.getVariant();
            VariantType variantType = variant.getVariantType();
            if (variantType == VariantType.NULL) {
                selection = new SelectedVariantImpl(policy, null,
                        selection.getDevice(), null);
            }
        }

        return selection;
    }
View Full Code Here

                        resolver.resolveUnquotedPolicyExpression(
                                imageComponentName, PolicyType.IMAGE);

                AssetResolver assetResolver = pageContext.getAssetResolver();

                SelectedVariant selected =
                        assetResolver.selectBestVariant(reference, null);

                // Try and find the best image asset with the specified name.
                if (selected != null) {
                    ImageAsset imageAsset =
                            (ImageAsset) selected.getOldObject();
                    if (imageAsset == null) {
                        // No image asset which matches could be found so use the
                        // alt text, if any.

                        // And then try and write out the alt or fallback text,
                        // if we can
                        AltTextAttributes altTextAttrs =
                                new AltTextAttributes(attributes);
                        altTextAttrs.setStyles(pattributes.getStyles());
                        altText = new FallbackComponentTextAssetReference(
                                assetResolver, selected.getPolicy(), altText);
                        altTextAttrs.setAltText(altText);

                        if (protocol.writeAltText(altTextAttrs)) {
                            return SKIP_ELEMENT_BODY;
                        }

                    } else {
                        String[] srcArray = pageContext.
                                retrieveImageAssetURLAsString(imageAsset);
                        url = srcArray[0];

                        AssetGroup assetGroup =
                                assetResolver.getAssetGroup(imageAsset);
                        if (assetGroup != null) {
                            pattributes.setLocalSrc(AssetGroup.ON_DEVICE ==
                                    assetGroup.getLocationType());
                        } else {
                            pattributes.setLocalSrc(false);
                        }

                        // Make a note of whether this image is a convertible
                        // image asset
                        if (imageAsset instanceof ConvertibleImageAsset) {
                            pattributes.setConvertibleImageAsset(true);
                        } else {
                            pattributes.setConvertibleImageAsset(false);
                        }

                        pattributes.setHeight(StringConvertor.
                                valueOf(imageAsset.getPixelsY()));
                        pattributes.setWidth(StringConvertor.
                                valueOf(imageAsset.getPixelsX()));

                        ImageMetaData metadata = (ImageMetaData) selected.getVariant().getMetaData();

                        if (ImageConversionMode.ALWAYS_CONVERT ==
                            metadata.getConversionMode()) {

                            PixelDimensionsMetaData dimMetaData =
                                (PixelDimensionsMetaData) selected
                                    .getVariant().getMetaData();

                            // save height and width in pixels unit to object's parameter map
                            if (dimMetaData.getHeight() != 0) {
                                pattributes.setHeight(StringConvertor.valueOf(dimMetaData
View Full Code Here

        RuntimePolicyReference reference =
            resolver.resolveUnquotedPolicyExpression(name,
                PolicyType.LAYOUT);

        SelectedVariant selected = assetResolver.selectBestVariant(
            reference, null);
        RuntimeDeviceLayout deviceLayout = null;

        if (selected != null) {
            deviceLayout = (RuntimeDeviceLayout)selected.getOldObject();
        }

        if (deviceLayout == null) {
            logger.warn("xdime-could-not-find-layout=", name);
        }
View Full Code Here

        RuntimePolicyReference reference =
            resolver.resolveUnquotedPolicyExpression(themeName,
                PolicyType.THEME);

        SelectedVariant selected = assetResolver.selectBestVariant(
            reference, null);

        RuntimeDeviceTheme runtimeDeviceTheme = null;

        if (selected != null) {
            runtimeDeviceTheme = (RuntimeDeviceTheme)selected.getOldObject();
        }

        return runtimeDeviceTheme;
    }
View Full Code Here

                            audioComponentName, PolicyType.AUDIO);

            AssetResolver assetResolver = pageContext.getAssetResolver();

            // Only supports AMR encoding at the moment.
            SelectedVariant selected = assetResolver.selectBestVariant(
                    reference, ENCODING_COLLECTION);
            if (selected != null) {
                usePolicy(pageContext, selected, attributes);
            }
        }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.runtime.policies.SelectedVariant

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.