Skip to main content



      Home
Home » Eclipse Projects » GEF » moving figures within figures
moving figures within figures [message #44026] Wed, 20 November 2002 21:22 Go to next message
Eclipse UserFriend
Originally posted by: jayuen.alumni.uwaterloo.ca

Hi:

I am having a problem with figures that have children (i.e. figures to which
I have added figures).

I have an ellipse and I have added two polylines inside of it so the result
looks like a circle with an X inside it. When I drag and move the ellipse,
the ellipse moves but the lines that I have drawn inside don't move with it.
In fact, when I move my ellipse back to the it's original location, I can
see the children lines that I originally drew again! Currently I handle the
move doing something like this:

Point location = getGlyph().getLocation();
Dimension size = this.getFigure().getSize();
Rectangle rect = new Rectangle(location, size);
((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(),
rect);

However, when I step through the setLayoutConstraints method, I notice two
things.
1. The constraints of any child figures don't seem to be updated and,
2. A deprecated method called setConstraint is called.

I have tried setting a layout manager on my figure but it doesn't seem to do
anything. I was considering calling setConstraint of each of the figure's
children individually but I saw that the method was deprecated (I'm using
GEF 2.0.0). Any ideas?

Thanks,
Jason
Re: moving figures within figures [message #44057 is a reply to message #44026] Wed, 20 November 2002 21:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

Polylines cannot be used with regular layoutManagers. The intended usage is
that you simply set the points, and the bounds update accordingly.

There are older posts on this type of stuff.

"Jason Yuen" <jayuen@alumni.uwaterloo.ca> wrote in message
news:arhdqd$d15$1@rogue.oti.com...
> Hi:
>
> I am having a problem with figures that have children (i.e. figures to
which
> I have added figures).
>
> I have an ellipse and I have added two polylines inside of it so the
result
> looks like a circle with an X inside it. When I drag and move the
ellipse,
> the ellipse moves but the lines that I have drawn inside don't move with
it.
> In fact, when I move my ellipse back to the it's original location, I can
> see the children lines that I originally drew again! Currently I handle
the
> move doing something like this:
>
> Point location = getGlyph().getLocation();
> Dimension size = this.getFigure().getSize();
> Rectangle rect = new Rectangle(location, size);
> ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(),
> rect);
>
> However, when I step through the setLayoutConstraints method, I notice two
> things.
> 1. The constraints of any child figures don't seem to be updated and,
> 2. A deprecated method called setConstraint is called.
>
> I have tried setting a layout manager on my figure but it doesn't seem to
do
> anything. I was considering calling setConstraint of each of the figure's
> children individually but I saw that the method was deprecated (I'm using
> GEF 2.0.0). Any ideas?
>
> Thanks,
> Jason
>
>
>
Re: moving figures within figures [message #44265 is a reply to message #44026] Thu, 21 November 2002 08:15 Go to previous messageGo to next message
Eclipse UserFriend
changing layout constraints of editparts are performed by
LayoutEditPolicies. putting them to the location specified by constraints
are performed by layoutmanagers. policies can only be installed to
editparts, which means, what you set constraint(move) is editpart in
reality. of course the figure bound to this edit part is (protected void
refreshVisuals()) also set this constraint, which then laid out(moved) by
layoutmanager.

so, make a figure(a single figure, which is ellipse) with two children
figures(which are lines), then make this figure, figure of editpart, then it
will move correctly.

ozz

"Jason Yuen" <jayuen@alumni.uwaterloo.ca> wrote in message
news:arhdqd$d15$1@rogue.oti.com...
> Hi:
>
> I am having a problem with figures that have children (i.e. figures to
which
> I have added figures).
>
> I have an ellipse and I have added two polylines inside of it so the
result
> looks like a circle with an X inside it. When I drag and move the
ellipse,
> the ellipse moves but the lines that I have drawn inside don't move with
it.
> In fact, when I move my ellipse back to the it's original location, I can
> see the children lines that I originally drew again! Currently I handle
the
> move doing something like this:
>
> Point location = getGlyph().getLocation();
> Dimension size = this.getFigure().getSize();
> Rectangle rect = new Rectangle(location, size);
> ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(),
> rect);
>
> However, when I step through the setLayoutConstraints method, I notice two
> things.
> 1. The constraints of any child figures don't seem to be updated and,
> 2. A deprecated method called setConstraint is called.
>
> I have tried setting a layout manager on my figure but it doesn't seem to
do
> anything. I was considering calling setConstraint of each of the figure's
> children individually but I saw that the method was deprecated (I'm using
> GEF 2.0.0). Any ideas?
>
> Thanks,
> Jason
>
>
>
Re: moving figures within figures [message #44548 is a reply to message #44265] Thu, 21 November 2002 11:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jayuen.alumni.uwaterloo.ca

Thanks Oz, Randy:

After reading Randy' comments, I put some code to redraw the lines (i.e.
removing the lines and then adding two new ones) each time I move the parent
glyph. With this method, I am a little concerned that the continual
redrawing may introduce some lags if the glyph is moved around alot. When
I did some quick testing, the UI response was pretty snappy but I suspect
that this might not be the most elegant solution.

Creating new edit parts (as Oz has suggested), seems to be a more elegant
solution. However, would creating these extra "line" edit parts incur
significant overhead and bloat the program size if many of these glyphs were
to be drawn?

Thanks for your help,

Jason

"Ozgur Kurt" <ozgurkurt@hotmail.com> wrote in message
news:arik4m$187$1@rogue.oti.com...
> changing layout constraints of editparts are performed by
> LayoutEditPolicies. putting them to the location specified by constraints
> are performed by layoutmanagers. policies can only be installed to
> editparts, which means, what you set constraint(move) is editpart in
> reality. of course the figure bound to this edit part is (protected void
> refreshVisuals()) also set this constraint, which then laid out(moved) by
> layoutmanager.
>
> so, make a figure(a single figure, which is ellipse) with two children
> figures(which are lines), then make this figure, figure of editpart, then
it
> will move correctly.
>
> ozz
>
> "Jason Yuen" <jayuen@alumni.uwaterloo.ca> wrote in message
> news:arhdqd$d15$1@rogue.oti.com...
> > Hi:
> >
> > I am having a problem with figures that have children (i.e. figures to
> which
> > I have added figures).
> >
> > I have an ellipse and I have added two polylines inside of it so the
> result
> > looks like a circle with an X inside it. When I drag and move the
> ellipse,
> > the ellipse moves but the lines that I have drawn inside don't move with
> it.
> > In fact, when I move my ellipse back to the it's original location, I
can
> > see the children lines that I originally drew again! Currently I handle
> the
> > move doing something like this:
> >
> > Point location = getGlyph().getLocation();
> > Dimension size = this.getFigure().getSize();
> > Rectangle rect = new Rectangle(location, size);
> > ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(),
> > rect);
> >
> > However, when I step through the setLayoutConstraints method, I notice
two
> > things.
> > 1. The constraints of any child figures don't seem to be updated and,
> > 2. A deprecated method called setConstraint is called.
> >
> > I have tried setting a layout manager on my figure but it doesn't seem
to
> do
> > anything. I was considering calling setConstraint of each of the
figure's
> > children individually but I saw that the method was deprecated (I'm
using
> > GEF 2.0.0). Any ideas?
> >
> > Thanks,
> > Jason
> >
> >
> >
>
>
Re: moving figures within figures [message #44809 is a reply to message #44548] Fri, 22 November 2002 08:28 Go to previous message
Eclipse UserFriend
you will draw three figures(not three editparts), one of them, which is
parent will be figure of edit part, there will be one editpart. if i were
you, i would go ahead and subclass figure to supply my paint method, and
paint ellipse and lines by myself... like the following code... i didn't
write painting method of course. it's easy...


public class EllipseLinesFigure
extends Figure
{

protected void paintFigure(Graphics g)
{
Rectangle rClient = getBounds();

Color color = BPMResources.clInputPort;

g.setBackgroundColor(color);
g.fillRectangle(rClient);

// g.setForegroundColor(FigureUtilities.lighter(color));
// g.drawLine(rClient.x, rClient.y, rClient.right(), rClient.y);
// g.drawLine(rClient.x, rClient.y, rClient.x, rClient.bottom());
//
// g.setForegroundColor(FigureUtilities.darker(color));
// g.drawLine(rClient.right(), rClient.y, rClient.right(),
rClient.bottom());
// g.drawLine(rClient.x, rClient.bottom(), rClient.right(),
rClient.bottom());
//
// rClient.crop( new Insets(1) );
// g.setForegroundColor(FigureUtilities.lighter(color));
// g.drawLine(rClient.x, rClient.y, rClient.right(), rClient.y);
// g.drawLine(rClient.x, rClient.y, rClient.x, rClient.bottom());
//
// g.setForegroundColor(FigureUtilities.darker(color));
// g.drawLine(rClient.right(), rClient.y, rClient.right(),
rClient.bottom());
// g.drawLine(rClient.x, rClient.bottom(), rClient.right(),
rClient.bottom());
// g.setForegroundColor(BPMResources.clBlack);

g.drawRectangle(rClient);

g.setForegroundColor(BPMResources.clBlack);
g.setFont(BPMResources.fnPortFont);
g.translate(bounds.x, bounds.y);
g.drawString(strLabel, 3, 1);
}

public Dimension getPreferredSize(int wHint, int hHint)
{
if(dText == null)
{
dText = FigureUtilities.getTextExtents(strLabel,
BPMResources.fnPortFont);
dText.height += 3;
dText.width += 5;
}

return dText;
}

}

i would recommend not care much about performance issues. if you do the
things in a correct way, you will not lose much performance, and further you
will have readible and elegant code.

"Jason Yuen" <jayuen@alumni.uwaterloo.ca> wrote in message
news:arivp9$b1g$1@rogue.oti.com...
> Thanks Oz, Randy:
>
> After reading Randy' comments, I put some code to redraw the lines (i.e.
> removing the lines and then adding two new ones) each time I move the
parent
> glyph. With this method, I am a little concerned that the continual
> redrawing may introduce some lags if the glyph is moved around alot.
When
> I did some quick testing, the UI response was pretty snappy but I suspect
> that this might not be the most elegant solution.
>
> Creating new edit parts (as Oz has suggested), seems to be a more elegant
> solution. However, would creating these extra "line" edit parts incur
> significant overhead and bloat the program size if many of these glyphs
were
> to be drawn?
>
> Thanks for your help,
>
> Jason
>
> "Ozgur Kurt" <ozgurkurt@hotmail.com> wrote in message
> news:arik4m$187$1@rogue.oti.com...
> > changing layout constraints of editparts are performed by
> > LayoutEditPolicies. putting them to the location specified by
constraints
> > are performed by layoutmanagers. policies can only be installed to
> > editparts, which means, what you set constraint(move) is editpart in
> > reality. of course the figure bound to this edit part is (protected void
> > refreshVisuals()) also set this constraint, which then laid out(moved)
by
> > layoutmanager.
> >
> > so, make a figure(a single figure, which is ellipse) with two children
> > figures(which are lines), then make this figure, figure of editpart,
then
> it
> > will move correctly.
> >
> > ozz
> >
> > "Jason Yuen" <jayuen@alumni.uwaterloo.ca> wrote in message
> > news:arhdqd$d15$1@rogue.oti.com...
> > > Hi:
> > >
> > > I am having a problem with figures that have children (i.e. figures to
> > which
> > > I have added figures).
> > >
> > > I have an ellipse and I have added two polylines inside of it so the
> > result
> > > looks like a circle with an X inside it. When I drag and move the
> > ellipse,
> > > the ellipse moves but the lines that I have drawn inside don't move
with
> > it.
> > > In fact, when I move my ellipse back to the it's original location, I
> can
> > > see the children lines that I originally drew again! Currently I
handle
> > the
> > > move doing something like this:
> > >
> > > Point location = getGlyph().getLocation();
> > > Dimension size = this.getFigure().getSize();
> > > Rectangle rect = new Rectangle(location, size);
> > > ((GraphicalEditPart)getParent()).setLayoutConstraint(this,
getFigure(),
> > > rect);
> > >
> > > However, when I step through the setLayoutConstraints method, I notice
> two
> > > things.
> > > 1. The constraints of any child figures don't seem to be updated and,
> > > 2. A deprecated method called setConstraint is called.
> > >
> > > I have tried setting a layout manager on my figure but it doesn't seem
> to
> > do
> > > anything. I was considering calling setConstraint of each of the
> figure's
> > > children individually but I saw that the method was deprecated (I'm
> using
> > > GEF 2.0.0). Any ideas?
> > >
> > > Thanks,
> > > Jason
> > >
> > >
> > >
> >
> >
>
>
Previous Topic:[contribution] Hello Gef 1 released for GEF 1.0
Next Topic:Difference between LogicDiagramFactory and LogicTemplateFactory in logic editor example
Goto Forum:
  


Current Time: Tue Jul 08 02:18:58 EDT 2025

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

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

Back to the top