| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import {Point, ViewTool} from './UIUtils';
- /**
- * 容器边界上的参考点
- * @author zhaoyk
- */
- export class ContainerRefPoint {
-
- static TL = "TL";
- static TR = "TR";
- static BR = "BR";
- static BL = "BL";
-
- containerId: string;
- name: string;
- location: Point;
-
- constructor(containerId:string, name:string){
- this.containerId = containerId;
- this.name = name;
- }
-
- static getRefPoints(containerId:string, conLocation: Point, conSize: Point): Array<ContainerRefPoint> {
- const points = new Array<ContainerRefPoint>();
- ContainerRefPoint.addPoint(containerId, ContainerRefPoint.TL, new Point(conLocation.x, conLocation.y), points);
- ContainerRefPoint.addPoint(containerId, ContainerRefPoint.TR, new Point(conLocation.x + conSize.x, conLocation.y), points);
- ContainerRefPoint.addPoint(containerId, ContainerRefPoint.BR, new Point(conLocation.x + conSize.x, conLocation.y + conSize.y), points);
- ContainerRefPoint.addPoint(containerId, ContainerRefPoint.BL, new Point(conLocation.x, conLocation.y + conSize.y), points);
- var len = conSize.x / 4;
- for (var i = 1; i <= 3; i++) {
- ContainerRefPoint.addPoint(containerId, "T" + i, new Point(conLocation.x + len * i, conLocation.y), points);
- ContainerRefPoint.addPoint(containerId, "B" + i, new Point(conLocation.x + len * i, conLocation.y + conSize.y), points);
- }
- len = conSize.y / 4;
- for (var i = 1; i <= 3; i++) {
- ContainerRefPoint.addPoint(containerId, "L" + i, new Point(conLocation.x, conLocation.y + len * i), points);
- ContainerRefPoint.addPoint(containerId, "R" + i, new Point(conLocation.x + conSize.x, conLocation.y + len * i), points);
- }
- return points;
- }
- static addPoint(containerId: string, name: string, location: Point, points: Array<ContainerRefPoint>): void{
- const refPoint = new ContainerRefPoint(containerId, name);
- refPoint.location = location;
- points.push(refPoint);
- }
- static getRefPoint(containerId:string, conLocation: Point, conSize: Point, refName: string) : ContainerRefPoint{
- const list = ContainerRefPoint.getRefPoints(containerId, conLocation, conSize);
- for(const p of list) {
- if(p.name.toLowerCase() == refName.toLowerCase())
- return p;
- }
- return null;
- }
-
- }
|