POSTNETLogicHandler extends AbstractVariableHeightLogicHandler { @Override public void addBar(boolean black, int height) { final POSTNETBean pnBean = (POSTNETBean)bcBean; final double w = black ? bcBean.getBarWidth(1) : bcBean.getBarWidth(-1); final double h = bcBean.getBarHeight(height); final BaselineAlignment baselinePosition = pnBean.getBaselinePosition(); if (black) { if (bcBean.getMsgPosition() == HumanReadablePlacement.HRP_TOP) { if (baselinePosition == BaselineAlignment.ALIGN_TOP) { canvas.drawRectWH(x, y + bcBean.getHumanReadableHeight(), w, h); } else if (baselinePosition == BaselineAlignment.ALIGN_BOTTOM) { canvas.drawRectWH(x, y + bcBean.getHeight() - h, w, h); } } else { if (baselinePosition == BaselineAlignment.ALIGN_TOP) { canvas.drawRectWH(x, y, w, h); } else if (baselinePosition == BaselineAlignment.ALIGN_BOTTOM) { canvas.drawRectWH(x, y + bcBean.getBarHeight() - h, w, h); } } } x += w; } POSTNETLogicHandler(POSTNETBean bcBean, Canvas canvas); @Override void startBarcode(String msg, String formattedMsg); @Override void addBar(boolean black, int height);  }
@Test public void testAddBarDefault() { System.out.println("addBar"); String expected = "<svg xmlns=\"http: boolean black = false; instance.addBar(black, -1); instance.addBar(!black, -1); instance.addBar(black, 1); instance.addBar(!black, 1); instance.addBar(black, 2); instance.addBar(!black, 2); assertEquals(expected, SVGCanvasProviderTest.getStringFromDoc(svg.getDOM())); }
@Test(expected = IllegalArgumentException.class) public void testAddBarFail() { System.out.println("addBar"); boolean black = false; instance.addBar(black, 0); }
@Test public void testAddBarPlacement() { System.out.println("addBar"); String expected = "<svg xmlns=\"http: boolean black = false; bean.setMsgPosition(HumanReadablePlacement.HRP_TOP); bean.setBaselinePosition(BaselineAlignment.ALIGN_TOP); instance.addBar(black, -1); instance.addBar(!black, -1); bean.setBaselinePosition(BaselineAlignment.ALIGN_BOTTOM); instance.addBar(black, 1); instance.addBar(!black, 1); bean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); bean.setBaselinePosition(BaselineAlignment.ALIGN_TOP); instance.addBar(black, -1); instance.addBar(!black, -1); assertEquals(expected, SVGCanvasProviderTest.getStringFromDoc(svg.getDOM())); }