package com.nexstreaming.nexplayerengine;

import static com.nexstreaming.nexplayerengine.NexCaptionSetting.DEFAULT;

/**
 * \brief This class manages the position of captions for NexCaptionSetting
 */

public class NexCaptionWindowRect {
    /**
     * This indicates the left position of the the caption window.
     * It can be set to a percentage of the horizontal caption render area.
     */
    public  int xPercent;

    /**
     * This indicates the top position of the the caption window.
     * It can be set to a percentage of the vertical caption render area.
     */
    public  int yPercent;

    /**
     * This indicates the width of the caption window.
     * It can be set to a percentage of the horizontal caption render area.
     */
    public  int widthPercent;

    /**
     * This indicates the height of the caption window.
     * It can be set to a percentage of the vertical caption render area.
     */
    public  int heightPercent;

    /**
     * This indicates ifthe position is set by user or not.
     * It should be set to true if the position set by the user should be applied instead of the position set by the content.
     *
     * <b>Default:</b> false Set by content.
     */
    public  boolean userDefined;

    /**
     * This indicates that the position is adjusted by NexPlayer.
     * It should be set to false if the position is set by the user.
     *
     * <b>Default:</b> true Automatically adjusted by NexPlayer
     */
    public  boolean autoAdjustment;

    /**
     * \brief Constructor of NexCaptionWindowRect.
     * The values in NexCaptionWindowRect will be initialized with NexCaptionSetting.DEFAULT
     */
    public NexCaptionWindowRect() {
        init();
    }

    /**
     * \brief Constructor of NexCaptionWindowRect.
     * The values will be generated by initializing settings object values.
     *
     * \param ref A \c NexCaptionWindowRect object.
     */
    public NexCaptionWindowRect(NexCaptionWindowRect ref) {
        init();
        copyAllSettings(ref);
    }

    /**
     * \brief This method resets all the values of NexCaptionWindowRect.
     */
    public void init() {
        xPercent = DEFAULT;
        yPercent = DEFAULT;
        widthPercent = DEFAULT;
        heightPercent = DEFAULT;
        userDefined = false;
        autoAdjustment = true;
    }

    /**
     * \brief This method sets the values by settings object values including NexCaptionSetting.DEFAULT
     *
     * \param ref A \c NexCaptionWindowRect object.
     */
    public void copyAllSettings(NexCaptionWindowRect ref) {
        if (null != ref) {
            xPercent = ref.xPercent;
            yPercent = ref.yPercent;
            widthPercent = ref.widthPercent;
            heightPercent = ref.heightPercent;
            userDefined = ref.userDefined;
        }
    }

    /**
     * \brief This method sets the values by settings object values excepting NexCaptionSetting.DEFAULT
     *
     * \param ref A \c NexCaptionWindowRect object.
     */
    public void copyTouchedSettings(NexCaptionWindowRect ref) {
        if (null != ref) {
            if (DEFAULT != ref.xPercent) { xPercent = ref.xPercent; }
            if (DEFAULT != ref.yPercent) { yPercent = ref.yPercent; }
            if (DEFAULT != ref.widthPercent) { widthPercent = ref.widthPercent; }
            if (DEFAULT != ref.heightPercent) { heightPercent = ref.heightPercent; }
            userDefined = ref.userDefined;
        }
    }
}
