增加文件

This commit is contained in:
ival 2019-07-22 13:40:15 +08:00
parent 3dd126da3a
commit fdc15d109e
2 changed files with 169 additions and 0 deletions

View File

@ -0,0 +1,78 @@
import Group from 'zrender/src/container/Group';
import Line from 'zrender/src/graphic/shape/Line';
class ESwCore extends Group {
constructor(model) {
super();
this.model = model;
this._create();
}
_create() {
const model = this.model;
const style = this.model.style;
this.line = new Line({
zlevel: model.zlevel,
z: model.z,
silent: true,
shape: {
x1: model.intersectionX - model.coverLength,
y1: model.intersectionY,
x2: model.intersectionX + model.coverLength,
y2: model.intersectionY
},
style: {
lineWidth: model.switchWidth,
stroke: style.backgroundColor
}
});
this.skewLine = new Line({
zlevel: model.zlevel,
z: model.z,
silent: true,
shape: {
x1: model.intersectionX,
y1: model.intersectionY,
x2: model.intersectionX + model.triangle.drictx * model.triangle.getCotRate() * model.coverLength,
y2: model.intersectiony + model.triangle.dricty * model.coverLength
},
style: {
lineWidth: model.switchWidth,
stroke: style.backgroundColor
}
});
this.add(this.line);
this.add(this.skewLine);
}
hide() {
this.line.hide();
this.skewLine.hide();
}
show() {
this.line.show();
this.skewLine.show();
}
setColor(color) {
this.line.setStyle('stroke', color);
this.skewLine.setStyle('stroke', color);
}
stopAnimation(flag) {
this.line.stopAnimation(flag);
this.skewLine.stopAnimation(flag);
}
animateStyle(cb) {
this.eachChild((child) => {
cb(child);
});
}
}
export default ESwCore;

View File

@ -0,0 +1,91 @@
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
import Rect from 'zrender/src/graphic/shape/Rect';
class ESwName extends Group {
constructor(model) {
super();
this.model = model;
this._create();
}
_create() {
const model = this.model;
const style = this.model.style;
this.nameText = new Text({
zlevel: model.zlevel,
z: model.z + 3,
style: {
x: model.nameTextX,
y: model.nameTextY,
text: model.name,
textAlign: model.triangle.drictx === 1 ? 'left' : 'right',
textVerticalAlign: model.triangle.dricty === 1 ? 'top' : 'bottom',
textFont: style.textFontSize + 'px ' + style.textFontFormat,
textFill: style.Switch.switchTextLossColor
}
});
const rect = this.nameText.getBoundingRect();
let textWidth = rect.width * 0.8;
if (model.triangle.drictx !== 1) {
rect.x += rect.width;
textWidth = -textWidth;
}
this.textRect = new Rect({
zlevel: model.zlevel,
z: model.z + 2,
silent: true,
shape: {
x: rect.x,
y: rect.y,
width: textWidth,
height: rect.height
},
style: {
lineWidth: 0,
lineDash: [3, 3],
stroke: style.Switch.switchTextBorderColor,
fill: style.transparentColor
}
});
this.arrowText = new Text({
zlevel: model.zlevel,
z: model.z,
style: {
x: model.arrowTextX,
y: model.arrowTextY,
text: `道岔区段名称: ${model.sectionName}`,
textFill: '#000',
textAlign: 'letf',
textFont: 10 + 'px consolas',
textPadding: 3,
textBackgroundColor: style.tipBackgroundColor
}
});
this.add(this.textRect);
this.add(this.nameText);
this.add(this.arrowText);
this.arrowText.hide();
model.nameShow ? this.nameText.show() : this.nameText.hide();
}
getArrowText() {
return this.arrowText;
}
getNameText() {
return this.nameText;
}
getTextRect() {
return this.textRect;
}
}
export default ESwName;