[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.gef] Search connection under mouse
|
How I can determine, is mouse pointer locate in the neighbourhood of connection?
I thus far make as follows:
[code]
IFigure connectionLayer = ((ScalableFreeformRootEditPart) (getCurrentViewer().getRootEditPart())).
getLayer(LayerConstants.CONNECTION_LAYER);
int delta = 5;
IFigure findingFigure = null;
int xScale = 0;
int yScale = 0;
for (int i = -delta; i <= delta; i++) {
for (int j = -delta; j <= delta; j++) {
Point relativePosition = getLocation();
findingFigure = connectionLayer.findFigureAt(relativePosition.x + i, relativePosition.y + j);
if (findingFigure != null) {
yScale = j;
break;
}
}
if (findingFigure != null) {
xScale = i;
break;
}
}
if (findingFigure != null && findingFigure instanceof PolylineConnection) {
Object findingEditPart = getCurrentViewer(). findObjectAt(new Point(getLocation().x + xScale,
getLocation().y + yScale));
}
[/code]
But this solution does not work with the scaled images