1 package net.sourceforge.barbecue.linear.postnet; 2 3 import net.sourceforge.barbecue.Module; 4 import net.sourceforge.barbecue.output.AbstractOutput; 5 import net.sourceforge.barbecue.output.OutputException; 6 7 /** 8 * @author Brendon Anderson 9 */ 10 public class PostNetModule extends Module { 11 12 protected final static double BARWIDTH = 3.0; 13 protected final static double BLANKWIDTH = 4.0; 14 15 public PostNetModule(int[] bars) { 16 super(bars); 17 } 18 19 protected double draw(AbstractOutput output, double x, double y) throws OutputException { 20 double sum = 0; 21 double fullheight = PostNetBarcode.HEIGHT; 22 double halfheight = fullheight * .4; 23 24 for (int i = 0; i < bars.length; i++) { 25 int bar = bars[i]; 26 if (bar == 0) { 27 output.drawBar((int) x, (int) (y + (fullheight - halfheight)), (int) BARWIDTH, (int) halfheight, true); 28 } else { 29 output.drawBar((int) x, (int) y, (int) BARWIDTH, (int) fullheight, true); 30 } 31 sum += BARWIDTH; 32 x += BARWIDTH; 33 output.drawBar((int) x, (int) y, (int) BLANKWIDTH, (int) fullheight, false); 34 sum += BLANKWIDTH; 35 x += BLANKWIDTH; 36 output.drawBar((int) x, (int) y, (int) BLANKWIDTH, (int) fullheight, false); 37 } 38 return sum; 39 } 40 } 41 42 43 44 45 46 47 48 49 50 51 52