javax.microedition.contactless.visual
Interface VisualTagConnection

All Superinterfaces:
javax.microedition.io.Connection

public interface VisualTagConnection
extends javax.microedition.io.Connection

This interface provides contactless connection to a visual tag (bar code) target. It can be used to retrieve data from visual tags and to generate visual tag images.

VisualTagConnection is built on top of Generic Connection Framework GCF. The URL needed to open a VisualTagConnection is provided in the TargetProperties received in the TargetListener callback when target is discovered. The connection may also be opened manually without DiscoveryManager functionality. Below is the definition for the URL in the EBNF format. As the connection is opened before any target is available, the URL only contains the scheme definition.

   <visual tag url> ::= "vtag:"
 


Method Summary
 java.lang.Object generateVisualTag(byte[] data, java.lang.Class imageClass, ImageProperties properties)
          Generates a visual tag image containing specified data.
 byte[] readVisualTag(java.lang.Object tagImage, java.lang.Class imageClass, java.lang.String symbologyName)
          Reads a visual tag.
 
Methods inherited from interface javax.microedition.io.Connection
close
 

Method Detail

readVisualTag

byte[] readVisualTag(java.lang.Object tagImage,
                     java.lang.Class imageClass,
                     java.lang.String symbologyName)
                     throws VisualTagCodingException,
                            java.io.IOException

Reads a visual tag. The application has access to the visual tag image and the used image class is provided as parameter. The symbology to be used in decoding the data is also specified. Names of the standardized symbologies are defined in SymbologyManager class. If decoding of the data fails, a VisualTagCodingException is thrown.

Parameters:
tagImage - visual tag image to be decoded
imageClass - the class identifying the type of the tagImage, null if platform default image class is used
symbologyName - name of the symbology to be used in the data decoding
Returns:
data from the visual tag
Throws:
java.lang.NullPointerException - if tagImage or symbology is null
java.lang.IllegalArgumentException - if symbology or imageClass is not supported by the API implementation
VisualTagCodingException - if decoding visual tag fails
java.io.IOException - if connection has been closed

generateVisualTag

java.lang.Object generateVisualTag(byte[] data,
                                   java.lang.Class imageClass,
                                   ImageProperties properties)
                                   throws VisualTagCodingException,
                                          java.io.IOException

Generates a visual tag image containing specified data. The visual tag image is generated according to the properties defined in the properties parameter and it is an instance of the specified image class. The application developer retrieves the image properties are with method SymbologyManager.getImageProperties. method. It is also recommended that the size of the screen is checked before generating the visual tag image to make sure that the generated image fits completely on the screen. If encoding of the data fails, a VisualTagCodingException is thrown.

The implementation of this method must produce the best quality image that fits into the given image dimensions. This must be done with as little anti-aliasing as possible, and the returned image must still be readable. If the implementation can not generate the image without heavy zooming or anti-aliasing, an IllegalArgumentException must be thrown.

Parameters:
data - data to be encoded into the visual tag image
imageClass - the instance of the Class object that must be used in the generated image, null if platform default image class is used
properties - properties of visual tag image to be generated
Returns:
generated visual tag image object
Throws:
java.lang.NullPointerException - if data or properties is null
java.lang.IllegalArgumentException - if imageClass is not supported by the API implementation or the image according the properties cannot be generated
VisualTagCodingException - if encoding of the data fails
java.io.IOException - if connection has been closed


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