Eclipse GEF
2.1

org.eclipse.gef.editpolicies
Class XYLayoutEditPolicy

java.lang.Object
  |
  +--org.eclipse.gef.editpolicies.AbstractEditPolicy
        |
        +--org.eclipse.gef.editpolicies.GraphicalEditPolicy
              |
              +--org.eclipse.gef.editpolicies.LayoutEditPolicy
                    |
                    +--org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy
                          |
                          +--org.eclipse.gef.editpolicies.XYLayoutEditPolicy
All Implemented Interfaces:
EditPolicy, RequestConstants

public abstract class XYLayoutEditPolicy
extends ConstrainedLayoutEditPolicy

An EditPolicy for use with Figures in XYLayout. The constraint for XYLayout is a Rectangle. Created on :Nov 12, 2002

Since:
2.0

Field Summary
 
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_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
 
Constructor Summary
XYLayoutEditPolicy()
           
 
Method Summary
protected  Object getConstraintFor(ChangeBoundsRequest request, GraphicalEditPart child)
          Overridden to prevent sizes from becoming too small, and to prevent preferred sizes from getting lost.
 Object getConstraintFor(Point p)
          Returns a Rectangle at the given Point with width and height of -1.
 Object getConstraintFor(Rectangle r)
          Returns a new Rectangle equivalent to the passed Rectangle.
protected  Rectangle getCurrentConstraintFor(GraphicalEditPart child)
          Retrieves the child's current constraint from the LayoutManager.
protected  Point getLayoutOrigin()
          Returns XYLayout.getOrigin(IFigure).
protected  Dimension getMinimumSizeFor(GraphicalEditPart child)
          Determines the minimum size that the specified child can be resized to.
protected  void showSizeOnDropFeedback(CreateRequest request)
          Places the feedback rectangle where the User indicated.
 
Methods inherited from class org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy
createAddCommand, createChangeConstraintCommand, createChildEditPolicy, getAddCommand, getAlignChildrenCommand, getCommand, getConstraintFor, getMoveChildrenCommand, getResizeChildrenCommand, translateToModelConstraint
 
Methods inherited from class org.eclipse.gef.editpolicies.LayoutEditPolicy
activate, createListener, deactivate, decorateChild, decorateChildren, eraseDragTargetFeedback, eraseLayoutTargetFeedback, eraseSizeOnDropFeedback, eraseTargetFeedback, getCreateCommand, getDeleteDependantCommand, getLayoutContainer, getOrphanChildrenCommand, getSizeOnDropFeedback, getTargetEditPart, setListener, showDragTargetFeedback, showLayoutTargetFeedback, showTargetFeedback
 
Methods inherited from class org.eclipse.gef.editpolicies.GraphicalEditPolicy
addFeedback, getHostFigure, getLayer, removeFeedback
 
Methods inherited from class org.eclipse.gef.editpolicies.AbstractEditPolicy
debugFeedback, eraseSourceFeedback, getHost, setHost, showSourceFeedback, toString, understandsRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XYLayoutEditPolicy

public XYLayoutEditPolicy()
Method Detail

getConstraintFor

public Object getConstraintFor(Rectangle r)
Returns a new Rectangle equivalent to the passed Rectangle.

Specified by:
getConstraintFor in class ConstrainedLayoutEditPolicy
Parameters:
r - the input Rectangle
Returns:
a copy of the input Rectangle

getConstraintFor

public Object getConstraintFor(Point p)
Returns a Rectangle at the given Point with width and height of -1. XYLayout uses width or height equal to '-1' to mean use the figure's preferred size.

Specified by:
getConstraintFor in class ConstrainedLayoutEditPolicy
Parameters:
p - the input Point
Returns:
a Rectangle

getConstraintFor

protected Object getConstraintFor(ChangeBoundsRequest request,
                                  GraphicalEditPart child)
Overridden to prevent sizes from becoming too small, and to prevent preferred sizes from getting lost. If the Request is a MOVE, the existing width and height are preserved. During RESIZE, the new width and height have a lower bound determined by getMinimumSizeFor(GraphicalEditPart).

Overrides:
getConstraintFor in class ConstrainedLayoutEditPolicy
Parameters:
request - the ChangeBoundsRequest
child - the child EditPart for which the constraint should be generated
Returns:
the draw2d constraint
See Also:
ConstrainedLayoutEditPolicy.getConstraintFor(ChangeBoundsRequest, GraphicalEditPart)

getCurrentConstraintFor

protected Rectangle getCurrentConstraintFor(GraphicalEditPart child)
Retrieves the child's current constraint from the LayoutManager.

Parameters:
child - the child
Returns:
the current constraint

getLayoutOrigin

protected Point getLayoutOrigin()
Returns XYLayout.getOrigin(IFigure).

Overrides:
getLayoutOrigin in class ConstrainedLayoutEditPolicy
Returns:
Point
See Also:
ConstrainedLayoutEditPolicy.getLayoutOrigin()

getMinimumSizeFor

protected Dimension getMinimumSizeFor(GraphicalEditPart child)
Determines the minimum size that the specified child can be resized to. Called from getConstraintFor(ChangeBoundsRequest, GraphicalEditPart). By default, a small Dimension is returned.

Parameters:
child - the child
Returns:
the minumum size

showSizeOnDropFeedback

protected void showSizeOnDropFeedback(CreateRequest request)
Places the feedback rectangle where the User indicated.

Overrides:
showSizeOnDropFeedback in class LayoutEditPolicy
Parameters:
request - the CreateRequest
See Also:
LayoutEditPolicy.showSizeOnDropFeedback(CreateRequest)

Eclipse GEF
2.1

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.