Skip to main content



      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 04:22 Go to next message
Eclipse UserFriend
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 08:33 Go to previous messageGo to next message
Eclipse UserFriend
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 09:36 Go to previous messageGo to next message
Eclipse UserFriend
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 04:55 Go to previous message
Eclipse UserFriend
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 Jul 04 17:29:14 EDT 2025

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

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

Back to the top