Home » Eclipse Projects » GEF » question on draw2d translateToAbsolute() and translateToRelative()
question on draw2d translateToAbsolute() and translateToRelative() [message #68922] |
Mon, 10 March 2003 10:13  |
Eclipse User |
|
|
|
Originally posted by: aroberts.bowstreet.com
I'm creating figures that contain nested figures, and I'm using local
coordinates in each figure. I also have a connection router that routes
connectors to and from children figures. All was fine and well until
scrolling came into play, when I noticed some strange x, y locations coming
back from nested figures. I looked at Figure.translateToAbsolute(), and
something looked funny to me. Can someone explain whether my interpretation
is right or wrong.
Here's Figure.translateToAbsolute()
public final void translateToAbsolute(Translatable t) {
if (getParent() != null) {
getParent().translateToParent(t);
getParent().translateToAbsolute(t);
}
}
I would think this should be:
public final void translateToAbsolute(Translatable t) {
if (getParent() != null) {
translateToParent(t);
getParent().translateToAbsolute(t);
}
}
Here's my reasoning. The method's job is to translate a point relative to
its own csys to absolute. To do this, the figure first translates the point
from being relative to its own csys to being relative to the csys of its
parent by calling its own translateToParent() method. Then, it asks its
parent to do a translateToAbsolute(). This takes the point from being
relative to the parent to being relative to absolute. The problem I have
with the method the way it is in Figure today is that its asking its parent
to translate to the parent's parent. The first call appears to be one level
too high. The same problem, in my opinion, exists in translateToRelative.
It should be changed from what it is today:
public final void translateToRelative(Translatable t) {
if (getParent() != null) {
getParent().translateToRelative(t);
getParent().translateFromParent(t);
}
}
to
public final void translateToRelative(Translatable t) {
if (getParent() != null) {
getParent().translateToRelative(t);
translateFromParent(t);
}
}
The latter one asks the parent to translate from absolute to parent csys
space, and then the figure translates from parent to its own.
I'd like to know if my interpretation is right or wrong.
Thanks;
Andy Roberts
|
|
|
Re: question on draw2d translateToAbsolute() and translateToRelative() [message #68964 is a reply to message #68922] |
Mon, 10 March 2003 11:20   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Relative to the figure means relative to that figure's bounds, not that
figure's children. A figure's bounds is a function of its parent's
coordinate system, not its own. So, when you take an absolute point and
call translateToRelative on a figure, you can then hit-test that point with
the figure's bounds.
If the only problem you are seeing is with scrolling, then this "off by one"
issue is probably not the problem. The Viewport is way up the chain. It is
probably an issue of the connection layer scrolling. How are the viewport
and connections being created?
"Andy Roberts" <aroberts@bowstreet.com> wrote in message
news:b4ia90$18b$1@rogue.oti.com...
> I'm creating figures that contain nested figures, and I'm using local
> coordinates in each figure. I also have a connection router that routes
> connectors to and from children figures. All was fine and well until
> scrolling came into play, when I noticed some strange x, y locations
coming
> back from nested figures. I looked at Figure.translateToAbsolute(), and
> something looked funny to me. Can someone explain whether my
interpretation
> is right or wrong.
>
> Here's Figure.translateToAbsolute()
>
> public final void translateToAbsolute(Translatable t) {
> if (getParent() != null) {
> getParent().translateToParent(t);
> getParent().translateToAbsolute(t);
> }
> }
>
> I would think this should be:
>
> public final void translateToAbsolute(Translatable t) {
> if (getParent() != null) {
> translateToParent(t);
> getParent().translateToAbsolute(t);
> }
> }
>
> Here's my reasoning. The method's job is to translate a point relative to
> its own csys to absolute. To do this, the figure first translates the
point
> from being relative to its own csys to being relative to the csys of its
> parent by calling its own translateToParent() method. Then, it asks its
> parent to do a translateToAbsolute(). This takes the point from being
> relative to the parent to being relative to absolute. The problem I have
> with the method the way it is in Figure today is that its asking its
parent
> to translate to the parent's parent. The first call appears to be one
level
> too high. The same problem, in my opinion, exists in translateToRelative.
> It should be changed from what it is today:
>
> public final void translateToRelative(Translatable t) {
> if (getParent() != null) {
> getParent().translateToRelative(t);
> getParent().translateFromParent(t);
> }
> }
>
> to
>
> public final void translateToRelative(Translatable t) {
> if (getParent() != null) {
> getParent().translateToRelative(t);
> translateFromParent(t);
> }
> }
>
> The latter one asks the parent to translate from absolute to parent csys
> space, and then the figure translates from parent to its own.
>
> I'd like to know if my interpretation is right or wrong.
>
> Thanks;
>
> Andy Roberts
>
>
|
|
|
understanding of local csys's in nested figures [message #69025 is a reply to message #68964] |
Mon, 10 March 2003 12:22   |
Eclipse User |
|
|
|
Originally posted by: aroberts.bowstreet.com
Hi Randy;
I want to make sure I'm working off the same understanding of local csys's
and nested figures before we move on.
If a figure called child is located at x=10, y=10 inside a figure called
parent, then child.getBounds().x will return 10, assuming each figure is
using local coordinates. This would confirm what you say below that
getBounds() is a function of its parent. Next, let's say that this child
has a point inside it at 5, 5, and someone wants to translate it from the
child's local csys to that of its parent. One would call
child.translateToParent(new Point(5, 5)). Assuming no insets, the result
would be 15, 15, which is the location of the child's internal point, but
now described relative to the parent's coordinate frame. The snippet of
code from Figure.translateToParent() below confirms this behavior.
public void translateToParent(Translatable t) {
if (useLocalCoordinates())
t.performTranslate(getBounds().x + getInsets().left, getBounds().y +
getInsets().top);
}
So, ultimately, if you call child.translateToAbsolute(new Point(5,5)), you'd
expect the child to first call its own translateToParent() method to get
15,15. Then, you'd expect the child to call on its parent to convert 15,15
to absolute coordinates. This would be done with
child.getOwner().translateToAbsolute(), using 15,15 as the argument.
Sorry to keep asking about this functionality, but I still don't understand
why translateToAbsolute() and translateToRelative() are the way they are
today in Figure. I still would think that translate toAbsolute() would look
like the following:
public final void translateToAbsolute(Translatable t) {
if (getParent() != null) {
translateToParent(t);
getParent().translateToAbsolute(t);
}
}
Finally, when I look at the translateToAbsolute() source code today,
something looks odd about it. It's a recursive function where all the work
is being done by the parent. I'm used to working with recursive functions
that perform some work themselves, and then call the recursive function on a
perent or child.
Can you describe the rational behind how translateToAbsolute() works today
if I'm still wrong.
On your question about how I create the Viewport and Connections, I do it as
follows:
I have a class that extends ViewPart and implements
createPartControl(Composite parent). This method creates a Panel that
displays directed graph structures, and a FigureCanvas that handles
scrolling. Next, I add Containers and Connectors, that extend Figure, to
the panel. Both the panel and containers/connectors implement
useLocalCoordinates = true.
My connectors extend PolylineConnection, and my connection router is very
similar to the ManhattanConnectionRouter. The difference is that the router
gets point locations relative to the anchor point parent containers, and
these container location values come back wrong when the panel is huge and
I'm scrolled down. Basically I get locations that are offset by the amount
that the user has vertically and horizontally scrolled.
Let me know if you need more info. Thanks - Andy R.
figureCanvas = new FigureCanvas(parent);
figureCanvas.setScrollBarVisibility(FigureCanvas.ALWAYS);
figureCanvas.setContents(directedGraphPanel);
figureCanvas.setParent(parent);
"Randy Hudson" <none@us.ibm.com> wrote in message
news:b4ie63$5g2$1@rogue.oti.com...
> Relative to the figure means relative to that figure's bounds, not that
> figure's children. A figure's bounds is a function of its parent's
> coordinate system, not its own. So, when you take an absolute point and
> call translateToRelative on a figure, you can then hit-test that point
with
> the figure's bounds.
>
> If the only problem you are seeing is with scrolling, then this "off by
one"
> issue is probably not the problem. The Viewport is way up the chain. It
is
> probably an issue of the connection layer scrolling. How are the viewport
> and connections being created?
>
> "Andy Roberts" <aroberts@bowstreet.com> wrote in message
> news:b4ia90$18b$1@rogue.oti.com...
> > I'm creating figures that contain nested figures, and I'm using local
> > coordinates in each figure. I also have a connection router that routes
> > connectors to and from children figures. All was fine and well until
> > scrolling came into play, when I noticed some strange x, y locations
> coming
> > back from nested figures. I looked at Figure.translateToAbsolute(), and
> > something looked funny to me. Can someone explain whether my
> interpretation
> > is right or wrong.
> >
> > Here's Figure.translateToAbsolute()
> >
> > public final void translateToAbsolute(Translatable t) {
> > if (getParent() != null) {
> > getParent().translateToParent(t);
> > getParent().translateToAbsolute(t);
> > }
> > }
> >
> > I would think this should be:
> >
> > public final void translateToAbsolute(Translatable t) {
> > if (getParent() != null) {
> > translateToParent(t);
> > getParent().translateToAbsolute(t);
> > }
> > }
> >
> > Here's my reasoning. The method's job is to translate a point relative
to
> > its own csys to absolute. To do this, the figure first translates the
> point
> > from being relative to its own csys to being relative to the csys of its
> > parent by calling its own translateToParent() method. Then, it asks its
> > parent to do a translateToAbsolute(). This takes the point from being
> > relative to the parent to being relative to absolute. The problem I
have
> > with the method the way it is in Figure today is that its asking its
> parent
> > to translate to the parent's parent. The first call appears to be one
> level
> > too high. The same problem, in my opinion, exists in
translateToRelative.
> > It should be changed from what it is today:
> >
> > public final void translateToRelative(Translatable t) {
> > if (getParent() != null) {
> > getParent().translateToRelative(t);
> > getParent().translateFromParent(t);
> > }
> > }
> >
> > to
> >
> > public final void translateToRelative(Translatable t) {
> > if (getParent() != null) {
> > getParent().translateToRelative(t);
> > translateFromParent(t);
> > }
> > }
> >
> > The latter one asks the parent to translate from absolute to parent csys
> > space, and then the figure translates from parent to its own.
> >
> > I'd like to know if my interpretation is right or wrong.
> >
> > Thanks;
> >
> > Andy Roberts
> >
> >
>
>
|
|
|
Re: understanding of local csys's in nested figures [message #69049 is a reply to message #69025] |
Mon, 10 March 2003 13:20   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
"Andy Roberts" <aroberts@bowstreet.com> wrote in message
news:b4ihqr$92e$1@rogue.oti.com...
> Hi Randy;
>
> I want to make sure I'm working off the same understanding of local csys's
> and nested figures before we move on.
>
> If a figure called child is located at x=10, y=10 inside a figure called
> parent, then child.getBounds().x will return 10, assuming each figure is
> using local coordinates. This would confirm what you say below that
> getBounds() is a function of its parent. Next, let's say that this child
> has a point inside it at 5, 5,
But that is the problem. (5,5) is *not* inside the child, since the child
is located at 10,10.
If you are talking about 5,5 in the child's client area, you must first call
translateToParent, then translate to absolute.
Here is the typical case around which the coordinates systems are modeled.
You have a figure, and you want to know its absolute bounds. So, you call:
Rectangle r = figure.getBounds().getCopy();
figure.translateToAbsolute(r);
> child's local csys to that of its parent. One would call
> child.translateToParent(new Point(5, 5)). Assuming no insets, the result
> would be 15, 15, which is the location of the child's internal point, but
> now described relative to the parent's coordinate frame. The snippet of
> code from Figure.translateToParent() below confirms this behavior.
> public void translateToParent(Translatable t) {
>
> if (useLocalCoordinates())
>
> t.performTranslate(getBounds().x + getInsets().left, getBounds().y +
> getInsets().top);
>
> }
>
> So, ultimately, if you call child.translateToAbsolute(new Point(5,5)),
you'd
> expect the child to first call its own translateToParent() method to get
> 15,15. Then, you'd expect the child to call on its parent to convert
15,15
> to absolute coordinates. This would be done with
> child.getOwner().translateToAbsolute(), using 15,15 as the argument.
>
> Sorry to keep asking about this functionality, but I still don't
understand
> why translateToAbsolute() and translateToRelative() are the way they are
> today in Figure. I still would think that translate toAbsolute() would
look
> like the following:
>
> public final void translateToAbsolute(Translatable t) {
> if (getParent() != null) {
> translateToParent(t);
> getParent().translateToAbsolute(t);
> }
> }
>
> Finally, when I look at the translateToAbsolute() source code today,
> something looks odd about it. It's a recursive function where all the
work
> is being done by the parent. I'm used to working with recursive functions
> that perform some work themselves, and then call the recursive function on
a
> perent or child.
> Can you describe the rational behind how translateToAbsolute() works today
> if I'm still wrong.
It is setup for convenience. The typical operation deals with a figure f,
and that figure's bounds.
> > My connectors extend PolylineConnection, and my connection router is
very
> similar to the ManhattanConnectionRouter. The difference is that the
router
> gets point locations relative to the anchor point parent containers, and
> these container location values come back wrong when the panel is huge and
> I'm scrolled down. Basically I get locations that are offset by the
amount
> that the user has vertically and horizontally scrolled.
ConnectionAnchor returns an absolute point. Therefore, your router must
make the endpoint relative to the connection. You must call
polylineConnection.translateToRelative(endpoint); this should fix your
problems.
|
|
|
Re: understanding of local csys's in nested figures [message #69113 is a reply to message #69049] |
Mon, 10 March 2003 17:57   |
Eclipse User |
|
|
|
Originally posted by: aroberts.bowstreet.com
Hi Randy;
Thanks for the reply. I did find and solve the problem - thanks to your
comments. On the problem, I had forgotten to convert some of the container
bounds to absolute coords. So, my connection router was working with a
mixed bag of locations - some points that were absolute, and some that were
not. I was already doing a polylineConnection.translateToRelative(endpoint)
on all my computed points at the end.
On the use of nested Figures with local coordinates, I still have a problem
with the behavior of the following simple snippet. translateToParent()
works fine, but TranslateToAbsolute() doesn't work in a manner that's
consistent.
public class TestRectangle extends RectangleFigure {
private String name;
public TestRectangle(String name)
{
this.name = name;
}
protected boolean useLocalCoordinates() {
return true;
}
}
TestRectangle parent = new TestRectangle("parent");
parent.setBounds(new Rectangle(100, 100, 100, 100));
parent.setBackgroundColor(ColorConstants.lightGreen);
directedGraphPanel.add(parent);
TestRectangle child = new TestRectangle("child");
child.setBounds(new Rectangle(10, 10, 80, 80));
child.setBackgroundColor(ColorConstants.lightBlue);
parent.add(child);
TestRectangle grandChild = new TestRectangle("grandChild");
grandChild.setBounds(new Rectangle(5, 5, 70, 70));
grandChild.setBackgroundColor(ColorConstants.lightGray);
child.add(grandChild);
// the following gives back (5,5,70,70)
Rectangle grandChildRelativeToChild1 = grandChild.getBounds().getCopy();
// the following correctly gives back (15,15,70,70)
child.translateToParent(grandChildRelativeToChild1);
// the following gives back (5,5,70,70) as before
Rectangle grandChildRelativeToChild2 = grandChild.getBounds().getCopy();
// the following should give back (115,115,70,70) - but actually gives back
(105,105,70,70)
child.translateToAbsolute(grandChildRelativeToChild2);
Any help on understanding the behavior of child.translateToAbsolute() above
would be great.
Andy R.
"Randy Hudson" <none@us.ibm.com> wrote in message
news:b4il6p$cev$1@rogue.oti.com...
>
> "Andy Roberts" <aroberts@bowstreet.com> wrote in message
> news:b4ihqr$92e$1@rogue.oti.com...
> > Hi Randy;
> >
> > I want to make sure I'm working off the same understanding of local
csys's
> > and nested figures before we move on.
> >
> > If a figure called child is located at x=10, y=10 inside a figure called
> > parent, then child.getBounds().x will return 10, assuming each figure is
> > using local coordinates. This would confirm what you say below that
> > getBounds() is a function of its parent. Next, let's say that this
child
> > has a point inside it at 5, 5,
>
> But that is the problem. (5,5) is *not* inside the child, since the child
> is located at 10,10.
> If you are talking about 5,5 in the child's client area, you must first
call
> translateToParent, then translate to absolute.
>
> Here is the typical case around which the coordinates systems are modeled.
> You have a figure, and you want to know its absolute bounds. So, you
call:
> Rectangle r = figure.getBounds().getCopy();
> figure.translateToAbsolute(r);
>
> > child's local csys to that of its parent. One would call
> > child.translateToParent(new Point(5, 5)). Assuming no insets, the
result
> > would be 15, 15, which is the location of the child's internal point,
but
> > now described relative to the parent's coordinate frame. The snippet of
> > code from Figure.translateToParent() below confirms this behavior.
> > public void translateToParent(Translatable t) {
> >
> > if (useLocalCoordinates())
> >
> > t.performTranslate(getBounds().x + getInsets().left, getBounds().y +
> > getInsets().top);
> >
> > }
> >
> > So, ultimately, if you call child.translateToAbsolute(new Point(5,5)),
> you'd
> > expect the child to first call its own translateToParent() method to get
> > 15,15. Then, you'd expect the child to call on its parent to convert
> 15,15
> > to absolute coordinates. This would be done with
> > child.getOwner().translateToAbsolute(), using 15,15 as the argument.
> >
> > Sorry to keep asking about this functionality, but I still don't
> understand
> > why translateToAbsolute() and translateToRelative() are the way they are
> > today in Figure. I still would think that translate toAbsolute() would
> look
> > like the following:
> >
> > public final void translateToAbsolute(Translatable t) {
> > if (getParent() != null) {
> > translateToParent(t);
> > getParent().translateToAbsolute(t);
> > }
> > }
> >
> > Finally, when I look at the translateToAbsolute() source code today,
> > something looks odd about it. It's a recursive function where all the
> work
> > is being done by the parent. I'm used to working with recursive
functions
> > that perform some work themselves, and then call the recursive function
on
> a
> > perent or child.
>
> > Can you describe the rational behind how translateToAbsolute() works
today
> > if I'm still wrong.
>
> It is setup for convenience. The typical operation deals with a figure f,
> and that figure's bounds.
>
> > > My connectors extend PolylineConnection, and my connection router is
> very
> > similar to the ManhattanConnectionRouter. The difference is that the
> router
> > gets point locations relative to the anchor point parent containers, and
> > these container location values come back wrong when the panel is huge
and
> > I'm scrolled down. Basically I get locations that are offset by the
> amount
> > that the user has vertically and horizontally scrolled.
>
> ConnectionAnchor returns an absolute point. Therefore, your router must
> make the endpoint relative to the connection. You must call
> polylineConnection.translateToRelative(endpoint); this should fix your
> problems.
>
>
|
|
|
Re: understanding of local csys's in nested figures [message #69252 is a reply to message #69113] |
Tue, 11 March 2003 11:19   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
This is a multi-part message in MIME format.
------=_NextPart_000_0019_01C2E7C0.0FDBDF00
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
>=20
> // the following correctly gives back (15,15,70,70)
>=20
> child.translateToParent(grandChildRelativeToChild1);
>=20
>=20
> // the following gives back (5,5,70,70) as before
>=20
> Rectangle grandChildRelativeToChild2 =3D =
grandChild.getBounds().getCopy();
>=20
> // the following should give back (115,115,70,70) - but actually gives =
back
> (105,105,70,70)
>=20
> child.translateToAbsolute(grandChildRelativeToChild2);
you should call either:
grandChild.translateToAbsolute(grandChildRelativeToChild2);
or the combination of
//This line translates from child's local coordinate system to the =
child's parent's coordinate system, thereby placing =
grandChildRelativeToChild2 relative to child's bounds (child's bounds is =
a rectangle in the *parent's* coordinate system, so the rect has been =
"translated to parent").
child.translateToParent(grandChildRelativeToChild2);
//This line takes a rectangle relative to child's bounds and makes it =
absolute
child.translateToAbsoluate(grandChildRelativeToChild2);
I have hopefully improved the JavaDoc for these methods.
------=_NextPart_000_0019_01C2E7C0.0FDBDF00
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>> <BR>> // the following =
correctly gives back=20
(15,15,70,70)<BR>> <BR>>=20
child.translateToParent(grandChildRelativeToChild1);<BR>> <BR>> =
<BR>>=20
// the following gives back (5,5,70,70) as before<BR>> <BR>> =
Rectangle=20
grandChildRelativeToChild2 =3D grandChild.getBounds().getCopy();<BR>> =
<BR>>=20
// the following should give back (115,115,70,70) - but actually gives=20
back<BR>> (105,105,70,70)<BR>> <BR>>=20
child.translateToAbsolute(grandChildRelativeToChild2);</FONT ></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>you should call either:</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>grandChild.translateToAbsolute(grandChildRelativeToChild2); </FON=
T></DIV>
<DIV><FONT face=3DArial size=3D2>or the combination of</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>//This line translates from child's =
local=20
coordinate system to the child's parent's coordinate system,=20
thereby placing grandChildRelativeToChild2 relative to child's =
bounds=20
(child's bounds is a rectangle in the *parent's* coordinate system, so =
the rect=20
has been "translated to parent").</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>child.translateToParent(grandChildRelativeToChild2); </FONT></DIV=
>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>//This line takes a rectangle relative =
to child's=20
bounds and makes it absolute</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>child.translateToAbsoluate(grandChildRelativeToChild2); </FONT></=
DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I have hopefully improved the =
JavaDoc for=20
these methods.</FONT></DIV></BODY></HTML>
------=_NextPart_000_0019_01C2E7C0.0FDBDF00--
|
|
|
Re: understanding of local csys's in nested figures [message #69293 is a reply to message #69252] |
Tue, 11 March 2003 11:46  |
Eclipse User |
|
|
|
Originally posted by: aroberts.bowstreet.com
This is a multi-part message in MIME format.
------=_NextPart_000_0027_01C2E7C3.E6B202E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Thanks Randy - I got it now.
Andy R.
"Randy Hudson" <none@us.ibm.com> wrote in message =
news:b4l2eg$1nf$1@rogue.oti.com...
>=20
> // the following correctly gives back (15,15,70,70)
>=20
> child.translateToParent(grandChildRelativeToChild1);
>=20
>=20
> // the following gives back (5,5,70,70) as before
>=20
> Rectangle grandChildRelativeToChild2 =3D =
grandChild.getBounds().getCopy();
>=20
> // the following should give back (115,115,70,70) - but actually =
gives back
> (105,105,70,70)
>=20
> child.translateToAbsolute(grandChildRelativeToChild2);
you should call either:
grandChild.translateToAbsolute(grandChildRelativeToChild2);
or the combination of
//This line translates from child's local coordinate system to the =
child's parent's coordinate system, thereby placing =
grandChildRelativeToChild2 relative to child's bounds (child's bounds is =
a rectangle in the *parent's* coordinate system, so the rect has been =
"translated to parent").
child.translateToParent(grandChildRelativeToChild2);
//This line takes a rectangle relative to child's bounds and makes it =
absolute
child.translateToAbsoluate(grandChildRelativeToChild2);
I have hopefully improved the JavaDoc for these methods.
------=_NextPart_000_0027_01C2E7C3.E6B202E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Thanks Randy - I got it =
now.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Andy R.</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Randy Hudson" <<A=20
href=3D"mailto:none@us.ibm.com">none@us.ibm.com</A>> wrote in =
message <A=20
=
href=3D"news:b4l2eg$1nf$1@rogue.oti.com">news:b4l2eg$1nf$1@rogue.oti.com<=
/A>...</DIV>
<DIV><FONT face=3DArial size=3D2>> <BR>> // the following =
correctly gives=20
back (15,15,70,70)<BR>> <BR>>=20
child.translateToParent(grandChildRelativeToChild1);<BR>> <BR>> =
<BR>>=20
// the following gives back (5,5,70,70) as before<BR>> <BR>> =
Rectangle=20
grandChildRelativeToChild2 =3D =
grandChild.getBounds().getCopy();<BR>>=20
<BR>> // the following should give back (115,115,70,70) - but =
actually=20
gives back<BR>> (105,105,70,70)<BR>> <BR>>=20
child.translateToAbsolute(grandChildRelativeToChild2);</FONT ></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>you should call either:</FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2>grandChild.translateToAbsolute(grandChildRelativeToChild2); </FON=
T></DIV>
<DIV><FONT face=3DArial size=3D2>or the combination of</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>//This line translates from child's =
local=20
coordinate system to the child's parent's coordinate system,=20
thereby placing grandChildRelativeToChild2 relative to child's =
bounds=20
(child's bounds is a rectangle in the *parent's* coordinate system, so =
the=20
rect has been "translated to parent").</FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2>child.translateToParent(grandChildRelativeToChild2); </FONT></DIV=
>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>//This line takes a rectangle =
relative to child's=20
bounds and makes it absolute</FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2>child.translateToAbsoluate(grandChildRelativeToChild2); </FONT></=
DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I have hopefully improved the =
JavaDoc for=20
these methods.</FONT></DIV></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_0027_01C2E7C3.E6B202E0--
|
|
|
Goto Forum:
Current Time: Mon Jul 14 14:53:15 EDT 2025
Powered by FUDForum. Page generated in 0.71030 seconds
|