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 11:31 Go to next message
Vitaly Savickas is currently offline Vitaly Savickas
Messages: 61
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 14: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 17:45 Go to previous messageGo to next message
Andreas Muelder is currently offline Andreas Muelder
Messages: 71
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 07:13 Go to previous messageGo to next message
Vitaly Savickas is currently offline Vitaly Savickas
Messages: 61
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 07: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 03:59 Go to previous message
Andreas Muelder is currently offline Andreas Muelder
Messages: 71
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 Aug 01 01:47:20 EDT 2014

Powered by FUDForum. Page generated in 0.01611 seconds