Home » Eclipse Projects » GEF » how to get the location of an image in a label?
how to get the location of an image in a label? [message #167922] |
Fri, 11 February 2005 23:15  |
Eclipse User |
|
|
|
Originally posted by: yabing.crimsonlogic.com
Hi,
I am trying to create connections between two labels, which are decorated
with images. I use the following method to create the labels:
Label label = new Label("text", new Image(d, "d:\\mapitem_field.gif"));
now I want to get the location of the image in the label so that I can
make it as the anchor point for the connection between the labels.
currently I am using the follwing method to get the location:
Rectangle r = getOwner().getBounds().getCopy();
// return the rectangel of the label
return r.getRight();
can anyone tell me how I can revise the code above to get the location of
the image in the label? Thanks so much!
Yabing
|
|
| |
Re: how to get the location of an image in a label? [message #168051 is a reply to message #167941] |
Sun, 13 February 2005 21:25   |
Eclipse User |
|
|
|
Originally posted by: yabing.crimsonlogic.com
Hi Brian,
instead of org.eclipse.draw2d.geometry.Rectangle, the method
((Label)getOwner()).getIcon().getBounds() returns an instance of
org.eclipse.swt.graphics.Rectangle, which always returns x and y values of
0.
so i still don't know how I can get the position of the image rectangle
object.
Thanks,
Yabing
Brian Fernandes wrote:
> Yabing,
> Without thinking too much, this should give you the bounds of the image.
> Rectangle r = ((Label)getOwner()).getIcon().getBounds();
> Hope this helps,
> Brian.
> yabing chen wrote:
>> Hi,
>> I am trying to create connections between two labels, which are decorated
>> with images. I use the following method to create the labels:
>> Label label = new Label("text", new Image(d, "d:mapitem_field.gif"));
>> now I want to get the location of the image in the label so that I can
>> make it as the anchor point for the connection between the labels.
>> currently I am using the follwing method to get the location:
>> Rectangle r = getOwner().getBounds().getCopy();
>> // return the rectangel of the label
>> return r.getRight();
>> can anyone tell me how I can revise the code above to get the location of
>> the image in the label? Thanks so much!
>> Yabing
|
|
|
Re: how to get the location of an image in a label? [message #168074 is a reply to message #168051] |
Sun, 13 February 2005 22:12   |
Eclipse User |
|
|
|
yabing,
Sorry, I checked the code right now and I you should use
Label#getIconBounds
That would make it
Rectangle r = ((Label)getOwner()).getIconBounds();
Hope that checks out :)
Brian.
yabing chen wrote:
> Hi Brian,
> instead of org.eclipse.draw2d.geometry.Rectangle, the method
> ((Label)getOwner()).getIcon().getBounds() returns an instance of
> org.eclipse.swt.graphics.Rectangle, which always returns x and y values of
> 0.
> so i still don't know how I can get the position of the image rectangle
> object.
> Thanks,
> Yabing
> Brian Fernandes wrote:
>> Yabing,
>> Without thinking too much, this should give you the bounds of the image.
>> Rectangle r = ((Label)getOwner()).getIcon().getBounds();
>> Hope this helps,
>> Brian.
>> yabing chen wrote:
>>> Hi,
>>> I am trying to create connections between two labels, which are decorated
>>> with images. I use the following method to create the labels:
>>> Label label = new Label("text", new Image(d, "d:mapitem_field.gif"));
>>> now I want to get the location of the image in the label so that I can
>>> make it as the anchor point for the connection between the labels.
>>> currently I am using the follwing method to get the location:
>>> Rectangle r = getOwner().getBounds().getCopy();
>>> // return the rectangel of the label
>>> return r.getRight();
>>> can anyone tell me how I can revise the code above to get the location of
>>> the image in the label? Thanks so much!
>>> Yabing
|
|
| |
Re: how to get the location of an image in a label? [message #168168 is a reply to message #168074] |
Mon, 14 February 2005 01:45  |
Eclipse User |
|
|
|
Originally posted by: yabing.crimsonlogic.com
Hi Brian,
Yeah, Now it is ok. thanks so much!
Yabing
Brian Fernandes wrote:
> yabing,
> Sorry, I checked the code right now and I you should use
> Label#getIconBounds
> That would make it
> Rectangle r = ((Label)getOwner()).getIconBounds();
> Hope that checks out :)
> Brian.
> yabing chen wrote:
>> Hi Brian,
>> instead of org.eclipse.draw2d.geometry.Rectangle, the method
>> ((Label)getOwner()).getIcon().getBounds() returns an instance of
>> org.eclipse.swt.graphics.Rectangle, which always returns x and y values of
>> 0.
>> so i still don't know how I can get the position of the image rectangle
>> object.
>> Thanks,
>> Yabing
>> Brian Fernandes wrote:
>>> Yabing,
>>> Without thinking too much, this should give you the bounds of the image.
>>> Rectangle r = ((Label)getOwner()).getIcon().getBounds();
>>> Hope this helps,
>>> Brian.
>>> yabing chen wrote:
>>>> Hi,
>>>> I am trying to create connections between two labels, which are decorated
>>>> with images. I use the following method to create the labels:
>>>> Label label = new Label("text", new Image(d, "d:mapitem_field.gif"));
>>>> now I want to get the location of the image in the label so that I can
>>>> make it as the anchor point for the connection between the labels.
>>>> currently I am using the follwing method to get the location:
>>>> Rectangle r = getOwner().getBounds().getCopy();
>>>> // return the rectangel of the label
>>>> return r.getRight();
>>>> can anyone tell me how I can revise the code above to get the location of
>>>> the image in the label? Thanks so much!
>>>> Yabing
|
|
|
Goto Forum:
Current Time: Tue Jun 24 16:36:25 EDT 2025
Powered by FUDForum. Page generated in 0.04917 seconds
|