cellsysBase/cellsysStyle.js

269 lines
7.1 KiB
JavaScript
Raw Permalink Normal View History

2024-08-14 16:20:56 +08:00
import './cellsysUtil.js';
import { CellsysType } from './cellsysUtil';
import { defaultIcon } from './cellsysIcon';
import { Query, QueryTask, QueryType, Operator, ThirdpartyObjectType } from './cellsysUtil.js';
//CellsysStyle废弃修改或新功能请使用最下面新封装的style对象
class CellsysStyle {
constructor(params) {
this.cellsysType = CellsysType.Style;
params = params || {};
this.iconId = params.id;
this.stroke = params.stroke;
// this.color = params.color ? params.color : '#000000'
this.weight = params.weight;
this.fillColor = params.fillColor; //图标颜色
this.fillOpacity = params.fillOpacity; //图标透明
this.strokeOpacity = params.strokeOpacity; // 边框透明度
this.strokeColor = params.strokeColor; // 边框颜色
this.dashArray = params.dashArray;
this.showLabel = params.showLabel;
this.name = params.name;
this.data = params.data;
this.rotate = params.rotate ? params.rotate : 0;
this.type = params.type;
}
setId(value) {
this.id = value;
}
setName(value) {
this.name = value;
}
setDescription(value) {
this.description = value;
}
setColor(value) {
this.color = value;
}
setWeight(value) {
this.weight = value;
}
setOpacity(value) {
this.opacity = value;
}
setFill(value) {
this.fill = value;
}
setFillColor(value) {
this.fillColor = value;
}
setFillOpacity(value) {
this.fillOpacity = value;
}
setDashArray(value) {
this.dashArray = value;
}
setShowLabel(value) {
this.showLabel = value;
}
setIcon(value) {
this.icon = value;
}
setPath(value) {
this.path = value;
}
getLayerStyle() {
return {
iconId: this.iconId,
fillColor: this.fillColor,
fillOpacity: this.fillOpacity,
name: this.name,
rotate: this.rotate,
data: this.data,
type: this.type,
};
}
getMemberStyle() {
return {
id: this.iconId,
iconId: this.iconId,
fillColor: this.fillColor,
fillOpacity: this.fillOpacity,
name: this.name,
rotate: this.rotate,
data: this.data,
type: this.type,
};
}
getFenceStyle() {
return {
color: this.color,
weight: this.weight,
opacity: this.opacity,
fillColor: this.fillColor,
showLabel: this.showLabel,
fillOpacity: this.fillOpacity,
};
}
getMarkStyle() {
return {
id: this.iconId,
iconId: this.iconId,
fillColor: this.fillColor,
fillOpacity: this.fillOpacity,
name: this.name,
rotate: this.rotate,
data: this.data,
type: this.type,
};
}
getLineStyle() {
return {
color: this.color,
weight: this.weight,
opacity: this.opacity,
fillColor: this.fillColor,
fillOpacity: this.fillOpacity,
dashArray: this.dashArray,
};
}
getEventTypeStyle() {
return {
color: this.color,
fillOpacity: this.fillOpacity,
opacity: this.opacity ? this.opacity : 1,
fill: this.fill ? this.fill : '#000000',
name: this.name ? this.name : '坐标',
rotate: this.rotate ? this.rotate : 0,
data: this.data
? this.data
: 'M526.1121875 122.86625c-158.5603125 0.301875-286.9940625 128.9025-286.9940625 287.53125 0 148.111875 120.916875 303.909375' +
' 260.7384375 471.5015625 7.348125 8.829375 16.8534375 13.5796875 26.255625 14.1196875 9.4021875-0.54 18.9075-5.2903125 26.251875-14.1196875 139.8225-167.5921875 260.7403125-323.38875 260.7403125-471.5015625 0-158.6296875-128.4346875-287.229375-286.993125-287.53125zM526.1121875 501.6565625c-61.940625-0.335625-112.089375-50.58375-112.089375-112.5928125s50.14875-112.25625 112.089375-112.5928125c61.9396875 0.335625 112.0846875 50.58375 112.0846875 112.5928125s-50.1440625 112.25625-112.0846875 112.5928125z',
type: this.type,
};
}
}
/**
* style基类 20200907 yw
*/
class BaseStyle {
constructor(params) {
this.fillColor = params.fillColor || null; //图标颜色
this.fillOpacity = params.fillOpacity || null; //图标透明
this.strokeOpacity = params.strokeOpacity || null; // 边框透明度
this.strokeColor = params.strokeColor || null; // 边框颜色
this.dashArray = params.dashArray || null;
}
static getDefaultStyle() {
// console.log(this.prototype.constructor.name)
return {
strokeColor: '#1890ff',
strokeOpacity: 1,
fillColor: '#1890ff',
fillOpacity: 0.2,
dashArray: '',
};
}
getVectorStyle() {
return {
color: this.strokeColor,
opacity: this.strokeOpacity,
fillColor: this.fillColor,
fillOpacity: this.fillOpacity,
weight: this.weight || 3,
dashArray: this.dashArray,
};
}
}
/**
* style
*/
class CellsysMarkerStyle extends BaseStyle {
constructor(params) {
params = params || {};
super(params);
// this.name = params.name
this.rotate = params.rotate;
// this.data = params.data
this.type = params.type;
}
static getDefaultStyle() {
return defaultIcon;
// return new Promise((resolve, reject) => {
// let queryTask = new QueryTask(QueryType.Config)
// queryTask.execute()
// .then(res => {
// if(res ) {
// let markerConfig = res["DEFAULT_POINT_STYLE"].value;
// resolve(markerConfig)
// }else{
// resolve()
// }
// })
// .catch(err => {
// reject(err)
// })
// })
}
}
/**
* 线 style
*/
class CellsysLineStyle extends BaseStyle {
constructor(params) {
params = params || {};
super(params);
this.weight = params.weight || 3;
}
static getDefaultStyle() {
return Object.assign(
{
weight: 3,
},
super.getDefaultStyle(),
);
}
}
/**
* 区域 style
*/
class CellsysPolygonStyle extends BaseStyle {
constructor(params) {
params = params || {};
super(params);
this.weight = params.weight || 3;
this.showLabel = params.showLabel; //是否显示名称
}
static getDefaultStyle() {
return Object.assign(
{
weight: 3,
},
super.getDefaultStyle(),
);
}
}
export { CellsysMarkerStyle, CellsysLineStyle, CellsysPolygonStyle };
export default CellsysStyle;