1223
This commit is contained in:
parent
0ea864e96d
commit
175417026c
1153
src/jmap/shape/Section.js
Normal file
1153
src/jmap/shape/Section.js
Normal file
File diff suppressed because it is too large
Load Diff
79
src/jmap/shape/Station.js
Normal file
79
src/jmap/shape/Station.js
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 车站
|
||||
*/
|
||||
import Group from 'zrender/src/container/Group';
|
||||
import Text from 'zrender/src/graphic/Text';
|
||||
|
||||
export default class Station extends Group {
|
||||
constructor({ _code, _type, zlevel, model, state }, style) {
|
||||
super({name: _code});
|
||||
this.z = 40;
|
||||
this._code = _code;
|
||||
this._type = _type;
|
||||
this.zlevel = zlevel;
|
||||
this.model = model;
|
||||
this.state = state;
|
||||
this.style = style;
|
||||
this._create();
|
||||
}
|
||||
|
||||
_create() {
|
||||
const model = this.model;
|
||||
const style = this.style;
|
||||
const state = this.state;
|
||||
|
||||
if (model.visible) {
|
||||
this.stationText = new Text({
|
||||
zlevel: this.zlevel,
|
||||
z: this.z,
|
||||
position: [0, 0],
|
||||
style: {
|
||||
x: model.position.x,
|
||||
y: model.position.y,
|
||||
text: model.name,
|
||||
textAlign: 'middle',
|
||||
textVerticalAlign: 'top',
|
||||
textFont: model.nameFont || '18px ' + style.textFontFormat,
|
||||
textFill: model.nameFontColor
|
||||
}
|
||||
});
|
||||
|
||||
this.mileageText = new Text({
|
||||
zlevel: this.zlevel,
|
||||
z: this.z,
|
||||
position: [0, 0],
|
||||
style: {
|
||||
x: model.position.x,
|
||||
y: model.position.y + parseInt(model.nameFont) + 2,
|
||||
text: model.kmPost,
|
||||
textAlign: 'middle',
|
||||
textVerticalAlign: 'top',
|
||||
textFont: model.kmPostFont || '12px ' + style.textFontFormat,
|
||||
textFill: model.kmPostFontColor
|
||||
}
|
||||
});
|
||||
|
||||
this.add(this.stationText);
|
||||
this.add(this.mileageText);
|
||||
this.setShowMileageText(model.kmPostShow);
|
||||
this.setState(state);
|
||||
}
|
||||
}
|
||||
|
||||
/** 设置公里标是否显示*/
|
||||
setShowMileageText(show) {
|
||||
if (show) {
|
||||
this.mileageText.show();
|
||||
} else {
|
||||
this.mileageText.hide();
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setState(state) {
|
||||
}
|
||||
|
||||
getShapeTipPoint() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,156 +0,0 @@
|
||||
/*
|
||||
* lC区域控制模式
|
||||
*/
|
||||
import Arc from 'zrender/src/graphic/shape/Arc';
|
||||
import Rect from 'zrender/src/graphic/shape/Rect';
|
||||
import Text from 'zrender/src/graphic/Text';
|
||||
import Group from 'zrender/src/container/Group';
|
||||
|
||||
export default class LcControl extends Group {
|
||||
constructor({ _code, _type, zlevel, model, state }, style) {
|
||||
super({name: _code});
|
||||
this.z = 20;
|
||||
this._code = _code;
|
||||
this._type = _type;
|
||||
this.zlevel = zlevel;
|
||||
this.model = model;
|
||||
this.state = state;
|
||||
this.style = style;
|
||||
this._create();
|
||||
|
||||
this.on('mouseout', this.mouseleave);
|
||||
this.on('mouseover', this.mouseenter);
|
||||
}
|
||||
|
||||
_create() {
|
||||
const model = this.model;
|
||||
const state = this.state;
|
||||
this.control = new Arc({
|
||||
_subType: 'Control',
|
||||
zlevel: this.zlevel,
|
||||
z: this.z,
|
||||
shape: {
|
||||
cx: model.position.x,
|
||||
cy: model.position.y,
|
||||
r: this.style.zcControlmodeR
|
||||
},
|
||||
style: {
|
||||
lineWidth: 0,
|
||||
fill: ''
|
||||
}
|
||||
});
|
||||
|
||||
this.text = new Text({
|
||||
_subType: 'Text',
|
||||
zlevel: this.zlevel,
|
||||
z: this.z,
|
||||
position: [0, 0],
|
||||
style: {
|
||||
x: model.position.x,
|
||||
y: model.position.y + this.style.zcControlmodeR + this.style.nameDistance,
|
||||
text: model.name,
|
||||
textFill: '',
|
||||
textAlign: 'middle',
|
||||
textVerticalAlign: 'top',
|
||||
textFont: this.style.stationControlTextSize + 'px ' + this.style.textFontFormat
|
||||
}
|
||||
});
|
||||
|
||||
this.textShadow = new Text({
|
||||
zlevel: this.zlevel,
|
||||
z: this.z + 1,
|
||||
position: [4, -2],
|
||||
silent: true,
|
||||
style: {
|
||||
x: model.position.x,
|
||||
y: model.position.y + this.style.zcControlmodeR + this.style.nameDistance,
|
||||
text: model.name,
|
||||
textFill: this.style.textShadowColor, // 黄色
|
||||
textAlign: 'middle',
|
||||
textVerticalAlign: 'top',
|
||||
textFont: 'bold ' + (this.style.stationControlTextSize + 1) + 'px ' + this.style.textFontFormat
|
||||
}
|
||||
});
|
||||
this.controlBorder = new Rect({
|
||||
zlevel: model.zlevel,
|
||||
z: this.z - 1,
|
||||
silent: true,
|
||||
shape: this.control.getBoundingRect(),
|
||||
style: {
|
||||
lineDash: [3, 3],
|
||||
stroke: this.style.borderColor,
|
||||
fill: this.style.transparentColor
|
||||
}
|
||||
});
|
||||
|
||||
this.textBorder = new Rect({
|
||||
zlevel: model.zlevel,
|
||||
z: this.z - 1,
|
||||
silent: true,
|
||||
shape: this.text.getBoundingRect(),
|
||||
style: {
|
||||
lineDash: [3, 3],
|
||||
stroke: this.style.borderColor,
|
||||
fill: this.style.borderContextBackgroundColor
|
||||
}
|
||||
});
|
||||
|
||||
this.add(this.control);
|
||||
this.add(this.text);
|
||||
this.add(this.textShadow);
|
||||
this.add(this.textBorder);
|
||||
this.add(this.controlBorder);
|
||||
this.setState(state);
|
||||
this.mouseStateRecover();
|
||||
}
|
||||
|
||||
// 设置状态
|
||||
setState(state) {}
|
||||
|
||||
getShapeTipPoint() {
|
||||
if (this.control) {
|
||||
var distance = 2;
|
||||
var rect = this.control.getBoundingRect();
|
||||
return {
|
||||
x: rect.x + rect.width / 2,
|
||||
y: rect.y - distance
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
mouseStateVisible(subType) {
|
||||
if (subType == 'Text') {
|
||||
this.textShadow.show();
|
||||
}
|
||||
|
||||
if (subType == 'Control') {
|
||||
this.textBorder.show();
|
||||
this.controlBorder.show();
|
||||
this.text.setStyle({ textFill: '#000' });
|
||||
this.control.setStyle({ fill: this.style.borderContextBackgroundColor });
|
||||
}
|
||||
}
|
||||
|
||||
mouseStateRecover() {
|
||||
this.textShadow.hide();
|
||||
this.textBorder.hide();
|
||||
this.controlBorder.hide();
|
||||
this.text.setStyle({ textFill: '#fff' });
|
||||
this.control.setStyle({ fill: this.style.lcControlColor });
|
||||
this.setState(this.state);
|
||||
}
|
||||
|
||||
mouseenter(e) {
|
||||
if (e.target._subType) {
|
||||
this.mouseStateRecover();
|
||||
this.mouseStateVisible(e.target._subType);
|
||||
}
|
||||
}
|
||||
|
||||
mouseleave(e) {
|
||||
if (e.target._subType) {
|
||||
this.mouseStateRecover();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,171 +0,0 @@
|
||||
/*
|
||||
* 权限临时限速
|
||||
*/
|
||||
import Arc from 'zrender/src/graphic/shape/Arc';
|
||||
import Rect from 'zrender/src/graphic/shape/Rect';
|
||||
import Text from 'zrender/src/graphic/Text';
|
||||
import Group from 'zrender/src/container/Group';
|
||||
|
||||
export default class LimitControl extends Group {
|
||||
constructor({ _code, _type, zlevel, model, state }, style) {
|
||||
super({name: _code});
|
||||
this.selected = false;
|
||||
this._code = _code;
|
||||
this._type = _type;
|
||||
this.model = model;
|
||||
this.state = state;
|
||||
this.style = style;
|
||||
this.zlevel = zlevel;
|
||||
this.z = 20;
|
||||
this._create(model);
|
||||
|
||||
this.on('mousedown', this.mouseclick);
|
||||
this.on('mouseout', this.mouseleave);
|
||||
this.on('mouseover', this.mouseenter);
|
||||
}
|
||||
|
||||
_create(model) {
|
||||
this.control = new Arc({
|
||||
_subType: 'Control',
|
||||
zlevel: this.zlevel,
|
||||
z: this.z,
|
||||
shape: {
|
||||
cx: model.position.x,
|
||||
cy: model.position.y,
|
||||
r: this.style.zcControlmodeR
|
||||
},
|
||||
style: {
|
||||
lineWidth: 0,
|
||||
fill: ''
|
||||
}
|
||||
});
|
||||
|
||||
this.text = new Text({
|
||||
_subType: 'Text',
|
||||
zlevel: this.zlevel,
|
||||
z: this.z,
|
||||
position: [0, 0],
|
||||
style: {
|
||||
x: model.position.x,
|
||||
y: model.position.y + this.style.zcControlmodeR + this.style.nameDistance,
|
||||
text: model.name,
|
||||
textFill: '',
|
||||
textAlign: 'middle',
|
||||
textVerticalAlign: 'top',
|
||||
textFont: this.style.stationControlTextSize + 'px ' + this.style.textFontFormat
|
||||
}
|
||||
});
|
||||
|
||||
this.textShadow = new Text({
|
||||
zlevel: this.zlevel,
|
||||
z: this.z + 1,
|
||||
position: [4, -4],
|
||||
silent: true,
|
||||
style: {
|
||||
x: model.position.x,
|
||||
y: model.position.y + this.style.zcControlmodeR + this.style.nameDistance,
|
||||
text: model.name,
|
||||
textFill: this.style.textShadowColor, // 黄色
|
||||
textAlign: 'middle',
|
||||
textVerticalAlign: 'top',
|
||||
textFont: 'bold ' + (this.style.stationControlTextSize + 1) + 'px ' + this.style.textFontFormat
|
||||
}
|
||||
});
|
||||
|
||||
this.controlBorder = new Rect({
|
||||
zlevel: model.zlevel,
|
||||
z: this.z - 1,
|
||||
silent: true,
|
||||
shape: this.control.getBoundingRect(),
|
||||
style: {
|
||||
lineDash: [3, 3],
|
||||
stroke: this.style.borderColor,
|
||||
fill: this.style.transparentColor
|
||||
}
|
||||
});
|
||||
|
||||
this.textBorder = new Rect({
|
||||
zlevel: model.zlevel,
|
||||
z: this.z - 1,
|
||||
silent: true,
|
||||
shape: this.text.getBoundingRect(),
|
||||
style: {
|
||||
lineDash: [3, 3],
|
||||
stroke: this.style.borderColor,
|
||||
fill: this.style.borderContextBackgroundColor
|
||||
}
|
||||
});
|
||||
|
||||
this.add(this.control);
|
||||
this.add(this.text);
|
||||
this.add(this.textShadow);
|
||||
this.add(this.textBorder);
|
||||
this.add(this.controlBorder);
|
||||
this.setState(this.state);
|
||||
this.mouseStateRecover();
|
||||
}
|
||||
|
||||
// 设置状态
|
||||
setState(state) {
|
||||
}
|
||||
|
||||
getShapeTipPoint() {
|
||||
if (this.control) {
|
||||
var distance = 2;
|
||||
var rect = this.control.getBoundingRect();
|
||||
return {
|
||||
x: rect.x + rect.width / 2,
|
||||
y: rect.y - distance
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
mouseStateVisible(subType) {
|
||||
if (subType == 'Text') {
|
||||
this.textShadow.show();
|
||||
}
|
||||
|
||||
if (subType == 'Control') {
|
||||
this.textBorder.show();
|
||||
this.controlBorder.show();
|
||||
this.text.setStyle({ textFill: '#000' });
|
||||
this.control.setStyle({ fill: this.style.borderContextBackgroundColor });
|
||||
}
|
||||
}
|
||||
|
||||
mouseStateRecover() {
|
||||
this.textShadow.hide();
|
||||
this.textBorder.hide();
|
||||
this.controlBorder.hide();
|
||||
this.text.setStyle({ textFill: '#fff' });
|
||||
this.control.setStyle({ fill: this.style.limitControlColor });
|
||||
this.setState(this.state);
|
||||
}
|
||||
|
||||
mouseclick(e) {
|
||||
if ([3].includes(e.which)) {
|
||||
this.selected = !this.selected;
|
||||
if (this.selected) {
|
||||
// this.mouseStateRecover();
|
||||
this.mouseStateVisible('Control');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mouseenter(e) {
|
||||
if (!this.selected && e.target._subType) {
|
||||
// this.mouseStateRecover();
|
||||
this.mouseStateVisible(e.target._subType);
|
||||
}
|
||||
}
|
||||
|
||||
mouseleave(e) {
|
||||
if (e.target && e.target._subType) {
|
||||
if (!this.selected && e.target._subType) {
|
||||
this.mouseStateRecover();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user