Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Change the Figure after it is first created
Change the Figure after it is first created [message #65458] Tue, 18 February 2003 20:45 Go to next message
yinglcs is currently offline yinglcsFriend
Messages: 64
Registered: July 2009
Member
Hi,

GEF uses MVC pattern, so every model has 1 figure. But can I change that
figure after it is first created thru a command? For example, I have a model
which represents as a Square (a figure), can I have a command in the menu to
switch that to a Circle? I notice the createFigure() only called once per
EditPart.

My question is if it is possible to swap that figure after it is initially
created.
Thank you.
Re: Change the Figure after it is first created [message #65483 is a reply to message #65458] Tue, 18 February 2003 20:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

There are workarounds, please open a feature request for this.

you might try overriding:

protected void setFigure(IFigure newFigure) {
if (figure != null) {
unregisterVisuals();
IFigure parent = figure.getParent();
int index = parent.indexOf(figure);
Object constraint = parent.getLayoutManager().getConstraint(figure);
figure = newFigure;
parent.add(figure, constraint, index);
registerVisuals();
} else
super.setFigure(newFigure);
}

"yinglcs" <yinglcs@netscape.com> wrote in message
news:b2u4ej$eb1$1@rogue.oti.com...
> Hi,
>
> GEF uses MVC pattern, so every model has 1 figure. But can I change that
> figure after it is first created thru a command? For example, I have a
model
> which represents as a Square (a figure), can I have a command in the menu
to
> switch that to a Circle? I notice the createFigure() only called once per
> EditPart.
>
> My question is if it is possible to swap that figure after it is initially
> created.
> Thank you.
>
>
Re: Change the Figure after it is first created [message #65628 is a reply to message #65483] Wed, 19 February 2003 15:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: john-mason.shackelford.pearson.com

> IFigure parent = figure.getParent();
> int index = parent.indexOf(figure);

In the latest drop of GEF neither IFigure nor Figure has an indexOf method.

--

John-Mason Shackelford

Software Developer
Pearson Educational Measurement - eMeasurement Group

2510 North Dodge St.
Iowa City, IA 52245
ph. 319-354-9200x6214
john-mason.shackelford@pearson.com
http://etest.ncspearson.com
Re: Change the Figure after it is first created [message #65649 is a reply to message #65628] Wed, 19 February 2003 15:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

"John-Mason P. Shackelford" <john-mason.shackelford@pearson.com> wrote in
message news:3E53A335.9070309@pearson.com...
>
>
> > IFigure parent = figure.getParent();
> > int index = parent.indexOf(figure);
>
> In the latest drop of GEF neither IFigure nor Figure has an indexOf
method.

try parent.getChildren().indexOf(child)
>
> --
>
> John-Mason Shackelford
>
> Software Developer
> Pearson Educational Measurement - eMeasurement Group
>
> 2510 North Dodge St.
> Iowa City, IA 52245
> ph. 319-354-9200x6214
> john-mason.shackelford@pearson.com
> http://etest.ncspearson.com
>
Re: Change the Figure after it is first created [message #65691 is a reply to message #65649] Wed, 19 February 2003 16:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: john-mason.shackelford.pearson.com

Randy,


What do you think about adding something like this to the API for Figure
and EditPart? Certaily could be handled by subclasses, but perhaps handy
enough to consider making more readily available. What do you think?

public int getChildCount(Class c) {
int i = 0;
Iterator iter = children.iterator();
while (iter.hasNext()) {
if (c.isAssignableFrom(iter.next().getClass())) {
i++;
}
}
return i;
}

--

John-Mason Shackelford

Software Developer
Pearson Educational Measurement - eMeasurement Group

2510 North Dodge St.
Iowa City, IA 52245
ph. 319-354-9200x6214
john-mason.shackelford@pearson.com
http://etest.ncspearson.com
Re: Change the Figure after it is first created [message #65713 is a reply to message #65691] Wed, 19 February 2003 16:25 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

What would this be used for?

"John-Mason P. Shackelford" <john-mason.shackelford@pearson.com> wrote in
message news:3E53AD2E.80208@pearson.com...
> Randy,
>
>
> What do you think about adding something like this to the API for Figure
> and EditPart? Certaily could be handled by subclasses, but perhaps handy
> enough to consider making more readily available. What do you think?
>
> public int getChildCount(Class c) {
> int i = 0;
> Iterator iter = children.iterator();
> while (iter.hasNext()) {
> if (c.isAssignableFrom(iter.next().getClass())) {
> i++;
> }
> }
> return i;
> }
>
> --
>
> John-Mason Shackelford
>
> Software Developer
> Pearson Educational Measurement - eMeasurement Group
>
> 2510 North Dodge St.
> Iowa City, IA 52245
> ph. 319-354-9200x6214
> john-mason.shackelford@pearson.com
> http://etest.ncspearson.com
>
Previous Topic:confused about ConstrainedLayoutPolicy.createAddCommand()
Next Topic:Getting the right location after scrolling
Goto Forum:
  


Current Time: Fri Dec 27 19:43:55 GMT 2024

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

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

Back to the top