调整:代码修改
This commit is contained in:
parent
94e16353f3
commit
358b3cf6d0
@ -456,7 +456,12 @@ class SkinStyle extends defaultStyle {
|
|||||||
fontFamily: 'consolas', // 默认字体 族类
|
fontFamily: 'consolas', // 默认字体 族类
|
||||||
haveTextHSDA: true, // 是否需创建textHSDA对象
|
haveTextHSDA: true, // 是否需创建textHSDA对象
|
||||||
haveArrowText: true, // 是否需创建arrowText对象
|
haveArrowText: true, // 是否需创建arrowText对象
|
||||||
haveTrainBorder: false// 是否需创建trainBorder对象
|
haveTrainBorder: false, // 是否需创建trainBorder对象
|
||||||
|
aspectRatio: 7/5, // 字体宽高比例(用以拼接text是计算位置)
|
||||||
|
textOffset: 4, // 字体偏移(用以控制字体据车头的距离)
|
||||||
|
trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸
|
||||||
|
useSelfFormat: true, // 使用配置项的nameFormat
|
||||||
|
useSelfText: true // 使用配置项的字体大小
|
||||||
},
|
},
|
||||||
trainStatusStyle: {
|
trainStatusStyle: {
|
||||||
destinationStatus: [
|
destinationStatus: [
|
||||||
|
@ -422,7 +422,12 @@ class SkinStyle extends defaultStyle {
|
|||||||
fontFamily: 'consolas', // 默认字体 族类
|
fontFamily: 'consolas', // 默认字体 族类
|
||||||
haveTextHSDA: true, // 是否需创建textHSDA对象
|
haveTextHSDA: true, // 是否需创建textHSDA对象
|
||||||
haveArrowText: true, // 是否需创建arrowText对象
|
haveArrowText: true, // 是否需创建arrowText对象
|
||||||
haveTrainBorder: false // 是否需创建trainBorder对象
|
haveTrainBorder: false, // 是否需创建trainBorder对象
|
||||||
|
aspectRatio: 7/5, // 字体宽高比例(用以拼接text是计算位置)
|
||||||
|
textOffset: 4, // 字体偏移(用以控制字体据车头的距离)
|
||||||
|
trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸
|
||||||
|
useSelfFormat: true, // 使用配置项的nameFormat
|
||||||
|
useSelfText: true // 使用配置项的字体大小
|
||||||
},
|
},
|
||||||
trainStatusStyle: {
|
trainStatusStyle: {
|
||||||
defaultDestinationColor: '#FFFFFF', // 默认目的地状态显示颜色
|
defaultDestinationColor: '#FFFFFF', // 默认目的地状态显示颜色
|
||||||
|
@ -419,7 +419,12 @@ class SkinStyle extends defaultStyle {
|
|||||||
fontFamily: 'consolas', // 默认字体 族类
|
fontFamily: 'consolas', // 默认字体 族类
|
||||||
haveTextHSDA: true, // 是否需创建textHSDA对象
|
haveTextHSDA: true, // 是否需创建textHSDA对象
|
||||||
haveArrowText: true, // 是否需创建arrowText对象
|
haveArrowText: true, // 是否需创建arrowText对象
|
||||||
haveTrainBorder: false // 是否需创建trainBorder对象
|
haveTrainBorder: false, // 是否需创建trainBorder对象
|
||||||
|
aspectRatio: 7/5, // 字体宽高比例(用以拼接text是计算位置)
|
||||||
|
textOffset: 4, // 字体偏移(用以控制字体据车头的距离)
|
||||||
|
trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸
|
||||||
|
useSelfFormat: true, // 使用配置项的nameFormat
|
||||||
|
useSelfText: true // 使用配置项的字体大小
|
||||||
},
|
},
|
||||||
trainStatusStyle: {
|
trainStatusStyle: {
|
||||||
defaultDestinationColor: '#FFFFFF', // 默认目的地状态显示颜色
|
defaultDestinationColor: '#FFFFFF', // 默认目的地状态显示颜色
|
||||||
|
@ -370,7 +370,10 @@ class SkinStyle extends defaultStyle {
|
|||||||
nameFontSize: 15, // 字体大小
|
nameFontSize: 15, // 字体大小
|
||||||
haveTextHSDA: false, // 是否需创建textHSDA对象
|
haveTextHSDA: false, // 是否需创建textHSDA对象
|
||||||
haveArrowText: true, // 是否需创建arrowText对象
|
haveArrowText: true, // 是否需创建arrowText对象
|
||||||
haveTrainBorder: false// 是否需创建trainBorder对象
|
haveTrainBorder: false, // 是否需创建trainBorder对象
|
||||||
|
aspectRatio: 8/15, // 字体宽高比例(用以拼接text是计算位置)
|
||||||
|
textOffset: 1, // 字体偏移(用以控制字体据车头的距离)
|
||||||
|
trainWidthMoreText: 2 // 计算列车长度时--列车长比text多出尺寸
|
||||||
},
|
},
|
||||||
trainStatusStyle: {
|
trainStatusStyle: {
|
||||||
destinationStatus: [
|
destinationStatus: [
|
||||||
|
@ -11,6 +11,7 @@ export default class TrainBody extends Group {
|
|||||||
super();
|
super();
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.deviceModel = model.model;
|
this.deviceModel = model.model;
|
||||||
|
this.nameFormat = model.nameFormat;
|
||||||
this.create();
|
this.create();
|
||||||
this.createMouse(); // 鼠标事件
|
this.createMouse(); // 鼠标事件
|
||||||
}
|
}
|
||||||
@ -158,7 +159,7 @@ export default class TrainBody extends Group {
|
|||||||
style.Train.trainBody.specialTrainType.some((item) =>{
|
style.Train.trainBody.specialTrainType.some((item) =>{
|
||||||
if (model.type === item.type) {
|
if (model.type === item.type) {
|
||||||
serviceNumber = item.serviceNumber;
|
serviceNumber = item.serviceNumber;
|
||||||
style.Train.trainBody.nameFormat = item.nameFormat;
|
this.nameFormat = item.nameFormat;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -213,20 +214,25 @@ export default class TrainBody extends Group {
|
|||||||
this.trainBodyBox && this.trainBodyBox.setColor(key, color);
|
this.trainBodyBox && this.trainBodyBox.setColor(key, color);
|
||||||
}
|
}
|
||||||
formatChangePosition(model, style) {
|
formatChangePosition(model, style) {
|
||||||
if (style.Train.trainBody.trainNameFormat) {
|
if (this.nameFormat) {
|
||||||
const arr = style.Train.trainBody.trainNameFormat.split(':');
|
const arr = this.nameFormat.split(':');
|
||||||
|
let fontNumber = 0;
|
||||||
arr.forEach(ele => {
|
arr.forEach(ele => {
|
||||||
if (ele == 'targetCode') {
|
if (ele == 'targetCode') {
|
||||||
this.textTrainNumber.setStyle('x', parseInt(model.point.x + style.Train.trainNumber.trainNumberOffset.x));
|
this.textTrainNumber.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset) );
|
||||||
|
fontNumber += (style.Train.trainNumber.targetCodePrefix || '').length;
|
||||||
this.add(this.textTrainNumber);
|
this.add(this.textTrainNumber);
|
||||||
} else if (ele == 'serviceNumber') {
|
} else if (ele == 'serviceNumber') {
|
||||||
this.textTrainServer.setStyle('x', parseInt(model.point.x + style.Train.trainServer.trainServerOffset.x));
|
this.textTrainServer.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset));
|
||||||
|
fontNumber += (style.Train.trainServer.serviceNumberPrefix || '').length;
|
||||||
this.add(this.textTrainServer);
|
this.add(this.textTrainServer);
|
||||||
} else if (ele == 'tripNumber') {
|
} else if (ele == 'tripNumber') {
|
||||||
this.textTrainTarget.setStyle('x', parseInt(model.point.x + style.Train.trainTarget.trainTargetOffset.x));
|
this.textTrainTarget.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset));
|
||||||
|
fontNumber += (style.Train.trainTarget.tripNumberPrefix || '').length;
|
||||||
this.add(this.textTrainTarget);
|
this.add(this.textTrainTarget);
|
||||||
} else if (ele == 'groupNumber') {
|
} else if (ele == 'groupNumber') {
|
||||||
this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + style.Train.textTrainTargetNumber.trainTargetNumberOffset.x));
|
this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset));
|
||||||
|
fontNumber += (style.Train.trainTargetNumber.groupNumberPrefix || '').length;
|
||||||
this.add(this.textTrainTargetNumber);
|
this.add(this.textTrainTargetNumber);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -16,8 +16,9 @@ export default class Train extends Group {
|
|||||||
this.z = 40;
|
this.z = 40;
|
||||||
this.size = 0;
|
this.size = 0;
|
||||||
this.section = null;
|
this.section = null;
|
||||||
this.fontSize = style.Train.common.nameFontSize || style.Train.common.trainTextFontSize;
|
this.fontSize = style.Train.common.useSelfText?style.Train.common.nameFontSize || style.Train.common.trainTextFontSize:model.nameFontSize || style.Train.common.nameFontSize || style.Train.common.trainTextFontSize;
|
||||||
this.newScale = this.fontSize / style.Train.common.trainTextFontSize;
|
this.newScale = this.fontSize / style.Train.common.trainTextFontSize;
|
||||||
|
this.nameFormat = style.Train.common.useSelfFormat?style.Train.trainBody.trainNameFormat:model.nameFormat || style.Train.trainBody.trainNameFormat;
|
||||||
this.create();
|
this.create();
|
||||||
this.setState(model);
|
this.setState(model);
|
||||||
}
|
}
|
||||||
@ -68,6 +69,7 @@ export default class Train extends Group {
|
|||||||
runControlStatus: model.runControlStatus,
|
runControlStatus: model.runControlStatus,
|
||||||
runStatus: model.runStatus,
|
runStatus: model.runStatus,
|
||||||
fontSize: this.fontSize,
|
fontSize: this.fontSize,
|
||||||
|
nameFormat: this.nameFormat,
|
||||||
type: model.type,
|
type: model.type,
|
||||||
speed: model.speed,
|
speed: model.speed,
|
||||||
maLen: model.maLen,
|
maLen: model.maLen,
|
||||||
@ -290,24 +292,24 @@ export default class Train extends Group {
|
|||||||
// 是否根据车身上车组号、服务号、车次号、目的地码显示情况改变列车长度
|
// 是否根据车身上车组号、服务号、车次号、目的地码显示情况改变列车长度
|
||||||
isChangeTrainWidth(model, style) {
|
isChangeTrainWidth(model, style) {
|
||||||
if (!style.Train.trainBody.changeTrainWidth) { return; }
|
if (!style.Train.trainBody.changeTrainWidth) { return; }
|
||||||
if (style.Train.trainBody.trainNameFormat) {
|
if (this.nameFormat) {
|
||||||
const arr = style.Train.trainBody.trainNameFormat.split(':');
|
const arr = this.nameFormat.split(':');
|
||||||
arr.forEach(ele => {
|
arr.forEach(ele => {
|
||||||
switch (ele) {
|
switch (ele) {
|
||||||
case 'targetCode': {
|
case 'targetCode': {
|
||||||
this.size += style.Train.trainNumber.targetCodePrefix.length || 0;
|
this.size += (style.Train.trainNumber.targetCodePrefix || '').length;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'serviceNumber': {
|
case 'serviceNumber': {
|
||||||
this.size += style.Train.trainServer.serviceNumberPrefix.length || 0;
|
this.size += (style.Train.trainServer.serviceNumberPrefix || '').length;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'tripNumber': {
|
case 'tripNumber': {
|
||||||
this.size += style.Train.trainTarget.tripNumberPrefix.length || 0;
|
this.size += (style.Train.trainTarget.tripNumberPrefix || '').length;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'groupNumber': {
|
case 'groupNumber': {
|
||||||
this.size += style.Train.trainTargetNumber.groupNumberPrefix.length || 0;
|
this.size += (style.Train.trainTargetNumber.groupNumberPrefix || '').length;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +317,7 @@ export default class Train extends Group {
|
|||||||
} else {
|
} else {
|
||||||
this.size = 9;
|
this.size = 9;
|
||||||
}
|
}
|
||||||
this.style.Train.common.trainWidth = this.size * this.fontSize * (2 / 3) -16;
|
this.style.Train.common.trainWidth = this.size * this.fontSize * this.style.Train.common.aspectRatio + this.style.Train.common.trainWidthMoreText;
|
||||||
}
|
}
|
||||||
removeTrainDetail() {
|
removeTrainDetail() {
|
||||||
this.trainB && this.trainB.removeTrainDetail();
|
this.trainB && this.trainB.removeTrainDetail();
|
||||||
|
Loading…
Reference in New Issue
Block a user