Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to increase figure's selectable area?
How to increase figure's selectable area? [message #1016489] Wed, 06 March 2013 16:31 Go to next message
Vitaly Savickas is currently offline Vitaly SavickasFriend
Messages: 62
Registered: March 2010
Member
I have a small node figure element in my diagram editor that is hard to select due to its size (5x5). Is it possible to increase its selectable area beyond its bounds, say, to be able to select it with a mouse when the pointer is close to it?

The figure is a circle, and acts as a node, which you can draw connections to. And the reason I don't want to increase its size is that it acts as an intermediate node to allow connection splitting to multiple target nodes.

Kind regards,
Vitaly

[Updated on: Wed, 06 March 2013 19:23]

Report message to a moderator

Re: How to increase figure's selectable area? [message #1016562 is a reply to message #1016489] Wed, 06 March 2013 22:45 Go to previous messageGo to next message
Andreas Muelder is currently offline Andreas MuelderFriend
Messages: 73
Registered: July 2011
Member
Hi Vitaly,

maybe you can override getTargetEditPart for the underlying editpart that "contains" your CircleEditPart (the DiagramEditPart or a compartmentEditPart?)
, expand the bounds and check if the location of the selection is contained by the new bounds. Then you could delegate the SelectionRequest to this editpart. This is just an idea as a starting point for you and not working out of the box:
@Override
public EditPart getTargetEditPart(Request request) {
  if (request instanceof SelectionRequest) {
  Point location = ((SelectionRequest) request).getLocation();
  getFigure().translateToAbsolute(location);
  List<IGraphicalEditPart> children = getChildren();
  for (IGraphicalEditPart child : children) {
     Rectangle bounds = child.getFigure().getBounds().getCopy();
     getFigure().translateToAbsolute(bounds);
     if (bounds.expand(20, 20).contains(location)) {
       return child;
      }
   }
}
return super.getTargetEditPart(request);


Best regards,

Andreas
Re: How to increase figure's selectable area? [message #1016700 is a reply to message #1016562] Thu, 07 March 2013 12:13 Go to previous messageGo to next message
Vitaly Savickas is currently offline Vitaly SavickasFriend
Messages: 62
Registered: March 2010
Member
Thank you, Andreas. This makes absolute sense.

Now it only requires some selection feedback for the user, as it is ambiguous that items can be selected while the mouse is on an empty canvas. I envision this as either a mouse cursor change or, better, a dynamically drawn selection figure. Any tips which classes/methods need to be overridden?

Btw, in the GMF 3.0 there's a new feature called InvisibleRectangle Figure. Can it also be used for this problem? Or what is it used for?

Regards,
Vitaly

[Updated on: Thu, 07 March 2013 12:31]

Report message to a moderator

Re: How to increase figure's selectable area? [message #1016928 is a reply to message #1016700] Fri, 08 March 2013 08:59 Go to previous message
Andreas Muelder is currently offline Andreas MuelderFriend
Messages: 73
Registered: July 2011
Member
Hi Vitaly,

you can override the EditParts showSourceFeedback method to display a selection figure.
Maybe you can override the PrimaryDrag Edit Part or you can create a new editpart for this.


Best regards,

Andreas


Previous Topic:Connection Constraint
Next Topic:After "Generate diagram code" the edit project is not found
Goto Forum:
  


Current Time: Fri Apr 19 19:32:32 GMT 2024

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

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

Back to the top