Skip to content

Commit

Permalink
Rename to Barcode, add BarcodeType, Remove unused files, reformat ext…
Browse files Browse the repository at this point in the history
…ensions to add field names
  • Loading branch information
itsmattking committed Jul 28, 2024
1 parent d0b1966 commit a05536b
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 30 deletions.
54 changes: 41 additions & 13 deletions src/main/kotlin/info/mking/k2zpl/builder/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

package info.mking.k2zpl.builder

import info.mking.k2zpl.command.Code39Barcode
import info.mking.k2zpl.command.BarCode
import info.mking.k2zpl.command.EndFormat
import info.mking.k2zpl.command.FieldBlock
import info.mking.k2zpl.command.FieldData
import info.mking.k2zpl.command.FieldOrientation
import info.mking.k2zpl.command.FieldOrigin
import info.mking.k2zpl.command.FieldSeparator
import info.mking.k2zpl.command.Font
Expand Down Expand Up @@ -33,7 +34,7 @@ import info.mking.k2zpl.command.options.ZplTextAlignment
* @param width The width of the label.
*/
fun ZplBuilder.printWidth(width: Int) {
command(PrintWidth(width))
command(PrintWidth(width = width))
}

/**
Expand All @@ -42,15 +43,15 @@ fun ZplBuilder.printWidth(width: Int) {
* @param y The y-coordinate of the label home.
*/
fun ZplBuilder.labelHome(x: Int, y: Int) {
command(LabelHome(x, y))
command(LabelHome(x = x, y = y))
}

/**
* Sets the label shift.
* @param shift The shift amount.
*/
fun ZplBuilder.labelShift(shift: Int) {
command(LabelShift(shift))
command(LabelShift(shift = shift))
}

/**
Expand All @@ -60,7 +61,11 @@ fun ZplBuilder.labelShift(shift: Int) {
* @param width The width of the font.
*/
fun ZplBuilder.font(font: ZplFont, height: Int, width: Int) {
command(Font(font, height, width))
command(Font(
font = font,
height = height,
width = width
))
}

/**
Expand All @@ -71,7 +76,12 @@ fun ZplBuilder.font(font: ZplFont, height: Int, width: Int) {
* @param path The path to the font file.
*/
fun ZplBuilder.fontAt(orientation: ZplFieldOrientation, height: Int, width: Int, path: String) {
command(FontAt(orientation, height, width, path))
command(FontAt(
orientation = orientation,
height = height,
width = width,
path = path
))
}

/**
Expand All @@ -83,7 +93,13 @@ fun ZplBuilder.fontAt(orientation: ZplFieldOrientation, height: Int, width: Int,
* @param hangingIndent The hanging indent for the block.
*/
fun ZplBuilder.fieldBlock(width: Int, lines: Int, lineSpacing: Int, alignment: ZplTextAlignment, hangingIndent: Int) {
command(FieldBlock(width, lines, lineSpacing, alignment, hangingIndent))
command(FieldBlock(
width = width,
lines = lines,
lineSpacing = lineSpacing,
alignment = alignment,
hangingIndent = hangingIndent
))
}

/**
Expand All @@ -101,15 +117,21 @@ fun ZplBuilder.code39Barcode(
line: Int,
lineAbove: Boolean
) {
command(Code39Barcode(orientation, checkDigit, height, line, lineAbove))
command(BarCode(
orientation = orientation,
checkDigit = checkDigit,
height = height,
line = line,
lineAbove = lineAbove
))
}

/**
* Sets the field orientation for text fields.
* @param orientation The orientation of the field.
*/
fun ZplBuilder.defaultFieldOrientation(orientation: ZplFieldOrientation) {
command(info.mking.k2zpl.command.FieldOrientation(orientation))
command(command = FieldOrientation(orientation = orientation))
}

/**
Expand All @@ -118,15 +140,15 @@ fun ZplBuilder.defaultFieldOrientation(orientation: ZplFieldOrientation) {
* @param darkness The print darkness.
*/
fun ZplBuilder.defaultPrintRate(speed: ZplPrintSpeed, darkness: Int) {
command(PrintRate(speed, darkness))
command(PrintRate(speed = speed, darkness = darkness))
}

/**
* Sets the media darkness.
* @param darkness The darkness level.
*/
fun ZplBuilder.defaultMediaDarkness(darkness: Int) {
command(MediaDarkness(darkness))
command(MediaDarkness(darkness = darkness))
}

/**
Expand All @@ -136,7 +158,7 @@ fun ZplBuilder.defaultMediaDarkness(darkness: Int) {
* @param alignment The alignment of the field (optional).
*/
fun ZplBuilder.fieldOrigin(x: Int, y: Int, alignment: ZplFieldOrientation? = null) {
command(FieldOrigin(x, y, alignment))
command(FieldOrigin(x = x, y = y, alignment = alignment))
}

/**
Expand All @@ -148,7 +170,13 @@ fun ZplBuilder.fieldOrigin(x: Int, y: Int, alignment: ZplFieldOrientation? = nul
* @param data The data for the graphic field.
*/
fun ZplBuilder.graphicField(format: Char, dataBytes: Int, totalBytes: Int, rowBytes: Int, data: String) {
command(GraphicField(format, dataBytes, totalBytes, rowBytes, data))
command(GraphicField(
format = format,
dataBytes = dataBytes,
totalBytes = totalBytes,
rowBytes = rowBytes,
data = data
))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package info.mking.k2zpl.command

import info.mking.k2zpl.command.options.ZplFieldOrientation

internal data class Code39Barcode(
val orientation: ZplFieldOrientation,
internal data class BarCode(
val type: BarcodeType = BarcodeType.CODE_39,
val orientation: ZplFieldOrientation = ZplFieldOrientation.NORMAL,
val checkDigit: Boolean,
val height: Int,
val line: Int,
Expand All @@ -22,4 +23,8 @@ internal data class Code39Barcode(
"l" to line,
"la" to lineAbove.toString()
)
}

enum class BarcodeType {
CODE_39
}
}
12 changes: 0 additions & 12 deletions src/main/kotlin/info/mking/k2zpl/command/BarcodeFieldDefault.kt

This file was deleted.

15 changes: 13 additions & 2 deletions src/main/kotlin/info/mking/k2zpl/command/GraphicBox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ fun ZplBuilder.graphicBox(
color: ZplLineColor = ZplLineColor.BLACK,
rounding: Int = 0
) {
command(GraphicBox(width, height, thickness, color, rounding))
command(GraphicBox(
width = width,
height = height,
thickness = thickness,
color = color,
rounding = rounding
))
}

/**
Expand All @@ -52,5 +58,10 @@ fun ZplBuilder.graphicBox(
* @param color The color of the line
*/
fun ZplBuilder.line(width: Int, thickness: Int = 1, color: ZplLineColor = ZplLineColor.BLACK) {
graphicBox(width, thickness, thickness, color)
graphicBox(
width = width,
height = thickness,
thickness = thickness,
color = color
)
}

0 comments on commit a05536b

Please sign in to comment.