Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Rotation of EditParts possible?
Rotation of EditParts possible? [message #82215] Sat, 02 December 2006 22:59 Go to next message
Sven Wende is currently offline Sven WendeFriend
Messages: 9
Registered: July 2009
Junior Member
Hi,

I just have discovered

RotatableShapeEditPolicy
( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/diagra m/ui/editpolicies/RotatableShapeEditPolicy.html)

and

IRotatableEditPart
( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/diagra m/ui/editparts/IRotatableEditPart.html)

in the documentation.

I wonder, if these can really be used to implement rotatable EditParts. Are
there any working examples?

I already tried to apply them to a simple GEF editor, but without success.

Kind regards

Sven
Re: Rotation of EditParts possible? [message #82793 is a reply to message #82215] Mon, 04 December 2006 22:06 Go to previous messageGo to next message
Cherie Revells is currently offline Cherie RevellsFriend
Messages: 299
Registered: July 2009
Senior Member
Sven,

I do not know of any working examples, but I have seen it implemented.

I believe the code you are looking at in GMF will provide a client with
the tool and feedback required to rotate a shape, but the drawing of
the shape would be left for the implementor of the editpart/figure.

If your editpart returns the RotatableShapeEditPolicy in the
getPrimaryDragEditPolicy() method and implements IRotatableEditPart,
then this should (I haven't tried it) provide you with the handles on
the corner of your shape to rotate the shape.

The RotatableShapeEditPolicy will set the resizeDirection on the
ChangeBoundsRequest. Now, all you have to do, is respond to this
request, by returning a command that will not only change the bounds of
your rotatable shape, but also somehow sets its direction. :-)

I would be interested in knowing if this works out for you.

- Cherie

Sven Wende wrote:
> Hi,
>
> I just have discovered
>
> RotatableShapeEditPolicy
> ( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/diagra m/ui/editpolicies/RotatableShapeEditPolicy.html)
>
> and
>
> IRotatableEditPart
> ( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/diagra m/ui/editparts/IRotatableEditPart.html)
>
> in the documentation.
>
> I wonder, if these can really be used to implement rotatable EditParts. Are
> there any working examples?
>
> I already tried to apply them to a simple GEF editor, but without success.
>
> Kind regards
>
> Sven
>
>
Re: Rotation of EditParts possible? [message #82848 is a reply to message #82793] Mon, 04 December 2006 23:43 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 650
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

I need the ability to rotate an edit part, too! In my case, I want to
change a custom style attribute to the direction the edit part's
figure should point (the figure is a triangle).

Based on your information, I tried to track what was happening during
a rotate. As far as I can tell, a rotate uses a RotateShapeRequest,
which for most practical purposes is a change bounds request, e.g. it
results in a commans that changes the bounds. A RotateShapeRequest
does provide an int telling which handle is used, e.g. NORTH_WEST, but
I could not find any information telling whether the rotate was
clockwise or counter-clockwise! For the rectangle this doesn't matter,
a rotate only swaps the width/height, but for me it does matter, as I
need to tell whether the triange figure should point up or down, left
or right.

So, how can I find the rotation direction (as opposed to the direction
of the handle used for rotating)? Do I need to make my own tracker (to
get the new direction), policy (to create the appropriate tracker) and
request (to record the final direction)?

Hallvard

On Mon, 04 Dec 2006 17:06:27 -0500, Cherie Revells
<crevells@ca.ibm.com> wrote:

>Sven,
>
>I do not know of any working examples, but I have seen it implemented.
>
>I believe the code you are looking at in GMF will provide a client with
> the tool and feedback required to rotate a shape, but the drawing of
>the shape would be left for the implementor of the editpart/figure.
>
>If your editpart returns the RotatableShapeEditPolicy in the
>getPrimaryDragEditPolicy() method and implements IRotatableEditPart,
>then this should (I haven't tried it) provide you with the handles on
>the corner of your shape to rotate the shape,
>
>The RotatableShapeEditPolicy will set the resizeDirection on the
>ChangeBoundsRequest. Now, all you have to do, is respond to this
>request, by returning a command that will not only change the bounds of
>your rotatable shape, but also somehow sets its direction. :-)
>
>I would be interested in knowing if this works out for you.
>
>- Cherie
>
>Sven Wende wrote:
>> Hi,
>>
>> I just have discovered
>>
>> RotatableShapeEditPolicy
>> ( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/diagra m/ui/editpolicies/RotatableShapeEditPolicy.html)
>>
>> and
>>
>> IRotatableEditPart
>> ( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/diagra m/ui/editparts/IRotatableEditPart.html)
>>
>> in the documentation.
>>
>> I wonder, if these can really be used to implement rotatable EditParts. Are
>> there any working examples?
>>
>> I already tried to apply them to a simple GEF editor, but without success.
>>
>> Kind regards
>>
>> Sven
>>
>>
Re: Rotation of EditParts possible? [message #84238 is a reply to message #82848] Thu, 07 December 2006 21:03 Go to previous messageGo to next message
Cherie Revells is currently offline Cherie RevellsFriend
Messages: 299
Registered: July 2009
Senior Member
Hallvard,

Yes, the current infrastructure in GMF seems to be quite restricted.
You are right on track with what needs to be done. I think this
behavior could be beneficial in GMF so you could even make the changes
with the existing RotateShape classes and submit it as a patch. :-)

Regards,
Cherie

Hallvard Trætteberg wrote:
> Hi,
>
> I need the ability to rotate an edit part, too! In my case, I want to
> change a custom style attribute to the direction the edit part's
> figure should point (the figure is a triangle).
>
> Based on your information, I tried to track what was happening during
> a rotate. As far as I can tell, a rotate uses a RotateShapeRequest,
> which for most practical purposes is a change bounds request, e.g. it
> results in a commans that changes the bounds. A RotateShapeRequest
> does provide an int telling which handle is used, e.g. NORTH_WEST, but
> I could not find any information telling whether the rotate was
> clockwise or counter-clockwise! For the rectangle this doesn't matter,
> a rotate only swaps the width/height, but for me it does matter, as I
> need to tell whether the triange figure should point up or down, left
> or right.
>
> So, how can I find the rotation direction (as opposed to the direction
> of the handle used for rotating)? Do I need to make my own tracker (to
> get the new direction), policy (to create the appropriate tracker) and
> request (to record the final direction)?
>
> Hallvard
>
> On Mon, 04 Dec 2006 17:06:27 -0500, Cherie Revells
> <crevells@ca.ibm.com> wrote:
>
>> Sven,
>>
>> I do not know of any working examples, but I have seen it implemented.
>>
>> I believe the code you are looking at in GMF will provide a client with
>> the tool and feedback required to rotate a shape, but the drawing of
>> the shape would be left for the implementor of the editpart/figure.
>>
>> If your editpart returns the RotatableShapeEditPolicy in the
>> getPrimaryDragEditPolicy() method and implements IRotatableEditPart,
>> then this should (I haven't tried it) provide you with the handles on
>> the corner of your shape to rotate the shape,
>>
>> The RotatableShapeEditPolicy will set the resizeDirection on the
>> ChangeBoundsRequest. Now, all you have to do, is respond to this
>> request, by returning a command that will not only change the bounds of
>> your rotatable shape, but also somehow sets its direction. :-)
>>
>> I would be interested in knowing if this works out for you.
>>
>> - Cherie
>>
>> Sven Wende wrote:
>>> Hi,
>>>
>>> I just have discovered
>>>
>>> RotatableShapeEditPolicy
>>> ( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/diagra m/ui/editpolicies/RotatableShapeEditPolicy.html)
>>>
>>> and
>>>
>>> IRotatableEditPart
>>> ( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/diagra m/ui/editparts/IRotatableEditPart.html)
>>>
>>> in the documentation.
>>>
>>> I wonder, if these can really be used to implement rotatable EditParts. Are
>>> there any working examples?
>>>
>>> I already tried to apply them to a simple GEF editor, but without success.
>>>
>>> Kind regards
>>>
>>> Sven
>>>
>>>
>
Re: Rotation of EditParts possible? [message #84360 is a reply to message #84238] Fri, 08 December 2006 14:31 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 650
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Cherie,

On Thu, 07 Dec 2006 16:03:42 -0500, Cherie Revells
<crevells@ca.ibm.com> wrote:

>Hallvard,
>
>Yes, the current infrastructure in GMF seems to be quite restricted.
>You are right on track with what needs to be done. I think this
>behavior could be beneficial in GMF so you could even make the changes
>with the existing RotateShape classes and submit it as a patch. :-)

I've now implemented new RotatableShapeEditPolicy and
RotateShapeRequest classes, that support rotating through the 8
directions defined in PositionConstants. The feedback is as before,
but the RotateShapeRequest will hold both the direction of the handle
(initial direction) and the final direction, so it's easy to define
another edit policy that generates a command defined in terms of
either absolute or relative direction. E.g. I have implemented my own
ChangeDirectionEditPolicy that based on the original direction of a
rotateable object and the difference between initial and final
direction, returns a command for setting a new direction. I have,
however, not been able to make the ChangeDirectionEditPolicy turn off
the setting of the bounds by the SetBoundsCommand returned by the
XYLayoutEditPolicy. Hence, both are executed, which is not ideal.

Due to class loading issues, I was not able to write drop-in
replacements for the existing classes and make a patch. I had to
change their names to RotatableShapeEditPolicyEx and
RotateShapeRequestEx. What is the best way to get them into GMF?
Register a request for enhancement and attach the files?

A side comment: It's fairly confusing and difficult to debug code that
involve tools, edit parts, edit policies and commands. Since commands
are build both during dragging and mouse button release it's
cumbersome to use the debugger. There really should be a way of
logging/tracing how a command is built, i.e. which edit parts and edit
policies participated in the creation of a specific command.

Hallvard

>
>Regards,
>Cherie
>
>Hallvard Trætteberg wrote:
>> Hi,
>>
>> I need the ability to rotate an edit part, too! In my case, I want to
>> change a custom style attribute to the direction the edit part's
>> figure should point (the figure is a triangle).
>>
>> Based on your information, I tried to track what was happening during
>> a rotate. As far as I can tell, a rotate uses a RotateShapeRequest,
>> which for most practical purposes is a change bounds request, e.g. it
>> results in a commans that changes the bounds. A RotateShapeRequest
>> does provide an int telling which handle is used, e.g. NORTH_WEST, but
>> I could not find any information telling whether the rotate was
>> clockwise or counter-clockwise! For the rectangle this doesn't matter,
>> a rotate only swaps the width/height, but for me it does matter, as I
>> need to tell whether the triange figure should point up or down, left
>> or right.
>>
>> So, how can I find the rotation direction (as opposed to the direction
>> of the handle used for rotating)? Do I need to make my own tracker (to
>> get the new direction), policy (to create the appropriate tracker) and
>> request (to record the final direction)?
>>
>> Hallvard
>>
>> On Mon, 04 Dec 2006 17:06:27 -0500, Cherie Revells
>> <crevells@ca.ibm.com> wrote:
>>
>>> Sven,
>>>
>>> I do not know of any working examples, but I have seen it implemented.
>>>
>>> I believe the code you are looking at in GMF will provide a client with
>>> the tool and feedback required to rotate a shape, but the drawing of
>>> the shape would be left for the implementor of the editpart/figure.
>>>
>>> If your editpart returns the RotatableShapeEditPolicy in the
>>> getPrimaryDragEditPolicy() method and implements IRotatableEditPart,
>>> then this should (I haven't tried it) provide you with the handles on
>>> the corner of your shape to rotate the shape,
>>>
>>> The RotatableShapeEditPolicy will set the resizeDirection on the
>>> ChangeBoundsRequest. Now, all you have to do, is respond to this
>>> request, by returning a command that will not only change the bounds of
>>> your rotatable shape, but also somehow sets its direction. :-)
>>>
>>> I would be interested in knowing if this works out for you.
>>>
>>> - Cherie
>>>
>>> Sven Wende wrote:
>>>> Hi,
>>>>
>>>> I just have discovered
>>>>
>>>> RotatableShapeEditPolicy
>>>> ( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/diagra m/ui/editpolicies/RotatableShapeEditPolicy.html)
>>>>
>>>> and
>>>>
>>>> IRotatableEditPart
>>>> ( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/diagra m/ui/editparts/IRotatableEditPart.html)
>>>>
>>>> in the documentation.
>>>>
>>>> I wonder, if these can really be used to implement rotatable EditParts. Are
>>>> there any working examples?
>>>>
>>>> I already tried to apply them to a simple GEF editor, but without success.
>>>>
>>>> Kind regards
>>>>
>>>> Sven
>>>>
>>>>
>>
Re: Rotation of EditParts possible? [message #84435 is a reply to message #84360] Fri, 08 December 2006 17:57 Go to previous messageGo to next message
Cherie Revells is currently offline Cherie RevellsFriend
Messages: 299
Registered: July 2009
Senior Member
Hallvard,

That's great! Yes, you should create an enhancement request and attach
your new files.

Thanks,
Cherie

Hallvard Trætteberg wrote:
> Cherie,
>
> On Thu, 07 Dec 2006 16:03:42 -0500, Cherie Revells
> <crevells@ca.ibm.com> wrote:
>
>> Hallvard,
>>
>> Yes, the current infrastructure in GMF seems to be quite restricted.
>> You are right on track with what needs to be done. I think this
>> behavior could be beneficial in GMF so you could even make the changes
>> with the existing RotateShape classes and submit it as a patch. :-)
>
> I've now implemented new RotatableShapeEditPolicy and
> RotateShapeRequest classes, that support rotating through the 8
> directions defined in PositionConstants. The feedback is as before,
> but the RotateShapeRequest will hold both the direction of the handle
> (initial direction) and the final direction, so it's easy to define
> another edit policy that generates a command defined in terms of
> either absolute or relative direction. E.g. I have implemented my own
> ChangeDirectionEditPolicy that based on the original direction of a
> rotateable object and the difference between initial and final
> direction, returns a command for setting a new direction. I have,
> however, not been able to make the ChangeDirectionEditPolicy turn off
> the setting of the bounds by the SetBoundsCommand returned by the
> XYLayoutEditPolicy. Hence, both are executed, which is not ideal.
>
> Due to class loading issues, I was not able to write drop-in
> replacements for the existing classes and make a patch. I had to
> change their names to RotatableShapeEditPolicyEx and
> RotateShapeRequestEx. What is the best way to get them into GMF?
> Register a request for enhancement and attach the files?
>
> A side comment: It's fairly confusing and difficult to debug code that
> involve tools, edit parts, edit policies and commands. Since commands
> are build both during dragging and mouse button release it's
> cumbersome to use the debugger. There really should be a way of
> logging/tracing how a command is built, i.e. which edit parts and edit
> policies participated in the creation of a specific command.
>
> Hallvard
>
>> Regards,
>> Cherie
>>
>> Hallvard Trætteberg wrote:
>>> Hi,
>>>
>>> I need the ability to rotate an edit part, too! In my case, I want to
>>> change a custom style attribute to the direction the edit part's
>>> figure should point (the figure is a triangle).
>>>
>>> Based on your information, I tried to track what was happening during
>>> a rotate. As far as I can tell, a rotate uses a RotateShapeRequest,
>>> which for most practical purposes is a change bounds request, e.g. it
>>> results in a commans that changes the bounds. A RotateShapeRequest
>>> does provide an int telling which handle is used, e.g. NORTH_WEST, but
>>> I could not find any information telling whether the rotate was
>>> clockwise or counter-clockwise! For the rectangle this doesn't matter,
>>> a rotate only swaps the width/height, but for me it does matter, as I
>>> need to tell whether the triange figure should point up or down, left
>>> or right.
>>>
>>> So, how can I find the rotation direction (as opposed to the direction
>>> of the handle used for rotating)? Do I need to make my own tracker (to
>>> get the new direction), policy (to create the appropriate tracker) and
>>> request (to record the final direction)?
>>>
>>> Hallvard
>>>
>>> On Mon, 04 Dec 2006 17:06:27 -0500, Cherie Revells
>>> <crevells@ca.ibm.com> wrote:
>>>
>>>> Sven,
>>>>
>>>> I do not know of any working examples, but I have seen it implemented.
>>>>
>>>> I believe the code you are looking at in GMF will provide a client with
>>>> the tool and feedback required to rotate a shape, but the drawing of
>>>> the shape would be left for the implementor of the editpart/figure.
>>>>
>>>> If your editpart returns the RotatableShapeEditPolicy in the
>>>> getPrimaryDragEditPolicy() method and implements IRotatableEditPart,
>>>> then this should (I haven't tried it) provide you with the handles on
>>>> the corner of your shape to rotate the shape,
>>>>
>>>> The RotatableShapeEditPolicy will set the resizeDirection on the
>>>> ChangeBoundsRequest. Now, all you have to do, is respond to this
>>>> request, by returning a command that will not only change the bounds of
>>>> your rotatable shape, but also somehow sets its direction. :-)
>>>>
>>>> I would be interested in knowing if this works out for you.
>>>>
>>>> - Cherie
>>>>
>>>> Sven Wende wrote:
>>>>> Hi,
>>>>>
>>>>> I just have discovered
>>>>>
>>>>> RotatableShapeEditPolicy
>>>>> ( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/diagra m/ui/editpolicies/RotatableShapeEditPolicy.html)
>>>>>
>>>>> and
>>>>>
>>>>> IRotatableEditPart
>>>>> ( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/diagra m/ui/editparts/IRotatableEditPart.html)
>>>>>
>>>>> in the documentation.
>>>>>
>>>>> I wonder, if these can really be used to implement rotatable EditParts. Are
>>>>> there any working examples?
>>>>>
>>>>> I already tried to apply them to a simple GEF editor, but without success.
>>>>>
>>>>> Kind regards
>>>>>
>>>>> Sven
>>>>>
>>>>>
>
Re: Rotation of EditParts possible? [message #1731428 is a reply to message #84360] Thu, 05 May 2016 07:57 Go to previous message
xiongtao xia is currently offline xiongtao xiaFriend
Messages: 2
Registered: May 2016
Junior Member
Hi, Hallvard .
Would you like share the code of the example. I have trouble in rotating figure in GMF. Thanks.
Previous Topic:How to Add a Shortcut to the Domain Model
Next Topic:Multiple Plugins, same Domain Model, DND
Goto Forum:
  


Current Time: Sat Oct 21 23:36:52 GMT 2017

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

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