[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] Re: Search connection under mouse

Connections already have a delta +/- (2 + 1/2 linewidth) pixels (at 100%). 
If you want this to be bigger, you could make the width of the line larger, 
but paint at a smaller width. You could also override containsPoint to make 
the threshold larger.

Your for loop has some issues.

"FanGrey" <fangrey@xxxxxxx> wrote in message 
news:13779333.1141049833123.JavaMail.root@xxxxxxxxxxxxxxxxxxxx
> 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