generation/unit.js

const _MwWrapper = require("../_mwbridge/_mw-wrapper.js");
const BarcodeGenerator = require("./index");

/**
 *  Specifies the size value in different units (Pixel, Inches, etc.).
 *  @example
 *  //This sample shows how to create and save a BarCode image.
 *    let generator = new BarcodeGenerator(EncodeTypes.CODE_128);
 *    generator.getParameters().getBarcode().getBarHeight().setMillimeters(10);
 *    generator.save("test.png", BarcodeImageFormat.PNG);
 */
class Unit extends _MwWrapper
{
    constructor(source)
    {
        super(Unit.initUnit(source));
        this._initializeWrapperMembers();
    }

    static initUnit(source)
    {
        if (source instanceof Unit) {
            return source.getJavaClass();
        }
        return source;
    }

    _initializeWrapperMembers()
    {
    }

    /**
     * Gets size value in pixels.
     */
    getPixels()
    {
        return this.getJavaClass().getPixelsSync();
    }

    /**
     * Sets size value in pixels.
     */
    setPixels(value)
    {
        this.getJavaClass().setPixelsSync(value);
    }

    /**
     * Gets size value in inches.
     */
    getInches()
    {
        return this.getJavaClass().getInchesSync();
    }

    /**
     * Sets size value in inches.
     */
    setInches(value)
    {
        this.getJavaClass().setInchesSync(value);
    }

    /**
     * Gets size value in millimeters.
     */
    getMillimeters()
    {
        return this.getJavaClass().getMillimetersSync();
    }

    /**
     * Sets size value in millimeters.
     */
    setMillimeters(value)
    {
        this.getJavaClass().setMillimetersSync(value);
    }

    /**
     * Gets size value in point.
     */
    getPoint()
    {
        return this.getJavaClass().getPointSync();
    }

    /**
     * Sets size value in point.
     */
    setPoint(value)
    {
        this.getJavaClass().setPointSync(value);
    }

    /**
     * Gets size value in document units.
     */
    getDocument()
    {
        return this.getJavaClass().getDocumentSync();
    }

    /**
     * Sets size value in document units.
     */
    setDocument(value)
    {
        this.getJavaClass().setDocumentSync(value);
    }

    /**
     * Returns a human-readable string representation of this Unit.<br>
     * @return A string that represents this Unit.
     */
    toString()
    {
        return this.getJavaClass().toStringSync();
    }

    /**
     * Determines whether this instance and a specified object,<br>
     * which must also be a Unit object, have the same value.<br>
     * @param obj The Unit to compare to this instance.
     * @return true if obj is a Unit and its value is the same as this instance;
     * otherwise, false. If obj is null, the method returns false.
     */
    equals(obj)
    {
        return this.getJavaClass().equalsSync(obj.getJavaClass());
    }
}

module.exports = Unit;