|
 |
|
|
org.eclipse.gef.editpolicies
Class ConstrainedLayoutEditPolicy
java.lang.Object
org.eclipse.gef.editpolicies.AbstractEditPolicy
org.eclipse.gef.editpolicies.GraphicalEditPolicy
org.eclipse.gef.editpolicies.LayoutEditPolicy
org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy
-
All Implemented Interfaces:
-
EditPolicy,
RequestConstants
-
Direct Known Subclasses:
-
XYLayoutEditPolicy
- public abstract class ConstrainedLayoutEditPolicy
- extends
LayoutEditPolicy
For use with LayoutManager that require a constraint.
ConstrainedLayoutEditPolicy understands
RequestConstants.REQ_ALIGN_CHILDREN
in addition to the Requests handled in the superclass.
-
Since:
- 2.0
Fields inherited from interface org.eclipse.gef.
EditPolicy
|
COMPONENT_ROLE,
CONNECTION_BENDPOINTS_ROLE,
CONNECTION_ENDPOINTS_ROLE,
CONNECTION_ROLE,
CONTAINER_ROLE,
DIRECT_EDIT_ROLE,
GRAPHICAL_NODE_ROLE,
LAYOUT_ROLE,
NODE_ROLE,
PRIMARY_DRAG_ROLE,
SELECTION_FEEDBACK_ROLE,
TREE_CONTAINER_ROLE
|
Fields inherited from interface org.eclipse.gef.
RequestConstants
|
REQ_ADD,
REQ_ALIGN,
REQ_ALIGN_CHILDREN,
REQ_CLONE,
REQ_CONNECTION_END,
REQ_CONNECTION_START,
REQ_CREATE,
REQ_CREATE_BENDPOINT,
REQ_DELETE,
REQ_DELETE_DEPENDANT,
REQ_DIRECT_EDIT,
REQ_MOVE,
REQ_MOVE_BENDPOINT,
REQ_MOVE_CHILDREN,
REQ_OPEN,
REQ_ORPHAN,
REQ_ORPHAN_CHILDREN,
REQ_RECONNECT_SOURCE,
REQ_RECONNECT_TARGET,
REQ_RESIZE,
REQ_RESIZE_CHILDREN,
REQ_SELECTION,
REQ_SELECTION_HOVER
|
Methods inherited from class org.eclipse.gef.editpolicies.
LayoutEditPolicy
|
activate,
createListener,
createSizeOnDropFeedback,
deactivate,
decorateChild,
decorateChildren,
eraseLayoutTargetFeedback,
eraseSizeOnDropFeedback,
eraseTargetFeedback,
getCloneCommand,
getCreateCommand,
getCreationFeedbackOffset,
getDeleteDependantCommand,
getLayoutContainer,
getOrphanChildrenCommand,
getSizeOnDropFeedback,
getSizeOnDropFeedback,
getTargetEditPart,
setListener,
showLayoutTargetFeedback,
showSizeOnDropFeedback,
showTargetFeedback,
undecorateChild,
undecorateChildren
|
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
|
ConstrainedLayoutEditPolicy
public ConstrainedLayoutEditPolicy()
createAddCommand
protected
Command createAddCommand(
EditPart child,
java.lang.Object constraint)
- Returns the
Command to perform an Add with the specified child and
constraint. The constraint has been converted from a draw2d constraint to an object
suitable for the model by calling
translateToModelConstraint(Object) .
-
-
Parameters:
-
child - the EditPart of the child being added -
constraint - the model constraint, after being
translated
-
Returns:
- the Command to add the child
createChangeConstraintCommand
protected
Command createChangeConstraintCommand(
ChangeBoundsRequest request,
EditPart child,
java.lang.Object constraint)
- The request is now made available when creating the change constraint command. By
default, this method invokes the old
method .
-
-
Parameters:
-
request - the ChangeBoundsRequest -
child - the EditPart of the child being changed -
constraint - the new constraint, after being
translated
-
Returns:
- A Command to change the constraints of the given child as specified in the
given request
-
Since:
- 3.0
-
See Also:
-
createChangeConstraintCommand(EditPart, Object)
createChangeConstraintCommand
protected abstract
Command createChangeConstraintCommand(
EditPart child,
java.lang.Object constraint)
- Returns the
Command to change the specified child's constraint. The
constraint has been converted from a draw2d constraint to an object suitable for the
model
-
-
Parameters:
-
child - the EditPart of the child being changed -
constraint - the new constraint, after being
translated
-
Returns:
- Command
-
See Also:
-
createChangeConstraintCommand(ChangeBoundsRequest, EditPart, Object)
createChildEditPolicy
protected
EditPolicy createChildEditPolicy(
EditPart child)
- A
ResizableEditPolicy is used by default for children. Subclasses may
override this method to supply a different EditPolicy.
-
-
Specified by:
-
createChildEditPolicy
in class
LayoutEditPolicy
-
-
Parameters:
-
child - the child EditPart
-
Returns:
- an EditPolicy to be installed as the
EditPolicy.PRIMARY_DRAG_ROLE
-
See Also:
-
LayoutEditPolicy.createChildEditPolicy(EditPart)
getAddCommand
protected
Command getAddCommand(
Request generic)
- Overrides
getAddCommand() to generate the proper constraint for each child
being added. Once the constraint is calculated,
createAddCommand(EditPart,Object) is called. Subclasses must implement this method.
-
-
Overrides:
-
getAddCommand
in class
LayoutEditPolicy
-
-
Parameters:
-
generic - the ADD Request
-
Returns:
- A command to perform the ADD.
-
See Also:
-
LayoutEditPolicy.getAddCommand(Request)
getAlignChildrenCommand
protected
Command getAlignChildrenCommand(
AlignmentRequest request)
- Returns the command to align a group of children. By default, this is treated the same
as a resize, and
getResizeChildrenCommand(ChangeBoundsRequest) is returned.
-
-
Parameters:
-
request - the AligmentRequest
-
Returns:
- the command to perform aligment
getCommand
public
Command getCommand(
Request request)
- Factors out RESIZE and ALIGN requests, otherwise calls
super .
-
-
Specified by:
-
getCommand
in interface
EditPolicy
-
Overrides:
-
getCommand
in class
LayoutEditPolicy
-
-
See Also:
-
EditPolicy.getCommand(Request)
getConstraintFor
protected java.lang.Object getConstraintFor(
ChangeBoundsRequest request,
GraphicalEditPart child)
- Generates a draw2d constraint object derived from the specified child EditPart using
the provided Request. The returned constraint will be translated to the application's
model later using
translateToModelConstraint(Object) .
-
-
Parameters:
-
request - the ChangeBoundsRequest -
child - the child EditPart for which the constraint should be generated
-
Returns:
- the draw2d constraint
getConstraintFor
protected abstract java.lang.Object getConstraintFor(
Point point)
- Generates a draw2d constraint given a
Point . This method is called during
creation, when only a mouse location is available.
-
-
Parameters:
-
point - the Point relative to the
layout origin
-
Returns:
- the constraint
getConstraintFor
protected abstract java.lang.Object getConstraintFor(
Rectangle rect)
- Generates a draw2d constraint given a
Rectangle . This method is called
during most operations.
-
-
Parameters:
-
rect - the Rectangle relative to the
layout origin
-
Returns:
- the constraint
getConstraintFor
protected java.lang.Object getConstraintFor(
CreateRequest request)
- Generates a draw2d constraint for the given
CreateRequest . If the
CreateRequest has a size,
getConstraintFor(Rectangle) is called with a
Rectangle of that size and the result is returned. This is used during size-on-drop
creation. Otherwise,
getConstraintFor(Point) is returned.
The CreateRequest's location is relative the Viewer. The location is made
layout-relative before calling one of the methods mentioned above.
-
-
Parameters:
-
request - the CreateRequest
-
Returns:
- a draw2d constraint
getConstraintForClone
protected java.lang.Object getConstraintForClone(
GraphicalEditPart part,
ChangeBoundsRequest request)
- Returns the correct rectangle bounds for the new clone's location.
-
-
Parameters:
-
part - the graphical edit part representing the object to be cloned. -
request - the changeboundsrequest that knows where to place the new
object.
-
Returns:
- the bounds that will be used for the new object.
translateToModelConstraint
protected java.lang.Object translateToModelConstraint(java.lang.Object figureConstraint)
- Converts a constraint from the format used by LayoutManagers,
to the form stored in the model.
-
-
Parameters:
-
figureConstraint - the draw2d constraint
-
Returns:
- the model constraint
getResizeChildrenCommand
protected
Command getResizeChildrenCommand(
ChangeBoundsRequest request)
- Returns the
Command to resize a group of children.
-
-
Parameters:
-
request - the ChangeBoundsRequest
-
Returns:
- the Command
getMoveChildrenCommand
protected
Command getMoveChildrenCommand(
Request request)
- Returns the
Command to move a group of children. By default, move is
treated the same as a resize.
-
-
Specified by:
-
getMoveChildrenCommand
in class
LayoutEditPolicy
-
-
Parameters:
-
request - the Request
-
Returns:
- the Command to perform the move
-
See Also:
-
LayoutEditPolicy.getMoveChildrenCommand(Request)
getLayoutOrigin
protected
Point getLayoutOrigin()
- Returns the layout's origin relative to the
LayoutEditPolicy.getLayoutContainer() . In other words, what Point on the parent Figure
does the LayoutManager use a reference when generating the child figure's bounds from
the child's constraint.
By default, it is assumed that the layout manager positions children relative to the
client area of the layout container. Thus, when processing Viewer-relative Points or
Rectangles, the clientArea's location (top-left corner) will be subtracted from the
Point/Rectangle, resulting in an offset from the LayoutOrigin.
-
-
Returns:
- Point
Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved.
|
|
|