Home » Eclipse Projects » GEF » createChangeConstraintCommand; weird values getting passed in... 
| createChangeConstraintCommand; weird values getting passed in... [message #120484] | 
Thu, 04 March 2004 02:30   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 12:16    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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] | 
Thu, 04 March 2004 20:31    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 13:37    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 #121009 is a reply to message #120992] | 
Fri, 05 March 2004 19:18    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 13:41   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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. 
> 
>
 |  
 |  
  |   
Goto Forum:
 
 Current Time: Mon Nov 03 23:18:14 EST 2025 
 Powered by  FUDForum. Page generated in 0.14955 seconds  
 |