javax.microedition.contactless.visual
Interface ImageProperties


public interface ImageProperties

This interface collects the properties of visual tag image that are common to all symbologies. It also provides an extension mechanism to manage varying properties of different symbologies. These properties are used in visual tag image generation.

The quiet zone required around the visual tag image to make it readable from the surrounding data is included into the height and width specified for the visual tag image. This means that the API implementation must make sure that the generated image with the quiet zone fits into the given image dimensions.

The API implementation must create a symbology specific class for each symbology that it supports. This symbology specific class must implement this interface. These new classes collect all properties specific to a particular symbology. The symbology specific classes must define key names for the new properties as integer constants. The naming convention for the extended keys is that the name must start with the symbology name, like for example CODE-39_X_DIMENSION. The API implementation must provide default values for all the properties and specify what is the object the property is represented in. The methods in this interface can be used to change those default values and to get the values of the symbology specific properties.

As this specification does not specify any extended properties for the different symbologies these properties are implementation dependent. This means that the application developer should always use the default values retrieved with SymbologyManager.getImageProperties(symbology) method. Changing the default values is possible, but it makes the application dependant on the specific API implementation.

Following list describes the tasks the symbology-specific property class must handle:

Below is an example of the properties class for Code 39 symbology. It provides four new properties for Code 39 symbology.

public class Code39Properties implements ImageProperties {

    private String symbology;
    private double resolution;
    private double width;
    private double height;
    private int sizeUnit;
    private int logicalSizeUnit;

    public final static int CODE-39_X_DIMENSION = 51; // double 
    public final static int CODE-39_WIDE_TO_NARROW = 52; // double
    public final static int CODE-39_INTERCHARACTER_GAP = 53; // double
    public final static int CODE-39_CHECK_CHARACTER = 54; // boolean

    public Code39Properties() {

        this.symbology = "code-39";
        this.resolution = 72.0;
        this.width = 100.0;
        this.height = 20.0; 
        this.sizeUnit = ImageProperties.PHYSICAL_SIZE_UNIT_PIXEL;
        this.logicalUnitSize = 1;

        // set Code 39 related properties
        setProperty(CODE-39_X_DIMENSION, new Double(20.0));
        setProperty(CODE-39_WIDE_TO_NARROW, new Double(2.2));
        setProperty(CODE-39_INTERCHARACTER_GAP, new Double(3));
        setProperty(CODE-39_CHECK_CHARACTER, new Boolean(true));
    }

    // Implements the methods from the ImageProperties
    ...
}
 


Field Summary
static int PHYSICAL_SIZE_UNIT_INCH
          Constant for inches as physical size unit
static int PHYSICAL_SIZE_UNIT_MILLIMETER
          Constant for millimeters as physical size unit
static int PHYSICAL_SIZE_UNIT_PIXEL
          Constant for pixels as physical size unit
 
Method Summary
 int getLogicalUnitSize()
          Returns the size of a single unit used in the symbology in pixels.
 double getPhysicalHeigth()
          Returns the maximum height of the visual tag image.
 int getPhysicalSizeUnit()
          Returns the unit for the physical dimensions.
 double getPhysicalWidth()
          Returns the maximum width of the visual tag image.
 java.lang.Object getProperty(int key)
          Returns the value of the requested property as an object.
 int[] getPropertyKeys()
          Returns the list of the property keys.
 double getResolution()
          Returns the resolution of the visual tag image.
 java.lang.String getSymbology()
          Returns the symbology of the visual tag image.
 void setLogicalUnitSize(int size)
          Sets the size of the single unit used in the symbology in pixels.
 void setPhysicalHeight(double height)
          Sets the maximum height for the visual tag image.
 void setPhysicalSizeUnit(int sizeUnit)
          Sets the unit for the physical dimensions.
 void setPhysicalWidth(double width)
          Sets the maximum width for the visual tag image.
 void setProperty(int key, java.lang.Object value)
          Sets the property for specified key.
 void setResolution(double resolution)
          Sets the resolution for the visual tag image.
 void setSymbology(java.lang.String symbology)
          Sets the symbology for the visual tag image.
 

Field Detail

PHYSICAL_SIZE_UNIT_INCH

static final int PHYSICAL_SIZE_UNIT_INCH
Constant for inches as physical size unit

See Also:
Constant Field Values

PHYSICAL_SIZE_UNIT_MILLIMETER

static final int PHYSICAL_SIZE_UNIT_MILLIMETER
Constant for millimeters as physical size unit

See Also:
Constant Field Values

PHYSICAL_SIZE_UNIT_PIXEL

static final int PHYSICAL_SIZE_UNIT_PIXEL
Constant for pixels as physical size unit

See Also:
Constant Field Values
Method Detail

getLogicalUnitSize

int getLogicalUnitSize()
Returns the size of a single unit used in the symbology in pixels. This unit can be, for example, the width of a module in data-matrix or the width of a narrow bar in code-39 symbology. The default value of this property is 1 pixel.

Returns:
the size of the symbology's logical unit in pixels

getPhysicalHeigth

double getPhysicalHeigth()
Returns the maximum height of the visual tag image. The height is represented in the unit specified by the ImagePropertyes.getPhysicalSizeUnit() method.

Returns:
the maximum height of the image

getPhysicalSizeUnit

int getPhysicalSizeUnit()
Returns the unit for the physical dimensions. This parameter is represented as integer, where only valid values are the constants defined in this class.

Returns:
physical size unit of the image

getPhysicalWidth

double getPhysicalWidth()
Returns the maximum width of the visual tag image. The width is represented in the unit specified by the ImagePropertyes.getPhysicalSizeUnit() method.

Returns:
the maximum width of the image

getProperty

java.lang.Object getProperty(int key)
Returns the value of the requested property as an object. Returned value is either the default value set by the implementation or the value modified by the application.

Parameters:
key - the identifier of the property
Returns:
value of the property, null if the key is not defined

getPropertyKeys

int[] getPropertyKeys()
Returns the list of the property keys. Since each property must have a default value, this method returns the keys for all extended properties. The actual property value can be retrieved with method ImageProperties.getProperty(int key) .

Returns:
key values of extended properties

getResolution

double getResolution()
Returns the resolution of the visual tag image. The resolution means the number of dots (in printing) or pixels (on screen) per physical unit. With this the dots or pixels can be converted to physical size and vice versa.

Returns:
the resolution of the image

getSymbology

java.lang.String getSymbology()
Returns the symbology of the visual tag image.

Returns:
the name of the symbology

setLogicalUnitSize

void setLogicalUnitSize(int size)
Sets the size of the single unit used in the symbology in pixels. This unit can be, for example, the width of a module in data-matrix or the width of a narrow bar in code-39 symbology. Value must be greater than zero.

Parameters:
size - the size of the logical unit in pixels
Throws:
java.lang.IllegalArgumentException - if size is less or equal to zero

setPhysicalHeight

void setPhysicalHeight(double height)
Sets the maximum height for the visual tag image. This is the maximum height of the visual tag image that the application is able to handle.

Parameters:
height - the maximum height
Throws:
java.lang.IllegalArgumentException - if height is less or equal to zero

setPhysicalSizeUnit

void setPhysicalSizeUnit(int sizeUnit)
Sets the unit for the physical dimensions. This parameter is represented as integer, where only valid values are the constants defined in this class.

Parameters:
sizeUnit - unit of the physical size
Throws:
java.lang.IllegalArgumentException - if sizeUnit is not one of the constants defined in this class

setPhysicalWidth

void setPhysicalWidth(double width)
Sets the maximum width for the visual tag image. This is the maximum width of the visual tag image that the application is able to handle.

Parameters:
width - the maximum width
Throws:
java.lang.IllegalArgumentException - if width is less or equal to zero

setProperty

void setProperty(int key,
                 java.lang.Object value)
Sets the property for specified key.

Parameters:
key - the key identifier of the property
value - the value of the property
Throws:
java.lang.IllegalArgumentException - if key is not one of the constants defined in the class implementing this interface or the value cannot be converted into the type of the property
java.lang.NullPointerException - if value is null

setResolution

void setResolution(double resolution)
Sets the resolution for the visual tag image.

Parameters:
resolution - the image resolution
Throws:
java.lang.IllegalArgumentException - if resolution is less or equal to zero

setSymbology

void setSymbology(java.lang.String symbology)
Sets the symbology for the visual tag image.

Parameters:
symbology - the name of the symbology
Throws:
java.lang.NullPointerException - if symbology is null


Copyright © 2005-2006 Nokia Corporation. All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.