package pt.inm.smartgwt_tester.client;

import com.smartgwt.client.types.ArrowStyle;
import com.smartgwt.client.widgets.drawing.DrawPane;

public class Edge extends DrawConnection {

	private Component fromComponent;
	private Component toComponent;
	
	public Edge(DrawPane drawPane, Component fromComponent, Component toComponent) {

		this.fromComponent = fromComponent;
		this.toComponent = toComponent;

		int ox = this.fromComponent.getLeft();
		int oy = this.fromComponent.getTop();
		int x = this.toComponent.getLeft();
		int y = this.toComponent.getTop();
		
		int fromWidth = this.fromComponent.getWidth();
		int fromHeight = this.fromComponent.getHeight();
		int toWidth = this.toComponent.getWidth();
		int toHeight = this.toComponent.getHeight();
		
		setDrawPane(drawPane);
		
		drawLine(ox, oy, x, y, fromWidth, fromHeight, toWidth, toHeight);
		setEndArrow(ArrowStyle.BLOCK);

		moveBy(-6, -6);

		draw();
	}
}
