CIC iSign Version 1.2

InkTools
Class CicDoodle

java.lang.Object
  |
  +--InkTools.CicDoodle
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class CicDoodle
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

CIC's general ink object. A signature is at its basic level a collection of x/y data (points) which are collected into strokes (defined as the points from 'pen down' to 'pen up')(see InkTools.CicStroke) which are then collected within a CicDoodle object. Therefore the CicDoodle object represents the ink data of a signature.

Within the InkTools SDK, the CicDoodle object is used to collect, store and manipulate the ink data of a signature. This structure is used as the input for many of the InkTools classes.

The ink data is collected and stored in its original (raw) form, this means the sampling resolution and sampling rate of the input device (digitizer) as well as the point range of the input device (digitizer extension) must be stored with the point data in order to correctly map the ink data onto the screen and to get the right result from the verification engine. Functions to set these values as well as function to rescale the ink data are provided.

In order to save the ink data on file or database, or to transmit ink data over network/internet, a streamOut function is provided. The streamOut function will convert the ink data into a byte stream, will compress and encrypt the ink data and transform the byte stream into an ASCI string if this is desired. Functions to set encryption and compression parameters are provided. With the streamIn function a previously streamed out signature can get relaoded into a doodle for redisplay or signature verification.

Version:
1.0
Author:
CIC
See Also:
Serialized Form

Field Summary
static int BASE64
          specifies stabdarde Base64 encoding
static int CIC_PRINTABLE
          specifies CIC's nonPrinting encoding
static int DES
          used in setEnryptionAlg: DES 56 bit encryption algorithm
static int DES40
          used in setEnryptionAlg: DES 40 bit encryption algorithm
static int FAST
          used in setEnryptionAlg: CIC's FAST encryption algorithm
static int TRIPLEDES
          used in setEnryptionAlg: DES 128 bit encryption algorithm
 
Constructor Summary
CicDoodle()
          Contructs an empty ink object.
CicDoodle(CicDoodle sourceD)
          Constructs an ink object from another ink object by duplicating all data.
 
Method Summary
 void add(CicStroke newStroke)
          Clones the stroke and adds it to the doodle.
 void copyDoodle(CicDoodle targetD, CicDoodle sourceD)
          Copies the source doodle into the target doodle.
 void delete()
          Deletes all the ink data from the doodle.
 void enableEncryption(boolean enable)
          Enables the encryption for the streamOut function.
 CicDoodle getCopyOfDoodle()
          Creates a new CicDoodle objects and dublicates all the values (clone).
 java.awt.Rectangle getInkBounds()
          Returns the bounderies of the current Ink in screen coordinates.
 CicStroke getLastStroke()
          Returns the last stroke added to this this object.
 int getNumberOfPoints()
          Returns the total number of points within this ink object.
 int getNumberOfStrokes()
          Returns the number of strokes within this ink object.
 int getSamplingRate()
          Returns the sampling rate of the input device on which the current ink was collected.
 int getSpatResolution()
          Returns the spatial resolution of the input device on which the current ink was collected.
 CicStroke getStroke(int index)
          Returns the stroke referenced by index.
 int getXExtent()
          Gets the x extent for this ink object.
 int getYExtent()
          Gets the y extent for this ink object.
 boolean hasInk()
          Checks if this ink object has any ink data in it.
 void newPoint(java.awt.Point newPoint)
          Adds a new point to the current stroke.
 CicStroke newStroke()
          Creates a new and empty CicStroke object and adds it to the doodle.
 void offsetDoodle(int xOff, int yOff)
          Adds the offset to all points of the doodle.
 void scale(double xScale, double yScale)
          Scales the current ink according to the passed in values.
 void setCompressionLevel(int level)
          Sets the compression level for the ink data the streamOut function will use:
 void setEncryptionAlg(int alg)
          Sets the encryption algorithm:
 void setEncryptionKey(java.lang.String key)
          Sets the encryption key.
 void setSamplingRate(int newSamplingRate)
          Sets the sampling rate of the device used for collecting the ink.
 void setSpatResolution(int newSpatResolution)
          Sets the spatial resolution of the input device for the current ink.
 boolean setStringEncodingAlg(int encoderAlgorithm)
          Sets the encoding algorithm if the streamOut function is called with removeNonPrinting set to true.
 void setXExtent(int newXExtent)
          Sets the x extent for this ink object.
 void setYExtent(int newYExtent)
          Sets the y extent for this ink object.
 boolean streamIn(byte[] byteInArray)
          Stream ink in from a byte array.
 boolean streamIn(java.lang.String fileName)
          Streams ink data in from a file.
 byte[] streamOut(boolean removeNonePrinting)
          Streams the current ink out into a byte array.
 boolean streamOut(java.lang.String fileName, boolean removeNonePrinting)
          Streams the current ink out into a file.
 void takeStroke(CicStroke newStroke)
          Adds this stroke to the doodle.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DES40

public static final int DES40
used in setEnryptionAlg: DES 40 bit encryption algorithm

See Also:
Constant Field Values

DES

public static final int DES
used in setEnryptionAlg: DES 56 bit encryption algorithm

See Also:
Constant Field Values

TRIPLEDES

public static final int TRIPLEDES
used in setEnryptionAlg: DES 128 bit encryption algorithm

See Also:
Constant Field Values

FAST

public static final int FAST
used in setEnryptionAlg: CIC's FAST encryption algorithm

See Also:
Constant Field Values

CIC_PRINTABLE

public static final int CIC_PRINTABLE
specifies CIC's nonPrinting encoding

See Also:
Constant Field Values

BASE64

public static final int BASE64
specifies stabdarde Base64 encoding

See Also:
Constant Field Values
Constructor Detail

CicDoodle

public CicDoodle()
Contructs an empty ink object. Default properties are set.


CicDoodle

public CicDoodle(CicDoodle sourceD)
Constructs an ink object from another ink object by duplicating all data.

Method Detail

newStroke

public CicStroke newStroke()
Creates a new and empty CicStroke object and adds it to the doodle.

Returns:
the new created CicStroke object

add

public void add(CicStroke newStroke)
Clones the stroke and adds it to the doodle.

Parameters:
newStroke - the stroke to be cloned

takeStroke

public void takeStroke(CicStroke newStroke)
Adds this stroke to the doodle.

Parameters:
newStroke - stroke to be added.

newPoint

public void newPoint(java.awt.Point newPoint)
Adds a new point to the current stroke.

Parameters:
newPoint - the point to be added

streamOut

public byte[] streamOut(boolean removeNonePrinting)
Streams the current ink out into a byte array. The ink is compressed according to the current compression level. If encryption is enabled, the ink data stream gets encrypted. If removeNonePrinting is true, the byte stream is converted into printable ASCI characters. The size of the returned array is exactly the 'byte.length' of the returned array.

Parameters:
removeNonePrinting - true if the byte stream should consist only of printable ASCII characters, false otherwise
Returns:
a byte buffer containing the ink

streamOut

public boolean streamOut(java.lang.String fileName,
                         boolean removeNonePrinting)
Streams the current ink out into a file. The ink is compressed according to the current compression level. If encryption is enabled, the ink data stream gets encrypted. If removeNonePrinting is true, the byte stream is converted into printable ASCI characters.

Parameters:
fileName - the file name for the ink data
removeNonePrinting - true if the byte stream should consist only of printable ASCII characters, false otherwise
Returns:
true if successful, otherwise false (file error)

streamIn

public boolean streamIn(java.lang.String fileName)
Streams ink data in from a file. Note that if the ink data is encrypted, the correct encryption key must be set beforehand. Encryption algorithm and compression level will be automatically dedected. The loading of the ink will fail if the file couldn't get read, if the ink data was encrypted and the encryption key (setEncryptionKey) was wrong or the ink data was corrupt.

Parameters:
fileName - the file containing the ink data
Returns:
true if ink was successfully loaded, otherwise false

streamIn

public boolean streamIn(byte[] byteInArray)
Stream ink in from a byte array. Note that if the ink data is encrypted, the correct encryption key must be set beforehand. Encryption algorithm and compression level will be automatically dedected. The loading of the ink will fail if the ink data was encrypted and the encryption key (setEncryptionKey) was wrong or the ink data was corrupt.

Parameters:
byteInArray - the byte array containing the ink
Returns:
true if the ink was successfully loaded, otherwise false

delete

public void delete()
Deletes all the ink data from the doodle. All strokes are deleted.


getNumberOfStrokes

public int getNumberOfStrokes()
Returns the number of strokes within this ink object. If no ink is present a '0' will be returned.

Returns:
number of strokes

hasInk

public boolean hasInk()
Checks if this ink object has any ink data in it.

Returns:
true if ink is available, otherwise false

getNumberOfPoints

public int getNumberOfPoints()
Returns the total number of points within this ink object. The points within each stroke are added for the end result.

Returns:
the number of points in this object

getStroke

public CicStroke getStroke(int index)
Returns the stroke referenced by index. The original stroke is returned, not a copy! Clone a new stroke from this stroke if the original data has to get preserved.

Parameters:
index - the index number of the stroke to be returned
Returns:
the stroke requested

getLastStroke

public CicStroke getLastStroke()
Returns the last stroke added to this this object.

Returns:
the last stroke

setXExtent

public void setXExtent(int newXExtent)
Sets the x extent for this ink object. The x extent is the maximum value the input device for this ink can report on the x axis.

Parameters:
newXExtent - the x extent

getXExtent

public int getXExtent()
Gets the x extent for this ink object. The x extent is the maximum value the input device for this ink can report on the x axis.

Returns:
the x extent

setYExtent

public void setYExtent(int newYExtent)
Sets the y extent for this ink object. The x extent is the maximum value the input device for this ink can report on the y axis.

Parameters:
newYExtent - the y extent

getYExtent

public int getYExtent()
Gets the y extent for this ink object. The y extent is the maximum value the input device for this ink can report on the y axis.

Returns:
the y extent

setSamplingRate

public void setSamplingRate(int newSamplingRate)
Sets the sampling rate of the device used for collecting the ink. The messurement is points per seconds (pps). It specifies how often the digitizer is sampling position data on the device.

Parameters:
newSamplingRate - the sampling rate

getSamplingRate

public int getSamplingRate()
Returns the sampling rate of the input device on which the current ink was collected. The messurement is points per seconds (pps). It specifies how often the digitizer is sampling position data on the device.

Returns:
the sampling rate

setSpatResolution

public void setSpatResolution(int newSpatResolution)
Sets the spatial resolution of the input device for the current ink. The messurement is lines per inch (lpi). It specifies how many distinctive values the digitizer can sample within one inch of its serface.

Parameters:
newSpatResolution - the new spatial resolution

getSpatResolution

public int getSpatResolution()
Returns the spatial resolution of the input device on which the current ink was collected. The messurement is lines per inch (lpi). It specifies how many distinctive values the digitizer can sample within one inch of its serface.

Returns:
the current spatial resolution

getInkBounds

public java.awt.Rectangle getInkBounds()
Returns the bounderies of the current Ink in screen coordinates. Note: x and y are the offset of the signature. To get the real width and height, substract the offet from the width and height (bounds.width-bounds.x). This function is used internal to see if the signature fits onto the InkControl.

Returns:
a Rectangle object for the current ink boundaries

scale

public void scale(double xScale,
                  double yScale)
Scales the current ink according to the passed in values. This is done through multiplication of every point with these values. Used internally if the ink data has to get resized in order to fit into the InkControl..

Parameters:
xScale - value
yScale - value

offsetDoodle

public void offsetDoodle(int xOff,
                         int yOff)
Adds the offset to all points of the doodle. Note: changes the Doodle Data. Note: to offset toward the origin, the offset value must be negative.

Parameters:
xOff - offset value
yOff - offset value

enableEncryption

public void enableEncryption(boolean enable)
Enables the encryption for the streamOut function. Note: the encryption key has to get set also!

Parameters:
enable - true to enable -, false to disable encryption

setEncryptionAlg

public void setEncryptionAlg(int alg)
Sets the encryption algorithm:

Parameters:
alg - the number for the encryption algorithm

setEncryptionKey

public void setEncryptionKey(java.lang.String key)
Sets the encryption key. For DES, DES40 and FAST, the key length must be 8 byte long, for TripleDES 24 byte long. No error checking is done here.

Parameters:
key - the encryption key string

setCompressionLevel

public void setCompressionLevel(int level)
Sets the compression level for the ink data the streamOut function will use:

Parameters:
level - the compression level

getCopyOfDoodle

public CicDoodle getCopyOfDoodle()
Creates a new CicDoodle objects and dublicates all the values (clone).

Returns:
a clone of this CicDoodle object

copyDoodle

public void copyDoodle(CicDoodle targetD,
                       CicDoodle sourceD)
Copies the source doodle into the target doodle.

Parameters:
targetD - the target doodle
sourceD - the source doodle

setStringEncodingAlg

public boolean setStringEncodingAlg(int encoderAlgorithm)
Sets the encoding algorithm if the streamOut function is called with removeNonPrinting set to true. Supportes at this time are only CIC_PRINTABLE and BASE64. The default value is CIC_PRINTABLE

Parameters:
encoderAlgorithm - either CIC_PRINTABLE or BASE64
Returns:
false if none supported Algorithm was specified

CIC iSign Version 1.2