Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Detecting boundaries of the target container
Detecting boundaries of the target container [message #1836950] Tue, 19 January 2021 19:08 Go to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 554
Registered: November 2009
Senior Member
I have shapes that consist of an invisible rectangle and image in the center of it. When I move one shape towards another I don't want shapes to overlap, and it works to some degree, however, it looks like boundary of target is calculated off the center of the image and not outside invisible rectangle. What ends up happening is that one shape can be positioned over the other. I check if two shapes are different by comparing their businessObjects. How can I avoid this behavior?

Below ins the progression of moving the shape, the orange outlines are the boundaries of rectangle when I cannot the shape because DefaultMoveShapeFeature.canMoveShape() returns false.

Boundaries of left shape
https://i.ibb.co/Wc6DnDY/1.png

Boundaries of right shape
https://i.ibb.co/G29ZjXL/2.png

Result of moving left shape closer to right shape
https://i.ibb.co/cbVMWJT/3.png

[Updated on: Tue, 19 January 2021 19:18]

Report message to a moderator

Re: Detecting boundaries of the target container [message #1836953 is a reply to message #1836950] Tue, 19 January 2021 19:26 Go to previous messageGo to next message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 96
Registered: April 2012
Member
I don't know if it would help but sometimes I just check overlapping by myself:
  public static boolean intersects(RuminaqShape label, RuminaqShape shape) {

    int xal = label.getX();
    int yal = label.getY();
    int xbl = xal;
    int ybl = yal + label.getHeight();
    int xdl = xal + label.getWidth();
    int ydl = yal;
    int xcl = xdl;
    int ycl = ybl;
    int xas = shape.getX();
    int yas = shape.getY();
    int xbs = xas;
    int ybs = yas + shape.getHeight();
    int xds = xas + shape.getWidth();
    int yds = yas;
    int xcs = xds;
    int ycs = ybs;

    return (xcl > xas && ycl > yas && xcl < xcs && ycl < ycs)
        || (xdl > xbs && ydl < ybs && xdl < xds && ydl > yds)
        || (xal < xcs && yal < ycs && xal > xas && yal > yas)
        || (xbl < xds && ybl > yds && xbl > xbs && ybl < ybs);
  }

Best,
Marek
Re: Detecting boundaries of the target container [message #1836958 is a reply to message #1836953] Wed, 20 January 2021 01:31 Go to previous messageGo to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 554
Registered: November 2009
Senior Member
Thanks, there are different ways to detect collision. I wanted to see if Graphiti has something built in.
Re: Detecting boundaries of the target container [message #1836977 is a reply to message #1836958] Wed, 20 January 2021 13:44 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1925
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Alex,

Graphiti does not really have collision detection, we do something like that for checking if one shape is dragged into another one (for containers). But I'm afraid that will not help in your case, because this is not available on the API and even for non-container shapes we still allow intersection, as you have noticed. Probably you will have to implement something as Marek suggested into your move feature.

Michael
Re: Detecting boundaries of the target container [message #1836985 is a reply to message #1836977] Wed, 20 January 2021 15:18 Go to previous messageGo to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 554
Registered: November 2009
Senior Member
Great thank you Michael.
Re: Detecting boundaries of the target container [message #1837080 is a reply to message #1836985] Thu, 21 January 2021 16:55 Go to previous message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 554
Registered: November 2009
Senior Member
No Message Body

[Updated on: Fri, 22 January 2021 00:54]

Report message to a moderator

Previous Topic:Undoing multiple commands during Graphiti undo execution
Next Topic:Problem with SVG
Goto Forum:
  


Current Time: Mon Apr 12 14:03:38 GMT 2021

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

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

Back to the top