123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- /*
- * *********************************************************************************************************************
- *
- * !!
- * .F88X
- * X8888Y
- * .}888888N;
- * i888888N; .:! .I$WI:
- * R888888I .'N88~ i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
- * .R888888I .;N8888~ .X8' "8I.!,/8" !%NY8`"8I8~~8>,88I
- * +888888N; .8888888Y "&&8Y.}8,
- * ./888888N; .R888888Y .'}~ .>}'.`+> i}! "i' +/' .'i~ !11,.:">, .~]! .i}i
- * ~888888%: .I888888l .]88~`1/iY88Ii+1'.R$8$8]"888888888> Y8$ W8E X8E W8888'188Il}Y88$*
- * 18888888 E8888881 .]W%8$`R8X'&8%++N8i,8N%N8+l8%` .}8N:.R$RE%N88N%N$K$R 188,FE$8%~Y88I
- * .E888888I .i8888888' .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
- * 8888888I .,N888888~ ~88i"8W,!N8*.I88.}888%F,i$88"F88" 888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
- * i888888N' I888Y ]88;/EX*IFKFK88X K8R .l8W 88Y ~88}'88E&%8W.X8N``]88!.$8K .:W8I
- * .i888888N; I8Y .&8$ .X88! i881.:%888>I88 ;88] +88+.';;;;:.Y88X 18N.,88l .+88/
- * .:R888888I
- * .&888888I Copyright (c) 2016-2020. 博锐尚格科技股份有限公司
- * ~8888'
- * .!88~ All rights reserved.
- *
- * *********************************************************************************************************************
- */
- import { SColor, SFont, SPoint, SArrowStyleType } from "@persagy-web/draw";
- import {
- Marker, Legend, Relation
- } from "@persagy-web/big";
- import { SEquipItem, SArrowItem, SPolygonItem, SArrowPoly, SItemFactory, ItemOrder, SPolylineItem, SIconTextItem } from "@persagy-web/big"
- import { SGraphCircleItem, STextItem, SImageItem, SGraphLineItem } from "@persagy-web/graph/lib"
- /**
- * item 创建工厂
- *
- * @author 韩耀龙 <han_yao_long@163.com>
- */
- export class topuFactory extends SItemFactory {
- /**
- * 构造函数
- */
- constructor() {
- super()
- }
- /**
- * 创建基础直线
- *
- * @param data 数据
- * @return 线
- */
- createBaseLineEdit(data: Marker): SGraphLineItem {
- const item = new SGraphLineItem(null,
- data.style.Line[0].x,
- data.style.Line[0].y,
- data.style.Line[1].x,
- data.style.Line[1].y,
- data.style.default.lineWidth,
- data.style.default.strokeColor);
- item.data = data;
- return item;
- }
- /**
- * 创建基础文本
- *
- * @param data 数据
- * @return 文本
- */
- createBaseTextEdit(data: Marker): STextItem {
- const item = new STextItem(null);
- if (data.size) {
- item.width = data.size.width;
- item.height = data.size.height;
- }
- item.zOrder = data.style.default.zorder;
- item.text = data.style.default.text;
- item.strokeColor = new SColor(data.style.default.strokeColor);
- item.font = new SFont("sans-serif", data.style.default.font);
- item.backgroundColor = new SColor(data.style.default.backgroundColor);
- item.data = data;
- return item;
- }
- /**
- * 创建基础图片
- *
- * @param data 数据
- * @return 图片
- */
- createBaseImageEdit(data: Marker): SImageItem {
- const item = new SImageItem(null);
- item.zOrder = ItemOrder.imageOrder;
- item.url = data.style.default.url;
- item.name = data.name;
- item.lineWidth = data.style.default.lineWidth;
- if (data.size) {
- item.width = data.size.width;
- item.height = data.size.height;
- }
- item.lineStyle = data.style.default.lineStyle
- item.strokeColor = new SColor(data.style.default.strokeColor);
- item.data = data;
- // item.backgroundColor = new SColor(data.style.default.backgroundColor);
- return item
- }
- /**
- * 创建基础矩形
- *
- * @param data 数据
- * @return 矩形
- */
- createBaseRectEdit(data: Marker) {
- // let line = data.style.default.line;
- // console.log('SGraphRectItem',line)
- // const item = new SGraphRectItem(null, line);
- // item.lineStyle = data.style.default.lineStyle;
- // item.lineWidth = data.style.default.lineWidth;
- // item.fillColor = data.style.default.fillColor;
- // item.strokeColor = data.style.default.strokeColor;
- // return item;
- }
- /**
- * 创建基础圆
- *
- * @param data 数据
- * @return 圆
- */
- createBaseCircleEdit(data: Marker): SGraphCircleItem {
- const line = data.style.default.line;
- const item = new SGraphCircleItem(null, line)
- // item.data = data;
- item.lineStyle = data.style.default.lineStyle;
- item.lineWidth = data.style.default.lineWidth;
- item.fillColor = data.style.default.fillColor;
- item.strokeColor = data.style.default.strokeColor;
- item.data = data;
- return item;
- }
- /**
- * 创建基础注释
- *
- * @param data 数据
- * @return 注释
- */
- createBaseExpainEdit(data: Marker): STextItem {
- const item = new STextItem(null);
- if (data.size) {
- item.width = data.size.width;
- item.height = data.size.height;
- }
- item.zOrder = data.style.default.zorder;
- item.text = data.style.default.text;
- item.strokeColor = new SColor(data.style.default.strokeColor);
- item.font = new SFont("sans-serif", data.style.default.font);
- item.backgroundColor = new SColor(data.style.default.backgroundColor);
- item.data = data;
- return item;
- }
- /**
- * 创建基础多边形
- *
- * @param data 数据
- * @return 注释
- */
- createBasePolygonEdit(data: Marker): SPolygonItem {
- const item = new SPolygonItem(null);
- const setPointList = data.style.outLine.map((i: any) => {
- return (new SPoint(i.x, i.y))
- })
- item.setPointList = setPointList;
- item.lineStyle = data.style.default.lineStyle;
- item.lineWidth = data.style.default.lineWidth;
- item.zOrder = data.style.default.zorder;
- item.strokeColor = new SColor(data.style.default.strokeColor);
- item.fillColor = new SColor(data.style.default.backgroundColor);
- item.data = data;
- return item;
- }
- /**
- * 创建基础基础箭头(折线)
- *
- * @param data 数据
- * @return 注释
- */
- createBaseArrow(data: Marker): SArrowItem {
- const setPointList = data.style.outLine.map((i: any) => {
- return new SPoint(i.x, i.y)
- });
- let item = new SArrowItem(null, setPointList);
- item.strokeColor = new SColor(data.style.default.strokeColor)
- item.lineWidth = data.style.default.lineWidth
- // 线样式
- if (data.style.default.lineStyle) {
- item.lineStyle = data.style.default.lineStyle
- }
- if (data && data.style) {
- item.begin = data.style.begin ? data.style.begin : SArrowStyleType.None;
- item.end = data.style.end ? data.style.end : SArrowStyleType.None
- }
- item.data = data;
- return item
- }
- /**
- * 创建基础基础箭头(折线)
- *
- * @param data 数据
- * @return 注释
- */
- createBasePolygonArrowEdit(data: Marker): SArrowPoly {
- const item = new SArrowPoly(null);
- const setPointList = data.style.line.map((i: any) => {
- return new SPoint(i.x, i.y)
- });
- item.pointList = setPointList;
- item.data = data;
- return item
- }
- /*
- * 创建基础设备
- *
- * @param data 数据
- * @return 注释
- */
- createBaseSEquipment(data: Legend): SEquipItem {
- const item = new SEquipItem(null);
- item.nodeId = data.nodeId ? data.nodeId : "";
- if (data.size) {
- item.sWidth = data.size.width;
- item.sHeight = data.size.height;
- }
- // // 存储信息点
- if (data.properties && data.properties.infoPointList) {
- const infoPointList = data.properties.infoPointList;
- if (infoPointList.length) {
- item.infoPointList = infoPointList;
- item.infoPointList.forEach((obj, i) => {
- item.setTextItem(obj, i)
- })
- } else {
- item.infoPointList = []
- }
- } else {
- item.infoPointList = []
- }
- item.url = data.style.default.base64Url ? data.style.default.base64Url : data.style.default.url
- item.x = data.pos.x;
- item.y = data.pos.y;
- item.selectable = true;
- item.zOrder = ItemOrder.imageOrder;
- item.data = data;
- return item;
- }
- /*
- * 创建基础管道
- *
- * @param data 数据
- * @return 注释
- */
- createBasePipe(data: Relation): SPolylineItem {
- const setPointList = data.pointList.map((i: any) => {
- return new SPoint(i.x, i.y)
- });
- const item = new SPolylineItem(null, setPointList);
- item.lineStyle = data.style.default.lineStyle;
- item.lineWidth = data.style.default.lineWidth;
- // item.zOrder = data.style.default.zorder;
- item.strokeColor = new SColor(data.style.default.strokeColor);
- item.fillColor = new SColor(data.style.default.backgroundColor);
- item.data = data;
- return item
- }
- }
|