Java Reference
In-Depth Information
Table 9-5
Moving and Resizing Interactions
Tools
Requests
Edit Policies and Roles
Actions
DragEditPartsTracker
ChangeBoundsRequest
LayoutEditPolicy
AlignmentAction
ResizeTracker
AlignmentRequest
ResizableEditPolicy
MatchSizeAction
REQ_MOVE
ContainerEditPolicy
REQ_ADD
REQ_ORPHAN
REQ_CLONE
REQ_ALIGN
REQ_RESIZE
The
DragEditPartsTracker
extends basic selection behavior so that the
selected parts can be dragged within their graphical viewer. Dragging the selected
parts results in three potential interactions: move, reparent, and clone. All three
use the
ChangeBoundsRequest
, which extends
GroupRequest
to include a
size delta, move delta, and mouse location.
While dragging the selection, if the tracker targets the part's original parent,
the request is typed as
REQ_MOVE
. If the target changes, the interaction becomes
a reparent. For a reparent, a request of type
REQ_ORPHAN
is sent to the old par-
ent, and the new target is sent a request of type
REQ_ADD
. Pressing the Ctrl key
(Alt on the Mac) always results in a
REQ_CLONE
, which is sent only to the target
part.
All these requests are related, in that they require the target to process a rec-
tangle and a mouse location. The
LayoutEditPolicy
is responsible for han-
dling each of these request types. For layouts that use constraints, each part's
original bounds are taken and modified by the size and move deltas to determine
a new bounds, for which a corresponding constraint is found. For index-based
layouts, the mouse location is used to establish the new index.
A
ContainerEditPolicy
can optionally contribute additional commands
(not related to the layout) during
ADD
,
ORPHAN
, and
CLONE
requests.
Resizing
Resizing falls under the same category as changing bounds. Note that when resiz-
ing either the top or left sides, the location of the part also changes. Resizing
makes sense only for layouts with constraints, such as
XYLayout
. The
ResizableEditPolicy
adds up to eight resize handles to its host. Clicking the
Selection Tool on one of these resize handles prompts a
ResizeTracker
to
Search WWH ::
Custom Search