Skip to main content



      Home
Home » Eclipse Projects » GEF » RotatedRectangeFigure And Relevant Edit Policies Contribution
RotatedRectangeFigure And Relevant Edit Policies Contribution [message #202795] Sat, 12 November 2005 19:33 Go to next message
Eclipse UserFriend
Hello,

I have seen the lack of support for rotated figures in gef and I got
down writing my own solution. If eclipse gef comitee is interested in I
would like to contribute my work whic has:

A rotated Rectangular figure dervived from Polygon
RotatableResize tracker which allows resizing based on rotated
coordianet system
Rotate tracker which allows rotating around top left corner
Rotatable edit policy which wraps up the tracker to commands
RotatableResize Request which encapsulates the related requests...

Regards,
Hasan Ceylan
Re: RotatedRectangeFigure And Relevant Edit Policies Contribution [message #202826 is a reply to message #202795] Sun, 13 November 2005 11:49 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

ok - I'm not the eclipse/gef comitee, but I'm very interested
about new solutions in the GEF world!!

Greetings

Andreas

......where is your code!!!!!! :-))


Hasan Ceylan wrote:
> Hello,
>
> I have seen the lack of support for rotated figures in gef and I got
> down writing my own solution. If eclipse gef comitee is interested in I
> would like to contribute my work whic has:
>
> A rotated Rectangular figure dervived from Polygon
> RotatableResize tracker which allows resizing based on rotated
> coordianet system
> Rotate tracker which allows rotating around top left corner
> Rotatable edit policy which wraps up the tracker to commands
> RotatableResize Request which encapsulates the related requests...
>
> Regards,
> Hasan Ceylan
Re: RotatedRectangeFigure And Relevant Edit Policies Contribution [message #202849 is a reply to message #202826] Sun, 13 November 2005 23:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Those look like some nice features!


CL

FreeGroup wrote:
> Hi,
>
> ok - I'm not the eclipse/gef comitee, but I'm very interested
> about new solutions in the GEF world!!
>
> Greetings
>
> Andreas
>
> .....where is your code!!!!!! :-))
>
>
> Hasan Ceylan wrote:
>
>> Hello,
>>
>> I have seen the lack of support for rotated figures in gef and I got
>> down writing my own solution. If eclipse gef comitee is interested in
>> I would like to contribute my work whic has:
>>
>> A rotated Rectangular figure dervived from Polygon
>> RotatableResize tracker which allows resizing based on rotated
>> coordianet system
>> Rotate tracker which allows rotating around top left corner
>> Rotatable edit policy which wraps up the tracker to commands
>> RotatableResize Request which encapsulates the related requests...
>>
>> Regards,
>> Hasan Ceylan
Re: RotatedRectangeFigure And Relevant Edit Policies Contribution [message #202869 is a reply to message #202795] Mon, 14 November 2005 10:59 Go to previous messageGo to next message
Eclipse UserFriend
OK For those interested in, the link to the deployable features
extending gef and draw2d is http://www.ytg.com.tr/rotatable.zip

You will need to create an XYLayout similar to following. (Sorry have no
time to create a demo. And my application is propraitery therefore I
will not be able to post it)

You will need to derive your figures from ROtatableRectangleFigure to
take advantage of rotation. Beware that the code may not be possible not
yet production quality.

Child node rotatable rectangle figures are aware of their parent's angle
and place & paint themselves accordingly. Other child figures do not yet
rotate since there is no support in SWT (AFAIK) for both rotataion and
scaling. So that's a todo.

I have 3 derived trackers for Move, resize and rotate. For move this may
not have been needed. I leave it up to more experinced gef fellows.

You may freely distribute and use the code for your own purposes both
commercial and noncommercial. Just provided that it is accepted as is.

However I do love my name to be kept in the sources.

Enjoy and plase also pass on your improvements to me too.

Greetings from Istanbul,
Hasan Ceylan

<CODE>
import java.util.Iterator;

import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.RotatableRequestConstants;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.RotatableResizableEditPolicy;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gef.requests.RotatableChangeBoundsRequest;

import com.ytg.cinema.layout.designer.commands.AddCommand;
import com.ytg.cinema.layout.designer.commands.CloneCommand;
import com.ytg.cinema.layout.designer.commands.CreateCommand;
import com.ytg.cinema.layout.designer.commands.SetConstraintCommand ;
import com.ytg.cinema.layout.designer.model.LayoutContainerElement;
import com.ytg.cinema.layout.designer.model.LayoutElement;

public class LayoutXYLayoutEditPolicy extends
org.eclipse.gef.editpolicies.XYLayoutEditPolicy implements
RotatableRequestConstants {

private boolean childrenResizable;

public LayoutXYLayoutEditPolicy(XYLayout layout, boolean
childrenResizable) {
super();
setXyLayout(layout);
this.childrenResizable = childrenResizable;
}

@Override
protected Command createChangeConstraintCommand(EditPart child,
Object constraint) {
return null;
}

@Override
protected Command getCreateCommand(CreateRequest request) {
CreateCommand cmd = new CreateCommand();
cmd.setParent((LayoutContainerElement) getHost().getModel());
cmd.setChild((LayoutElement) request.getNewObject());
cmd.setLabel("Create");

return cmd;
}

protected EditPolicy createChildEditPolicy(EditPart child) {
return new RotatableResizableEditPolicy(childrenResizable);
}

protected Command createRotatableChangeConstraintCommand(
RotatableChangeBoundsRequest request) {
return new SetConstraintCommand(request);

}

@Override
protected Command createAddCommand(EditPart child, Object constraint) {
AddCommand command = new AddCommand();
command.setChild((LayoutElement) child.getModel());
command.setParent((LayoutContainerElement) (getHost().getModel()));
return command;
}

/*
* (non-Javadoc)
*
* @see
org.eclipse.gef.editpolicies.AbstractEditPolicy#understandsR equest(org.eclipse.gef.Request)
*/
@Override
public boolean understandsRequest(Request req) {
Object type = req.getType();
if (REQ_ROTATABLE_MOVE_CHILDREN.equals(type)
|| REQ_ROTATABLE_RESIZE_CHILDREN.equals(type)
|| REQ_ROTATE.equals(type))
return true;
return super.understandsRequest(req);
}

/*
* (non-Javadoc)
*
* @see
org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#get Command(org.eclipse.gef.Request)
*/
@Override
public Command getCommand(Request request) {
Object type = request.getType();
if (REQ_ROTATABLE_MOVE_CHILDREN.equals(type)
|| REQ_ROTATABLE_RESIZE_CHILDREN.equals(type)
|| REQ_ROTATE_CHILDREN.equals(type))
return
createRotatableChangeConstraintCommand((RotatableChangeBound sRequest)
request);

return super.getCommand(request);
}

/**
* Returns the <i>host</i> if the Request is an ADD, MOVE, or CREATE.
*
* @see org.eclipse.gef.EditPolicy#getTargetEditPart(Request)
*/
@Override
public EditPart getTargetEditPart(Request request) {
if (REQ_ROTATABLE_MOVE.equals(request.getType()))
return getHost();
else
return super.getTargetEditPart(request);
}

/*
* (non-Javadoc)
*
* @see
org.eclipse.gef.editpolicies.LayoutEditPolicy#getCloneComman d(org.eclipse.gef.requests.ChangeBoundsRequest)
*/
protected Command getCloneCommand(ChangeBoundsRequest request) {
CloneCommand clone = new CloneCommand();

clone.setParent((LayoutContainerElement) getHost().getModel());

Iterator i = request.getEditParts().iterator();
while (i.hasNext()) {
GraphicalEditPart part = (GraphicalEditPart) i.next();
clone.addPart((LayoutElement) part.getModel(),
(Rectangle) getConstraintForClone(part, request));
}

return clone;
}

}

</CODE>
CL [dnoyeb] Gilbert wrote:
> Those look like some nice features!
>
>
> CL
>
> FreeGroup wrote:
>
>> Hi,
>>
>> ok - I'm not the eclipse/gef comitee, but I'm very interested
>> about new solutions in the GEF world!!
>>
>> Greetings
>>
>> Andreas
>>
>> .....where is your code!!!!!! :-))
>>
>>
>> Hasan Ceylan wrote:
>>
>>> Hello,
>>>
>>> I have seen the lack of support for rotated figures in gef and I got
>>> down writing my own solution. If eclipse gef comitee is interested in
>>> I would like to contribute my work whic has:
>>>
>>> A rotated Rectangular figure dervived from Polygon
>>> RotatableResize tracker which allows resizing based on rotated
>>> coordianet system
>>> Rotate tracker which allows rotating around top left corner
>>> Rotatable edit policy which wraps up the tracker to commands
>>> RotatableResize Request which encapsulates the related requests...
>>>
>>> Regards,
>>> Hasan Ceylan
Re: RotatedRectangeFigure And Relevant Edit Policies Contribution [message #202982 is a reply to message #202795] Tue, 15 November 2005 14:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Currently rotating does not work generally because we cannot fully support
the API on Graphics. For example, if you rotate by 10 degrees, you can't
call clip afterwards because there is no easy way to create the
intersection.

But, we could support increments of 90 degrees better since the rotated
rectangle would still be a rectangle. You could then compose and rotate any
standard figure in multiples of 90.

The easiest way to contribute is just to open a bugzilla and attach the
code.

"Hasan Ceylan" <hceylan@ytg.com.tr> wrote in message
news:dl61l3$3l8$1@news.eclipse.org...
> Hello,
>
> I have seen the lack of support for rotated figures in gef and I got down
> writing my own solution. If eclipse gef comitee is interested in I would
> like to contribute my work whic has:
>
> A rotated Rectangular figure dervived from Polygon
> RotatableResize tracker which allows resizing based on rotated coordianet
> system
> Rotate tracker which allows rotating around top left corner
> Rotatable edit policy which wraps up the tracker to commands
> RotatableResize Request which encapsulates the related requests...
>
> Regards,
> Hasan Ceylan
Re: RotatedRectangeFigure And Relevant Edit Policies Contribution [message #203025 is a reply to message #202982] Wed, 16 November 2005 06:52 Go to previous messageGo to next message
Eclipse UserFriend
Thank you Randy...

I needed to rotate for sub 90 degrees. Therefore Icame up with idea of
updating the bounds fixing the *virtual* top left corner of rectangle in
the absolute coordinate system and generating a polygon off of
transformed coordinates of the all four points.

I know that currently api does not support this and I know the reasons
for that. I am waiting for the SWT team to implement better state
push/pop/restore so that I can use advanced futures like
scale/alpha/rotate side by side.

I will open a bugzilla for the contribution.

Fells good to give back something...

Hasan Ceylan

Randy Hudson wrote:
> Currently rotating does not work generally because we cannot fully support
> the API on Graphics. For example, if you rotate by 10 degrees, you can't
> call clip afterwards because there is no easy way to create the
> intersection.
>
> But, we could support increments of 90 degrees better since the rotated
> rectangle would still be a rectangle. You could then compose and rotate any
> standard figure in multiples of 90.
>
> The easiest way to contribute is just to open a bugzilla and attach the
> code.
>
> "Hasan Ceylan" <hceylan@ytg.com.tr> wrote in message
> news:dl61l3$3l8$1@news.eclipse.org...
>
>>Hello,
>>
>>I have seen the lack of support for rotated figures in gef and I got down
>>writing my own solution. If eclipse gef comitee is interested in I would
>>like to contribute my work whic has:
>>
>>A rotated Rectangular figure dervived from Polygon
>>RotatableResize tracker which allows resizing based on rotated coordianet
>>system
>>Rotate tracker which allows rotating around top left corner
>>Rotatable edit policy which wraps up the tracker to commands
>>RotatableResize Request which encapsulates the related requests...
>>
>>Regards,
>>Hasan Ceylan
>
>
>
Re: RotatedRectangeFigure And Relevant Edit Policies Contribution [message #205433 is a reply to message #203025] Fri, 16 December 2005 08:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ananth.exorindia.com

Hi Hasan
Iam realy very happy to see your artical (14 Nov 2005)Rotatable figure.
Which is very help full for all developers......

Actually i am new to eclipse plug-in development.I need ur great help..
Iam designing a widget.The widget name is Line widget.My req is ..The =
widget should be with 2 handles.
Even the widget is rotatable i mean the widget should have to act like =
line in MS WORD.
The 2 handle have to move any where in the editor and acc to that i have =
to draw the line.

Is it possiable in eclipse?
Can i possiable to use ur code i mean rotatable.zip.

Plz i need ur great reply
Regards,

S.Ananth
Re: RotatedRectangeFigure And Relevant Edit Policies Contribution [message #207863 is a reply to message #202869] Mon, 23 January 2006 09:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: michal.cabak.jcommerce.pl

Hi,

Could You give me a hint about possible model object that could handle
the RotatableRectangleFigure? I mean, what attributes should I store in
order to fully construct this figure:

just points?

Furthermore, what methods and in what order should I invoke (in method
refreshVisuals) to create this figure from the model:

for each point: addPoint()?


Would be great if you enclose instances of Command and EditPart that
handles this figure features.

Thanks in advance

Michal
Re: RotatedRectangeFigure And Relevant Edit Policies Contribution [message #211512 is a reply to message #207863] Mon, 13 March 2006 14:06 Go to previous message
Eclipse UserFriend
Originally posted by: ytgyazilim.gmail.com

All,

I know that I kinda threw an idea and left it out there.

I am sorry for that.
Give me couple of more months to maturize the idea then I will post the
results. Meanwhile keep the figures not rotated and provide the feature
as a future feature.

That's actually what I will do since then...

Thanks,
Hasan

Michal Cabak wrote:
> Hi,
>
> Could You give me a hint about possible model object that could handle
> the RotatableRectangleFigure? I mean, what attributes should I store in
> order to fully construct this figure:
>
> just points?
>
> Furthermore, what methods and in what order should I invoke (in method
> refreshVisuals) to create this figure from the model:
>
> for each point: addPoint()?
>
>
> Would be great if you enclose instances of Command and EditPart that
> handles this figure features.
>
> Thanks in advance
>
> Michal
>
>
>
>
Previous Topic:How to prevent resize feedback in a LayoutEditPolicy?
Next Topic:right mouse click, mouse position
Goto Forum:
  


Current Time: Sat May 10 10:12:57 EDT 2025

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

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

Back to the top