J4L-One Code for the Java[TM] platform
Copyright J4L Components (http://www.java4less.com)
2006.
Introduction
The package J4L-OneCode contains
the classes you need to create One Code barcodes (also known as the USPS 4-State
Customer Barcode , 4CB or 4-CB) within your jsp or java applications.
One Code barcodes consist of 65 bars.
Each bar can be printed in one of four states; full, track, ascender or descender.
One Code barcodes can encode the
following information:
- barcode identifier: This is a
2 digit identifier (the second digit must be in the range 0-4)
- Special services: this is a numeric
value between 0 and 999.
- Customer identifier: this is a
numeric value between 0 and 999999.
- Sequence number: this is a numeric
value between 0 and 999999999.
- Routing code (delivery point ZIP
code) , optional, can be a 0,5 9 or 11 digits long.
The component allows you to configure
the dimensions of the barcode:
- Bar width
- Bar height (height of track bars)
- Extended bar height (height of
full bars)
- top and bottom texts
- quite zone

Installation
and requirements
In order to install the software
you just need to unzip the ZIP file in an empty directory (your must unzip with
pathname so that the subdirectories are properly created.
- The java class and the applet
will run on java 1.1 or later.
- The servlet requires java 1.2
or later since it uses the BufferedImage class (let us know if you need a
servlet for jdk 1.1)
- The sample application requires
java 1.3 or later since it uses the PageAttributes class to change the printer
resolution.
Java applications
In order to run the sample application
you must execute runDEMO.bat. The sample application requires JDK 1.3
or later. However the component will also work with JDK 1.1 or 1.2. Let us know
if you need a test version for java 1.1 or 1.2.
In the sample application you can
set all properties of the OneCode symbology.
You can execute the following commands:
- Apply: repaint the symbol using
the new properties.
- Print: send image to printer at
the selected resolution.
- Save: save the symbol in jpg format.
We recommend you to use gif or png formats,however the sample application
uses JPG because it does not require you to download any additional package.
In order to create gif or png files you must download an external encoder
(see javadoc).
- Exit: terminate application.
The Servlet
OneCode comes with a standard servlet
(OneCodeServlet) you can use to create One Code images. The parameters for the
servlet can be sent using GET or POST commands. The parameters are:
- BARCODE_IDENTIFIER. (see
description in Introduction section)
- SPECIAL_SERVICES. (see
description in Introduction section)
- CUSTOMER_IDENTIFIER. (see
description in Introduction section)
- SEQUENCE_NUMBER. (see description
in Introduction section)
- ROUTING_CODE. (see description
in Introduction section)
- BAR_WIDTH (see description
in Introduction section)
- BAR_SPACING (see description
in Introduction section)
- BAR_HEIGHT (see description
in Introduction section)
- EXTENDED_BAR_HEIGHT (see
description in Introduction section)
- QUITE_ZONE (see description
in Introduction section)
- TEXT1 (see description
in Introduction section)
- TEXT2 (see description
in Introduction section)
- BAR_COLOR: color of the
bars. Valid values are: RED,BLUE,GREEN,BLACK,GRAY,LIGHTGRAY,WHITE,DARKGRAY,YELLOW,ORANGE,CYAN
and MAGENTA. You can also use the RGB numerical value of a color as parameter
(e.g. 0x00FF00 is green).
- BACK_COLOR: color of the
background.
- TEXT_FONT:
font of user text above and below the barcode. Fonts have the format <font
name>|<style>|<size>. Style can be PLAIN, ITALIC or BOLD. Example:
"Arial|BOLD|12"
- TEXT_COLOR:
color of user text above and below the barcode.
- WIDTH: size of the image.
Default is 400.
- HEIGHT: size of the image.
Default is 200.
- FORMAT: output format:
PNG, GIF or JPEG (default):
For example, if you want to test
the servlet using Tomcat 5 you must do the following:
- copy the content of the jsp_servlet
subdirectory to /tomcat/webapps/onecode/
- Start the server and test the
servlet entering the following address:
http://localhost:8080/onecode/ServletExample.html
In order to propertly print a barcode
created with the servlet you must use the <IMG> tag. In this way you can
embed the image in your HTML page. Note that you will need to use the attibutes
height and width in
order to achieve the correct size of the barcode on the printed page.
This is a simple HTML page that contains
a qrcode symbol:
<HTML>
<HEAD>
<TITLE>Servlet
Example META http-equiv=Content-Type content="text/html; charset=windows-1252">
</HEAD>
<BODY bgColor=#ffffff>
This is your Barcode:
<IMG height=100 width=100
src="http://localhost:8080/onecode/servlet/OneCodeServlet?BARCODE_IDENTIFIER=1&SPECIAL_SERVICES=234&...."
>
</BODY>
</HTML>
The Applet
You must add the following code in
your html pages to use the applet:
<APPLET
CODEBASE = "./"
CODE = "com.java4less.onecode.OneCodeApplet.class"
ARCHIVE = "onecode.jar"
NAME = "TestApplet"
WIDTH = 300
HEIGHT = 250
HSPACE = 0
VSPACE = 0
ALIGN = middle
>
<PARAM NAME =
"BARCODE_IDENTIFIER" VALUE = "1">
.....
</APPLET>
Note that the onecode.jar file must
be located in the directory referenced by the CODEBASE parameter.
The available paramete are the same
as those used by the servlet (see list description in the previous section).
There is an examle in applet/AppletExample.html
file.