RotatedRectangeFigure And Relevant Edit Policies Contribution [message #202795] |
Sat, 12 November 2005 19:33  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #211512 is a reply to message #207863] |
Mon, 13 March 2006 14:06  |
Eclipse User |
|
|
|
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
>
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.04161 seconds