|
|
import { getShapeStyleFuction, getTextStyleFunction } from './getShapeStyleUtil.js'
const { PureCurvedPolylineEdge, PureCurvedPolylineEdgeModel } = window
// 折线
class PureCurvedConnection extends PureCurvedPolylineEdge { constructor() { super() this.textRef = null }
getText() { return null }
getEndArrow() { const h = window.h const { model, graphModel } = this.props const { id, properties: { arrowType, borderColor }, } = model const { stroke, strokeWidth } = model.getArrowStyle() const pathAttr = { stroke, strokeWidth, } if (arrowType === 'empty') { // 空心箭头
return h('path', { ...pathAttr, fill: '#FFF', d: 'M 0 0 -10 -5 -10 5 z', }) } else if (arrowType === 'half') { // 半箭头
return h('path', { ...pathAttr, d: 'M 0 0 -10 5', }) } else if (arrowType === 'none') { // 无箭头
return h('path', { ...pathAttr, d: '', }) } return h('path', { ...pathAttr, fill: borderColor, d: 'M 0 0 -10 -5 -10 5 z', }) }}class PureCurvedModel extends PureCurvedPolylineEdgeModel { constructor(data, graphModel) { super(data, graphModel) this.strokeWidth = 1 this.isShowAdjustPoint = false this.modelType = 'pure-curved-polyline-edge' this.isCurved = false }
getEdgeAnimationStyle() { const animation = super.getEdgeAnimationStyle() const { borderColor, strokeDashWidth, strokeDashWidth2, strokeDashSpace, animationName, animationDuration, animationReverse } = this.properties animation.stroke = borderColor animation.strokeDashoffset = '' animation.strokeDasharray = `${strokeDashWidth},${strokeDashSpace},${strokeDashWidth2}` animation.animationName = animationName || 'lf_animate_dash' animation.animationDuration = animationDuration || '20s' animation.animationDirection = animationReverse ? 'reverse' : '' return animation }
setAttributes() { const { defaultValue, min, max } = this.properties if (defaultValue) { const realValue = window.resolveScadaNewValue(defaultValue) const realMin = min < max ? min : max const realMax = max > min ? max : min if (realValue >= realMin && realValue <= realMax) this.isAnimation = true
else this.isAnimation = false } else { this.isAnimation = this.properties.isAnimation || false } }
getTextStyle() { const style = super.getTextStyle() return getTextStyleFunction(style, this.properties) }
getEdgeStyle() { const attributes = super.getEdgeStyle() const properties = this.properties const style = getShapeStyleFuction(attributes, properties) return { ...style, fill: 'none', class: properties.isCustomHelperLine ? 'customHelperLine' : '' } }}export default { type: 'pure-curved-polyline', view: PureCurvedConnection, model: PureCurvedModel,}
|