    import VisualVariable from './VisualVariable'
    import { defaultValue } from '../../../util'
    import VisualVariableType from '../../../base/enum/VisualVariableType'
    import OpacityStop from './support/OpacityStop'
    import { Zondy } from '../../../base'
    /**
     * opacity视觉变量
     * @class OpacityVariable
     * @moduleEX RendererModule
     * @param {Object} options 初始化参数
     * @param {String} [options.normalizationField] 归一化字段
     * @param {Array<OpacityStop>} [options.stops] 透明度分段数组
     */
    class OpacityVariable extends VisualVariable {
      constructor(options) {
        super(options)
        options = defaultValue(options, {})
        this.type = VisualVariableType.opacity
        /**
         * 归一化字段
         * @member {String} OpacityVariable.prototype.normalizationField
         */
        this.normalizationField = defaultValue(options.normalizationField, '')
        /**
         * 透明度分段数组
         * @member {Array<OpacityStop>} OpacityVariable.prototype.stops
         */
        this.stops = defaultValue(options.stops, [])
        this.stops = this.stops.map((v) => OpacityStop.fromJSON(v))
      }

      /**
       * 通过json构造OpacityVariable对象
       * @return {OpacityVariable} json对象
       * */
      static fromJSON(json) {
        return new OpacityVariable(json)
      }

      /**
       * 导出为json对象
       * @return {Object} json对象
       * */
      toJSON() {
        const json = super.toJSON()
        json.type = this.type
        json.normalizationField = this.normalizationField
        json.stops = this.stops.map((v) => v.toJSON())
        return json
      }

      /**
       * 克隆对象
       * @return {OpacityVariable} 克隆后的OpacityVariable对象
       */
      clone() {
        return new OpacityVariable(this.toJSON())
      }
    }

    Zondy.Renderer.VisualVariable.OpacityVariable = OpacityVariable
    export default OpacityVariable