Label location with main figure [message #146226] |
Tue, 03 August 2004 12:21 |
Eclipse User |
|
|
|
Originally posted by: daniel.yahoo.com
Hi
I want to decorate MyFigure with a Label which is behind MyFigure . when
MyFigure move this label will move(label use locator to locate himself). I
want to use this label to set anther model's(Model2) name when this model
was created in current MyModel. in refreshVisual() I refresh the label's
text by propertyChange.
Now has some problems:
protected IFigure createFigure(){
MainFigure myFigure = new MainFigure();
Label l = new Label("");
this.getParent().getFigure().add(l); // get parent to add this label.
l.setLocation(new Point(myFigure.getBounds().x -
20,myFigure.getBounds().y);// but when I save it and open again it stills
in top left corner
return myFigure;
}
protected void refreshVisuals(){
Model1 m1 = myModel.getModel1();
l.setText(m1.getName);
this.getParent().setLayoutConstraint(null,l,new MyLocator(myFigure));
}
when I new my file everything works well.but when I save this file and
open it again.in top left corner there is the label with text.
how can I remove this figure. Must I create Model1's EditPart? and do
some mapping works between MyModel and Model1?
I am stump...
thanks
daniel
|
|
|
Re: Label location with main figure [message #146245 is a reply to message #146226] |
Tue, 03 August 2004 13:44 |
Eclipse User |
|
|
|
Originally posted by: mastr.arcor.de
daniel wrote:
> Hi
> I want to decorate MyFigure with a Label which is behind MyFigure . when
> MyFigure move this label will move(label use locator to locate himself). I
> want to use this label to set anther model's(Model2) name when this model
> was created in current MyModel. in refreshVisual() I refresh the label's
> text by propertyChange.
> Now has some problems:
> protected IFigure createFigure(){
> MainFigure myFigure = new MainFigure();
> Label l = new Label("");
> this.getParent().getFigure().add(l); // get parent to add this label.
> l.setLocation(new Point(myFigure.getBounds().x -
> 20,myFigure.getBounds().y);// but when I save it and open again it stills
> in top left corner
> return myFigure;
> }
> protected void refreshVisuals(){
> Model1 m1 = myModel.getModel1();
> l.setText(m1.getName);
> this.getParent().setLayoutConstraint(null,l,new MyLocator(myFigure));
> }
Don't now exactly but you instantiate the Label in createFigure() as local
variable. You want to refresh Label "l" which is not the label you
instantiated, or?
Seems to be the mistake, am I right?
Martin
|
|
|
Decorating EditPart with Label [message #146399 is a reply to message #146245] |
Wed, 04 August 2004 01:01 |
Eclipse User |
|
|
|
Originally posted by: daniel.yahoo.com
Sorry, it's my fault. Label l is global variable in MainFigure. I want to
refresh the l in refreshVisuals()
where can I initantiate the l? I want to assign a Label for every
MainFigure
and when refreshVisuals() I want to refresh the label's location and
contents
thanks
mastr wrote:
> daniel wrote:
> > Hi
> > I want to decorate MyFigure with a Label which is behind MyFigure . when
> > MyFigure move this label will move(label use locator to locate himself). I
> > want to use this label to set anther model's(Model2) name when this model
> > was created in current MyModel. in refreshVisual() I refresh the label's
> > text by propertyChange.
> > Now has some problems:
> > protected IFigure createFigure(){
> > MainFigure myFigure = new MainFigure();
> > Label l = new Label("");
> > this.getParent().getFigure().add(l); // get parent to add this label.
> > l.setLocation(new Point(myFigure.getBounds().x -
> > 20,myFigure.getBounds().y);// but when I save it and open again it stills
> > in top left corner
> > return myFigure;
> > }
> > protected void refreshVisuals(){
> > Model1 m1 = myModel.getModel1();
> > l.setText(m1.getName);
> > this.getParent().setLayoutConstraint(null,l,new MyLocator(myFigure));
> > }
> Don't now exactly but you instantiate the Label in createFigure() as local
> variable. You want to refresh Label "l" which is not the label you
> instantiated, or?
> Seems to be the mistake, am I right?
> Martin
|
|
|
Re: Decorating EditPart with Label [message #146605 is a reply to message #146399] |
Thu, 05 August 2004 09:56 |
Eclipse User |
|
|
|
Originally posted by: mastr.arcor.de
daniel wrote:
> Sorry, it's my fault. Label l is global variable in MainFigure. I want to
> refresh the l in refreshVisuals()
> where can I initantiate the l? I want to assign a Label for every
> MainFigure
> and when refreshVisuals() I want to refresh the label's location and
> contents
So you have to call ((MainFigure)getFigure()).getLabel() which returns
your global l Label in refreshVisuals() method.
Is it that what you want to do?
CU, Martin.
|
|
|
Powered by
FUDForum. Page generated in 0.03676 seconds