Packagemx.core
Classpublic class RuntimeDPIProvider
InheritanceRuntimeDPIProvider Inheritance Object

Language Version : ActionScript 3.0
Product Version : Flex 4.5
Runtime Versions : Flash Player 10, AIR 2.5

The RuntimeDPIProvider class provides the default mapping of similar device DPI values into predefined DPI classes. An Application may have its runtimeDPIProvider property set to a subclass of RuntimeDPIProvider to override Flex's default mappings. Overriding Flex's default mappings will cause changes in the Application's automatic scaling behavior.

Overriding Flex's default mappings is usually only necessary for devices that incorrectly report their screenDPI and for devices that may scale better in a different DPI class.

Flex's default mappings are:

160 DPI<140 DPI
160 DPI>=140 DPI and <=200 DPI
240 DPI>=200 DPI and <=280 DPI
320 DPI>=280 DPI and <=400 DPI
480 DPI>=400 DPI and <=560 DPI
640 DPI>=640 DPI

Subclasses of RuntimeDPIProvider should only depend on runtime APIs and should not depend on any classes specific to the Flex framework except mx.core.DPIClassification.

View the examples

See also

mx.core.DPIClassification
spark.components.Application.applicationDPI


Public Properties
 PropertyDefined By
  runtimeDPI : Number
[read-only] Returns the runtime DPI of the current device by mapping its flash.system.Capabilities.screenDPI to one of several DPI values in mx.core.DPIClassification.
RuntimeDPIProvider
Public Methods
 MethodDefined By
  
Constructor.
RuntimeDPIProvider
Property Detail
runtimeDPIproperty
runtimeDPI:Number  [read-only]

Language Version : ActionScript 3.0
Product Version : Flex 4.5
Runtime Versions : Flash Player 10, AIR 2.5

Returns the runtime DPI of the current device by mapping its flash.system.Capabilities.screenDPI to one of several DPI values in mx.core.DPIClassification. A number of devices can have slightly different DPI values and Flex maps these into the several DPI classes. Flex uses this method to calculate the current DPI value when an Application authored for a specific DPI is adapted to the current one through scaling.

Exceptions:


Implementation
    public function get runtimeDPI():Number

See also

flash.system.Capabilities
mx.core.DPIClassification
Constructor Detail
RuntimeDPIProvider()Constructor
public function RuntimeDPIProvider()

Language Version : ActionScript 3.0
Product Version : Flex 4.5
Runtime Versions : Flash Player 10, AIR 2.5

Constructor.

Examples
RuntimeDPIProviderApp.mxml
<?xml version="1.0" encoding="utf-8"?>
<!--

  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

-->
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark"
        firstView="views.RuntimeDPIProviderAppView" 
        applicationDPI="160" runtimeDPIProvider="RuntimeDPIProviderExample" >
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
</s:ViewNavigatorApplication>
RuntimeDPIProviderExample.as

////////////////////////////////////////////////////////////////////////////////
//
//  Licensed to the Apache Software Foundation (ASF) under one or more
//  contributor license agreements.  See the NOTICE file distributed with
//  this work for additional information regarding copyright ownership.
//  The ASF licenses this file to You under the Apache License, Version 2.0
//  (the "License"); you may not use this file except in compliance with
//  the License.  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
package
{
import flash.system.Capabilities;

import mx.core.DPIClassification;
import mx.core.RuntimeDPIProvider;

public class RuntimeDPIProviderExample extends RuntimeDPIProvider
{
    public function RuntimeDPIProviderExample()
    {
    }
    
    override public function get runtimeDPI():Number
    {
        // A tablet reporting an incorrect DPI of 240.
        if (Capabilities.screenDPI == 240 &&
            Capabilities.screenResolutionX == 600 &&
            Capabilities.screenResolutionY == 1024)
        {
            return DPIClassification.DPI_160;
        }
        
        return super.runtimeDPI;
    }
}
}
RuntimeDPIProviderAppView.mxml
<?xml version="1.0" encoding="utf-8"?>
<!--

  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

-->
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView">

    <s:layout>
        <s:VerticalLayout />
    </s:layout>
    
    <s:Button label="Example Button" />
    <s:HSlider />
    <s:List width="100%" height="100%" borderVisible="true">
        <s:ArrayList>
            <fx:String>apple</fx:String>
            <fx:String>banana</fx:String>
            <fx:String>cherry</fx:String>
            <fx:String>diagonal</fx:String>
            <fx:String>ergonomical</fx:String>
            <fx:String>freedom</fx:String>
            <fx:String>gorge</fx:String>
            <fx:String>house</fx:String>
            <fx:String>ice</fx:String>
        </s:ArrayList>
    </s:List>
</s:View>