[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: Length of a ConnectionNodeEditPart

Hi,

your decoration should be referencing its source and its target. You can get the locations of those two and calculate the difference to get the length of the connection edit part.

Best,
Artur

josiaspaesjr wrote:

Hi all,

I have a class that extends the class ConnectionNodeEditPart. I need to retrieve the size of this connection (1) to put the decorator always at the center of the connection. There is a way to do or suggest another solution?

For example:

(1)http://img16.imageshack.us/img16/8229/lenghtconnection.jpg

Following code decorator:

private RotatableDecoration createTargetDecoration() {
			PolygonDecoration df = new PolygonDecoration();
			PointList pl = new PointList();
			pl.addPoint(-1,-4);
			pl.addPoint(-3,-3);
			pl.addPoint(-4,-1);
			pl.addPoint(-4,1);
			pl.addPoint(-3,3);
			pl.addPoint(-1,4);
			df.setTemplate(pl);
			df.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));
			df.setBackgroundColor(DF_WHITE);
			df.setForegroundColor(DF_BLACK);
			return df;
		}

Thanks
Josias Paes