Shape [message #146569] |
Wed, 04 August 2004 23:30 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04448 seconds