Package com.volantis.mcs.devices

Examples of com.volantis.mcs.devices.InternalDevice


        HashMap policies = new HashMap();
        policies.put(DeviceCapabilityConstants.HR_SUPPORTED, "none");
        policies.put(DeviceCapabilityConstants.DIV_SUPPORTED, "full");


        InternalDevice device = INTERNAL_DEVICE_FACTORY.createInternalDevice(
            new DefaultDevice("device", policies, null));
        device.setProtocolConfiguration(config);

        DeviceCapabilityManagerBuilder builder =
                new DeviceCapabilityManagerBuilder(device);

        config.setDeviceCapabilityManager(builder.build());
View Full Code Here


        policies.put(DeviceCapabilityConstants.DIV_BORDER_TOP_COLOR, "none");
        policies.put(DeviceCapabilityConstants.DIV_BORDER_TOP_WIDTH, "none");
        policies.put(DeviceCapabilityConstants.DIV_BORDER_BOTTOM_COLOR, "full");
        policies.put(DeviceCapabilityConstants.DIV_BORDER_BOTTOM_WIDTH, "full");

        InternalDevice device = INTERNAL_DEVICE_FACTORY.createInternalDevice(
            new DefaultDevice("device", policies, null));
        device.setProtocolConfiguration(config);

        DeviceCapabilityManagerBuilder builder =
                new DeviceCapabilityManagerBuilder(device);

        config.setDeviceCapabilityManager(builder.build());
View Full Code Here

        policies.put(DeviceCapabilityConstants.DIV_BORDER_TOP_COLOR, "full");
        policies.put(DeviceCapabilityConstants.DIV_BORDER_TOP_WIDTH, "full");
        policies.put(DeviceCapabilityConstants.DIV_BORDER_BOTTOM_COLOR, "none");
        policies.put(DeviceCapabilityConstants.DIV_BORDER_BOTTOM_WIDTH, "none");

        InternalDevice device = INTERNAL_DEVICE_FACTORY.createInternalDevice(
            new DefaultDevice("device", policies, null));
        device.setProtocolConfiguration(config);

        DeviceCapabilityManagerBuilder builder =
                new DeviceCapabilityManagerBuilder(device);

        config.setDeviceCapabilityManager(builder.build());
View Full Code Here

        policies.put(DeviceCapabilityConstants.DIV_BORDER_BOTTOM_COLOR, "none");
        policies.put(DeviceCapabilityConstants.DIV_BORDER_BOTTOM_WIDTH, "none");
        policies.put(DeviceCapabilityConstants.DIV_MARGIN_BOTTOM, "partial");
        policies.put(DeviceCapabilityConstants.DIV_MARGIN_TOP, "partial");

        InternalDevice device = INTERNAL_DEVICE_FACTORY.createInternalDevice(
            new DefaultDevice("device", policies, null));
        device.setProtocolConfiguration(config);

        DeviceCapabilityManagerBuilder builder =
                new DeviceCapabilityManagerBuilder(device);

        config.setDeviceCapabilityManager(builder.build());
View Full Code Here

        policies.put(DeviceCapabilityConstants.DIV_BORDER_BOTTOM_COLOR, "none");
        policies.put(DeviceCapabilityConstants.DIV_BORDER_BOTTOM_WIDTH, "none");
        policies.put(DeviceCapabilityConstants.DIV_MARGIN_BOTTOM, "partial");
        policies.put(DeviceCapabilityConstants.DIV_MARGIN_TOP, "partial");

        InternalDevice device = INTERNAL_DEVICE_FACTORY.createInternalDevice(
            new DefaultDevice("device", policies, null));
        device.setProtocolConfiguration(config);

        DeviceCapabilityManagerBuilder builder =
                new DeviceCapabilityManagerBuilder(device);

        config.setDeviceCapabilityManager(builder.build());
View Full Code Here

        implements VariablePolicyTypeSpecificSelector {

    public Variant selectVariant(
            SelectionContext context, ActivatedVariablePolicy variablePolicy) {

        InternalDevice device = context.getDevice();

        EncodingCollection supportedEncodings = device.getSupportedVideoEncodings();
        Variant variant;

        // Try TV first if it is supported.
        if (supportedEncodings.contains(VideoEncoding.TV)) {
            variant = variablePolicy.getVariantWithEncoding(VideoEncoding.TV);
View Full Code Here

        List genericVariants = variablePolicy.getGenericImages();
        if (genericVariants == null || genericVariants.isEmpty()) {
            return null;
        }

        InternalDevice device = context.getDevice();

        List images = new ArrayList(genericVariants);

        int maxWidth = -1;
        int deviceWidth = device.getPixelsX();

        EncodingCollection supportedEncodings =
                device.getSupportedImageEncodings();

        // Check each image is supported by the requesting device.  If not then
        // we can discard the image from our selection. Also remove any images that
        // are wider than the width of the device.
//        for (int i = 0; i < images.length; i++) {
        for (Iterator i = images.iterator(); i.hasNext();) {
            Variant variant = (Variant) i.next();
            ImageMetaData image = (ImageMetaData) variant.getMetaData();

            ImageEncoding encoding = image.getImageEncoding();
            if (!supportedEncodings.contains(encoding)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Discarding variant " + variant +
                            " as device does not support encoding.");
                }
                i.remove();
                continue;
            }

            int currentWidth = image.getWidth();
            if (currentWidth > deviceWidth) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Discarding variant " + variant +
                            " - width greater than device width.");
                }
                i.remove();
                continue;
            }
        }

        // If the list is empty then the device does not support any of the
        // images in the collection we are testing so we can return null.
        if (images.isEmpty()) {
            return null;
        }


        // Remove any images that are wider than the specified widthHint percentage
        // of the device width.  In this loop we also find the maximum width of all
        // the remaining variants.
        for (Iterator i = images.iterator(); i.hasNext();) {
            Variant variant = (Variant) i.next();
            ImageMetaData image = (ImageMetaData) variant.getMetaData();

            GenericImageSelection generic = (GenericImageSelection)
                    variant.getSelection();

            int widthHint = generic.getWidthHint();
            int currentWidth = image.getWidth();
            if (widthHint != 0) {
                int allowedWidth = (widthHint * deviceWidth) / 100;
                if (currentWidth > allowedWidth) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Discarding variant " + variant +
                                " - width (" + currentWidth +
                                ") greater than " + widthHint +
                                "% of device width (" + deviceWidth + ")");
                    }
                    i.remove();
                    continue;
                }
            }

            if (currentWidth > maxWidth) {
                maxWidth = currentWidth;
            }
        }

        // If the list is empty then the device does not support any of the
        // images in the collection we are testing so we can return null.
        if (images.isEmpty()) {
            return null;
        }

        // Remove any images that are less than the maximum width as we always want
        // to return the largest possible image.  Here we also check if any of the
        // images' rendering type matches the device.
        ImageRendering deviceRenderingMode = device.getRenderMode();
        boolean renderingMatch = false;
        for (Iterator i = images.iterator(); i.hasNext();) {
            Variant variant = (Variant) i.next();
            ImageMetaData image = (ImageMetaData) variant.getMetaData();

            if (image.getWidth() < maxWidth) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Discarding variant " + variant +
                            " - width less than best width.");
                }
                i.remove();
                continue;
            }

            if (image.getRendering() == deviceRenderingMode) {
                renderingMatch = true;
            }
        }

        // If the list is empty then the device does not support any of the
        // images in the collection we are testing so we can return null.
        if (images.isEmpty()) {
            return null;
        }

        int devicePixelDepth = device.getPixelDepth();

        // there is an image with a pixelDepth => devicePixelDepth
        boolean pixelDepthMatch = false;
        // there is an image with a pixelDepth of 1 when the device supports better
        boolean poorPixelDepthMatch = false;
View Full Code Here

     */
    public void testInitialisePage() throws Exception {

        // Prepare mocks and stubs

        InternalDevice device = INTERNAL_DEVICE_FACTORY.createInternalDevice(
            new DefaultDevice(null, null, null));
        final VolantisProtocolMock protocolMock =
                new VolantisProtocolMock("protocolMock", expectations, null);
        final StylingFactoryMock stylingFactoryMock =
                new StylingFactoryMock("stylingFactoryMock", expectations);
View Full Code Here

        if (policy == null) {
            return null;
        }

        // 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);
View Full Code Here

        final DefaultDevice defaultDevice =
            new DefaultDevice("device", new HashMap(), null);
        defaultDevice.setPolicyValue(
            DevicePolicyConstants.SUPPORTS_JAVASCRIPT, "true");
   
        InternalDevice device =
            INTERNAL_DEVICE_FACTORY.createInternalDevice(defaultDevice);
        DOMProtocol protocol = (DOMProtocol)builder.build(
            new ProtocolRegistry.XHTMLBasicFactory(), device);

        return protocol;
View Full Code Here

TOP

Related Classes of com.volantis.mcs.devices.InternalDevice

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.