Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Shape
Shape [message #146569] Wed, 04 August 2004 23:30 Go to next message
Eclipse UserFriend
Originally posted by: svenkat.asu.edu

The snippet below is from the Pipe and Filter editor example. I am trying
to change the shape of the node. Currently it's a rectangle. I want the
node to take the shape of my own image instead of a rectangle. Can anybody
help me edit this code to do that?


protected IFigure createFigure()
{
RectangleFigure rectangle = new RectangleFigure();
rectangle.setBackgroundColor(color_);

Label label = new Label(label_);
label.setLocation(new Point(0,0));
rectangle.add(label);

Point location = new Point(60,50);
rectangle.setLocation(location);
rectangle.setSize(new Dimension(70,50));
return rectangle;

}

protected void refreshVisuals()
{
NodeModel node = (NodeModel)getModel();
RectangleFigure rectangle = (RectangleFigure)getFigure();
Point p = node.getLocation();
Dimension s = node.getSize();

Rectangle r = new Rectangle(p, s);

((GraphicalEditPart) getParent()).setLayoutConstraint(this,
rectangle, r);
super.refreshVisuals();
}
Re: Shape [message #146969 is a reply to message #146569] Mon, 09 August 2004 18:26 Go to previous message
Eclipse UserFriend
Originally posted by: gupolet.ulb.ac.be

Change the RectangleFigure to an ImageFigure (or Label if you want to add
text). In the createFigure(), put the image you want with
setImage(Image image).
For the refreshVisuals, it stays pretty much the same, except that you need
to cast to an ImageFigure of course.
"Swami Venkataramani" <svenkat@asu.edu> a
Previous Topic:Three Edit Parts for one Domain Model (Conditional Connector)
Next Topic:Display just a small area of figure...
Goto Forum:
  


Current Time: Fri Apr 26 17:46:08 GMT 2024

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

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

Back to the top