import { Color, Zondy } from '../../base'
import {
SimpleMarkerSymbol,
SimpleLineSymbol,
SimpleFillSymbol,
TextSymbol
} from '../../base/symbol'
import { defaultValue } from '../../util'
/**
* 草图样式管理类
* @classdesc 草图样式管理类
* @class SketchStyle
* @moduleEX SketchEditorModule
* @param {Object} options
* @param {SimpleMarkerSymbol} [options.vertexStyle] 草图点样式
* @param {SimpleLineSymbol} [options.lineStyle] 草图线样式
* @param {SimpleFillSymbol} [options.fillStyle] 草图区样式
* @param {TextSymbol} [options.selectBoxStyle] 草图选中框样式
* @param {TextSymbol} [options.selectBoxVertexStyle] 草图选中框的顶点样式
* @param {TextSymbol} [options.selectVertexStyle] 草图选中时,被编辑中点样式
* @param {TextSymbol} [options.selectMidVertexStyle] 草图选中时,被编辑中点样式
* @param {Boolean} [options.isShowSegmentLength] 是否显示分段长度
* @param {Boolean} [options.isShowArea] 是否显示面积
*/
class SketchStyle {
constructor(options) {
options = defaultValue(options, {})
/**
* 绘制草图点样式
*/
this._vertexStyle = defaultValue(
options.vertexStyle,
new SimpleMarkerSymbol({
color: new Color(24, 144, 255, 1),
size: 10,
outline: new SimpleLineSymbol({
color: new Color(255, 255, 255, 1),
width: 1
})
})
)
/**
* 绘制草图线样式
*/
this._lineStyle = defaultValue(
options.lineStyle,
new SimpleLineSymbol({
color: new Color(24, 144, 255, 1),
width: 3
})
)
/**
* 绘制草图区样式
*/
this._fillStyle = defaultValue(
options.fillStyle,
new SimpleFillSymbol({
color: new Color(24, 144, 255, 0.3),
outline: new SimpleLineSymbol({
color: new Color(24, 144, 255, 1),
width: 2
})
})
)
this._textStyle = defaultValue(
options.textStyle,
new TextSymbol({
color: new Color(255, 255, 255, 1),
font: {
size: 15
}
})
)
/**
* 草图正在移动线样式
*/
this._movingLineStyle = defaultValue(
options.lineStyle,
new SimpleLineSymbol({
color: new Color(255, 255, 0, 1),
width: 2
})
)
/**
* 草图选中框的样式
*/
this._selectBoxStyle = defaultValue(
options.selectBoxStyle,
new SimpleFillSymbol({
color: new Color(241, 188, 0, 0.1),
outline: new SimpleLineSymbol({
color: new Color(241, 188, 0, 0.8),
width: 2
})
})
)
/**
* 草图选中框的顶点样式
*/
this._selectBoxVertexStyle = defaultValue(
options.selectBoxVertexStyle,
new SimpleMarkerSymbol({
color: new Color(255, 255, 255, 1),
size: 10,
outline: new SimpleLineSymbol({
color: new Color(241, 188, 0, 1),
width: 3
})
})
)
/**
* 草图选中时,被编辑顶点样式
*/
this._selectVertexStyle = defaultValue(
options.selectVertexStyle,
new SimpleMarkerSymbol({
color: new Color(241, 188, 0, 1),
size: 11,
outline: new SimpleLineSymbol({
color: new Color(255, 255, 255, 1),
width: 1
})
})
)
/**
* 草图选中时,被编辑中点样式
*/
this._selectMidVertexStyle = defaultValue(
options.selectMidVertexStyle,
new SimpleMarkerSymbol({
color: new Color(255, 255, 255, 1),
size: 8,
outline: new SimpleLineSymbol({
color: new Color(241, 188, 0, 1),
width: 1
})
})
)
/**
* 捕获点重合样式
*/
this._coincidentPointStyle = defaultValue(
options.coincidentPointStyle,
new SimpleMarkerSymbol({
color: new Color(255, 255, 0, 1),
size: 10,
outline: new SimpleLineSymbol({
color: new Color(255, 255, 255, 1),
width: 1
})
})
)
/**
* 是否显示分段长度
*/
this._isShowSegmentLength = defaultValue(options.isShowSegmentLength, false)
/**
* 是否显示面积
*/
this._isShowArea = defaultValue(options.isShowArea, false)
}
/**
* 点样式
* @readonly
* @member SketchStyle.property.vertexStyle
* @type {SimpleMarkerSymbol}
*/
get vertexStyle() {
return this._vertexStyle
}
/**
* 线样式
* @readonly
* @member SketchStyle.property.lineStyle
* @type {SimpleLineSymbol}
*/
get lineStyle() {
return this._lineStyle
}
/**
* 填充样式
* @readonly
* @member SketchStyle.property.fillStyle
* @type {SimpleFillSymbol}
*/
get fillStyle() {
return this._fillStyle
}
/**
* 文字样式
* @readonly
* @member SketchStyle.property.textStyle
* @type {TextSymbol}
*/
get textStyle() {
return this._textStyle
}
/**
* 是否显示分段长度
* @readonly
* @member SketchStyle.property.isShowSegmentLength
* @type {Boolean}
*/
get isShowSegmentLength() {
return this._isShowSegmentLength
}
/**
* 是否显示面积
* @readonly
* @member SketchStyle.property.isShowArea
* @type {Boolean}
*/
get isShowArea() {
return this._isShowArea
}
}
export default SketchStyle
Zondy.SketchStyle = SketchStyle