Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to rotate a border item
How to rotate a border item [message #161946] Wed, 21 November 2007 22:50 Go to next message
Jaap Reitsma is currently offline Jaap ReitsmaFriend
Messages: 69
Registered: July 2009
Member
Hi all,

What is the best way to a rotate border item, depending on its position
w.r.t. the parent?

The situation: Our border item is a triangle, created with a Polygon. The
triangle is sitting on the border of a rectangle and should always point
inwards into the rectangle. Actually we gave it an offset
(borderlocator.setBorderOffset()) so it appears pointing thru the border.

A trick that works is to create four triangles, for each side one. Use a
StackLayout as the LayoutManager and in the editpart.refreshBounds()
determine which side the item is sitting
(getBorderItemLocator().getCurrentSideOfParent().) and then set one of the
four triangles to visible.

But I am thinking of using a transformation to rotate the polygone (or some
other shape), and to spare me the hassle with the StackLayout. Is that
possible, and if so, how?

Kind regards,

Jaap Reitsma
Re: How to rotate a border item [message #161987 is a reply to message #161946] Thu, 22 November 2007 07:15 Go to previous messageGo to next message
Jacques LESCOT is currently offline Jacques LESCOTFriend
Messages: 247
Registered: July 2009
Senior Member
There is an existing thread titled "how to change the border item's
direction?" about this issue that could help you.

Jacques

Jaap Reitsma a écrit :
> Hi all,
>
> What is the best way to a rotate border item, depending on its position
> w.r.t. the parent?
>
> The situation: Our border item is a triangle, created with a Polygon. The
> triangle is sitting on the border of a rectangle and should always point
> inwards into the rectangle. Actually we gave it an offset
> (borderlocator.setBorderOffset()) so it appears pointing thru the border.
>
> A trick that works is to create four triangles, for each side one. Use a
> StackLayout as the LayoutManager and in the editpart.refreshBounds()
> determine which side the item is sitting
> (getBorderItemLocator().getCurrentSideOfParent().) and then set one of the
> four triangles to visible.
>
> But I am thinking of using a transformation to rotate the polygone (or some
> other shape), and to spare me the hassle with the StackLayout. Is that
> possible, and if so, how?
>
> Kind regards,
>
> Jaap Reitsma
>
>
Re: How to rotate a border item [message #162003 is a reply to message #161987] Thu, 22 November 2007 08:55 Go to previous messageGo to next message
Jaap Reitsma is currently offline Jaap ReitsmaFriend
Messages: 69
Registered: July 2009
Member
Hi Jacques,

The thread you refer to describes indeed the same issue. What I am looking
for is a solution for rotating the figure, and also for solving the
initialization problem that you also seem to have.

Kind regards,

Jaap

"Jacques LESCOT" <jacques.lescot@anyware-tech.com> wrote in message
news:fi3a9r$t99$1@build.eclipse.org...
> There is an existing thread titled "how to change the border item's
> direction?" about this issue that could help you.
>
> Jacques
>
> Jaap Reitsma a
Re: How to rotate a border item [message #162479 is a reply to message #162003] Fri, 23 November 2007 19:13 Go to previous messageGo to next message
Cherie Revells is currently offline Cherie RevellsFriend
Messages: 299
Registered: July 2009
Senior Member
Jaap, Jacques:

The figure for the connection handles on shapes also changes based on
the side of the shape the connection handles appear on. I solved the
initialization problem discussed in the other thread in the connection
handles, by putting the locator.relocate() call in the border item
figure's validate() method. It seemed sense to put it here to me as
this is where the layout of the figure is normally triggered. I'm not
sure if this will work for your scenario.

As for rotating a figure, there is a rotate() method on the
org.eclipse.draw2d.Graphics class. This method is implemented in the
SWTGraphics class, but not in GMF's ScaledGraphics class. I would
suggest you create a bugzilla to add this support to GMF's
ScaledGraphics class, or better yet, try it yourself first and include
your results in the bugzilla. I'm not sure if there are any
implications to this or if it was just overlooked in GMF.

Regards,
Cherie

Jaap Reitsma wrote:
> Hi Jacques,
>
> The thread you refer to describes indeed the same issue. What I am looking
> for is a solution for rotating the figure, and also for solving the
> initialization problem that you also seem to have.
>
> Kind regards,
>
> Jaap
>
> "Jacques LESCOT" <jacques.lescot@anyware-tech.com> wrote in message
> news:fi3a9r$t99$1@build.eclipse.org...
>> There is an existing thread titled "how to change the border item's
>> direction?" about this issue that could help you.
>>
>> Jacques
>>
>> Jaap Reitsma a écrit :
>>> Hi all,
>>>
>>> What is the best way to a rotate border item, depending on its position
>>> w.r.t. the parent?
>>>
>>> The situation: Our border item is a triangle, created with a Polygon. The
>>> triangle is sitting on the border of a rectangle and should always point
>>> inwards into the rectangle. Actually we gave it an offset
>>> (borderlocator.setBorderOffset()) so it appears pointing thru the border.
>>>
>>> A trick that works is to create four triangles, for each side one. Use a
>>> StackLayout as the LayoutManager and in the editpart.refreshBounds()
>>> determine which side the item is sitting
>>> (getBorderItemLocator().getCurrentSideOfParent().) and then set one of
>>> the four triangles to visible.
>>>
>>> But I am thinking of using a transformation to rotate the polygone (or
>>> some other shape), and to spare me the hassle with the StackLayout. Is
>>> that possible, and if so, how?
>>>
>>> Kind regards,
>>>
>>> Jaap Reitsma
>
>
Re: How to rotate a border item [message #162768 is a reply to message #162479] Tue, 27 November 2007 11:09 Go to previous messageGo to next message
kent gibson is currently offline kent gibsonFriend
Messages: 114
Registered: July 2009
Senior Member
I think idea for a bugzilla entry to add rotation to ScaledGraphics is
great. Has anyone done this? Or should I do it? I just wanted to check
first to see if it has been done so I don't add a redundant entry.
Re: How to rotate a border item [message #162984 is a reply to message #162768] Wed, 28 November 2007 10:53 Go to previous messageGo to next message
kent gibson is currently offline kent gibsonFriend
Messages: 114
Registered: July 2009
Senior Member
There is an issue already for this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=130419

Unfortunately the gef project does not seem to support voting, otherwise I
would assign all of my votes to it.
Re: How to rotate a border item [message #165460 is a reply to message #162479] Fri, 14 December 2007 15:32 Go to previous messageGo to next message
Jaap Reitsma is currently offline Jaap ReitsmaFriend
Messages: 69
Registered: July 2009
Member
Hi Cherie,

How did you do that with the invalidate()? With the debugger it looks as if
the position with reference to its border is still unknown. Only after
moving the border item the position (side) is determined correctly....

Kind regards,

Jaap

"Cherie Revells" <crevells@ca.ibm.com> wrote in message
news:fi78uj$ap0$1@build.eclipse.org...
> Jaap, Jacques:
>
> The figure for the connection handles on shapes also changes based on the
> side of the shape the connection handles appear on. I solved the
> initialization problem discussed in the other thread in the connection
> handles, by putting the locator.relocate() call in the border item
> figure's validate() method. It seemed sense to put it here to me as this
> is where the layout of the figure is normally triggered. I'm not sure if
> this will work for your scenario.
>
> As for rotating a figure, there is a rotate() method on the
> org.eclipse.draw2d.Graphics class. This method is implemented in the
> SWTGraphics class, but not in GMF's ScaledGraphics class. I would suggest
> you create a bugzilla to add this support to GMF's ScaledGraphics class,
> or better yet, try it yourself first and include your results in the
> bugzilla. I'm not sure if there are any implications to this or if it was
> just overlooked in GMF.
>
> Regards,
> Cherie
>
> Jaap Reitsma wrote:
>> Hi Jacques,
>>
>> The thread you refer to describes indeed the same issue. What I am
>> looking for is a solution for rotating the figure, and also for solving
>> the initialization problem that you also seem to have.
>>
>> Kind regards,
>>
>> Jaap
>>
>> "Jacques LESCOT" <jacques.lescot@anyware-tech.com> wrote in message
>> news:fi3a9r$t99$1@build.eclipse.org...
>>> There is an existing thread titled "how to change the border item's
>>> direction?" about this issue that could help you.
>>>
>>> Jacques
>>>
>>> Jaap Reitsma a
Re: How to rotate a border item [message #170927 is a reply to message #161946] Thu, 31 January 2008 15:55 Go to previous messageGo to next message
Jaap Reitsma is currently offline Jaap ReitsmaFriend
Messages: 69
Registered: July 2009
Member
Hi all,

At last I have fond a solution that rotates my bordered triangle (always
pointing inwards in a container) as well as being initialized properly when
opening the diagram. In my first attempt I used
MyTriangleEditPart.refreshBounds() to manipulate the orientation. Although
it works when dragging the triangle around the container, it does not get
initialized properly as the refreshBounds of the bordered item is called
when the layout of the parent has not been done yet.

The seemingly elegant solution is to hook into the layout of the border item
container, i.e. the parent of my bordered triangle figure. The code I have
used follows below:

/* (non-Javadoc)
* @see
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt#activate()
*/
@Override
public void activate() {
IBorderItemLocator locator = getBorderItemLocator();
if (locator instanceof BorderItemLocator) {
((BorderItemLocator)locator).setBorderItemOffset(new Dimension(8,
8));
}
IFigure figure = getFigure();
if (figure instanceof BorderedNodeFigure) {
BorderedNodeFigure bnf = (BorderedNodeFigure)figure;
IFigure bicf = bnf.getBorderItemContainer();
bicf.addLayoutListener(new LayoutListener.Stub() {
@Override
public void postLayout(IFigure container) {
getBorderItemLocator().relocate(getFigure());
int position =
getBorderItemLocator().getCurrentSideOfParent();
int rotation = 0;
switch (position) {
case PositionConstants.WEST:
break;
case PositionConstants.NORTH:
rotation = 90;
break;
case PositionConstants.EAST:
rotation = 180;
break;
case PositionConstants.SOUTH:
rotation = 270;
break;
default:
break;
}
getPrimaryShape().setRotationInDegrees(rotation);
}
});
}
super.activate();
}

The setRotationInDegrees is a method in my custom RotableScalablePolygon
which is actually a copy of the implementation of the inner figure generated
by GMF when using a scalable polygon as figure.

Kind Regards,

Jaap


"Jaap Reitsma" <jaap.reitsma@telin.nl> wrote in message
news:fi2co4$cq4$1@build.eclipse.org...
> Hi all,
>
> What is the best way to a rotate border item, depending on its position
> w.r.t. the parent?
>
> The situation: Our border item is a triangle, created with a Polygon. The
> triangle is sitting on the border of a rectangle and should always point
> inwards into the rectangle. Actually we gave it an offset
> (borderlocator.setBorderOffset()) so it appears pointing thru the border.
>
> A trick that works is to create four triangles, for each side one. Use a
> StackLayout as the LayoutManager and in the editpart.refreshBounds()
> determine which side the item is sitting
> (getBorderItemLocator().getCurrentSideOfParent().) and then set one of the
> four triangles to visible.
>
> But I am thinking of using a transformation to rotate the polygone (or
> some other shape), and to spare me the hassle with the StackLayout. Is
> that possible, and if so, how?
>
> Kind regards,
>
> Jaap Reitsma
>
Re: How to rotate a border item [message #668318 is a reply to message #170927] Thu, 05 May 2011 07:42 Go to previous message
Rahma  is currently offline Rahma Friend
Messages: 7
Registered: February 2011
Junior Member
Hi Jaap,

Can you please Help me,
I Have the same problem, but I can't understand your solution:
1) Can you, give me the code of the method setRotationInDegrees and in which class is placed?

2)In which class exactly is placed the following code ?

* (non-Javadoc)
* @see
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt#activate()
*/
@Override
public void activate() {
IBorderItemLocator locator = getBorderItemLocator();
if (locator instanceof BorderItemLocator) {
.......

Thanks.

Rahma

[Updated on: Thu, 05 May 2011 07:43]

Report message to a moderator

Previous Topic:Edit Expression for Expression Label Mapping
Next Topic:extend the palette
Goto Forum:
  


Current Time: Tue Apr 16 06:34:43 GMT 2024

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

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

Back to the top