|
|
|
@ -10,6 +10,14 @@ export class AxLegend extends AxShape {
|
|
|
|
|
// 数据
|
|
|
|
|
public shapeMap: Map<string,Legend> = new Map<string,Legend>(); |
|
|
|
|
pen: Graphics = new Graphics(); |
|
|
|
|
// up: Sprite = new Sprite(this.pointTexture);
|
|
|
|
|
// down: Sprite= new Sprite(this.pointTexture);
|
|
|
|
|
// left: Sprite= new Sprite(this.pointTexture);
|
|
|
|
|
// right: Sprite= new Sprite(this.pointTexture);
|
|
|
|
|
upLeft: Sprite= new Sprite(this.pointTexture); |
|
|
|
|
upRight: Sprite= new Sprite(this.pointTexture); |
|
|
|
|
downLeft: Sprite= new Sprite(this.pointTexture); |
|
|
|
|
downRight: Sprite= new Sprite(this.pointTexture); |
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
@ -102,6 +110,120 @@ export class AxLegend extends AxShape {
|
|
|
|
|
}
|
|
|
|
|
this.addChild(this.pen); |
|
|
|
|
this.angle = -this.workingArea.backgroundImage.angle; |
|
|
|
|
// 添加border
|
|
|
|
|
this.addChild(this.border); |
|
|
|
|
// 添加控制点
|
|
|
|
|
this.addChild(this.upLeft); |
|
|
|
|
this.upLeft.anchor.set(0.5); |
|
|
|
|
this.upLeft.interactive = true; |
|
|
|
|
this.upLeft.visible = false; |
|
|
|
|
var posX = 0; |
|
|
|
|
var w = this.width; |
|
|
|
|
this.upLeft |
|
|
|
|
.on('pointerdown', event => { |
|
|
|
|
event.stopPropagation(); |
|
|
|
|
event.currentTarget.data = event.data; |
|
|
|
|
event.currentTarget.alpha = 0.5; |
|
|
|
|
event.currentTarget.dragging = true; |
|
|
|
|
|
|
|
|
|
event.currentTarget.dragPoint = event.data.getLocalPosition(event.currentTarget.parent); |
|
|
|
|
|
|
|
|
|
var gPos = this.upLeft.getGlobalPosition(new Point(this.downRight.x, this.downRight.y)); |
|
|
|
|
var temp1 = this.workingArea.backgroundImage.toLocal(gPos); |
|
|
|
|
this.pivot.set(this.downRight.x, this.downRight.y); |
|
|
|
|
this.position.set(temp1.x,temp1.y); |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
.on('pointerup', event => { |
|
|
|
|
if (event.currentTarget.dragging) { |
|
|
|
|
event.currentTarget.alpha = 1; |
|
|
|
|
event.currentTarget.dragging = false; |
|
|
|
|
event.currentTarget.data = null; |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.on('pointerupoutside', event => { |
|
|
|
|
if (event.currentTarget.dragging) { |
|
|
|
|
event.currentTarget.alpha = 1; |
|
|
|
|
event.currentTarget.dragging = false; |
|
|
|
|
event.currentTarget.data = null; |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.on('pointermove', event => { |
|
|
|
|
if (event.currentTarget.dragging) { |
|
|
|
|
const newPosition = event.currentTarget.data.getLocalPosition(event.currentTarget.parent); |
|
|
|
|
// event.currentTarget.x = newPosition.x;
|
|
|
|
|
// event.currentTarget.y = newPosition.y;
|
|
|
|
|
var width = -(newPosition.x - event.currentTarget.dragPoint.x) |
|
|
|
|
var height = -(newPosition.y - event.currentTarget.dragPoint.y); |
|
|
|
|
if (width > 0) { |
|
|
|
|
this.scale.x += 0.01; |
|
|
|
|
this.scale.y += 0.01; |
|
|
|
|
} else { |
|
|
|
|
this.scale.x -= 0.01; |
|
|
|
|
this.scale.y -= 0.01; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.on('rightclick', event => { |
|
|
|
|
this.border.visible = false; |
|
|
|
|
}) |
|
|
|
|
.on('pointerover', event => { |
|
|
|
|
event.stopPropagation(); |
|
|
|
|
}) |
|
|
|
|
.on('pointerout', event => { |
|
|
|
|
event.stopPropagation(); |
|
|
|
|
}); |
|
|
|
|
this.addChild(this.upRight); |
|
|
|
|
this.upRight.anchor.set(0.5); |
|
|
|
|
this.upRight.interactive = true; |
|
|
|
|
this.upRight.visible = false; |
|
|
|
|
this.addChild(this.downLeft); |
|
|
|
|
this.downLeft.anchor.set(0.5); |
|
|
|
|
this.downLeft.interactive = true; |
|
|
|
|
this.downLeft.visible = false; |
|
|
|
|
this.addChild(this.downRight); |
|
|
|
|
this.downRight.anchor.set(0.5); |
|
|
|
|
this.downRight.interactive = true; |
|
|
|
|
this.downRight.visible = false; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 设置点显示状态 |
|
|
|
|
* @param value 显示状态 |
|
|
|
|
*/ |
|
|
|
|
public setPointVisiable(value: boolean) { |
|
|
|
|
let rect = this.getLocalBounds(); |
|
|
|
|
this.upLeft.x = rect.left; |
|
|
|
|
this.upLeft.y = rect.top; |
|
|
|
|
this.upRight.x = rect.right; |
|
|
|
|
this.upRight.y = rect.top; |
|
|
|
|
this.downLeft.x = rect.left; |
|
|
|
|
this.downLeft.y = rect.bottom; |
|
|
|
|
this.downRight.x = rect.right; |
|
|
|
|
this.downRight.y = rect.bottom; |
|
|
|
|
this.upLeft.visible = value; |
|
|
|
|
this.upRight.visible = value; |
|
|
|
|
this.downLeft.visible = value; |
|
|
|
|
this.downRight.visible = value; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
*
|
|
|
|
|
* @param scale 绘制边框 |
|
|
|
|
*/ |
|
|
|
|
public drawBorder(scale: number) { |
|
|
|
|
let visible = this.upLeft.visible; |
|
|
|
|
this.setPointVisiable(false); |
|
|
|
|
|
|
|
|
|
super.drawBorder(scale); |
|
|
|
|
let rect = this.getLocalBounds(); |
|
|
|
|
this.upLeft.x = rect.left; |
|
|
|
|
this.upLeft.y = rect.top; |
|
|
|
|
this.upRight.x = rect.right; |
|
|
|
|
this.upRight.y = rect.top; |
|
|
|
|
this.downLeft.x = rect.left; |
|
|
|
|
this.downLeft.y = rect.bottom; |
|
|
|
|
this.downRight.x = rect.right; |
|
|
|
|
this.downRight.y = rect.bottom; |
|
|
|
|
this.setPointVisiable(visible); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|