View Javadoc

1   /***********************************************************************************************************************
2   Copyright (c) 2003, International Barcode Consortium
3   All rights reserved.
4   
5   Redistribution and use in source and binary forms, with or without modification,
6   are permitted provided that the following conditions are met:
7   
8       * Redistributions of source code must retain the above copyright notice, this list of
9         conditions and the following disclaimer.
10      * Redistributions in binary form must reproduce the above copyright notice, this list of
11        conditions and the following disclaimer in the documentation and/or other materials
12        provided with the distribution.
13      * Neither the name of the International Barcode Consortium nor the names of any contributors may be used to endorse
14        or promote products derived from this software without specific prior written permission.
15  
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
17  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24  POSSIBILITY OF SUCH DAMAGE.
25  ***********************************************************************************************************************/
26  
27  package net.sourceforge.barbecue;
28  
29  import net.sourceforge.barbecue.output.Output;
30  import net.sourceforge.barbecue.output.OutputException;
31  
32  /**
33   * Specific implementation of Module that draws a blank bar (of configurable width).
34   * This can be used to insert inter-module spaces (as required by some barcode formats)
35   * without having to modify the data to be encoded to include the spaces.
36   * <p/>Note: You should not instantiate this class directly.
37   *
38   * @author <a href="mailto:opensource@ianbourke.com">Ian Bourke</a>
39   */
40  public class SeparatorModule extends Module {
41  
42  	/**
43  	 * Constructs a new SeparatorModule with a width of 1.
44  	 */
45  	public SeparatorModule() {
46  		super(new int[] {1});
47  	}
48  
49  	/**
50  	 * Constructs a new SeparatorModule with the specified width.
51  	 * @param width The width of the separator in bar widths.
52  	 */
53  	public SeparatorModule(int width) {
54  		super(new int[] {width});
55  	}
56  
57  	/**
58  	 * Draws the module to the specified output.
59  	 * @param output The barcode output to draw to
60  	 * @param x The starting X co-ordinate
61  	 * @param y The starting Y co-ordinate
62  	 * @param barWidth
63  	 * @param barHeight
64  	 * @return The total width drawn
65  	 */
66  	protected int draw(Output output, int x, int y, int barWidth, int barHeight) throws OutputException {
67  		int w = bars[0] * barWidth;
68  		output.drawBar((int) x, (int) y, (int) w, (int) barHeight, false);
69  		return w;
70  	}
71  
72  	/**
73  	 * Returns the symbol that this module encodes.
74  	 * @return A blank string
75  	 */
76  	public String getSymbol() {
77  		return "";
78  	}
79  }