J2ME Polish
J2ME Polish 2.4 Documentation
Enough Software

Designing for Specific Devices or Device-Groups

Sometimes the design needs to be adapted to a specific device or a group of devices. You can easily use specific pictures, styles etcetera by using the appropriate sub folders of the "resources" folder.
See also the general resources assembling.

The Hierarchy of the "resources" Folder

In the resources folder itself you put all resources and design definitions which should be valid for all devices. In the folder named like the vendor of a device (e.g. "Nokia", "Samsung" or "Motorola") you put all resources and design definitions for devices of that vendor. In the folder named like the explicit and implicit groups of a device you add the resources and design definitions for these device-groups. An explicit group is for example the "Series60" group, implicit groups are defined by the supported APIs of a device and the BitsPerPixel capability of devices. You can add a small movie for all devices which support the Mobile Media API (mmapi) by putting that movie into the "resources/mmapi" folder. Or you can add colored images for all devices which have at least a color depth of 8 bits per pixel by putting these images into the "resources/BitsPerPixel8+" folder. Last but not least you can use device specific resources and design definitions by putting them into the "resources/[vendor]/[device]" folder, e.g. "resources/Nokia/N95 " or "resources/Samsung/E700". Any existing resources will be overwritten by more specific resources:

  1. At first the basic resources and definitions found in the "resources" folder will be used.
  2. Secondly the vendor-specific resources will be used, e.g. "resources/Nokia".
  3. Thirdly the group-specific resources will be used, e.g. "resources/mmapi", "resources/Series60", "resources/BitsPerPixel.8+" or "resources/BitsPerPixe.16".
  4. The resources and settings in the device specific folder will overwrite all other resources and settings. The device specific folder is for example the folder "resources/Nokia/N95 " for the Nokia/N95 phone or the folder "resources/Samsung/E700" for Samsung's E700.

All resources will be copied into the root of the application, so if you want to access an image called "my-imgage.png" you need to load it with the path "/my-image.png" in the source code.

When you add the polish.css file for a specific vendor, group or device, you do not need to repeat all styles and attributes from the more basic settings. You need to specify the more specific setting only. When you want to change the color of a font, you just need to specify the "font-color" attribute of that style. No other attributes or styles need to be defined. This is the cascading character of the Cascading Style Sheets of J2ME Polish.

This example illustrates the cascading character of polish.css:

In "resources/polish.css" you define the style "myStyle":

.myStyle {
	font-color: white;
	font-style: bold;
	font-size: large;
	font-face: proportional;
	background-color: black;
}

You can change the font-color of that style for all Nokia devices with the following declaration in "resources/Nokia/polish.css":

.myStyle {
	font-color: gray;
}

You can specify another font-size and font-color for the Nokia 6600 phone with these settings in "resources/Nokia/N95 /polish.css":

.myStyle {
	font-color: red;
	font-size: medium;
}

Groups

Every device can have explicit and implicit groups. Explicit groups are stated by the <groups> element of the device in the file devices.xml. Implicit groups are defined by the capabilities of the device: Each supported API results in an implicit group and the BitsPerPixel capability results in several groups.

Java-Platform-Groups

When a device supports the MIDP/1.0 standard, it belongs to the "midp1" group.

When a device supports the MIDP/2.0 standard, it belongs to the "midp2" group.

Java-Configuration-Groups

When a device supports the CLDC/1.0 standard, it belongs to the "cldc1.0" group.

When a device supports the CLDC/1.1 standard, it belongs to the "cldc1.1" group.

API-Groups

For each supported API the device belongs to a group with the name of that API (in lowercase). When the device supports the Mobile Media API (mmapi), it belongs to the "mmapi"-group. When the device supports the Nokia-UI API, it belongs to the "nokia-ui" group. The name of the group is defined by the <symbol> element of the API in the file apis.xml.

BitsPerPixel-Groups

Every device display has a specific color depth which is specified by the BitsPerPixel-capability of that device in the devices.xml file. Depending on how many bits per pixel are supported, the device belongs to different groups:

BitsPerPixel  Colors  Groups
1 21=2 (b/w) BitsPerPixel.1
4 24=16 BitsPerPixel.4
BitsPerPixel.4+
8 28=256 BitsPerPixel.8
BitsPerPixel.8+
BitsPerPixel.4+
12 212=4.096 BitsPerPixel.12
BitsPerPixel.12+
BitsPerPixel.8+
BitsPerPixel.4+
16 216=65.536 BitsPerPixel.16
BitsPerPixel.16+
BitsPerPixel.12+
BitsPerPixel.8+
BitsPerPixel.4+
18 218=262.144 BitsPerPixel.18
BitsPerPixel.18+
BitsPerPixel.16+
BitsPerPixel.12+
BitsPerPixel.8+
BitsPerPixel.4+
24 224=16.777.216 BitsPerPixel.24
BitsPerPixel.24+
BitsPerPixel.16+
BitsPerPixel.12+
BitsPerPixel.8+
BitsPerPixel.4+

So you can put images for phones with at least 16 colors into the "resources/BitsPerPixel.4+" folder. And you can specify settings for true color devices in the file "resources/BitsPerPixel.24/polish.css".

back to top