rt-sim-training-client/src/jmapNew/shape/Station/index.js

125 lines
4.3 KiB
JavaScript
Raw Normal View History

2019-11-29 12:51:58 +08:00
/*
* 车站
*/
import Group from 'zrender/src/container/Group';
import ETextName from '../element/ETextName';
2019-12-04 18:39:28 +08:00
// import EHighlight from '../element/EHighlight'; // 名称文字 (共有)
import EControl from '../element/EControl';
2019-11-29 12:51:58 +08:00
export default class Station extends Group {
constructor(model, style) {
super();
this._code = model.code;
this._type = model._type;
this.zlevel = model.zlevel;
this.z = 40;
this.model = model;
this.style = style;
this.create();
2019-12-04 18:39:28 +08:00
// this.createTurnBack(); // 创建按图折返
this.setState(model);
2019-12-04 18:39:28 +08:00
// this.checkIsDrawMap();
}
2019-11-29 12:51:58 +08:00
create() {
const model = this.model;
const style = this.style;
2019-11-29 12:51:58 +08:00
if (model.visible) {
// 公里标名称是否显示
this.stationText = new ETextName({
zlevel: this.zlevel,
z: this.z,
position: [0, 0],
x: model.position.x,
y: model.position.y,
fontWeight: model.fontWeight,
fontSize: model.nameFont || 18,
fontFamily: style.fontFamily,
text: model.name,
textAlign: 'middle',
textVerticalAlign: 'top',
textFill: model.nameFontColor
});
this.add(this.stationText);
const path = window.location.href;
if (style.Station.kmPostShow || path.includes('/map/draw')) {
// 公里标是否显示
let direction = 1;
if (this.style.Station.kilometerPosition == 'up') {
direction = -1;
}
this.mileageText = new ETextName({
zlevel: this.zlevel,
z: this.z,
position: [0, 0],
x: model.position.x,
y: model.position.y + ((parseInt(model.nameFont) + 2) * direction),
fontWeight: model.fontWeight,
fontSize: model.kmPostFont || 18,
fontFamily: style.fontFamily,
text: model.kmPost,
textAlign: 'middle',
textVerticalAlign: 'top',
textFill: model.kmPostFontColor
});
this.add(this.mileageText);
}
}
}
2019-12-04 18:39:28 +08:00
createTurnBack() { // 创建按图折返
2019-12-04 14:59:04 +08:00
const model = this.model;
const style = this.style;
if (model.visible && model.isCreateTurnBack) {
2019-12-04 18:39:28 +08:00
this.turnBack = new EControl({
2019-12-04 14:59:04 +08:00
zlevel: this.zlevel,
z: this.z,
2019-12-04 18:39:28 +08:00
arc: {
shape: {
cx: model.pullBackModel.position.x,
cy: model.pullBackModel.position.y,
r: style.Station.lamp.radiusR
},
lineWidth: 0,
fill: style.Station.lamp.controlColor
},
text: {
position: [0, 0],
x: model.pullBackModel.position.x,
y: model.pullBackModel.position.y + style.Station.lamp.radiusR + style.Station.text.distance,
fontWeight: style.Station.text.fontWeight,
fontSize: style.Station.text.fontSize,
fontFamily: style.fontFamily,
text: '按图折返',
textFill: '#fff',
textAlign: 'middle',
textVerticalAlign: 'top'
},
style: this.style
2019-12-04 14:59:04 +08:00
});
this.add(this.turnBack);
}
}
2019-11-29 12:51:58 +08:00
// eslint-disable-next-line no-unused-vars
setState(model) {
}
2019-11-29 12:51:58 +08:00
getShapeTipPoint() {
return null;
}
drawSelected(selected) {
this.highlight && this.highlight.drawSelected(selected);
}
2019-12-04 18:39:28 +08:00
// checkIsDrawMap() {
// const path = window.location.href;
// if (path.includes('/map/draw')) {
// this.highlight = new EHighlight(this);
// this.add(this.highlight);
// this.on('mouseout', () => { this.highlight.mouseout(); });
// this.on('mouseover', () => { this.highlight.mouseover(); });
// }
// }
2019-11-29 12:51:58 +08:00
}