Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » createChangeConstraintCommand; weird values getting passed in...
createChangeConstraintCommand; weird values getting passed in... [message #120484] Thu, 04 March 2004 07:30 Go to next message
Eclipse UserFriend
Originally posted by: smallpocks.yahoo.com

Hey Guys,
I have created a very simple graphical editor which allows the draging and
dropping of Figures. To this end, I have extended the XYLayoutEditPolicy,
and I have overridden the createChangeConstraintCommand(EditPart arg0,Object
arg1) method in this class. Everything seems to work, and when I drag a
figure and the createChangeConstraintCommand method figure is called, I cast
arg1 as a Rectangle. The only problem is, while the x and y of the rectangle
are the valid point that I dragged the figure to, the height and width of
the rectangle are both -1, and I need these values to be the valid height
and width of the dragged figure. I checked the archives but couldn't find an
answer to my problem. I'm using a XYLayout on my content Figure, if this
helps. Thanks in advance for any help.
Guy
Re: createChangeConstraintCommand; weird values getting passed in... [message #120617 is a reply to message #120484] Thu, 04 March 2004 17:16 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
If you've just dragged a figure, then only its location would change, not
its size. Then why do you need the size of the rectangle? Take a look at
LogicXYLayoutEditPolicy to see what it does.

If you really must figure out the size of the rectangle, you can always get
the Figure from the EditPart (cast it to GraphicalEditPart) that is passed
as a parameter to that method.

"Guy Beckman" <smallpocks@yahoo.com> wrote in message
news:c26lic$k7k$1@eclipse.org...
> Hey Guys,
> I have created a very simple graphical editor which allows the draging and
> dropping of Figures. To this end, I have extended the XYLayoutEditPolicy,
> and I have overridden the createChangeConstraintCommand(EditPart
arg0,Object
> arg1) method in this class. Everything seems to work, and when I drag a
> figure and the createChangeConstraintCommand method figure is called, I
cast
> arg1 as a Rectangle. The only problem is, while the x and y of the
rectangle
> are the valid point that I dragged the figure to, the height and width of
> the rectangle are both -1, and I need these values to be the valid height
> and width of the dragged figure. I checked the archives but couldn't find
an
> answer to my problem. I'm using a XYLayout on my content Figure, if this
> helps. Thanks in advance for any help.
> Guy
>
>
Re: createChangeConstraintCommand; weird values getting passed in... [message #120878 is a reply to message #120617] Fri, 05 March 2004 01:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smallpocks.yahoo.com

Well upon further examination, it seems as if you are right here. Resize the
figure, the rectangle passed to createChangeConstraintCommand has valid
height, width, x and y. However if I just try and drag the figure, the
height and width are both -1. Is this just to let me know that the size
hasn't changed? This is a little awkward for me because if means that I'll
have to check to see if the size is -1, instead of just automatically
setting it...
Thanks


"Pratik Shah" <ppshah@us.ibm.com> wrote in message
news:c27o2h$5g2$1@eclipse.org...
> If you've just dragged a figure, then only its location would change, not
> its size. Then why do you need the size of the rectangle? Take a look at
> LogicXYLayoutEditPolicy to see what it does.
>
> If you really must figure out the size of the rectangle, you can always
get
> the Figure from the EditPart (cast it to GraphicalEditPart) that is passed
> as a parameter to that method.
>
> "Guy Beckman" <smallpocks@yahoo.com> wrote in message
> news:c26lic$k7k$1@eclipse.org...
> > Hey Guys,
> > I have created a very simple graphical editor which allows the draging
and
> > dropping of Figures. To this end, I have extended the
XYLayoutEditPolicy,
> > and I have overridden the createChangeConstraintCommand(EditPart
> arg0,Object
> > arg1) method in this class. Everything seems to work, and when I drag a
> > figure and the createChangeConstraintCommand method figure is called, I
> cast
> > arg1 as a Rectangle. The only problem is, while the x and y of the
> rectangle
> > are the valid point that I dragged the figure to, the height and width
of
> > the rectangle are both -1, and I need these values to be the valid
height
> > and width of the dragged figure. I checked the archives but couldn't
find
> an
> > answer to my problem. I'm using a XYLayout on my content Figure, if this
> > helps. Thanks in advance for any help.
> > Guy
> >
> >
>
>
Re: createChangeConstraintCommand; weird values getting passed in... [message #120967 is a reply to message #120878] Fri, 05 March 2004 18:37 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Hmm, what version of GEF are you using? I just looked at
LogicXYLayoutEditPolicy.createChangeConstraintCommand(Reques t, EditPart,
Object) and I see the correct size being passed everytime, irrespective of
whether it's a move or resize.

"Guy Beckman" <smallpocks@yahoo.com> wrote in message
news:c28kt0$5oa$1@eclipse.org...
> Well upon further examination, it seems as if you are right here. Resize
the
> figure, the rectangle passed to createChangeConstraintCommand has valid
> height, width, x and y. However if I just try and drag the figure, the
> height and width are both -1. Is this just to let me know that the size
> hasn't changed? This is a little awkward for me because if means that I'll
> have to check to see if the size is -1, instead of just automatically
> setting it...
> Thanks
>
>
> "Pratik Shah" <ppshah@us.ibm.com> wrote in message
> news:c27o2h$5g2$1@eclipse.org...
> > If you've just dragged a figure, then only its location would change,
not
> > its size. Then why do you need the size of the rectangle? Take a look
at
> > LogicXYLayoutEditPolicy to see what it does.
> >
> > If you really must figure out the size of the rectangle, you can always
> get
> > the Figure from the EditPart (cast it to GraphicalEditPart) that is
passed
> > as a parameter to that method.
> >
> > "Guy Beckman" <smallpocks@yahoo.com> wrote in message
> > news:c26lic$k7k$1@eclipse.org...
> > > Hey Guys,
> > > I have created a very simple graphical editor which allows the draging
> and
> > > dropping of Figures. To this end, I have extended the
> XYLayoutEditPolicy,
> > > and I have overridden the createChangeConstraintCommand(EditPart
> > arg0,Object
> > > arg1) method in this class. Everything seems to work, and when I drag
a
> > > figure and the createChangeConstraintCommand method figure is called,
I
> > cast
> > > arg1 as a Rectangle. The only problem is, while the x and y of the
> > rectangle
> > > are the valid point that I dragged the figure to, the height and width
> of
> > > the rectangle are both -1, and I need these values to be the valid
> height
> > > and width of the dragged figure. I checked the archives but couldn't
> find
> > an
> > > answer to my problem. I'm using a XYLayout on my content Figure, if
this
> > > helps. Thanks in advance for any help.
> > > Guy
> > >
> > >
> >
> >
>
>
Re: createChangeConstraintCommand; weird values getting passed in... [message #120992 is a reply to message #120967] Fri, 05 March 2004 19:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

It is possible that the current size (of the constraint) it -1,-1, meaning
"auto-size" in XYLayout, in which case we preserve that during moves.
Re: createChangeConstraintCommand; weird values getting passed in... [message #121009 is a reply to message #120992] Sat, 06 March 2004 00:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smallpocks.yahoo.com

Hmm, I think you might be on to something.
This is how I initially set the size of my figure, where "size" comes from
my model. And yes, I use an XYLayout for my layout manager.

FigureEditPart::refreshVisuals() {
....
fig.setPreferredSize(size);
Rectangle r = new Rectangle(location.x,location.y,-1,-1);
((GraphicalEditPart) getParent()).setLayoutConstraint(this, fig, r);
....
}

I know that those -1s mean to give the figure its preferred size. Is this
why I am getting -1 for width and height when I drag my figure?
Thanks
Guy


"Randy Hudson" <none@us.ibm.com> wrote in message
news:c2aksg$gtl$1@eclipse.org...
> It is possible that the current size (of the constraint) it -1,-1, meaning
> "auto-size" in XYLayout, in which case we preserve that during moves.
Re: createChangeConstraintCommand; weird values getting passed in... [message #121146 is a reply to message #121009] Tue, 09 March 2004 18:41 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Yes.

"Guy Beckman" <smallpocks@yahoo.com> wrote in message
news:c2b511$370$1@eclipse.org...
> Hmm, I think you might be on to something.
> This is how I initially set the size of my figure, where "size" comes from
> my model. And yes, I use an XYLayout for my layout manager.
>
> FigureEditPart::refreshVisuals() {
> ...
> fig.setPreferredSize(size);
> Rectangle r = new Rectangle(location.x,location.y,-1,-1);
> ((GraphicalEditPart) getParent()).setLayoutConstraint(this, fig, r);
> ...
> }
>
> I know that those -1s mean to give the figure its preferred size. Is this
> why I am getting -1 for width and height when I drag my figure?
> Thanks
> Guy
>
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:c2aksg$gtl$1@eclipse.org...
> > It is possible that the current size (of the constraint) it -1,-1,
meaning
> > "auto-size" in XYLayout, in which case we preserve that during moves.
>
>
Previous Topic:Model has undirected connections; ConnectionEditPart?
Next Topic:Why isn't the SelectionTool working?
Goto Forum:
  


Current Time: Wed Jul 17 20:17:25 GMT 2024

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

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

Back to the top