Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to place Label above Ellipse?(I am trying to place a Label above an Ellipse, but each time refreshVisuals is called from the EditPart the figure shrinks!)
icon5.gif  How to place Label above Ellipse? [message #633546] Mon, 18 October 2010 11:19 Go to next message
Mikkel Jonassen is currently offline Mikkel Jonassen
Messages: 24
Registered: September 2010
Junior Member
Hello Experts Smile

I am trying to place a Label above an Ellipse shape, but each time refreshVisuals is called from the EditPart the figure shrinks. My paintFigure method looks like the following:


Rectangle r = this.getBounds().getCopy();

setConstraint(getLabelFigure(), new Rectangle(0, 0, (int)(r.width*0.9), (int)(r.height*0.1)));
getLabelFigure().invalidate();

// ellipse starts where label ends and fill the rest 90% in height and width
setConstraint(getEllipseFigure(), new Rectangle(0, (int)(r.height*0.1), (int)(r.width*0.9), (int)(r.height*0.9))); 
getEllipseFigure().invalidate();



It seems that I can't use the constraints in this way, so how do I place the Label figure right above the Ellipse.

I am using normal draw2D label and a normal draw2D Ellipse shape.

Thanks in advantage.

Regards Mikkel

Re: How to place Label above Ellipse? [message #633548 is a reply to message #633546] Mon, 18 October 2010 11:27 Go to previous messageGo to next message
Mikkel Jonassen is currently offline Mikkel Jonassen
Messages: 24
Registered: September 2010
Junior Member
And also my refreshVisuals method looks like the following:


MyNodeFigure figure = (MyNodeFigure) getFigure();
		
// set constraints for ellipse
Point location = figure.getEllipseFigure().getLocation();
Dimension size = figure.getEllipseFigure().getSize();
GraphEditPart graph = (GraphEditPart) getParent();
Rectangle constraint = new Rectangle(location, size);
graph.setLayoutConstraint(this, figure, constraint);

Re: How to place Label above Ellipse? [message #633560 is a reply to message #633548] Mon, 18 October 2010 12:19 Go to previous message
Mikkel Jonassen is currently offline Mikkel Jonassen
Messages: 24
Registered: September 2010
Junior Member
I figured out the problem.

Now I am using BorderLayout instead and using constants CENTER and TOP.

Also the problem was not the layout manager itself but the way I updated the constraints in the EditPart.
Previous Topic:Testing and setting workbench button states
Next Topic:mouse-selecting nodes
Goto Forum:
  


Current Time: Sat Oct 25 09:49:27 GMT 2014

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

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