mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
91 lines
3 KiB
Java
91 lines
3 KiB
Java
![]() |
package com.google.zxing.oned;
|
||
|
|
||
|
import com.google.zxing.BarcodeFormat;
|
||
|
import com.google.zxing.EncodeHintType;
|
||
|
import com.google.zxing.Writer;
|
||
|
import com.google.zxing.common.BitMatrix;
|
||
|
import java.util.Collection;
|
||
|
import java.util.Map;
|
||
|
import java.util.regex.Pattern;
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public abstract class OneDimensionalCodeWriter implements Writer {
|
||
|
private static final Pattern NUMERIC = Pattern.compile("[0-9]+");
|
||
|
|
||
|
public abstract boolean[] encode(String str);
|
||
|
|
||
|
public int getDefaultMargin() {
|
||
|
return 10;
|
||
|
}
|
||
|
|
||
|
protected Collection<BarcodeFormat> getSupportedWriteFormats() {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.zxing.Writer
|
||
|
public final BitMatrix encode(String str, BarcodeFormat barcodeFormat, int i, int i2) {
|
||
|
return encode(str, barcodeFormat, i, i2, null);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.zxing.Writer
|
||
|
public BitMatrix encode(String str, BarcodeFormat barcodeFormat, int i, int i2, Map<EncodeHintType, ?> map) {
|
||
|
if (str.isEmpty()) {
|
||
|
throw new IllegalArgumentException("Found empty contents");
|
||
|
}
|
||
|
if (i < 0 || i2 < 0) {
|
||
|
throw new IllegalArgumentException("Negative size is not allowed. Input: " + i + 'x' + i2);
|
||
|
}
|
||
|
Collection<BarcodeFormat> supportedWriteFormats = getSupportedWriteFormats();
|
||
|
if (supportedWriteFormats != null && !supportedWriteFormats.contains(barcodeFormat)) {
|
||
|
throw new IllegalArgumentException("Can only encode " + supportedWriteFormats + ", but got " + barcodeFormat);
|
||
|
}
|
||
|
int defaultMargin = getDefaultMargin();
|
||
|
if (map != null && map.containsKey(EncodeHintType.MARGIN)) {
|
||
|
defaultMargin = Integer.parseInt(map.get(EncodeHintType.MARGIN).toString());
|
||
|
}
|
||
|
return renderResult(encode(str), i, i2, defaultMargin);
|
||
|
}
|
||
|
|
||
|
private static BitMatrix renderResult(boolean[] zArr, int i, int i2, int i3) {
|
||
|
int length = zArr.length;
|
||
|
int i4 = i3 + length;
|
||
|
int max = Math.max(i, i4);
|
||
|
int max2 = Math.max(1, i2);
|
||
|
int i5 = max / i4;
|
||
|
int i6 = (max - (length * i5)) / 2;
|
||
|
BitMatrix bitMatrix = new BitMatrix(max, max2);
|
||
|
int i7 = 0;
|
||
|
while (i7 < length) {
|
||
|
if (zArr[i7]) {
|
||
|
bitMatrix.setRegion(i6, 0, i5, max2);
|
||
|
}
|
||
|
i7++;
|
||
|
i6 += i5;
|
||
|
}
|
||
|
return bitMatrix;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public static void checkNumeric(String str) {
|
||
|
if (!NUMERIC.matcher(str).matches()) {
|
||
|
throw new IllegalArgumentException("Input should only contain digits 0-9");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public static int appendPattern(boolean[] zArr, int i, int[] iArr, boolean z) {
|
||
|
int i2 = 0;
|
||
|
for (int i3 : iArr) {
|
||
|
int i4 = 0;
|
||
|
while (i4 < i3) {
|
||
|
zArr[i] = z;
|
||
|
i4++;
|
||
|
i++;
|
||
|
}
|
||
|
i2 += i3;
|
||
|
z = !z;
|
||
|
}
|
||
|
return i2;
|
||
|
}
|
||
|
}
|