topuFactory.ts 9.6 KB

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