Simplified Java code to use StringBuilder method chaining.
This commit is contained in:
parent
f3ba9c0837
commit
ea29e58e9c
|
@ -283,14 +283,13 @@ public final class QrCode {
|
||||||
if (size + border * 2L > Integer.MAX_VALUE)
|
if (size + border * 2L > Integer.MAX_VALUE)
|
||||||
throw new IllegalArgumentException("Border too large");
|
throw new IllegalArgumentException("Border too large");
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder()
|
||||||
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
|
||||||
sb.append("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
|
.append("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n")
|
||||||
sb.append(String.format(
|
.append(String.format("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 %1$d %1$d\" stroke=\"none\">\n",
|
||||||
"<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 %1$d %1$d\" stroke=\"none\">\n",
|
size + border * 2))
|
||||||
size + border * 2));
|
.append("\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\"/>\n")
|
||||||
sb.append("\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\"/>\n");
|
.append("\t<path d=\"");
|
||||||
sb.append("\t<path d=\"");
|
|
||||||
boolean head = true;
|
boolean head = true;
|
||||||
for (int y = 0; y < size; y++) {
|
for (int y = 0; y < size; y++) {
|
||||||
for (int x = 0; x < size; x++) {
|
for (int x = 0; x < size; x++) {
|
||||||
|
@ -303,9 +302,10 @@ public final class QrCode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sb.append("\" fill=\"#000000\"/>\n");
|
return sb
|
||||||
sb.append("</svg>\n");
|
.append("\" fill=\"#000000\"/>\n")
|
||||||
return sb.toString();
|
.append("</svg>\n")
|
||||||
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue