Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Getting the label at the center
Getting the label at the center [message #4765] Thu, 03 August 2006 08:54 Go to next message
Eclipse UserFriend
Originally posted by: sayed.shoed.tavant.com

Hi,

I have a node which has a name property.I want to set the label for the
name at the vertical center of my node.I tried to use Constrained
toolbar layout but could not get the desired result.Could anyone please
tell me how to do it.


Thanks
Sayed Aamir Shoeb
Re: Getting the label at the center [message #5034 is a reply to message #4765] Thu, 03 August 2006 10:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: 5d5.mail.ru

Hello!

It's not that hard to write your own draw2d layout; StackLayout may be
a good starting point.

sayed wrote:
> Hi,
>
> I have a node which has a name property.I want to set the label for the
> name at the vertical center of my node.I tried to use Constrained
> toolbar layout but could not get the desired result.Could anyone please
> tell me how to do it.
>
>
> Thanks
> Sayed Aamir Shoeb
Re: Getting the label at the center [message #6434 is a reply to message #5034] Fri, 04 August 2006 04:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sayed.shoed.tavant.com

Hi,
I think the geoshapes plugin example has this. For example, when you
create a cylinder figure you are prompted to enter some name and that
name appears in the center of the figure.

I started from CylinderEditPart(GeoShapeEditPart, ShapeNodeEditPart) and
digged through the subclasses to see the layout being used but couldnt
get hold of it. My guess is I do not have to write layouts from
scratch!!! Can someone point me to the classes where this is being done
in geoshapes?

Dmitry Stadnik wrote:
> Hello!
>
> It's not that hard to write your own draw2d layout; StackLayout may
> be a good starting point.
>
> sayed wrote:
>> Hi,
>>
>> I have a node which has a name property.I want to set the label for
>> the name at the vertical center of my node.I tried to use Constrained
>> toolbar layout but could not get the desired result.Could anyone
>> please tell me how to do it.
>>
>>
>> Thanks
>> Sayed Aamir Shoeb
Re: Getting the label at the center [message #6453 is a reply to message #6434] Fri, 04 August 2006 05:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: 5d5.mail.ru

Hello!

Wow - it uses GeoShapeCylinderFigure that extends GeoShapeFigure that
uses modified StackLayout to center content pane )))
You could ask GMF runtime team to refactor this layout manager for
public use or just copy the code.

sayed wrote:
> Hi,
> I think the geoshapes plugin example has this. For example, when you
> create a cylinder figure you are prompted to enter some name and that
> name appears in the center of the figure.
>
> I started from CylinderEditPart(GeoShapeEditPart, ShapeNodeEditPart) and
> digged through the subclasses to see the layout being used but couldnt
> get hold of it. My guess is I do not have to write layouts from
> scratch!!! Can someone point me to the classes where this is being done
> in geoshapes?
>
> Dmitry Stadnik wrote:
>> Hello!
>>
>> It's not that hard to write your own draw2d layout; StackLayout
>> may be a good starting point.
>>
>> sayed wrote:
>>> Hi,
>>>
>>> I have a node which has a name property.I want to set the label for
>>> the name at the vertical center of my node.I tried to use Constrained
>>> toolbar layout but could not get the desired result.Could anyone
>>> please tell me how to do it.
>>>
>>>
>>> Thanks
>>> Sayed Aamir Shoeb
Re: Getting the label at the center [message #6471 is a reply to message #6453] Fri, 04 August 2006 05:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sayed.shoed.tavant.com

Hei,
Even we got the code, the following code will make the label come in the
center. I will try to make a layout of it

setLayoutManager(new StackLayout() {
public void layout(IFigure figure) {
Rectangle r = figure.getClientArea();
List children = figure.getChildren();
IFigure child;
Dimension d;
for (int i = 0; i < children.size(); i++) {
child = (IFigure)children.get(i);
d = child.getPreferredSize(r.width, r.height);
d.width = Math.min(d.width, r.width);
d.height = Math.min(d.height, r.height);
Rectangle childRect = new Rectangle(
r.x + (r.width - d.width)/2,
r.y + (r.height - d.height)/2,
d.width,
d.height);
child.setBounds(childRect);
}
}
});

Thanks,
Sayed Aamir Shoeb

Dmitry Stadnik wrote:
> Hello!
>
> Wow - it uses GeoShapeCylinderFigure that extends GeoShapeFigure
> that uses modified StackLayout to center content pane )))
> You could ask GMF runtime team to refactor this layout manager for
> public use or just copy the code.
>
> sayed wrote:
>> Hi,
>> I think the geoshapes plugin example has this. For example, when you
>> create a cylinder figure you are prompted to enter some name and that
>> name appears in the center of the figure.
>>
>> I started from CylinderEditPart(GeoShapeEditPart, ShapeNodeEditPart)
>> and digged through the subclasses to see the layout being used but
>> couldnt get hold of it. My guess is I do not have to write layouts
>> from scratch!!! Can someone point me to the classes where this is
>> being done in geoshapes?
>>
>> Dmitry Stadnik wrote:
>>> Hello!
>>>
>>> It's not that hard to write your own draw2d layout; StackLayout
>>> may be a good starting point.
>>>
>>> sayed wrote:
>>>> Hi,
>>>>
>>>> I have a node which has a name property.I want to set the label for
>>>> the name at the vertical center of my node.I tried to use
>>>> Constrained toolbar layout but could not get the desired
>>>> result.Could anyone please tell me how to do it.
>>>>
>>>>
>>>> Thanks
>>>> Sayed Aamir Shoeb
Re: Getting the label at the center [message #108992 is a reply to message #6471] Mon, 05 March 2007 15:08 Go to previous message
Eclipse UserFriend
Hi there,

I tried this to get the label of my elliptical node centred. But it
doesn't work. I put it in the CreateNodeFigure-method of *EditPart of
the Figure.
Is it the problem because of the rectangle as box for the ellipse? I
also iterated a step deeper with the children, so I can get the label of
the ellipse, but here too -> nothing happens with the label, I is top
centred but not vertically.

Thanks for help

Jens

sayed schrieb:
> Hei,
> Even we got the code, the following code will make the label come in the
> center. I will try to make a layout of it
>
> setLayoutManager(new StackLayout() {
> public void layout(IFigure figure) {
> Rectangle r = figure.getClientArea();
> List children = figure.getChildren();
> IFigure child;
> Dimension d;
> for (int i = 0; i < children.size(); i++) {
> child = (IFigure)children.get(i);
> d = child.getPreferredSize(r.width, r.height);
> d.width = Math.min(d.width, r.width);
> d.height = Math.min(d.height, r.height);
> Rectangle childRect = new Rectangle(
> r.x + (r.width - d.width)/2,
> r.y + (r.height - d.height)/2,
> d.width,
> d.height);
> child.setBounds(childRect);
> }
> }
> });
>
> Thanks,
> Sayed Aamir Shoeb
>
> Dmitry Stadnik wrote:
>> Hello!
>>
>> Wow - it uses GeoShapeCylinderFigure that extends GeoShapeFigure
>> that uses modified StackLayout to center content pane )))
>> You could ask GMF runtime team to refactor this layout manager for
>> public use or just copy the code.
>>
>> sayed wrote:
>>> Hi,
>>> I think the geoshapes plugin example has this. For example, when you
>>> create a cylinder figure you are prompted to enter some name and that
>>> name appears in the center of the figure.
>>>
>>> I started from CylinderEditPart(GeoShapeEditPart, ShapeNodeEditPart)
>>> and digged through the subclasses to see the layout being used but
>>> couldnt get hold of it. My guess is I do not have to write layouts
>>> from scratch!!! Can someone point me to the classes where this is
>>> being done in geoshapes?
>>>
>>> Dmitry Stadnik wrote:
>>>> Hello!
>>>>
>>>> It's not that hard to write your own draw2d layout; StackLayout
>>>> may be a good starting point.
>>>>
>>>> sayed wrote:
>>>>> Hi,
>>>>>
>>>>> I have a node which has a name property.I want to set the label for
>>>>> the name at the vertical center of my node.I tried to use
>>>>> Constrained toolbar layout but could not get the desired
>>>>> result.Could anyone please tell me how to do it.
>>>>>
>>>>>
>>>>> Thanks
>>>>> Sayed Aamir Shoeb
Previous Topic:How to modify key bindings
Next Topic:GMF Tutorial Part 3 - Custom Actions
Goto Forum:
  


Current Time: Fri May 09 14:09:39 EDT 2025

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

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

Back to the top