Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Changing background color and location's node
Changing background color and location's node [message #666120] Tue, 19 April 2011 08:22 Go to next message
nicolas h is currently offline nicolas hFriend
Messages: 60
Registered: February 2011
Location: Grenoble, France
Member
Hi there,
I need to modify background color and location's node programmatically.

To do this I found on this forum some helps. But I don't have any "ComponentImpl" and I don't know where I can find it.

Finally, I use ShapeNodeEditPart#getNodeFigure().setLocation(Point p) and setBackgroundColor(Color bg) like this :

	protected void handleNotificationEvent(Notification notification) {
		super.handleNotificationEvent(notification);

		Point rect = new Point (100,100);
		System.out.println ("change background and location");
		this.getNodeFigure().setLocation(rect);

		Color bgColor = new Color (null, 255,0,0);
		bgColor.dispose();
		this.getNodeFigure().setBackgroundColor(bgColor);
		refreshBackgroundColor();
		
		refreshChildren();
		if (AmDiagramEditorUtil.dEditPart != null)
			AmDiagramEditorUtil.dEditPart.refresh();
	}


The handle function is executed, however, nothing happens.

Does anyone have an idea about this ?

Regards,

--
Nicolas
Re: Changing background color and location's node [message #666187 is a reply to message #666120] Tue, 19 April 2011 12:33 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

did you try this

performRequest(new Request(RequestConstants.REQ_REFRESH));


You should consider using the GMF notation model to change the visual appearance. You can get the notation model element of you editpart by using

getNotationView()


You can also try the SetBoundsCommand for setting the location. I used it to set the size.

Rectangle rect = figure.getClientArea().getCopy();
rect.setSize((cachedSize != null) ? cachedSize : new Dimension(10, 10));
SetBoundsCommand sbc = new SetBoundsCommand( this.getEditingDomain(), "change size", new EObjectAdapter((View) this.getModel()), rect);
getEditDomain().getCommandStack().execute(new ICommandProxy(sbc));


Hope that helps.

Ralph
Re: Changing background color and location's node [message #666209 is a reply to message #666187] Tue, 19 April 2011 13:36 Go to previous messageGo to next message
nicolas h is currently offline nicolas hFriend
Messages: 60
Registered: February 2011
Location: Grenoble, France
Member
Thanks for your reply.
the performRequest changes nothing but your two others solutions work both.

Thank you !
Re: Changing background color and location's node [message #687795 is a reply to message #666187] Thu, 23 June 2011 08:55 Go to previous message
vincent988923 is currently offline vincent988923Friend
Messages: 29
Registered: June 2011
Junior Member
Hi, I need you help urgently. I have the same problem. But I can't solve it after seeing the reply. Could you tell me how to achieve it in DETAIL? Because I can't find the function or class you mentioned in the question and I don't know where I should put the code! Thank you very much.

Best Regards,
Vincent
Previous Topic:GMF Diagram Partitioning
Next Topic:How to set font color for generated diagram?
Goto Forum:
  


Current Time: Fri Apr 26 15:51:01 GMT 2024

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

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

Back to the top