Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Search connection under mouse
Search connection under mouse [message #210393] Mon, 27 February 2006 14:16 Go to next message
Eclipse UserFriend
Originally posted by: fangrey.mail.ru

How I can determine, is mouse pointer locate in the neighbourhood of connection?
I thus far make as follows:
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));
}

But this solution does not work with the scaled images
Re: Search connection under mouse [message #210405 is a reply to message #210393] Mon, 27 February 2006 19:32 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

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@mail.ru> wrote in message
news:13779333.1141049833123.JavaMail.root@cp1.javalobby.org...
> How I can determine, is mouse pointer locate in the neighbourhood of
> connection?
> I thus far make as follows:
>
> 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));
> }
> 

> But this solution does not work with the scaled images
Previous Topic:snapToGrip not working
Next Topic:Newbie Question Regarding The Display of Model
Goto Forum:
  


Current Time: Fri Apr 26 20:50:19 GMT 2024

Powered by FUDForum. Page generated in 0.02904 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top