home *** CD-ROM | disk | FTP | other *** search
-
- package sub_arctic.input;
-
- import sub_arctic.lib.interactor;
- import java.awt.Point;
-
- /**
- * This interface provides the input protocol for objects which are the
- * targets of snapping. Normally these objects are stationary while
- * snap_draggable objects are dragged. Where the right conditions occur,
- * feedback is produced which snaps the objects together in
- * some way (typically by pulling the dragged object to the target object).
- * Snapping is considered to be "from" snap_draggable objects (called the
- * "drag" objects) "to" snap_targetable objects (called the "target" objects).
- * Both this protocol and the snap_draggable protocol are managed and
- * delivered by the snap_drag_agent.<p>
- *
- * Snapping requires a two part test. The first part is geometric. In this
- * part we determine if a feature point of the drag object is close enough
- * geometrically to snap to the target. If this test passes, then a second
- * semantic test is performed to determine if the two objects are semantically
- * compatible (this second test by snap_from_ok() may involve type tests
- * and/or exchange of information between the drag and target objects). If
- * both snapping tests succeed, and the snap is the closest candidate snap,
- * the snap will occur.<p>
- *
- * If their are no suitable snaps, but some snaps pass the geometric test
- * (i.e., are close enough) then "anti-snaps" will be considered. An
- * anti-snap is designed to provide feedback about a negative condition --
- * it is typically used to produce a kind of dynamic "error message" that
- * indicates why a geometrically possible snap is not semantically suitable.
- * Anti-snaps must pass a second semantic test (performed by
- * anti_snap_from_ok()) before they are activated.<p>
- *
- * @see sub_arctic.input.snap_draggable
- * @see sub_arctic.input.snap_drag_agent
- * @author Scott Hudson
- */
- public interface snap_targetable extends interactor {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Determine if the given point (in local coordinates) is close enough
- * to snap to this object (and return the square of its distance, and
- * the point snapped to). This is a geometric test only. To maintain
- * uniformity, objects should normally report a snap here if the square
- * of the distance to the point is less than or equal to
- * snap_drag_agent.snap_dist2(). The return_dist2 object should be
- * modified so that it contains the square of the distance from the point
- * to the target. The return_snap_pt object should be modified to return
- * the final snap point. Both return_dist2 and return_snap_pt are ignored
- * if the routine returns false.
- *
- * @param pt the point being tested (in local coordinates).
- * @param return_dist2 to be modified to contain the square of the distance
- * to the point (ignored if false is returned).
- * @param return_snap_pt to be modified to contain the final snap target
- * point in local coordinates (ignored if false is
- * returned).
- * @return boolean indicating whether snap is geometrically accepted.
- */
- public boolean point_snaps(
- Point pt,
- int_holder return_dist2,
- Point return_snap_pt);
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Determine if a geometrically accepted snap should be semantically
- * accepted. Normally target objects only accept snaps from drag
- * objects that meet certain qualifications. This routine is responsible
- * for determining if the given object and the given feature point within
- * that object meets the current criteria for a snap. This normally
- * involves determining whether the drag object implements a certain
- * (application specific) interface, then using the protocol of that
- * interface to query the properties of the drag object.
- *
- * @param pt the pre-snap location of the feature point being
- * tested.
- * @param drag_obj the drag object being tested.
- * @param feature_pt_indx the index of the feature point (within drag_obj)
- * being tested.
- * @return whether the snap is acceptable.
- */
- public boolean snap_from_ok(
- Point pt,
- snap_draggable drag_obj,
- int feature_pt_indx);
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Determine if a geometrically accepted snap which has been semantically
- * rejected (by snap_from_obj()) should provide anti-snap feedback.
- * (Anti-snap feedback supplies a sort of dynamic error message that
- * indicates why a snap is illegal.) This may involve determining whether
- * the drag object implements a certain (application specific) interface,
- * then using the protocol of that interface to query the properties of the
- * drag object. In other cases a generic "wrong type" anti-snap might be
- * performed.<p>
- *
- * If no anti-snap is to be applied, null is returned. Otherwise an object
- * with information about the reason for the anti-snap is returned. This
- * object will then be passed to various anti-snap calls.
- *
- * @param pt the pre-snap location of the feature point being
- * tested.
- * @param drag_obj the drag object being tested.
- * @param feature_pt_indx the index of the feature point (within drag_obj)
- * being tested.
- * @return Object null for no anti-snap. If anti-snap feedback is desired a
- * non-null object is returned (which is later passed to
- * various anti-snap routines in the protocol).
- */
- public Object anti_snap_from_ok(
- Point pt,
- snap_draggable drag_obj,
- int feature_pt_indx);
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Do the feedback corresponding to a snap from the given drag object.
- *
- * @param event evt the event "causing" the snap.
- * @param Point orig_pt where the dragged object would be
- * without the snap.
- * @param Point snap_pt the snap point.
- * @param snap_draggable drag_obj the dragged object we are snapping
- * from.
- * @param int feature_pt_indx the feature point of that object
- * that we are snapping with.
- * @param Object user_info the user info for this input.
- * @return boolean indicating if the input has been consumed.
- */
- public boolean snap_from(
- event evt,
- Point orig_pt,
- Point snap_pt,
- snap_draggable drag_obj,
- int feature_pt_indx,
- Object user_info);
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Perform feedback while a snap is active.
- *
- * @param event evt the event "causing" the snap.
- * @param Point orig_pt where the dragged object would be
- * without the snap.
- * @param Point snap_pt the snap point.
- * @param snap_draggable drag_obj the dragged object we are snapping
- * from.
- * @param int feature_pt_indx the feature point of that object
- * that we are snapping with.
- * @param Object user_info the user info for this input.
- * @return boolean indicating if the input has been consumed.
- */
- public boolean snap_feedback(
- event evt,
- Point orig_pt,
- Point snap_pt,
- snap_draggable drag_obj,
- int feature_pt_indx,
- Object user_info);
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Remove feedback for a snap that is now being broken.
- *
- * @param event evt the event "causing" the unsnap.
- * @param Point orig_pt where the dragged object would be
- * without the snap.
- * @param Point snap_pt the snap point.
- * @param snap_draggable drag_obj the dragged object we are
- * unsnapping from.
- * @param int feature_pt_indx the feature point of that object
- * that we are unsnapping with.
- * @param Object user_info the user info for this input.
- * @return boolean indicating if the input has been consumed.
- */
- public boolean unsnap_from(
- event evt,
- Point orig_pt,
- Point snap_pt,
- snap_draggable drag_obj,
- int feature_pt_indx,
- Object user_info);
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Do anti-snap feedback corresponding to an anti-snap from the given
- * drag object.
- *
- * @param event evt the event "causing" the anti-snap.
- * @param Point orig_pt where the dragged object would be
- * without the anti-snap.
- * @param Point snap_pt the anti-snap point.
- * @param snap_draggable drag_obj the dragged object we are
- * anti-snapping from.
- * @param int feature_pt_indx the feature point of that object
- * that we are anti-snapping with.
- * @param Object user_info the user info for this input.
- * @return boolean indicating if the input has been consumed.
- */
- public boolean anti_snap_from(
- event evt,
- Point orig_pt,
- Point snap_pt,
- snap_draggable drag_obj,
- int feature_pt_indx,
- Object anti_snap_info,
- Object user_info);
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Perform feedback while an anti-snap is active.
- *
- * @param event evt the event "causing" the anti-snap.
- * @param Point orig_pt where the dragged object would be
- * without the anti-snap.
- * @param Point snap_pt the anti-snap point.
- * @param snap_draggable drag_obj the dragged object we are
- * anti-snapping from.
- * @param int feature_pt_indx the feature point of that object
- * that we are anti-snapping with.
- * @param Object user_info the user info for this input.
- * @return boolean indicating if the input has been consumed.
- */
- public boolean anti_snap_feedback(
- event evt,
- Point orig_pt,
- Point snap_pt,
- snap_draggable drag_obj,
- int feature_pt_indx,
- Object anti_snap_info,
- Object user_info);
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Remove anti-snap feedback for an anti-snap that is now being broken.
- *
- * @param event evt the event "causing" the unanti-snap.
- * @param Point orig_pt where the dragged object would be
- * without the anti-snap.
- * @param Point snap_pt the anti-snap point.
- * @param snap_draggable drag_obj the dragged object we are
- * unanti-snapping from.
- * @param int feature_pt_indx the feature point of that object
- * that we are unanti-snapping with.
- * @param Object user_info the user info for this input.
- * @return boolean indicating if the input has been consumed.
- */
- public boolean unanti_snap_from(
- event evt,
- Point orig_pt,
- Point snap_pt,
- snap_draggable drag_obj,
- int feature_pt_indx,
- Object anti_snap_info,
- Object user_info);
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- }
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-