Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to change edit part size
How to change edit part size [message #192820] Mon, 16 June 2008 11:15 Go to next message
Nagesh is currently offline NageshFriend
Messages: 55
Registered: July 2009
Member
Hello All,

I have a "BorderedBorderItemEditPart" extended class rectangle editpart. I
want to change the size of the same using coding. I have tried this using
different methods like

Method1:
ChangeBoundsRequest resizeRequest = new ChangeBoundsRequest(
org.eclipse.gef.RequestConstants.REQ_RESIZE);
resizeRequest.setEditParts(iGeditPart);
resizeRequest.setSizeDelta(new Dimension(widthDelta,heightDelta));

Command cmd = editPart.getCommand(resizeRequest);
cc.add(cmd);

Method2:
((BorderedNodeFigure)iGeditPart.getFigure()).setPreferredSiz e(new
Dimension(widthDelta,heightDelta));

Method3:
((BorderedNodeFigure)iGeditPart.getFigure()).setSize(new
Dimension(widthDelta,heightDelta));

But it is not changing size of it. Please help me how change size of
component programatically?.
Re: How to change edit part size [message #192873 is a reply to message #192820] Mon, 16 June 2008 13:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: luetze.cs.tu-berlin.de

Hi Nagesh.

Overwrite the paintFigure(Graphics g) method of
the figure class you are using! just add
this.setPreferredSize(x,y) there and you will be fine!

Marco


Nagesh schrieb:


> Hello All,
>
> I have a "BorderedBorderItemEditPart" extended class rectangle editpart.
> I want to change the size of the same using coding. I have tried this
> using different methods like
>
> Method1:
> ChangeBoundsRequest resizeRequest = new ChangeBoundsRequest(
>
> org.eclipse.gef.RequestConstants.REQ_RESIZE);
> resizeRequest.setEditParts(iGeditPart);
> resizeRequest.setSizeDelta(new
> Dimension(widthDelta,heightDelta));
> Command cmd =
> editPart.getCommand(resizeRequest);
> cc.add(cmd);
>
> Method2:
> ((BorderedNodeFigure)iGeditPart.getFigure()).setPreferredSiz e(new
> Dimension(widthDelta,heightDelta));
>
> Method3:
> ((BorderedNodeFigure)iGeditPart.getFigure()).setSize(new
> Dimension(widthDelta,heightDelta));
>
> But it is not changing size of it. Please help me how change size of
> component programatically?.
>
>
Re: How to change edit part size [message #192985 is a reply to message #192873] Tue, 17 June 2008 04:01 Go to previous messageGo to next message
Nagesh is currently offline NageshFriend
Messages: 55
Registered: July 2009
Member
Hello luetze,

Thank you for reply. I have overrided the paintFigure(Graphics) method.
This has been changed the size of the component on initial run. But from
other class how to call this paint method or change the size?.

I want this change in size of component by an action. How can I do it
programatically?. Please help me.

Thanks In Advance,
Nagesh


luetze wrote:

> Hi Nagesh.

> Overwrite the paintFigure(Graphics g) method of
> the figure class you are using! just add
> this.setPreferredSize(x,y) there and you will be fine!

> Marco


> Nagesh schrieb:


>> Hello All,
>>
>> I have a "BorderedBorderItemEditPart" extended class rectangle editpart.
>> I want to change the size of the same using coding. I have tried this
>> using different methods like
>>
>> Method1:
>> ChangeBoundsRequest resizeRequest = new ChangeBoundsRequest(
>>
>> org.eclipse.gef.RequestConstants.REQ_RESIZE);
>> resizeRequest.setEditParts(iGeditPart);
>> resizeRequest.setSizeDelta(new
>> Dimension(widthDelta,heightDelta));
>> Command cmd =
>> editPart.getCommand(resizeRequest);
>> cc.add(cmd);
>>
>> Method2:
>> ((BorderedNodeFigure)iGeditPart.getFigure()).setPreferredSiz e(new
>> Dimension(widthDelta,heightDelta));
>>
>> Method3:
>> ((BorderedNodeFigure)iGeditPart.getFigure()).setSize(new
>> Dimension(widthDelta,heightDelta));
>>
>> But it is not changing size of it. Please help me how change size of
>> component programatically?.
>>
>>
Re: How to change edit part size [message #193006 is a reply to message #192985] Tue, 17 June 2008 07:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: luetze.cs.tu-berlin.de

well, just add 2 memebers (including setters) to the figure-class:

int size_x;
int size_y;

public void setMySize(int x, int y){
size_x = x;
size_y = y;
}

use your action to set your "new" size:

figure.setMySize(100,100);


....and finally, you include the call of

setPreferredSize(size_x,size_y);

within your overwritten paintFigure(Graphics g)-method!
hope that will work out for you!

Take care, Marco



Nagesh schrieb:
> Hello luetze,
>
> Thank you for reply. I have overrided the paintFigure(Graphics) method.
> This has been changed the size of the component on initial run. But from
> other class how to call this paint method or change the size?.
> I want this change in size of component by an action. How can I do it
> programatically?. Please help me.
>
> Thanks In Advance,
> Nagesh
>
>
> luetze wrote:
>
>> Hi Nagesh.
>
>> Overwrite the paintFigure(Graphics g) method of
>> the figure class you are using! just add
>> this.setPreferredSize(x,y) there and you will be fine!
>
>> Marco
>
>
>> Nagesh schrieb:
>
>
>>> Hello All,
>>>
>>> I have a "BorderedBorderItemEditPart" extended class rectangle
>>> editpart. I want to change the size of the same using coding. I have
>>> tried this using different methods like
>>>
>>> Method1:
>>> ChangeBoundsRequest resizeRequest = new ChangeBoundsRequest(
>>>
>>> org.eclipse.gef.RequestConstants.REQ_RESIZE);
>>>
>>> resizeRequest.setEditParts(iGeditPart);
>>> resizeRequest.setSizeDelta(new
>>> Dimension(widthDelta,heightDelta));
>>> Command cmd =
>>> editPart.getCommand(resizeRequest);
>>> cc.add(cmd);
>>>
>>> Method2:
>>> ((BorderedNodeFigure)iGeditPart.getFigure()).setPreferredSiz e(new
>>> Dimension(widthDelta,heightDelta));
>>>
>>> Method3:
>>> ((BorderedNodeFigure)iGeditPart.getFigure()).setSize(new
>>> Dimension(widthDelta,heightDelta));
>>>
>>> But it is not changing size of it. Please help me how change size of
>>> component programatically?.
>>>
>>>
>
>
Re: How to change edit part size [message #193050 is a reply to message #193006] Tue, 17 June 2008 12:14 Go to previous messageGo to next message
Nagesh is currently offline NageshFriend
Messages: 55
Registered: July 2009
Member
Hi Marco,

Thanks for solution. From my action class now I am setting sizes and
calling paintFigure(Graphics g). But how can I get graphics object for
parameter?.

Nagesh.


luetze wrote:

> well, just add 2 memebers (including setters) to the figure-class:

> int size_x;
> int size_y;

> public void setMySize(int x, int y){
> size_x = x;
> size_y = y;
> }

> use your action to set your "new" size:

> figure.setMySize(100,100);


> ....and finally, you include the call of

> setPreferredSize(size_x,size_y);

> within your overwritten paintFigure(Graphics g)-method!
> hope that will work out for you!

> Take care, Marco



> Nagesh schrieb:
>> Hello luetze,
>>
>> Thank you for reply. I have overrided the paintFigure(Graphics) method.
>> This has been changed the size of the component on initial run. But from
>> other class how to call this paint method or change the size?.
>> I want this change in size of component by an action. How can I do it
>> programatically?. Please help me.
>>
>> Thanks In Advance,
>> Nagesh
>>
>>
>> luetze wrote:
>>
>>> Hi Nagesh.
>>
>>> Overwrite the paintFigure(Graphics g) method of
>>> the figure class you are using! just add
>>> this.setPreferredSize(x,y) there and you will be fine!
>>
>>> Marco
>>
>>
>>> Nagesh schrieb:
>>
>>
>>>> Hello All,
>>>>
>>>> I have a "BorderedBorderItemEditPart" extended class rectangle
>>>> editpart. I want to change the size of the same using coding. I have
>>>> tried this using different methods like
>>>>
>>>> Method1:
>>>> ChangeBoundsRequest resizeRequest = new ChangeBoundsRequest(
>>>>
>>>> org.eclipse.gef.RequestConstants.REQ_RESIZE);
>>>>
>>>> resizeRequest.setEditParts(iGeditPart);
>>>> resizeRequest.setSizeDelta(new
>>>> Dimension(widthDelta,heightDelta));
>>>> Command cmd =
>>>> editPart.getCommand(resizeRequest);
>>>> cc.add(cmd);
>>>>
>>>> Method2:
>>>> ((BorderedNodeFigure)iGeditPart.getFigure()).setPreferredSiz e(new
>>>> Dimension(widthDelta,heightDelta));
>>>>
>>>> Method3:
>>>> ((BorderedNodeFigure)iGeditPart.getFigure()).setSize(new
>>>> Dimension(widthDelta,heightDelta));
>>>>
>>>> But it is not changing size of it. Please help me how change size of
>>>> component programatically?.
>>>>
>>>>
>>
>>
Re: How to change edit part size [message #193113 is a reply to message #193050] Tue, 17 June 2008 16:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: luetze.cs.tu-berlin.de

that's the beauty if it :-) ...you don't need that anymore! you do not
need to call paintFigure()! ...just call YOURFIGURE.repaint()
and paintFigure(Graphics g) is called automatically!

tell me if you made it!

Cheers, Marco


Nagesh schrieb:

> Hi Marco,
>
> Thanks for solution. From my action class now I am setting sizes and
> calling paintFigure(Graphics g). But how can I get graphics object for
> parameter?.
>
> Nagesh.
>
>
> luetze wrote:
>
>> well, just add 2 memebers (including setters) to the figure-class:
>
>> int size_x;
>> int size_y;
>
>> public void setMySize(int x, int y){
>> size_x = x;
>> size_y = y;
>> }
>
>> use your action to set your "new" size:
>
>> figure.setMySize(100,100);
>
>
>> ....and finally, you include the call of
>
>> setPreferredSize(size_x,size_y);
>
>> within your overwritten paintFigure(Graphics g)-method!
>> hope that will work out for you!
>
>> Take care, Marco
>
>
>
>> Nagesh schrieb:
>>> Hello luetze,
>>>
>>> Thank you for reply. I have overrided the paintFigure(Graphics)
>>> method. This has been changed the size of the component on initial
>>> run. But from other class how to call this paint method or change the
>>> size?.
>>> I want this change in size of component by an action. How can I do it
>>> programatically?. Please help me.
>>>
>>> Thanks In Advance,
>>> Nagesh
>>>
>>>
>>> luetze wrote:
>>>
>>>> Hi Nagesh.
>>>
>>>> Overwrite the paintFigure(Graphics g) method of
>>>> the figure class you are using! just add
>>>> this.setPreferredSize(x,y) there and you will be fine!
>>>
>>>> Marco
>>>
>>>
>>>> Nagesh schrieb:
>>>
>>>
>>>>> Hello All,
>>>>>
>>>>> I have a "BorderedBorderItemEditPart" extended class rectangle
>>>>> editpart. I want to change the size of the same using coding. I
>>>>> have tried this using different methods like
>>>>>
>>>>> Method1:
>>>>> ChangeBoundsRequest resizeRequest = new ChangeBoundsRequest(
>>>>>
>>>>> org.eclipse.gef.RequestConstants.REQ_RESIZE);
>>>>>
>>>>> resizeRequest.setEditParts(iGeditPart);
>>>>> resizeRequest.setSizeDelta(new
>>>>> Dimension(widthDelta,heightDelta));
>>>>> Command cmd
>>>>> = editPart.getCommand(resizeRequest);
>>>>> cc.add(cmd);
>>>>>
>>>>> Method2:
>>>>> ((BorderedNodeFigure)iGeditPart.getFigure()).setPreferredSiz e(new
>>>>> Dimension(widthDelta,heightDelta));
>>>>>
>>>>> Method3:
>>>>> ((BorderedNodeFigure)iGeditPart.getFigure()).setSize(new
>>>>> Dimension(widthDelta,heightDelta));
>>>>>
>>>>> But it is not changing size of it. Please help me how change size
>>>>> of component programatically?.
>>>>>
>>>>>
>>>
>>>
>
>
Re: How to change edit part size [message #193169 is a reply to message #193113] Wed, 18 June 2008 05:50 Go to previous messageGo to next message
Nagesh is currently offline NageshFriend
Messages: 55
Registered: July 2009
Member
Hi Marco,

Great!!! it works. Thanks alot.
This size change not makes figure as dirty ie changes can't be saved. How
can I make this option on size change?.

Nagesh.

luetze wrote:

> that's the beauty if it :-) ...you don't need that anymore! you do not
> need to call paintFigure()! ...just call YOURFIGURE.repaint()
> and paintFigure(Graphics g) is called automatically!

> tell me if you made it!

> Cheers, Marco


> Nagesh schrieb:

>> Hi Marco,
>>
>> Thanks for solution. From my action class now I am setting sizes and
>> calling paintFigure(Graphics g). But how can I get graphics object for
>> parameter?.
>>
>> Nagesh.
>>
>>
>> luetze wrote:
>>
>>> well, just add 2 memebers (including setters) to the figure-class:
>>
>>> int size_x;
>>> int size_y;
>>
>>> public void setMySize(int x, int y){
>>> size_x = x;
>>> size_y = y;
>>> }
>>
>>> use your action to set your "new" size:
>>
>>> figure.setMySize(100,100);
>>
>>
>>> ....and finally, you include the call of
>>
>>> setPreferredSize(size_x,size_y);
>>
>>> within your overwritten paintFigure(Graphics g)-method!
>>> hope that will work out for you!
>>
>>> Take care, Marco
>>
>>
>>
>>> Nagesh schrieb:
>>>> Hello luetze,
>>>>
>>>> Thank you for reply. I have overrided the paintFigure(Graphics)
>>>> method. This has been changed the size of the component on initial
>>>> run. But from other class how to call this paint method or change the
>>>> size?.
>>>> I want this change in size of component by an action. How can I do it
>>>> programatically?. Please help me.
>>>>
>>>> Thanks In Advance,
>>>> Nagesh
>>>>
>>>>
>>>> luetze wrote:
>>>>
>>>>> Hi Nagesh.
>>>>
>>>>> Overwrite the paintFigure(Graphics g) method of
>>>>> the figure class you are using! just add
>>>>> this.setPreferredSize(x,y) there and you will be fine!
>>>>
>>>>> Marco
>>>>
>>>>
>>>>> Nagesh schrieb:
>>>>
>>>>
>>>>>> Hello All,
>>>>>>
>>>>>> I have a "BorderedBorderItemEditPart" extended class rectangle
>>>>>> editpart. I want to change the size of the same using coding. I
>>>>>> have tried this using different methods like
>>>>>>
>>>>>> Method1:
>>>>>> ChangeBoundsRequest resizeRequest = new ChangeBoundsRequest(
>>>>>>
>>>>>> org.eclipse.gef.RequestConstants.REQ_RESIZE);
>>>>>>
>>>>>> resizeRequest.setEditParts(iGeditPart);
>>>>>> resizeRequest.setSizeDelta(new
>>>>>> Dimension(widthDelta,heightDelta));
>>>>>> Command cmd
>>>>>> = editPart.getCommand(resizeRequest);
>>>>>> cc.add(cmd);
>>>>>>
>>>>>> Method2:
>>>>>> ((BorderedNodeFigure)iGeditPart.getFigure()).setPreferredSiz e(new
>>>>>> Dimension(widthDelta,heightDelta));
>>>>>>
>>>>>> Method3:
>>>>>> ((BorderedNodeFigure)iGeditPart.getFigure()).setSize(new
>>>>>> Dimension(widthDelta,heightDelta));
>>>>>>
>>>>>> But it is not changing size of it. Please help me how change size
>>>>>> of component programatically?.
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
Re: How to change edit part size [message #193704 is a reply to message #193169] Thu, 19 June 2008 13:58 Go to previous message
Eclipse UserFriend
Originally posted by: luetze.cs.tu-berlin.de

Huh, difficult one! ...due to the fact, that you are saving
these things, you need to update your model with a size-attribute,
because otherwise reloaded diagramms will have initial values for size!
in the case of a model representation you just perform an update
model-action and the model is dirty again! have you thought about
that possibility (saving size to the model-file) ?

Nagesh schrieb:
> Hi Marco,
>
> Great!!! it works. Thanks alot. This size change not makes figure as
> dirty ie changes can't be saved. How can I make this option on size
> change?.
>
> Nagesh.
>
> luetze wrote:
>
>> that's the beauty if it :-) ...you don't need that anymore! you do not
>> need to call paintFigure()! ...just call YOURFIGURE.repaint()
>> and paintFigure(Graphics g) is called automatically!
>
>> tell me if you made it!
>
>> Cheers, Marco
>
>
>> Nagesh schrieb:
>
>>> Hi Marco,
>>>
>>> Thanks for solution. From my action class now I am setting sizes and
>>> calling paintFigure(Graphics g). But how can I get graphics object
>>> for parameter?.
>>>
>>> Nagesh.
>>>
>>>
>>> luetze wrote:
>>>
>>>> well, just add 2 memebers (including setters) to the figure-class:
>>>
>>>> int size_x;
>>>> int size_y;
>>>
>>>> public void setMySize(int x, int y){
>>>> size_x = x;
>>>> size_y = y;
>>>> }
>>>
>>>> use your action to set your "new" size:
>>>
>>>> figure.setMySize(100,100);
>>>
>>>
>>>> ....and finally, you include the call of
>>>
>>>> setPreferredSize(size_x,size_y);
>>>
>>>> within your overwritten paintFigure(Graphics g)-method!
>>>> hope that will work out for you!
>>>
>>>> Take care, Marco
>>>
>>>
>>>
>>>> Nagesh schrieb:
>>>>> Hello luetze,
>>>>>
>>>>> Thank you for reply. I have overrided the paintFigure(Graphics)
>>>>> method. This has been changed the size of the component on initial
>>>>> run. But from other class how to call this paint method or change
>>>>> the size?.
>>>>> I want this change in size of component by an action. How can I do
>>>>> it programatically?. Please help me.
>>>>>
>>>>> Thanks In Advance,
>>>>> Nagesh
>>>>>
>>>>>
>>>>> luetze wrote:
>>>>>
>>>>>> Hi Nagesh.
>>>>>
>>>>>> Overwrite the paintFigure(Graphics g) method of
>>>>>> the figure class you are using! just add
>>>>>> this.setPreferredSize(x,y) there and you will be fine!
>>>>>
>>>>>> Marco
>>>>>
>>>>>
>>>>>> Nagesh schrieb:
>>>>>
>>>>>
>>>>>>> Hello All,
>>>>>>>
>>>>>>> I have a "BorderedBorderItemEditPart" extended class rectangle
>>>>>>> editpart. I want to change the size of the same using coding. I
>>>>>>> have tried this using different methods like
>>>>>>>
>>>>>>> Method1:
>>>>>>> ChangeBoundsRequest resizeRequest = new ChangeBoundsRequest(
>>>>>>>
>>>>>>> org.eclipse.gef.RequestConstants.REQ_RESIZE);
>>>>>>>
>>>>>>> resizeRequest.setEditParts(iGeditPart);
>>>>>>> resizeRequest.setSizeDelta(new
>>>>>>> Dimension(widthDelta,heightDelta));
>>>>>>> Command
>>>>>>> cmd = editPart.getCommand(resizeRequest);
>>>>>>> cc.add(cmd);
>>>>>>>
>>>>>>> Method2:
>>>>>>> ((BorderedNodeFigure)iGeditPart.getFigure()).setPreferredSiz e(new
>>>>>>> Dimension(widthDelta,heightDelta));
>>>>>>>
>>>>>>> Method3:
>>>>>>> ((BorderedNodeFigure)iGeditPart.getFigure()).setSize(new
>>>>>>> Dimension(widthDelta,heightDelta));
>>>>>>>
>>>>>>> But it is not changing size of it. Please help me how change size
>>>>>>> of component programatically?.
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Previous Topic:Problem with compartments in GMF 2.1
Next Topic:Re-size constraint visible through the preview gray rectangle
Goto Forum:
  


Current Time: Thu Mar 28 19:27:59 GMT 2024

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

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

Back to the top