import Symbol from './Symbol'
import { defaultValue } from '../../util'
import { SymbolType } from '../enum'
import Color from '../Color'
/**
* 线符号基类
* @class LineSymbol
* @moduleEX SymbolModule
* @extends Symbol
* @param {Object} options 线符号样式
* @param {Number} [options.width = 1] 线符号宽度,默认为1
*/
class LineSymbol extends Symbol {
constructor(options) {
super(options)
options = defaultValue(options, {})
/**
* 颜色
* @member {Color} LineSymbol.prototype.color
*/
this.color = Color.fromColor(
defaultValue(options.color, new Color(0, 0, 0, 1))
)
/**
* 符号类型
* @member {String} LineSymbol.prototype.type
*/
this.type = SymbolType.simpleLine
/**
* 线宽度
* @member {Number} LineSymbol.prototype.width
*/
this.width = defaultValue(options.width, 1)
}
/**
* @function LineSymbol.prototype.toJSON
* @description 将JS对象转换为JSON格式
* @returns {Object} 符号的实例化JSON
*/
toJSON() {
const json = super.toJSON()
json.type = this.type
json.width = this.width
return json
}
}
export default LineSymbol