topuFactory.ts 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. /**
  34. * item 创建工厂
  35. *
  36. * @author 韩耀龙 <han_yao_long@163.com>
  37. */
  38. export class topuFactory extends SItemFactory {
  39. /**
  40. * 构造函数
  41. */
  42. constructor() {
  43. super()
  44. }
  45. /**
  46. * 创建基础直线
  47. *
  48. * @param data 数据
  49. * @return 线
  50. */
  51. createBaseLineEdit(data: Marker): SGraphLineItem {
  52. const item = new SGraphLineItem(null,
  53. data.style.Line[0].x,
  54. data.style.Line[0].y,
  55. data.style.Line[1].x,
  56. data.style.Line[1].y,
  57. data.style.default.lineWidth,
  58. data.style.default.strokeColor);
  59. item.data = data;
  60. return item;
  61. }
  62. /**
  63. * 创建基础文本
  64. *
  65. * @param data 数据
  66. * @return 文本
  67. */
  68. createBaseTextEdit(data: Marker): STextItem {
  69. const item = new STextItem(null);
  70. if (data.size) {
  71. item.width = data.size.width;
  72. item.height = data.size.height;
  73. }
  74. item.zOrder = data.style.default.zorder;
  75. item.text = data.style.default.text;
  76. item.strokeColor = new SColor(data.style.default.strokeColor);
  77. item.font = new SFont("sans-serif", data.style.default.font);
  78. item.backgroundColor = new SColor(data.style.default.backgroundColor);
  79. item.data = data;
  80. return item;
  81. }
  82. /**
  83. * 创建基础图片
  84. *
  85. * @param data 数据
  86. * @return 图片
  87. */
  88. createBaseImageEdit(data: Marker): SImageItem {
  89. const item = new SImageItem(null);
  90. item.zOrder = ItemOrder.imageOrder;
  91. item.url = data.style.default.url;
  92. item.name = data.name;
  93. item.lineWidth = data.style.default.lineWidth;
  94. if (data.size) {
  95. item.width = data.size.width;
  96. item.height = data.size.height;
  97. }
  98. item.lineStyle = data.style.default.lineStyle
  99. item.strokeColor = new SColor(data.style.default.strokeColor);
  100. item.data = data;
  101. // item.backgroundColor = new SColor(data.style.default.backgroundColor);
  102. return item
  103. }
  104. /**
  105. * 创建基础矩形
  106. *
  107. * @param data 数据
  108. * @return 矩形
  109. */
  110. createBaseRectEdit(data: Marker) {
  111. // let line = data.style.default.line;
  112. // console.log('SGraphRectItem',line)
  113. // const item = new SGraphRectItem(null, line);
  114. // item.lineStyle = data.style.default.lineStyle;
  115. // item.lineWidth = data.style.default.lineWidth;
  116. // item.fillColor = data.style.default.fillColor;
  117. // item.strokeColor = data.style.default.strokeColor;
  118. // return item;
  119. }
  120. /**
  121. * 创建基础圆
  122. *
  123. * @param data 数据
  124. * @return 圆
  125. */
  126. createBaseCircleEdit(data: Marker): SGraphCircleItem {
  127. const line = data.style.default.line;
  128. const item = new SGraphCircleItem(null, line)
  129. // item.data = data;
  130. item.lineStyle = data.style.default.lineStyle;
  131. item.lineWidth = data.style.default.lineWidth;
  132. item.fillColor = data.style.default.fillColor;
  133. item.strokeColor = data.style.default.strokeColor;
  134. item.data = data;
  135. return item;
  136. }
  137. /**
  138. * 创建基础注释
  139. *
  140. * @param data 数据
  141. * @return 注释
  142. */
  143. createBaseExpainEdit(data: Marker): STextItem {
  144. const item = new STextItem(null);
  145. if (data.size) {
  146. item.width = data.size.width;
  147. item.height = data.size.height;
  148. }
  149. item.zOrder = data.style.default.zorder;
  150. item.text = data.style.default.text;
  151. item.strokeColor = new SColor(data.style.default.strokeColor);
  152. item.font = new SFont("sans-serif", data.style.default.font);
  153. item.backgroundColor = new SColor(data.style.default.backgroundColor);
  154. item.data = data;
  155. return item;
  156. }
  157. /**
  158. * 创建基础多边形
  159. *
  160. * @param data 数据
  161. * @return 注释
  162. */
  163. createBasePolygonEdit(data: Marker): SPolygonItem {
  164. const item = new SPolygonItem(null);
  165. const setPointList = data.style.outLine.map((i: any) => {
  166. return (new SPoint(i.x, i.y))
  167. })
  168. item.setPointList = setPointList;
  169. item.lineStyle = data.style.default.lineStyle;
  170. item.lineWidth = data.style.default.lineWidth;
  171. item.zOrder = data.style.default.zorder;
  172. item.strokeColor = new SColor(data.style.default.strokeColor);
  173. item.fillColor = new SColor(data.style.default.backgroundColor);
  174. item.data = data;
  175. return item;
  176. }
  177. /**
  178. * 创建基础基础箭头(折线)
  179. *
  180. * @param data 数据
  181. * @return 注释
  182. */
  183. createBaseArrow(data: Marker): SArrowItem {
  184. const setPointList = data.style.outLine.map((i: any) => {
  185. return new SPoint(i.x, i.y)
  186. });
  187. let item = new SArrowItem(null, setPointList);
  188. item.strokeColor = new SColor(data.style.default.strokeColor)
  189. item.lineWidth = data.style.default.lineWidth
  190. // 线样式
  191. if (data.style.default.lineStyle) {
  192. item.lineStyle = data.style.default.lineStyle
  193. }
  194. if (data && data.style) {
  195. item.begin = data.style.begin ? data.style.begin : SArrowStyleType.None;
  196. item.end = data.style.end ? data.style.end : SArrowStyleType.None
  197. }
  198. item.data = data;
  199. return item
  200. }
  201. /**
  202. * 创建基础基础箭头(折线)
  203. *
  204. * @param data 数据
  205. * @return 注释
  206. */
  207. createBasePolygonArrowEdit(data: Marker): SArrowPoly {
  208. const item = new SArrowPoly(null);
  209. const setPointList = data.style.line.map((i: any) => {
  210. return new SPoint(i.x, i.y)
  211. });
  212. item.pointList = setPointList;
  213. item.data = data;
  214. return item
  215. }
  216. /*
  217. * 创建基础设备
  218. *
  219. * @param data 数据
  220. * @return 注释
  221. */
  222. createBaseSEquipment(data: Legend): EquipItem {
  223. const item = new EquipItem(null);
  224. item.nodeId = data.nodeId ? data.nodeId : "";
  225. if (data.size) {
  226. item.sWidth = data.size.width;
  227. item.sHeight = data.size.height;
  228. }
  229. // // 存储信息点
  230. if (data.properties && data.properties.infoPointList) {
  231. const infoPointList = data.properties.infoPointList;
  232. if (infoPointList.length) {
  233. item.infoPointList = infoPointList;
  234. item.infoPointList.forEach((obj, i) => {
  235. item.setTextItem(obj, i)
  236. })
  237. } else {
  238. item.infoPointList = []
  239. }
  240. } else {
  241. item.infoPointList = []
  242. }
  243. item.url = data.style.default.base64Url ? data.style.default.base64Url : data.style.default.url
  244. item.x = data.pos.x;
  245. item.y = data.pos.y;
  246. item.selectable = true;
  247. item.zOrder = ItemOrder.imageOrder;
  248. item.data = data;
  249. return item;
  250. }
  251. /*
  252. * 创建基础管道
  253. *
  254. * @param data 数据
  255. * @return 注释
  256. */
  257. createBasePipe(data: Relation): SPolylineItem {
  258. const setPointList = data.pointList.map((i: any) => {
  259. return new SPoint(i.x, i.y)
  260. });
  261. const item = new SPolylineItem(null, setPointList);
  262. item.lineStyle = data.style.default.lineStyle;
  263. item.lineWidth = data.style.default.lineWidth;
  264. // item.zOrder = data.style.default.zorder;
  265. item.strokeColor = new SColor(data.style.default.strokeColor);
  266. item.fillColor = new SColor(data.style.default.backgroundColor);
  267. item.data = data;
  268. return item
  269. }
  270. }