FourStateLogicHandler extends AbstractVariableHeightLogicHandler { @Override public void addBar(boolean black, int height) { final double w = bcBean.getBarWidth(1); final double h = bcBean.getBarHeight(height); final double middle = bcBean.getBarHeight() / 2; double y1; switch (height) { case 0: case 2: y1 = middle - (bcBean.getBarHeight(0) / 2); break; case 1: case 3: y1 = middle - (bcBean.getBarHeight(3) / 2); break; default: throw new RuntimeException("Bug!"); } canvas.drawRectWH(x, getStartY() + y1, w, h); x += w + bcBean.getBarWidth(-1); } FourStateLogicHandler(HeightVariableBarcodeBean bcBean, Canvas canvas); @Override void addBar(boolean black, int height);  }
@Test public void testAddBar() { System.out.println("addBar"); FourStateLogicHandler instance = new FourStateLogicHandler(bean, canvas); String expected = "<svg xmlns=\"http: boolean black = false; instance.addBar(black, 0); instance.addBar(black, 1); instance.addBar(black, 2); instance.addBar(black, 3); black = true; instance.addBar(black, 0); instance.addBar(black, 1); instance.addBar(black, 2); instance.addBar(black, 3); assertEquals(expected, SVGCanvasProviderTest.getStringFromDoc(svg.getDOM())); }
@Test(expected = RuntimeException.class) public void testAddBarBadHeight() { FourStateLogicHandler instance = new FourStateLogicHandler(bean, canvas); instance.addBar(true, -1); }