Skip to content

Commit de46f82

Browse files
committed
Force DataMatrix to square by default.
1 parent 9cba6ea commit de46f82

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

config/types/UPC_A.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"nonprinting": false,
2121
"example": "123456789012",
2222
"pattern": {
23-
"auto": "^(?=.*0)[0-9]{12}$",
24-
"extended": "^(?=.*0)[0-9]{11,12}$"
23+
"auto": "^[0-9]{12}$",
24+
"extended": "^[0-9]{11,12}$"
2525
},
2626
"description": {
2727
"en": "A universally recognized 12 digit barcode. Encodes manufacturer, product / variant, and store use codes."

src/main/java/org/barcodeapi/server/gen/impl/DefaultBarcodeProvider.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public DefaultBarcodeProvider(CodeType codeType, AbstractBarcodeBean bean) {
1818
this.generator = bean;
1919
}
2020

21+
protected AbstractBarcodeBean getBean() {
22+
23+
return this.generator;
24+
}
25+
2126
@Override
2227
public byte[] onRender(BarcodeRequest request) throws Exception {
2328

src/main/java/org/barcodeapi/server/gen/types/DataMatrixGenerator.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.barcodeapi.server.core.CodeType;
44
import org.barcodeapi.server.gen.impl.DefaultBarcodeProvider;
55
import org.krysalis.barcode4j.impl.datamatrix.DataMatrixBean;
6+
import org.krysalis.barcode4j.impl.datamatrix.SymbolShapeHint;
67

78
/**
89
* DataMatrixGenerator.java
@@ -12,8 +13,12 @@
1213
public class DataMatrixGenerator extends DefaultBarcodeProvider {
1314

1415
public DataMatrixGenerator(CodeType codeType) {
16+
super(codeType, initBean());
17+
}
1518

16-
// Setup DataMatrix generator
17-
super(codeType, new DataMatrixBean());
19+
private static DataMatrixBean initBean() {
20+
DataMatrixBean bean = new DataMatrixBean();
21+
bean.setShape(SymbolShapeHint.FORCE_SQUARE);
22+
return bean;
1823
}
1924
}

0 commit comments

Comments
 (0)