CIC iSign Version 1.2

InkTools
Class CicUtils

java.lang.Object
  |
  +--InkTools.CicUtils
Direct Known Subclasses:
CicUtilsEx

public class CicUtils
extends java.lang.Object

This is a general utiliy class for Cic's InkTools package. It covers two areas: helper functions for what is called HTTP Tunneling and helper functions to convert signatures into images.

A HTTP form can communicate with a servlet through GET and POST requests. Java's 'java.net' package provides classes that can be utilized to establish a direct HTTP communication between an applet and a servlet, a technique known as HTTP Tunneling. If the URL of the servlet is known, an applet can simple call the functions 'httpGet' or 'httpPost' to send requests and receive the servlet response.

Often it is reqired to display ink data or signatures as an image rather than redisplay it in an InkControl. The 'createJpegImage' will create a Jpeg image from a signature. Note: this function is using Sun's Jpeg encoder, which is very slow.

Version:
1.0
Author:
CIC

Field Summary
static int BMP_FILE
          CreateSignatureImage: specify to produce a Bmp file.
static int GIF_FILE
          CreateSignatureImage: specify to produce a Gif file.
static int JPEG_FILE
          CreateSignatureImage: specify to produce a Jpeg file.
static int PNG_FILE
          CreateSignatureImage: specify to produce a Png file.
static int TIFF_FILE
          CreateSignatureImage: specify to produce a Tiff file.
 
Constructor Summary
CicUtils()
          Constructs a CicUtils object.
 
Method Summary
 boolean createGifImage(CicDoodle doodle, int width, int height, java.awt.Component comp, java.lang.String fileName)
          Creates a Gif image from the ink of a CicDoodle and writes it to disk.
 boolean createGifImage(CicDoodle doodle, int width, int height, java.lang.String fileName)
          Creates a Gif image from the ink of a CicDoodle and writes it to disk.
 boolean createGifImageEx(CicDoodle doodle, int width, int height, java.lang.String fileName)
          Creates a Gif image from the ink of a CicDoodle and writes it to disk.
 boolean createJpegImage(CicDoodle doodle, int width, int height, java.awt.Component comp, java.lang.String fileName)
          Creates a Jpeg image from the ink of a CicDoodle and writes it to disk.
 boolean createJpegImage(CicDoodle doodle, int width, int height, java.lang.String fileName)
          Creates a Jpeg image from the ink of a CicDoodle and writes it to disk.
 boolean createJpegImageEx(CicDoodle doodle, int width, int height, java.lang.String fileName)
          Creates a Jpeg image from the ink of a CicDoodle and writes it to disk.
 boolean createSignatureImage(CicDoodle doodle, int width, int height, java.lang.String fileName, int format)
          Creates an image from the ink of a CicDoodle and writes it to disk.
 boolean createSignatureImageEx(CicDoodle doodle, int width, int height, java.lang.String fileName, int format)
          Creates an image from the ink of a CicDoodle and writes it to disk.
 java.awt.Image getSigImage()
          Creates a Java Image of the current CicDoodle.
 java.awt.Image getSigImage(java.awt.Component comp)
          Creates a Java Image of the current CicDoodle.
 java.awt.Image getSigImageEx()
          Creates a Java Image of the current CicDoodle.
 java.io.InputStream httpGet(java.net.URL servlet, java.lang.String field, java.lang.String value)
          HTTP - Tunneling: this function performs a GET request to the given servlet.
 java.io.InputStream httpPost(java.net.URL servlet, java.lang.String field, java.lang.String value)
          HTTP - Tunneling: this function performs a POST request to the given servlet.
 void setImageInkWidth(int newInkWidth)
          This function should get called before 'createJpegImage' or 'createGifImage' to set the ink width used for creating the image Values are: 1 for thin ink, 2 for thick ink.
 void setImageOptions(java.awt.Color ink, java.awt.Color background, int writingGuide)
          This function should get called before 'createJpegImage' or 'createGifImage' to set the ink and background colors used for creating the image as well as if the writing guide shoulf get included in the image.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GIF_FILE

public static final int GIF_FILE
CreateSignatureImage: specify to produce a Gif file.

See Also:
Constant Field Values

JPEG_FILE

public static final int JPEG_FILE
CreateSignatureImage: specify to produce a Jpeg file.

See Also:
Constant Field Values

TIFF_FILE

public static final int TIFF_FILE
CreateSignatureImage: specify to produce a Tiff file.

See Also:
Constant Field Values

PNG_FILE

public static final int PNG_FILE
CreateSignatureImage: specify to produce a Png file.

See Also:
Constant Field Values

BMP_FILE

public static final int BMP_FILE
CreateSignatureImage: specify to produce a Bmp file.

See Also:
Constant Field Values
Constructor Detail

CicUtils

public CicUtils()
Constructs a CicUtils object.

Method Detail

httpGet

public java.io.InputStream httpGet(java.net.URL servlet,
                                   java.lang.String field,
                                   java.lang.String value)
                            throws java.io.IOException
HTTP - Tunneling: this function performs a GET request to the given servlet. It will build a query string from the supplied fiels and value.

Example: http://java:8080/servlet/iSignServlet?field:value

Parameters:
servlet - the URL object of the servlet
value - the value associated with the field
Returns:
an InputStream object representing the return from the servlet
Throws:
throws - IOExeption
java.io.IOException

httpPost

public java.io.InputStream httpPost(java.net.URL servlet,
                                    java.lang.String field,
                                    java.lang.String value)
                             throws java.io.IOException
HTTP - Tunneling: this function performs a POST request to the given servlet. It will build a query string from the supplied fiels and value.

Parameters:
servlet - the URL object of the servlet
value - the value associated with the field
Returns:
an InputStream object representing the return from the servlet
Throws:
throws - IOExeption
java.io.IOException

createGifImage

public boolean createGifImage(CicDoodle doodle,
                              int width,
                              int height,
                              java.lang.String fileName)
Creates a Gif image from the ink of a CicDoodle and writes it to disk.

Note 1: Use this method if the calling process runs on a backend with no graphic context (no applet or application)

Note 2: This function requiers Java 1.3 (BufferedImage class)

The encoder class is provided by ACME Labs:

GifEncoder - write out an image as a GIF

Transparency handling and variable bit size courtesy of Jack Palevich.

Copyright (C)1996,1998 by Jef Poskanzer . All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Visit the ACME Labs Java page for up-to-date versions of this and other fine Java utilities: http://www.acme.com/java/

Parameters:
doodle - the ink which should get transformed into an image
width - the width of the image
height - the height of the image
fileName - the file name under which the image should get written onto the hard disk
Returns:
true if the opperation was successful, else false

createGifImageEx

public boolean createGifImageEx(CicDoodle doodle,
                                int width,
                                int height,
                                java.lang.String fileName)
Creates a Gif image from the ink of a CicDoodle and writes it to disk. This extended version will antialias the signature to smooth the ink.

Note 1: Use this method if the calling process runs on a backend with no graphic context (no applet or application)

Note 2: This function requiers Java 1.3 (BufferedImage class, Graphics2D)

The encoder class is provided by ACME Labs:

GifEncoder - write out an image as a GIF

Transparency handling and variable bit size courtesy of Jack Palevich.

Copyright (C)1996,1998 by Jef Poskanzer . All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Visit the ACME Labs Java page for up-to-date versions of this and other fine Java utilities: http://www.acme.com/java/

Parameters:
doodle - the ink which should get transformed into an image
width - the width of the image
height - the height of the image
fileName - the file name under which the image should get written onto the hard disk
Returns:
true if the opperation was successful, else false

createGifImage

public boolean createGifImage(CicDoodle doodle,
                              int width,
                              int height,
                              java.awt.Component comp,
                              java.lang.String fileName)
Creates a Gif image from the ink of a CicDoodle and writes it to disk.

Note: Use this method if the calling process an applet or application which has a graphic context.

The encoder class is provided by ACME Labs:

GifEncoder - write out an image as a GIF

Transparency handling and variable bit size courtesy of Jack Palevich.

Copyright (C)1996,1998 by Jef Poskanzer . All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Visit the ACME Labs Java page for up-to-date versions of this and other fine Java utilities: http://www.acme.com/java/

Parameters:
doodle - the ink which should get transformed into an image
width - the width of the image
height - the height of the image
comp - the main component of the calling applet or application ('this')
fileName - the file name under which the image should get written onto the hard disk
Returns:
true if the opperation was successful, else false

createJpegImage

public boolean createJpegImage(CicDoodle doodle,
                               int width,
                               int height,
                               java.awt.Component comp,
                               java.lang.String fileName)
Creates a Jpeg image from the ink of a CicDoodle and writes it to disk.

Note: Use this method if the calling process an applet or application which has a graphic context.

Parameters:
doodle - the ink which should get transformed into an image
width - the width of the image
height - the height of the image
fileName - the file name under which the image should get written onto the hard disk
Returns:
true if the opperation was successful, else false

The JpegEncoder and its associated classes are Copyright (c) 1998, James R. Weeks and BioElectroMech. This software is based in part on the work of the Independent JPEG Group.

Disclaimer: THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


createJpegImage

public boolean createJpegImage(CicDoodle doodle,
                               int width,
                               int height,
                               java.lang.String fileName)
Creates a Jpeg image from the ink of a CicDoodle and writes it to disk.

Note 1: Use this method if the calling process runs on a backend with no graphic context (no applet or application)

Note 2: This function requiers Java 1.3 (BufferedImage class)

Parameters:
doodle - the ink which should get transformed into an image
width - the width of the image
height - the height of the image
fileName - the file name under which the image should get written onto the hard disk
Returns:
true if the opperation was successful, else false

The JpegEncoder and its associated classes are Copyright (c) 1998, James R. Weeks and BioElectroMech. This software is based in part on the work of the Independent JPEG Group.

Disclaimer: THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


createJpegImageEx

public boolean createJpegImageEx(CicDoodle doodle,
                                 int width,
                                 int height,
                                 java.lang.String fileName)
Creates a Jpeg image from the ink of a CicDoodle and writes it to disk. This extended version will antialias the signature to smooth the ink.

Note 1: Use this method if the calling process runs on a backend with no graphic context (no applet or application)

Note 2: This function requiers Java 1.3 (BufferedImage class, Graphics2D)

Parameters:
doodle - the ink which should get transformed into an image
width - the width of the image
height - the height of the image
fileName - the file name under which the image should get written onto the hard disk
Returns:
true if the opperation was successful, else false

The JpegEncoder and its associated classes are Copyright (c) 1998, James R. Weeks and BioElectroMech. This software is based in part on the work of the Independent JPEG Group.

Disclaimer: THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


createSignatureImage

public boolean createSignatureImage(CicDoodle doodle,
                                    int width,
                                    int height,
                                    java.lang.String fileName,
                                    int format)
Creates an image from the ink of a CicDoodle and writes it to disk. This function replaces 'CreateGifImage' and 'CreateJpegImage' since you can specify in which format you would like the grafics output.

Note: This function requiers Java 1.3 (BufferedImage class, Graphics2D)

Parameters:
doodle - the ink which should get transformed into an image
width - the width of the image
height - the height of the image
fileName - the file name under which the image should get written onto the hard disk
format - The grafic format of the output file: GIF_FILE, JPEG_FILE, TIFF_FILE, PNG_FILE, BMP_FILE
Returns:
true if the opperation was successful, else false


createSignatureImageEx

public boolean createSignatureImageEx(CicDoodle doodle,
                                      int width,
                                      int height,
                                      java.lang.String fileName,
                                      int format)
Creates an image from the ink of a CicDoodle and writes it to disk. This function replaces 'CreateGifImage' and 'CreateJpegImage' since you can specify in which format you would like the grafics output. This extended version will antialias the signature to smooth the ink.

Note: This function requiers Java 1.3 (BufferedImage class, Graphics2D)

Parameters:
doodle - the ink which should get transformed into an image
width - the width of the image
height - the height of the image
fileName - the file name under which the image should get written onto the hard disk
format - The grafic format of the output file: GIF_FILE, JPEG_FILE, TIFF_FILE, PNG_FILE, BMP_FILE
Returns:
true if the opperation was successful, else false


setImageOptions

public void setImageOptions(java.awt.Color ink,
                            java.awt.Color background,
                            int writingGuide)
This function should get called before 'createJpegImage' or 'createGifImage' to set the ink and background colors used for creating the image as well as if the writing guide shoulf get included in the image.

Parameters:
ink - The color of the ink
background - The color of the background
writingGuide - The style of the writing guide included in the image

setImageInkWidth

public void setImageInkWidth(int newInkWidth)
This function should get called before 'createJpegImage' or 'createGifImage' to set the ink width used for creating the image Values are: 1 for thin ink, 2 for thick ink.

Parameters:
newInkWidth - The width of the ink

getSigImage

public java.awt.Image getSigImage(java.awt.Component comp)
Creates a Java Image of the current CicDoodle. The image can be used for passing into specific image encoders. Use createJpegImage to load a CicDoodle object into this class with fileName set to 'null'.

Returns:
The java image created.

getSigImage

public java.awt.Image getSigImage()
Creates a Java Image of the current CicDoodle. The image can be used for passing into specific image encoders. Use createJpegImage to load a CicDoodle object into this class with fileName set to 'null'.

Returns:
The java image created.

getSigImageEx

public java.awt.Image getSigImageEx()
Creates a Java Image of the current CicDoodle. The image can be used for passing into specific image encoders. Use createJpegImage to load a CicDoodle object into this class with fileName set to 'null'. This extended version will antialias the signature to smooth the ink. Note: requires Java 1.3 (BufferedImage, Graphics2D)

Returns:
The java image created.

CIC iSign Version 1.2