@Test(expected = NullPointerException.class) public void should_throw_npe_when_parse_null_matrix() { svgConverter.parseQRCodeMatrix(null); }
public List<SvgPath> parseQRCodeMatrix(QRCode qrcode) { Objects.requireNonNull(qrcode); List<SvgPath> paths = Lists.newArrayList(); for (int y = 0; y < qrcode.getMatrix().getHeight(); y++) { for (int x = 0; x < qrcode.getMatrix().getWidth(); x++) { Point startedPoint = Point.create(x, y); if (qrcode.getMatrix().get(x, y)==1) { if(x + 1 == qrcode.getMatrix().getWidth()){ paths.add(SvgPath.create(startedPoint, 1)); } for (x = x + 1; x < qrcode.getMatrix().getWidth(); x++) { if (qrcode.getMatrix().get(x, y)==0) { paths.add(SvgPath.create(startedPoint, x - startedPoint.x())); break; } else if(x + 1 == qrcode.getMatrix().getWidth()){ paths.add(SvgPath.create(startedPoint, x - startedPoint.x() + 1)); } } } } } return paths; }
SvgConverter { public List<SvgPath> parseQRCodeMatrix(QRCode qrcode) { Objects.requireNonNull(qrcode); List<SvgPath> paths = Lists.newArrayList(); for (int y = 0; y < qrcode.getMatrix().getHeight(); y++) { for (int x = 0; x < qrcode.getMatrix().getWidth(); x++) { Point startedPoint = Point.create(x, y); if (qrcode.getMatrix().get(x, y)==1) { if(x + 1 == qrcode.getMatrix().getWidth()){ paths.add(SvgPath.create(startedPoint, 1)); } for (x = x + 1; x < qrcode.getMatrix().getWidth(); x++) { if (qrcode.getMatrix().get(x, y)==0) { paths.add(SvgPath.create(startedPoint, x - startedPoint.x())); break; } else if(x + 1 == qrcode.getMatrix().getWidth()){ paths.add(SvgPath.create(startedPoint, x - startedPoint.x() + 1)); } } } } } return paths; } }
SvgConverter { public List<SvgPath> parseQRCodeMatrix(QRCode qrcode) { Objects.requireNonNull(qrcode); List<SvgPath> paths = Lists.newArrayList(); for (int y = 0; y < qrcode.getMatrix().getHeight(); y++) { for (int x = 0; x < qrcode.getMatrix().getWidth(); x++) { Point startedPoint = Point.create(x, y); if (qrcode.getMatrix().get(x, y)==1) { if(x + 1 == qrcode.getMatrix().getWidth()){ paths.add(SvgPath.create(startedPoint, 1)); } for (x = x + 1; x < qrcode.getMatrix().getWidth(); x++) { if (qrcode.getMatrix().get(x, y)==0) { paths.add(SvgPath.create(startedPoint, x - startedPoint.x())); break; } else if(x + 1 == qrcode.getMatrix().getWidth()){ paths.add(SvgPath.create(startedPoint, x - startedPoint.x() + 1)); } } } } } return paths; }  }
SvgConverter { public List<SvgPath> parseQRCodeMatrix(QRCode qrcode) { Objects.requireNonNull(qrcode); List<SvgPath> paths = Lists.newArrayList(); for (int y = 0; y < qrcode.getMatrix().getHeight(); y++) { for (int x = 0; x < qrcode.getMatrix().getWidth(); x++) { Point startedPoint = Point.create(x, y); if (qrcode.getMatrix().get(x, y)==1) { if(x + 1 == qrcode.getMatrix().getWidth()){ paths.add(SvgPath.create(startedPoint, 1)); } for (x = x + 1; x < qrcode.getMatrix().getWidth(); x++) { if (qrcode.getMatrix().get(x, y)==0) { paths.add(SvgPath.create(startedPoint, x - startedPoint.x())); break; } else if(x + 1 == qrcode.getMatrix().getWidth()){ paths.add(SvgPath.create(startedPoint, x - startedPoint.x() + 1)); } } } } } return paths; }  List<SvgPath> parseQRCodeMatrix(QRCode qrcode); String generatePathSvg(QRCode qrCode); String generateSvg(QRCode qrCode, String color, String content); }
SvgConverter { public List<SvgPath> parseQRCodeMatrix(QRCode qrcode) { Objects.requireNonNull(qrcode); List<SvgPath> paths = Lists.newArrayList(); for (int y = 0; y < qrcode.getMatrix().getHeight(); y++) { for (int x = 0; x < qrcode.getMatrix().getWidth(); x++) { Point startedPoint = Point.create(x, y); if (qrcode.getMatrix().get(x, y)==1) { if(x + 1 == qrcode.getMatrix().getWidth()){ paths.add(SvgPath.create(startedPoint, 1)); } for (x = x + 1; x < qrcode.getMatrix().getWidth(); x++) { if (qrcode.getMatrix().get(x, y)==0) { paths.add(SvgPath.create(startedPoint, x - startedPoint.x())); break; } else if(x + 1 == qrcode.getMatrix().getWidth()){ paths.add(SvgPath.create(startedPoint, x - startedPoint.x() + 1)); } } } } } return paths; }  List<SvgPath> parseQRCodeMatrix(QRCode qrcode); String generatePathSvg(QRCode qrCode); String generateSvg(QRCode qrCode, String color, String content);  }