Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
RobFaustLZ committed Dec 5, 2023
1 parent 7f08686 commit 0832f47
Show file tree
Hide file tree
Showing 38 changed files with 100 additions and 99 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.8'
version = '1.0.9'

repositories {
mavenCentral()
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/labelzoom/api/model/components/AComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
public abstract class AComponent implements Cloneable {

@Setter
protected int left;
private int left;

@Setter
protected int top;
private int top;

protected float rotation = 0;
private float rotation = 0;
public void setRotation(float rotation) { this.rotation = rotation % 360; }

@Setter
protected boolean reverse = false;
private boolean reverse = false;

@Setter
protected Justification justification = Justification.Left;
private Justification justification = Justification.Left;

@Setter
protected PositioningMode positioningMode = PositioningMode.Origin;
private PositioningMode positioningMode = PositioningMode.Origin;

/**
* Parameterless constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@Getter
public abstract class AContainer extends AComponent
{
protected List<AComponent> children = new ArrayList<>(); // Using ArrayList because that's what Jackson uses
private final List<AComponent> children = new ArrayList<>(); // Using ArrayList because that's what Jackson uses

/**
* Parameterless constructor
Expand All @@ -37,12 +37,9 @@ protected AContainer(final AContainer original)
super(original);

// Clone children
if (original.children != null)
for (final AComponent component : original.children)
{
for (final AComponent component : original.children)
{
children.add(component.clone());
}
children.add(component.clone());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
@Getter @Setter
public abstract class AFontComponent extends AComponent
{
protected float horizontalScaling = 1.0f;
private float horizontalScaling = 1.0f;

protected float fontSize = 10.0f;
private float fontSize = 10.0f;

protected String font = "0";
private String font = "0";

protected boolean blankWhenNull = false;
private boolean blankWhenNull = false;

/**
* Parameterless constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
@Getter @Setter
public class CAddressBlock extends AFontComponent
{
protected boolean useLocalizedAddressFormat = true;
private boolean useLocalizedAddressFormat = true;

protected int staticAddressFormat = 1;
private int staticAddressFormat = 1;

protected boolean showContactName = false;
private boolean showContactName = false;

protected boolean showCountry = false;
private boolean showCountry = false;

protected String addressId;
private String addressId;

/**
* Parameterless constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
@Getter @Setter
public class CDataCommand implements Cloneable
{
protected String language;
private String language;

protected String dataCommand;
private String dataCommand;

/**
* Parameterless constructor
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/labelzoom/api/model/components/CImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
@Getter @Setter
public class CImage extends AComponent
{
protected BufferedImage image;
private BufferedImage image;

protected float horizontalScaling = 1;
private float horizontalScaling = 1;

protected float verticalScaling = 1;
private float verticalScaling = 1;

/**
* Parameterless constructor
Expand Down
28 changes: 17 additions & 11 deletions src/main/java/com/labelzoom/api/model/components/CLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@ public class CLabel
{
// Fields
@Getter @Setter
protected int width;
private int width;

@Getter @Setter
protected int height;
private int height;

@Getter @Setter
protected boolean isHighRes = false;
private boolean isHighRes = false;

@Getter @Setter
protected PageOrientation orientation = PageOrientation.Portrait;
private PageOrientation orientation = PageOrientation.Portrait;

@Getter @Setter
protected List<CLayer> layers = new ArrayList<>(); // Using ArrayList because that's what Jackson uses
private List<CLayer> layers = new ArrayList<>(); // Using ArrayList because that's what Jackson uses

protected final Map<String, CLayer> layerMap = new TreeMap<>();
private final Map<String, CLayer> layerMap = new TreeMap<>();

@Getter @Setter
protected CDataCommand dataCommand;
private CDataCommand dataCommand;

@Getter @Setter
protected String schemaLocation;
private String schemaLocation;

@Getter @Setter
protected String schemaVersion = "v1";
private String schemaVersion = "v1";

@Getter @Setter
protected UUID id = UUID.randomUUID();
private UUID id = UUID.randomUUID();

// Static/constants
public static final String DEFAULT_LAYER_NAME = "background";
Expand Down Expand Up @@ -170,7 +170,13 @@ public CLabel clone(final boolean cloneData)

public void addElement(final AComponent component)
{
getLayerMap().get(DEFAULT_LAYER_NAME).getElements().add(component);
if (layers.isEmpty())
{
final CLayer mainContainer = new CLayer();
mainContainer.setName(DEFAULT_LAYER_NAME);
layers.add(mainContainer);
}
layers.get(0).getElements().add(component);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/labelzoom/api/model/components/CLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
@Getter @Setter
public class CLayer
{
protected String name;
private String name;

protected List<AComponent> elements = new ArrayList<>(); // Using ArrayList because that's what Jackson uses
private List<AComponent> elements = new ArrayList<>(); // Using ArrayList because that's what Jackson uses

/**
* Parameterless constructor
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/labelzoom/api/model/components/CLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public enum Orientation
Horizontal, Vertical;
}

protected Orientation orientation;
private Orientation orientation;

protected int thickness;
private int thickness;

protected int length;
private int length;

/**
* Parameterless constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
@Getter @Setter
public class CRectangle extends AComponent
{
protected int width;
private int width;

protected int height;
private int height;

protected int thickness;
private int thickness;

/**
* Parameterless constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@Getter @Setter
public class CStaticText extends AFontComponent
{
protected String text;
private String text;

/**
* Parameterless constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
@Getter @Setter
public class CVariableText extends AFontComponent implements IDynamicField
{
protected String expression;
private String expression;

protected String fieldValue;
private String fieldValue;

protected boolean autoSize = true;
private boolean autoSize = true;

protected int width = 0;
private int width = 0;

protected int height = 0;
private int height = 0;

protected HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left;
private HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left;

public enum HorizontalAlignment
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
@Getter @Setter
public abstract class ABarcode extends AComponent implements IDynamicField
{
protected String expression;
private String expression;

protected String fieldValue;
private String fieldValue;

protected BarcodeStyle barcodeStyle = BarcodeStyle.Unknown;
private BarcodeStyle barcodeStyle = BarcodeStyle.Unknown;

protected boolean blankWhenNull = false;
private boolean blankWhenNull = false;

@Getter
public enum BarcodeStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
@Getter @Setter
public abstract class ALinearBarcode extends ABarcode
{
protected ZebraBarcodeSize barcodeSize;
private ZebraBarcodeSize barcodeSize;

protected int height;
private int height;

protected boolean humanReadableEnabled;
private boolean humanReadableEnabled;

protected HumanReadableStyle humanReadablePosition;
private HumanReadableStyle humanReadablePosition;

@Getter
public enum ZebraBarcodeSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
@Getter @Setter
public class CBarcodeAnsiCodabar extends ALinearBarcode implements IBarcodeWithCheckDigit, IBarcodeWithWideToNarrowRatio
{
protected boolean checkDigitEnabled = false;
private boolean checkDigitEnabled = false;

protected char startCharacter = 'A';
private char startCharacter = 'A';

protected char stopCharacter = 'A';
private char stopCharacter = 'A';

protected float wideToNarrowRatio = 3.0f;
private float wideToNarrowRatio = 3.0f;

/**
* Parameterless constructor
Expand All @@ -44,7 +44,7 @@ public class CBarcodeAnsiCodabar extends ALinearBarcode implements IBarcodeWithC
protected CBarcodeAnsiCodabar(final CBarcodeAnsiCodabar original, final boolean cloneData)
{
super(original, cloneData);
barcodeStyle = BarcodeStyle.ANSICodabar;
setBarcodeStyle(BarcodeStyle.ANSICodabar);
if (original != null)
{
this.checkDigitEnabled = original.checkDigitEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
@Getter @Setter
public class CBarcodeCode11 extends ALinearBarcode implements IBarcodeWithCheckDigit, IBarcodeWithWideToNarrowRatio
{
protected boolean checkDigitEnabled = false;
private boolean checkDigitEnabled = false;

protected float wideToNarrowRatio = 3.0f;
private float wideToNarrowRatio = 3.0f;

/**
* Parameterless constructor
Expand All @@ -40,7 +40,7 @@ public class CBarcodeCode11 extends ALinearBarcode implements IBarcodeWithCheckD
protected CBarcodeCode11(final CBarcodeCode11 original, final boolean cloneData)
{
super(original, cloneData);
barcodeStyle = BarcodeStyle.Code11;
setBarcodeStyle(BarcodeStyle.Code11);
if (original != null)
{
this.checkDigitEnabled = original.checkDigitEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
@Getter @Setter
public class CBarcodeCode128 extends ALinearBarcode implements IBarcodeWithCheckDigit
{
protected boolean checkDigitEnabled = false;
private boolean checkDigitEnabled = false;

protected char uccCaseMode = 'N';
private char uccCaseMode = 'N';

/**
* Parameterless constructor
Expand All @@ -39,7 +39,7 @@ public class CBarcodeCode128 extends ALinearBarcode implements IBarcodeWithCheck
protected CBarcodeCode128(final CBarcodeCode128 original, final boolean cloneData)
{
super(original, cloneData);
barcodeStyle = BarcodeStyle.Code128;
setBarcodeStyle(BarcodeStyle.Code128);
if (original != null)
{
this.checkDigitEnabled = original.checkDigitEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
@Getter @Setter
public class CBarcodeCode39 extends ALinearBarcode implements IBarcodeWithCheckDigit, IBarcodeWithWideToNarrowRatio
{
protected boolean checkDigitEnabled = false;
private boolean checkDigitEnabled = false;

protected float wideToNarrowRatio = 3.0f;
private float wideToNarrowRatio = 3.0f;

/**
* Parameterless constructor
Expand All @@ -40,7 +40,7 @@ public class CBarcodeCode39 extends ALinearBarcode implements IBarcodeWithCheckD
protected CBarcodeCode39(final CBarcodeCode39 original, final boolean cloneData)
{
super(original, cloneData);
barcodeStyle = BarcodeStyle.Code39;
setBarcodeStyle(BarcodeStyle.Code39);
if (original != null)
{
this.checkDigitEnabled = original.checkDigitEnabled;
Expand Down
Loading

0 comments on commit 0832f47

Please sign in to comment.