|
@@ -0,0 +1,109 @@
|
|
|
+/*
|
|
|
+ * ********************************************************************************************************************
|
|
|
+ *
|
|
|
+ * :*$@@%$*: ;: ;; ;;
|
|
|
+ * :@@%! :!@@%: %! ;%%@@%$ =@@@@@@@%; @%@@@%%%%@@@@@
|
|
|
+ * :@%; :$= %%$$$%$$ ;$$ ;$@= !@$
|
|
|
+ * =@! %! @ $=;% !@@@%: !$$$$$$$$$$$$$$=
|
|
|
+ * =@* %! @ $= % %@= =%@! %=
|
|
|
+ * *$%%! @@= ;=$%%%$*: %! @ $= % =%%%%%%@$ *%: =%
|
|
|
+ * %@@!: !@@@%=$@@@@%! :*@@$: %! @ $= % $* ;@ @* :%*
|
|
|
+ * ;@@! ;!!!;: ;@%: =======@%========* @ $$ % $%*****$@ :@$=*********=@$
|
|
|
+ * $@* ;@@@%=!: *@*
|
|
|
+ * =@$ ;;;!=%@@@@=! =@!
|
|
|
+ * %@$: =@%: :*@@@* %@= Copyright (c) 2016-2019. 北京上格云技术有限公司
|
|
|
+ * ;%@@$=$@@%* *@@@$=%@@%;
|
|
|
+ * ::;:: ::;:: All rights reserved.
|
|
|
+ *
|
|
|
+ * ********************************************************************************************************************
|
|
|
+ */
|
|
|
+
|
|
|
+import { SGraphyView } from "@saga-web/graphy/lib";
|
|
|
+import { SMouseButton, SMouseEvent, SNetUtil } from "@saga-web/base/lib";
|
|
|
+import { SPoint } from "@saga-web/draw/lib";
|
|
|
+
|
|
|
+/**
|
|
|
+ * 拓扑图视图
|
|
|
+ *
|
|
|
+ * @author 郝建龙
|
|
|
+ */
|
|
|
+export class TopoView extends SGraphyView {
|
|
|
+ /** 鼠标左键键按下时位置 */
|
|
|
+ private _leftKeyPos = new SPoint();
|
|
|
+ /** 空格是否被按下 */
|
|
|
+ private spaceKey: boolean = false;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按键按下事件
|
|
|
+ *
|
|
|
+ * @param event 事件参数
|
|
|
+ */
|
|
|
+ protected onKeyDown(event: KeyboardEvent): void {
|
|
|
+ let keyCode = event.keyCode;
|
|
|
+ this.spaceKey = false;
|
|
|
+ switch (keyCode) {
|
|
|
+ case 32:
|
|
|
+ this.spaceKey = true;
|
|
|
+ break;
|
|
|
+ case 87:
|
|
|
+ this.origin.y -= 10;
|
|
|
+ break;
|
|
|
+ case 83:
|
|
|
+ this.origin.y += 10;
|
|
|
+ break;
|
|
|
+ case 68:
|
|
|
+ this.origin.x += 10;
|
|
|
+ break;
|
|
|
+ case 65:
|
|
|
+ this.origin.x -= 10;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ super.onKeyDown(event);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } // Function onKeyDown()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按键松开事件
|
|
|
+ *
|
|
|
+ * @param event 事件参数
|
|
|
+ */
|
|
|
+ protected onKeyUp(event: KeyboardEvent): void {
|
|
|
+ this.spaceKey = false;
|
|
|
+ super.onKeyUp(event);
|
|
|
+ } // Function onKeyUp()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 鼠标按下事件
|
|
|
+ *
|
|
|
+ * @param event 事件参数
|
|
|
+ */
|
|
|
+ protected onMouseDown(event: MouseEvent): void {
|
|
|
+ let se = new SMouseEvent(event);
|
|
|
+ if (se.buttons & SMouseButton.LeftButton) {
|
|
|
+ this._leftKeyPos.x = se.x;
|
|
|
+ this._leftKeyPos.y = se.y;
|
|
|
+ }
|
|
|
+ super.onMouseDown(event);
|
|
|
+ } // Function onMouseDown()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 鼠标移动事件
|
|
|
+ *
|
|
|
+ * @param event 事件参数
|
|
|
+ */
|
|
|
+ protected onMouseMove(event: MouseEvent): void {
|
|
|
+ // 按左键移动
|
|
|
+ let se = new SMouseEvent(event);
|
|
|
+ if (se.buttons & SMouseButton.LeftButton) {
|
|
|
+ if (this.spaceKey) {
|
|
|
+ this.origin.x += se.x - this._leftKeyPos.x;
|
|
|
+ this.origin.y += se.y - this._leftKeyPos.y;
|
|
|
+ }
|
|
|
+ this._leftKeyPos.x = se.x;
|
|
|
+ this._leftKeyPos.y = se.y;
|
|
|
+ this.update();
|
|
|
+ }
|
|
|
+ super.onMouseMove(event);
|
|
|
+ } // Function onMouseMove()
|
|
|
+} // Class TopoView
|