topuFactory1.ts 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /*
  2. * *********************************************************************************************************************
  3. *
  4. * !!
  5. * .F88X
  6. * X8888Y
  7. * .}888888N;
  8. * i888888N; .:! .I$WI:
  9. * R888888I .'N88~ i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
  10. * .R888888I .;N8888~ .X8' "8I.!,/8" !%NY8`"8I8~~8>,88I
  11. * +888888N; .8888888Y "&&8Y.}8,
  12. * ./888888N; .R888888Y .'}~ .>}'.`+> i}! "i' +/' .'i~ !11,.:">, .~]! .i}i
  13. * ~888888%: .I888888l .]88~`1/iY88Ii+1'.R$8$8]"888888888> Y8$ W8E X8E W8888'188Il}Y88$*
  14. * 18888888 E8888881 .]W%8$`R8X'&8%++N8i,8N%N8+l8%` .}8N:.R$RE%N88N%N$K$R 188,FE$8%~Y88I
  15. * .E888888I .i8888888' .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
  16. * 8888888I .,N888888~ ~88i"8W,!N8*.I88.}888%F,i$88"F88" 888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
  17. * i888888N' I888Y ]88;/EX*IFKFK88X K8R .l8W 88Y ~88}'88E&%8W.X8N``]88!.$8K .:W8I
  18. * .i888888N; I8Y .&8$ .X88! i881.:%888>I88 ;88] +88+.';;;;:.Y88X 18N.,88l .+88/
  19. * .:R888888I
  20. * .&888888I Copyright (c) 2016-2020. 博锐尚格科技股份有限公司
  21. * ~8888'
  22. * .!88~ All rights reserved.
  23. *
  24. * *********************************************************************************************************************
  25. */
  26. import { SColor, SFont, SPoint, SArrowStyleType } from "@persagy-web/draw";
  27. import {
  28. Marker, Legend, Relation
  29. } from "@persagy-web/big";
  30. import { SEquipItem, SArrowItem, SPolygonItem, SArrowPoly, SItemFactory, ItemOrder, SPolylineItem, SIconTextItem } from "@persagy-web/big"
  31. import { SGraphCircleItem, STextItem, SImageItem, SGraphLineItem } from "@persagy-web/graph/lib"
  32. import { EquipItem } from "./equipment"
  33. import { Pipe } from "./pipe"
  34. /**
  35. * item 创建工厂
  36. *
  37. * @author 韩耀龙 <han_yao_long@163.com>
  38. */
  39. export class topuFactory extends SItemFactory {
  40. /**
  41. * 构造函数
  42. */
  43. constructor() {
  44. super()
  45. }
  46. /**
  47. * 创建基础直线
  48. *
  49. * @param data 数据
  50. * @return 线
  51. */
  52. createBaseLineEdit(data: Marker): SGraphLineItem {
  53. const item = new SGraphLineItem(null,
  54. data.style.Line[0].x,
  55. data.style.Line[0].y,
  56. data.style.Line[1].x,
  57. data.style.Line[1].y,
  58. data.style.default.lineWidth,
  59. data.style.default.strokeColor);
  60. item.data = data;
  61. return item;
  62. }
  63. /**
  64. * 创建基础文本
  65. *
  66. * @param data 数据
  67. * @return 文本
  68. */
  69. createBaseTextEdit(data: Marker): STextItem {
  70. const item = new STextItem(null);
  71. if (data.size) {
  72. item.width = data.size.width;
  73. item.height = data.size.height;
  74. }
  75. item.zOrder = data.style.default.zorder;
  76. item.text = data.style.default.text;
  77. item.strokeColor = new SColor(data.style.default.strokeColor);
  78. item.font = new SFont("sans-serif", data.style.default.font);
  79. item.backgroundColor = new SColor(data.style.default.backgroundColor);
  80. item.data = data;
  81. return item;
  82. }
  83. /**
  84. * 创建基础图片
  85. *
  86. * @param data 数据
  87. * @return 图片
  88. */
  89. createBaseImageEdit(data: Marker): SImageItem {
  90. const item = new SImageItem(null);
  91. item.zOrder = ItemOrder.imageOrder;
  92. item.url = data.style.default.url;
  93. item.name = data.name;
  94. item.lineWidth = data.style.default.lineWidth;
  95. if (data.size) {
  96. item.width = data.size.width;
  97. item.height = data.size.height;
  98. }
  99. item.lineStyle = data.style.default.lineStyle
  100. item.strokeColor = new SColor(data.style.default.strokeColor);
  101. item.data = data;
  102. // item.backgroundColor = new SColor(data.style.default.backgroundColor);
  103. return item
  104. }
  105. /**
  106. * 创建基础矩形
  107. *
  108. * @param data 数据
  109. * @return 矩形
  110. */
  111. createBaseRectEdit(data: Marker) {
  112. // let line = data.style.default.line;
  113. // console.log('SGraphRectItem',line)
  114. // const item = new SGraphRectItem(null, line);
  115. // item.lineStyle = data.style.default.lineStyle;
  116. // item.lineWidth = data.style.default.lineWidth;
  117. // item.fillColor = data.style.default.fillColor;
  118. // item.strokeColor = data.style.default.strokeColor;
  119. // return item;
  120. }
  121. /**
  122. * 创建基础圆
  123. *
  124. * @param data 数据
  125. * @return 圆
  126. */
  127. createBaseCircleEdit(data: Marker): SGraphCircleItem {
  128. const line = data.style.default.line;
  129. const item = new SGraphCircleItem(null, line)
  130. // item.data = data;
  131. item.lineStyle = data.style.default.lineStyle;
  132. item.lineWidth = data.style.default.lineWidth;
  133. item.fillColor = data.style.default.fillColor;
  134. item.strokeColor = data.style.default.strokeColor;
  135. item.data = data;
  136. return item;
  137. }
  138. /**
  139. * 创建基础注释
  140. *
  141. * @param data 数据
  142. * @return 注释
  143. */
  144. createBaseExpainEdit(data: Marker): STextItem {
  145. const item = new STextItem(null);
  146. if (data.size) {
  147. item.width = data.size.width;
  148. item.height = data.size.height;
  149. }
  150. item.zOrder = data.style.default.zorder;
  151. item.text = data.style.default.text;
  152. item.strokeColor = new SColor(data.style.default.strokeColor);
  153. item.font = new SFont("sans-serif", data.style.default.font);
  154. item.backgroundColor = new SColor(data.style.default.backgroundColor);
  155. item.data = data;
  156. return item;
  157. }
  158. /**
  159. * 创建基础多边形
  160. *
  161. * @param data 数据
  162. * @return 注释
  163. */
  164. createBasePolygonEdit(data: Marker): SPolygonItem {
  165. const item = new SPolygonItem(null);
  166. const setPointList = data.style.outLine.map((i: any) => {
  167. return (new SPoint(i.x, i.y))
  168. })
  169. item.setPointList = setPointList;
  170. item.lineStyle = data.style.default.lineStyle;
  171. item.lineWidth = data.style.default.lineWidth;
  172. item.zOrder = data.style.default.zorder;
  173. item.strokeColor = new SColor(data.style.default.strokeColor);
  174. item.fillColor = new SColor(data.style.default.backgroundColor);
  175. item.data = data;
  176. return item;
  177. }
  178. /**
  179. * 创建基础基础箭头(折线)
  180. *
  181. * @param data 数据
  182. * @return 注释
  183. */
  184. createBaseArrow(data: Marker): SArrowItem {
  185. const setPointList = data.style.outLine.map((i: any) => {
  186. return new SPoint(i.x, i.y)
  187. });
  188. let item = new SArrowItem(null, setPointList);
  189. item.strokeColor = new SColor(data.style.default.strokeColor)
  190. item.lineWidth = data.style.default.lineWidth
  191. // 线样式
  192. if (data.style.default.lineStyle) {
  193. item.lineStyle = data.style.default.lineStyle
  194. }
  195. if (data && data.style) {
  196. item.begin = data.style.begin ? data.style.begin : SArrowStyleType.None;
  197. item.end = data.style.end ? data.style.end : SArrowStyleType.None
  198. }
  199. item.data = data;
  200. return item
  201. }
  202. /**
  203. * 创建基础基础箭头(折线)
  204. *
  205. * @param data 数据
  206. * @return 注释
  207. */
  208. createBasePolygonArrowEdit(data: Marker): SArrowPoly {
  209. const item = new SArrowPoly(null);
  210. const setPointList = data.style.line.map((i: any) => {
  211. return new SPoint(i.x, i.y)
  212. });
  213. item.pointList = setPointList;
  214. item.data = data;
  215. return item
  216. }
  217. /*
  218. * 创建基础设备
  219. *
  220. * @param data 数据
  221. * @return 注释
  222. */
  223. createBaseSEquipment(data: Legend): EquipItem {
  224. const item = new EquipItem(null);
  225. item.nodeId = data.nodeId ? data.nodeId : "";
  226. if (data.size) {
  227. item.sWidth = data.size.width;
  228. item.sHeight = data.size.height;
  229. }
  230. // // 存储信息点
  231. if (data.properties && data.properties.infoPointList) {
  232. const infoPointList = data.properties.infoPointList;
  233. if (infoPointList.length) {
  234. item.infoPointList = infoPointList;
  235. item.infoPointList.forEach((obj, i) => {
  236. item.setTextItem(obj, i)
  237. })
  238. } else {
  239. item.infoPointList = []
  240. }
  241. } else {
  242. item.infoPointList = []
  243. }
  244. item.url = data.style.default.base64Url ? data.style.default.base64Url : data.style.default.url
  245. item.x = data.pos.x;
  246. item.y = data.pos.y;
  247. item.selectable = true;
  248. item.zOrder = ItemOrder.imageOrder;
  249. item.data = data;
  250. return item;
  251. }
  252. /*
  253. * 创建基础管道
  254. *
  255. * @param data 数据
  256. * @return 注释
  257. */
  258. createBasePipe(data: Relation): Pipe {
  259. const setPointList = data.pointList.map((i: any) => {
  260. return new SPoint(i.x, i.y)
  261. });
  262. const item = new Pipe(null, setPointList);
  263. item.lineStyle = data.style.default.lineStyle;
  264. item.lineWidth = data.style.default.lineWidth;
  265. // item.zOrder = data.style.default.zorder;
  266. item.strokeColor = new SColor(data.style.default.strokeColor);
  267. item.fillColor = new SColor(data.style.default.backgroundColor);
  268. item.data = data;
  269. return item
  270. }
  271. }