Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Changing Figure at runtime
Changing Figure at runtime [message #217704] Mon, 12 June 2006 07:49
Eclipse UserFriend
Originally posted by: robert.moestl.joanneum.at

Hello!

I spent a lot of time trying to change the figure of an editpart from a
rectangle to an ellipse at runtime. So if my model changes its
geometryType from 'box' to 'cylinder' a circle should be drawn instead
of a rectangle. I'm trying this in the Editpart method refreshVisuals()
like this:

protected void refreshVisuals() {
String geometryType = getExhibit().getGeometryType();
Rectangle bounds = null;
if(geometryType.equals(VisualExhibit.GEOMETRY_TYPE_BOX)) {
setFigure(new VisualExhibitFigure(getExhibit()));
bounds = new
Rectangle(UnitConversion.toPoint(getExhibit().getPosition()) ,
((VisualExhibitFigure)getFigure()).getVirtualBounds().getSiz e());
} else if(geometryType.equals(VisualExhibit.GEOMETRY_TYPE_CYLINDER) ) {
setFigure(new Ellipse());
bounds = new
Rectangle(UnitConversion.toPoint(getExhibit().getPosition()) ,
(getFigure()).getSize());
}

GefUtilities.addOffset(bounds);
ensureMinimumBounds(bounds);
((GraphicalEditPart) getParent()).setLayoutConstraint(this,
getFigure(), bounds);
getFigure().repaint();
super.refreshVisuals();
}


But it doesn't work. I always got an NullPointerException in
setLayoutConstraint, because the figure has no parent. I also tried to
set the parent of the new figure via setParent, but it still didn't worked.

Did anybody know a standard way changing figures at runtime?

Thanks in advance,
Robert
Previous Topic:XY Anchor usage
Next Topic:Direct instantiation of SWTGraphics in DeferredUpdateManager
Goto Forum:
  


Current Time: Mon Jan 13 14:39:56 GMT 2025

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

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

Back to the top