generation/barcode-parameters.js

const _MwWrapper = require("../_mwbridge/_mw-wrapper.js");
const  Unit = require("./unit.js");
const  CodetextParameters = require("./codetext-parameters.js");
const  PostalParameters = require("./postal-parameters.js");
const  AustralianPostParameters = require("./australian-post-parameters.js");
const  CodablockParameters = require("./codablock-parameters.js");
const  DataBarParameters = require("./databar-parameters.js");
const  GS1CompositeBarParameters = require("./gs1-composite-bar-parameters.js");
const  DataMatrixParameters = require("./data-matrix-parameters.js");
const  Code16KParameters = require("./code16k-parameters.js");
const  ITFParameters = require("./itf-parameters.js");
const  QrParameters = require("./qr-parameters.js");
const  Pdf417Parameters = require("./pdf-417-parameters.js");
const  MaxiCodeParameters = require("./maxicode-parameters.js");
const  AztecParameters = require("./aztec-parameters.js");
const  Code128Parameters = require("./code-128-parameters.js");
const  CodabarParameters = require("./codabar-parameters.js");
const  CouponParameters = require("./coupon-parameters.js");
const  HanXinParameters = require("./hanxin-parameters.js");
const  SupplementParameters = require("./supplement-parameters.js");
const  DotCodeParameters = require("./dotcode-parameters.js");
const  Padding = require("./padding.js");
const  PatchCodeParameters = require("./patchcode-parameters.js");
/**
 * Barcode generation parameters.
 */
class BarcodeParameters extends _MwWrapper
{
    xDimension;
    barHeight;
    codeTextParameters;
    postal;
    australianPost;
    codablock;
    dataBar;
    gs1CompositeBar;
    dataMatrix;
    code16K;
    itf;
    qr;
    pdf417;
    maxiCode;
    aztec;
    code128;
    codabar;
    coupon;
    hanXin;
    supplement;
    dotCode;
    padding;
    patchCode;
    barWidthReduction;

    constructor(mwObject)
    {
        super(mwObject);
        this._initializeWrapperMembers();
    }

    _initializeWrapperMembers()
    {
        this.xDimension = new Unit(this.getJavaClass().getXDimensionSync());
        this.barWidthReduction = new Unit(this.getJavaClass().getBarWidthReductionSync());
        this.barHeight = new Unit(this.getJavaClass().getBarHeightSync());
        this.codeTextParameters = new CodetextParameters(this.getJavaClass().getCodeTextParametersSync());
        this.postal = new PostalParameters(this.getJavaClass().getPostalSync());
        this.australianPost = new AustralianPostParameters(this.getJavaClass().getAustralianPostSync());
        this.codablock = new CodablockParameters(this.getJavaClass().getCodablockSync());
        this.dataBar = new DataBarParameters(this.getJavaClass().getDataBarSync());
        this.gs1CompositeBar = new GS1CompositeBarParameters(this.getJavaClass().getGS1CompositeBarSync());
        this.dataMatrix = new DataMatrixParameters(this.getJavaClass().getDataMatrixSync());
        this.code16K = new Code16KParameters(this.getJavaClass().getCode16KSync());
        this.itf = new ITFParameters(this.getJavaClass().getITFSync());
        this.qr = new QrParameters(this.getJavaClass().getQRSync());
        this.pdf417 = new Pdf417Parameters(this.getJavaClass().getPdf417Sync());
        this.maxiCode = new MaxiCodeParameters(this.getJavaClass().getMaxiCodeSync());
        this.aztec = new AztecParameters(this.getJavaClass().getAztecSync());
        this.code128 = new Code128Parameters(this.getJavaClass().getCode128Sync());
        this.codabar = new CodabarParameters(this.getJavaClass().getCodabarSync());
        this.coupon = new CouponParameters(this.getJavaClass().getCouponSync());
        this.hanXin = new HanXinParameters(this.getJavaClass().getHanXinSync());
        this.supplement = new SupplementParameters(this.getJavaClass().getSupplementSync());
        this.dotCode = new DotCodeParameters(this.getJavaClass().getDotCodeSync());
        this.padding = new Padding(this.getJavaClass().getPaddingSync());
        this.patchCode = new PatchCodeParameters(this.getJavaClass().getPatchCodeSync());
    }

    /**
     * x-dimension is the smallest width of the unit of BarCode bars or spaces.<br>
     * Increase this will increase the whole barcode image width.<br>
     * Ignored if AutoSizeMode property is set to AutoSizeMode.NEAREST or AutoSizeMode.INTERPOLATION.
     */
    getXDimension()
    {
        return this.xDimension;
    }

    /**
     * x-dimension is the smallest width of the unit of BarCode bars or spaces.<br>
     * Increase this will increase the whole barcode image width.<br>
     * Ignored if AutoSizeMode property is set to AutoSizeMode.NEAREST or AutoSizeMode.INTERPOLATION.
     * @throws BarcodeException
     */
    setXDimension(value)
    {
        this.getJavaClass().setXDimensionSync(value.getJavaClass());
        this.xDimension = value;
    }

    /**
     * Height of 1D barcodes' bars in Unit value.<br>
     * Ignored if AutoSizeMode property is set to AutoSizeMode.NEAREST or AutoSizeMode.INTERPOLATION.
     * @throws BarcodeException
     */
    getBarHeight()
    {
        return this.barHeight;
    }

    /**
     * Height of 1D barcodes' bars in Unit value.<br>
     * Ignored if AutoSizeMode property is set to AutoSizeMode.NEAREST or AutoSizeMode.INTERPOLATION.
     * @throws BarcodeException
     */
    setBarHeight(value)
    {
        this.getJavaClass().setBarHeightSync(value.getJavaClass());
        this.barHeight = value;
    }

    /**
     * Bars color.
     * @return value of Bar color
     * Default value: #000000
     */
    getBarColor()
    {
        let intColor = this.getJavaClass().getBarColorSync();
        let hexColor = ((intColor) >>> 0).toString(16).slice(-6).toUpperCase()
        while (hexColor.length < 6) {
            hexColor = "0" + hexColor;
        }
        hexColor = "#" + hexColor;
        return hexColor;
    }

    /**
     * Bars color.
     * @param {String} value for Bar color
     * Default value: #000000.
     */
    setBarColor(value)
    {
        this.getJavaClass().setBarColorSync((parseInt(value.substr(1), 16) << 8) / 256);
    }

    /**
     * Barcode paddings.<br>
     * Default value: 5pt 5pt 5pt 5pt.
     */
    getPadding()
    {
        return this.padding;
    }

    /**
     * Barcode paddings.<br>
     * Default value: 5pt 5pt 5pt 5pt.
     */
    setPadding(value)
    {
        this.getJavaClass().setPaddingSync(value.getJavaClass());
        this.padding = value;
    }

    /**
     *  Always display checksum digit in the human readable text for Code128 and GS1Code128 barcodes.
     */
    getChecksumAlwaysShow()
    {
        return this.getJavaClass().getChecksumAlwaysShowSync();
    }

    /**
     *  Always display checksum digit in the human readable text for Code128 and GS1Code128 barcodes.
     */
    setChecksumAlwaysShow(value)
    {
        this.getJavaClass().setChecksumAlwaysShowSync(value);
    }

    /**
     * Enable checksum during generation 1D barcodes.<br>
     * Default is treated as Yes for symbology which must contain checksum, as No where checksum only possible.<br>
     * Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN, Codabar<br>
     * Checksum always used: Rest symbology
     */
    isChecksumEnabled()
    {
        return this.getJavaClass().isChecksumEnabledSync();
    }

    /**
     * Enable checksum during generation 1D barcodes.<br>
     * Default is treated as Yes for symbology which must contain checksum, as No where checksum only possible.<br>
     * Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN, Codabar<br>
     * Checksum always used: Rest symbology
     */
    setChecksumEnabled(value)
    {
        this.getJavaClass().setChecksumEnabledSync(value);
    }

    /**
     * Indicates whether explains the character "\" as an escape character in CodeText property. Used for Pdf417, DataMatrix, Code128 only<br>
     * If the EnableEscape is true, "\" will be explained as a special escape character. Otherwise, "\" acts as normal characters.<br>
     * Aspose.BarCode supports inputing decimal ascii code and mnemonic for ASCII control-code characters. For example, \013 and \\CR stands for CR.
     */
    getEnableEscape()
    {
        return this.getJavaClass().getEnableEscapeSync();
    }

    /**
     * Indicates whether explains the character "\" as an escape character in CodeText property. Used for Pdf417, DataMatrix, Code128 only<br>
     * If the EnableEscape is true, "\" will be explained as a special escape character. Otherwise, "\" acts as normal characters.<br>
     *<hr>Aspose.BarCode supports the decimal ascii code and mnemonic for ASCII control-code characters. For example, \013 and \\CR stands for CR.</hr>
     */
    setEnableEscape(value)
    {
        this.getJavaClass().setEnableEscapeSync(value);
    }

    /**
     * Wide bars to Narrow bars ratio<br>.
     * Default value: 3, that is, wide bars are 3 times as wide as narrow bars<br>.
     * Used for ITF, PZN, PharmaCode, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, IATA2of5, VIN, DeutschePost, OPC, Code32, DataLogic2of5, PatchCode, Code39Extended, Code39Standard<br>
     *
     * The WideNarrowRatio parameter value is less than or equal to 0.
     */
    getWideNarrowRatio()
    {
        return this.getJavaClass().getWideNarrowRatioSync();
    }

    /**
     * Wide bars to Narrow bars ratio.<br>
     * Default value: 3, that is, wide bars are 3 times as wide as narrow bars.<br>
     * Used for ITF, PZN, PharmaCode, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, IATA2of5, <br>
     * VIN, DeutschePost, OPC, Code32, DataLogic2of5, PatchCode, Code39Extended, Code39Standard<br>
     * <br>
     * The WideNarrowRatio parameter value is less than or equal to 0.
     */
    setWideNarrowRatio(value)
    {
        this.getJavaClass().setWideNarrowRatioSync(value);
    }

    /**
     * Codetext parameters.
     */
    getCodeTextParameters()
    {
        return this.codeTextParameters;
    }

    /**
     * Gets a value indicating whether bars filled.<br>
     * Only for 1D barcodes.<br>
     * Default value: true.
     */
    getFilledBars()
    {
        return this.getJavaClass().getFilledBarsSync();
    }

    /**
     * Sets a value indicating whether bars filled.<br>
     * Only for 1D barcodes.<br>
     * Default value: true.
     */
    setFilledBars(value)
    {
        this.getJavaClass().setFilledBarsSync(value);
    }

    /**
     * Get bars reduction value that is used to compensate ink spread while printing.<br>
     * @return Unit value of BarWidthReduction
     */
    getBarWidthReduction()
    {
        return this.barWidthReduction;
    }

    /**
     * Sets bars reduction value that is used to compensate ink spread while printing.
     */
    setBarWidthReduction(value)
    {
        this.getJavaClass().setBarWidthReductionSync(value.getJavaClass());
        this.barWidthReduction = value;
    }


    /**
     * Postal parameters. Used for Postnet, Planet.
     */
    getPostal()
    {
        return this.postal;
    }

    /**
     * PatchCode parameters.
     */
    getPatchCode()
    {
        return this.patchCode;
    }


    /**
     * AustralianPost barcode parameters.
     */
    getAustralianPost()
    {
        return this.australianPost;
    }

    /**
     * Databar parameters.
     */
    getDataBar()
    {
        return this.dataBar;
    }

    /**
     * GS1 Composite Bar parameters.<br>
     * <br>
     * This sample shows how to create and save a GS1 Composite Bar image.<br>
     * Note that 1D codetext and 2D codetext are separated by symbol '/'
     *
     * @example
     * let codetext = "(01)03212345678906/(21)A1B2C3D4E5F6G7H8";
     * let generator = new BarcodeGenerator(EncodeTypes.GS_1_COMPOSITE_BAR, codetext);
     *
     * generator.getParameters().getBarcode().getGS1CompositeBar().setLinearComponentType(EncodeTypes.GS_1_CODE_128);
     * generator.getParameters().getBarcode().getGS1CompositeBar().setTwoDComponentType(TwoDComponentType.CC_A);
     *
     * // Aspect ratio of 2D component
     * generator.getParameters().getBarcode().getPdf417().setAspectRatio(3);
     *
     * // X-Dimension of 1D and 2D components
     * generator.getParameters().getBarcode().getXDimension().setPixels(3);
     * ///
     * // Height of 1D component
     * generator.getParameters().getBarcode().getBarHeight().setPixels(100);
     * ///
     * generator.save("test.png", BarcodeImageFormat.PNG);
     *
     * @return GS1CompositeBarParameters GS1 Composite Bar parameters.
     */
    getGS1CompositeBar()
    {
        return this.gs1CompositeBar;
    }

    /**
     * GS1 Composite Bar parameters.<br>
     * <br>
     * This sample shows how to create and save a GS1 Composite Bar image.<br>
     * Note that 1D codetext and 2D codetext are separated by symbol '/'
     *
     * @example
     * let codetext = "(01)03212345678906/(21)A1B2C3D4E5F6G7H8";
     * let generator = new BarcodeGenerator(EncodeTypes.GS_1_COMPOSITE_BAR, codetext);
     *
     * generator.getParameters().getBarcode().getGS1CompositeBar().setLinearComponentType(EncodeTypes.GS_1_CODE_128);
     * generator.getParameters().getBarcode().getGS1CompositeBar().setTwoDComponentType(TwoDComponentType.CC_A);
     *
     * // Aspect ratio of 2D component
     * generator.getParameters().getBarcode().getPdf417().setAspectRatio(3);
     *
     * // X-Dimension of 1D and 2D components
     * generator.getParameters().getBarcode().getXDimension().setPixels(3);
     *
     * // Height of 1D component
     * generator.getParameters().getBarcode().getBarHeight().setPixels(100);
     *
     * generator.save("test.png", BarcodeImageFormat.PNG);
     */
    setGS1CompositeBar(value)
    {
        this.gs1CompositeBar = value;
        this.getJavaClass().setGS1CompositeBarSync(value.getJavaClass());
    }

    /**
     * Codablock parameters.
     */
    getCodablock()
    {
        return this.codablock;
    }

    /**
     * DataMatrix parameters.
     */
    getDataMatrix()
    {
        return this.dataMatrix;
    }

    /**
     * Code16K parameters.
     */
    getCode16K()
    {
        return this.code16K;
    }

    /**
     * DotCode parameters.
     */
    getDotCode()
    {
        return this.dotCode;
    }

    /**
     * ITF parameters.
     */
    getITF()
    {
        return this.itf;
    }

    /**
     * PDF417 parameters.
     */
    getPdf417()
    {
        return this.pdf417;
    }

    /**
     * QR parameters.
     */
    getQR()
    {
        return this.qr;
    }

    /**
     * Supplement parameters. Used for Interleaved2of5, Standard2of5, EAN13, EAN8, UPCA, UPCE, ISBN, ISSN, ISMN.
     */
    getSupplement()
    {
        return this.supplement;
    }

    /**
     * MaxiCode parameters.
     */
    getMaxiCode()
    {
        return this.maxiCode;
    }

    /**
     * Aztec parameters.
     */
    getAztec()
    {
        return this.aztec;
    }

    /**
     * <p>
     * Code128 parameters.
     * </p>
     */
    getCode128()
    {
        return this.code128;
    }

    /**
     * Codabar parameters.
     */
    getCodabar()
    {
        return this.codabar;
    }

    /**
     * Coupon parameters. Used for UpcaGs1DatabarCoupon, UpcaGs1Code128Coupon.
     */
    getCoupon()
    {
        return this.coupon;
    }

    /**
     * HanXin parameters.
     */
    getHanXin()
    {
        return this.hanXin;
    }
}

module.exports = BarcodeParameters;