Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Weird Node Resizing Problem (My Figures don't resize, if I've moved them before)
Weird Node Resizing Problem [message #894775] Tue, 10 July 2012 13:21 Go to next message
Saurabh Srivastava is currently offline Saurabh SrivastavaFriend
Messages: 7
Registered: June 2012
Junior Member
Hi,

I am building a Zest based Graph Drawing Tool. I use some Complex Draw2d Figures as My Nodes. I am facing a strange problem, that I am not able to track.

My nodes have a "collapsible" part. which can be expanded or collapsed on a Label click. It all works fine to start with. The nodes get shrunk or expanded, as I click on the Label.

index.php/fa/10643/0/
index.php/fa/10644/0/

However, if I drag my nodes a bit, and then try to Collapse/Expand my nodes, my "node won't resize itself".

index.php/fa/10645/0/
index.php/fa/10646/0/

I tried repainting my node's figure, but it didn't helped. Can anyone suggest what may be going wrong??

The Screen shots of the problem are also attached.
  • Attachment: Screen 1.bmp
    (Size: 125.93KB, Downloaded 864 times)
  • Attachment: Screen 2.bmp
    (Size: 573.94KB, Downloaded 947 times)
  • Attachment: Screen 3.bmp
    (Size: 319.97KB, Downloaded 897 times)
  • Attachment: Screen 4.bmp
    (Size: 478.25KB, Downloaded 918 times)

[Updated on: Tue, 10 July 2012 13:22]

Report message to a moderator

Re: Weird Node Resizing Problem [message #894925 is a reply to message #894775] Wed, 11 July 2012 06:26 Go to previous messageGo to next message
Saurabh Srivastava is currently offline Saurabh SrivastavaFriend
Messages: 7
Registered: June 2012
Junior Member
Ok, SO I found the problem after a lot of debugging. I am posting my experience, just in case its of help to someone else.

I am using Zest 1.1 for drawing my Graphs. It has a Class called GraphNode, which acts as a Starting Point if you want to have Custom Nodes in your Graph. So I just extended this Class and added my Figures to be used as the Node Figures.

There is, however, a method called refreshLocation() in this Class. This is called whenever there is a Drag Event on a Node, and the node is repositioned. The code for the same is below:

	protected void refreshLocation() {
		Point loc = this.getLocation();
		Dimension size = this.getSize();
		Rectangle bounds = new Rectangle(loc, size);

		if (nodeFigure == null || nodeFigure.getParent() == null) {
			return; // node figure has not been created yet
		}
		//nodeFigure.setBounds(bounds);
		nodeFigure.getParent().setConstraint(nodeFigure, bounds);
	}


See the Last Line in the Method, that is doing the major work,
nodeFigure.getParent().setConstraint(nodeFigure, bounds);

It sets the Constraints on the Node Figure. However, see the Lines:

Dimension size = this.getSize();
Rectangle bounds = new Rectangle(loc, size);


Which essentially would never allow the Figure to resize at all !!
Since we'll keep using the "previous" size, the new size is never calculated.

I've overridden that method in my own class, copied the above code in my method, and just changed one line:
Dimension size = new Dimension(-1, -1);

That does the trick.... Hope it may have been already changed in later versions of Zest !!
Re: Weird Node Resizing Problem [message #1420047 is a reply to message #894925] Tue, 09 September 2014 12:38 Go to previous message
Pedram Khoshdani is currently offline Pedram KhoshdaniFriend
Messages: 2
Registered: September 2014
Junior Member
Hi Saurabh, I am also using Zest 1.x and I want to do the exact same thing as you did with the nodes as in expanding and collapsing functionality. Could you please help me with that?
For the layout, I have implemented LayoutAlgorithm but it doesn't provide the expanding action.
How did you do that with "Label"? Is it Label from SWT or org.eclipse.draw2d?

Thanks in advance Razz
Previous Topic:creating bend point - zoom problem
Next Topic:Executing directEdit request on EditOart after its creation
Goto Forum:
  


Current Time: Sat Apr 20 02:27:41 GMT 2024

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

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

Back to the top