Skip to content

Commit

Permalink
PDF417 module width
Browse files Browse the repository at this point in the history
  • Loading branch information
RobFaustLZ committed Dec 25, 2023
1 parent 345404a commit 9173391
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 32 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'com.labelzoom.api'
version = '1.0.14'
version = '1.0.15'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.labelzoom.api.model.components.barcodes;

import lombok.Getter;

/**
* <b>***NOTE***</b> When adding additional fields to barcodes, the BarcodeDeserializer must also be updated
*/
public interface IBarcodeWithModuleWidth
{
@Getter
enum ZebraBarcodeSize
{
Smallest(1),
Smaller(2),
Normal(3),
Large(4),
XLarge(5),
XXLarge(6),
XXXLarge(7),
XXXXLarge(8),
XXXXXLarge(9);

private final int value;

ZebraBarcodeSize(final int value) {
this.value = value;
}
}

ZebraBarcodeSize getBarcodeSize();
void setBarcodeSize(ZebraBarcodeSize size);

default float getModuleWidthInMm(final int dpi)
{
return (float)this.getBarcodeSize().getValue() / (float)dpi * 25.4f;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,24 @@
*/

import com.labelzoom.api.model.components.barcodes.ABarcode;
import com.labelzoom.api.model.components.barcodes.IBarcodeWithModuleWidth;
import lombok.Getter;
import lombok.Setter;

/**
* <b>***NOTE***</b> When adding additional fields to barcodes, the BarcodeDeserializer must also be updated
*/
@Getter @Setter
public abstract class ALinearBarcode extends ABarcode
public abstract class ALinearBarcode extends ABarcode implements IBarcodeWithModuleWidth
{
private ZebraBarcodeSize barcodeSize;
private ZebraBarcodeSize barcodeSize = ZebraBarcodeSize.Normal;

private int height;

private boolean humanReadableEnabled;

private HumanReadableStyle humanReadablePosition;

@Getter
public enum ZebraBarcodeSize
{
Smallest(1),
Smaller(2),
Normal(3),
Large(4),
XLarge(5),
XXLarge(6),
XXXLarge(7),
XXXXLarge(8),
XXXXXLarge(9);

private final int value;
ZebraBarcodeSize(final int value) {
this.value = value;
}
}

public enum HumanReadableStyle
{
Above,
Expand Down Expand Up @@ -76,15 +58,6 @@ protected ALinearBarcode(final ALinearBarcode original, final boolean cloneData)
}
}

public ZebraBarcodeSize getBarcodeSize()
{
if (this.barcodeSize != null)
{
return this.barcodeSize;
}
return ZebraBarcodeSize.Normal;
}

public HumanReadableStyle getHumanReadablePosition()
{
if (this.humanReadablePosition != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
*/

import com.labelzoom.api.model.components.AComponent;
import com.labelzoom.api.model.components.barcodes.IBarcodeWithModuleWidth;
import lombok.Getter;
import lombok.Setter;

/**
* <b>***NOTE***</b> When adding additional fields to barcodes, the BarcodeDeserializer must also be updated
*/
@Getter @Setter
public class CBarcodePDF417 extends A2DBarcode
public class CBarcodePDF417 extends A2DBarcode implements IBarcodeWithModuleWidth
{
private int rowHeight = 1;

Expand All @@ -32,6 +33,8 @@ public class CBarcodePDF417 extends A2DBarcode

private boolean truncateRightRow = false;

private ZebraBarcodeSize barcodeSize = ZebraBarcodeSize.Normal;

public CBarcodePDF417() { this(null, false); }

protected CBarcodePDF417(final CBarcodePDF417 original, final boolean cloneData)
Expand All @@ -45,6 +48,7 @@ protected CBarcodePDF417(final CBarcodePDF417 original, final boolean cloneData)
columns = original.columns;
rows = original.rows;
truncateRightRow = original.truncateRightRow;
barcodeSize = original.barcodeSize;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/labelzoom/api/DeepCopyTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void testSimpleClone()
final CLabel clone = label.clone();
final String labelSerialized = assertDoesNotThrow(() -> objectMapper.writeValueAsString(label));
final String cloneSerialized = assertDoesNotThrow(() -> objectMapper.writeValueAsString(clone));
assertNotSame(label, clone);
assertEquals(labelSerialized, cloneSerialized);
}
}

0 comments on commit 9173391

Please sign in to comment.