Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Draw2D Add Figure at Location(Adding figures to a specific location on the screen)
Draw2D Add Figure at Location [message #1706098] Sat, 22 August 2015 14:02 Go to next message
A Jaro is currently offline A JaroFriend
Messages: 5
Registered: October 2012
Junior Member
I'm trying to add figures to the screen in a specific location, but the setLocation method doesn't seem to be working the way I expect. I've set my root editPart as a freeFormLayer with a freeFormLayout as the manager. Then in each of the nodes, I create a label figure and set the location. The node figures don't end up displaying at all. What am I missing here?

public class RootEditPart extends AbstractGraphicalEditPart{

	@Override
	protected IFigure createFigure() {
		Figure f = new FreeformLayer();
		f.setLayoutManager(new FreeformLayout());
		f.setBorder(new MarginBorder(1));
		f.setBackgroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		return f;
		
		
	}
}


public class NodeEditPart extends AbstractGraphicalEditPart {

	@Override
	protected IFigure createFigure() {
		System.out.println("Called NodeEditPart.createFigure()");
		Label node = new Label();
		return node;
	}

	@Override
	protected void createEditPolicies() {

	}
	protected void refreshVisuals() {
		System.out.println("Called NodeEditPart.refreshVisuals()");
		
		Point loc = new Point(100, 100);
		Label node = (Label) getFigure();
		node.setIcon(image);
		node.setText("test");
		node.setLocation(loc);
		System.out.println("  setting location to: " + loc);
	}
}
Re: Draw2D Add Figure at Location [message #1706124 is a reply to message #1706098] Sun, 23 August 2015 22:29 Go to previous message
A Jaro is currently offline A JaroFriend
Messages: 5
Registered: October 2012
Junior Member
I was able to resolve this by using the setBounds method on the Label instead of the setLocation method
Previous Topic:[GEF4] About events consumption and policy ordering
Next Topic:o.e.gef4.common standalone compilation problem
Goto Forum:
  


Current Time: Thu Apr 25 05:38:22 GMT 2024

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

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

Back to the top