home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-10-04 | 195.9 KB | 5,628 lines |
-
- package sub_arctic.lib;
-
- import sub_arctic.input.pick_collector;
- import sub_arctic.input.event;
- import sub_arctic.input.focus_dispatch_agent;
- import sub_arctic.input.move_drag_filter;
-
- import sub_arctic.constraints.std_encoding_consts;
- import sub_arctic.constraints.std_constraint_consts;
- import sub_arctic.constraints.std_constraint_impl;
- import sub_arctic.constraints.std_constraint;
- import sub_arctic.constraints.std_function;
- import sub_arctic.constraints.std_ext_constraint;
- import sub_arctic.constraints.constraint;
- import sub_arctic.constraints.value_consumer;
- import sub_arctic.constraints.value_provider;
- import sub_arctic.constraints.consumer_part_ref;
- import sub_arctic.constraints.provider_part_ref;
-
- import sub_arctic.output.drawable;
-
- import java.util.Vector;
- import java.awt.Component;
- import java.awt.Point;
- import java.awt.Dimension;
- import java.awt.Rectangle;
-
- /**
- * This class provides the basic implementation for interactor objects.
- * Although it is possible to build interactor objects without inheriting
- * from this class (since interactor itself is an interface) all interactor
- * objects currently in the system inherit from this class. <p>
- *
- * This class provides basic capabilities in 12 areas:
- * <ul>
- * <li> constructor and initialization support,
- * <li> geometry management,
- * <li> coordinate system
- * <li> transformations,
- * <li> hierarchy management,
- * <li> traversal support,
- * <li> layout,
- * <li> picking,
- * <li> object status,
- * <li> output,
- * <li> support for common input protocols,
- * <li> user information, and
- * <li>debugging support.
- * </ul>
- * Each of these areas has a section in the source code. See the user's
- * manual for conceptual material related to each area (each of these areas
- * is covered by a sub-section of the user's manual) and see the methods
- * below for the details of each supported routine.<p>
- *
- * Note: due to limitations on some (most?) platforms that do not allow for
- * protected methods in interfaces, a number of routines here (and in the
- * interactor interface) that should be protected, are currently public.
- * These are marked by comments in the code, and will be reverted to protected
- * as soon as enough platforms allow.<p>
- *
- * By convention (here and throughout the system) instance variables are all
- * protected and begin with an underscore ('_'). When access methods are
- * provide, the read method has the same name but without the underscore
- * (e.g., x()), while the write method begins with 'set_' followed by the
- * base name (e.g., set_x()).<p>
- *
- * @author Scott Hudson
- */
- public class base_interactor extends min_interactor implements move_drag_filter{
-
- /*---------------------------------------------------------------------*/
- /* Instance variables */
- /*---------------------------------------------------------------------*/
-
- /* By convention instance variables are all protected and begin with
- * an underscore ('_'). When access methods are provide, the read
- * method has the same name but without the underscore (e.g., x()),
- * while the write method begins with 'set_' followed by the base name
- * (e.g., set_x()).
- */
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * X position of the object's top-left corner in parent's coordinate
- * system. Like all instance variables of this class, this variable
- * should probably never be accessed directly -- use the public access
- * methods instead.
- * @see #x
- * @see #set_x
- */
- protected int _x;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Y position of the object's top-left corner in parent's coordinate
- * system. Like all instance variables of this class, this variable
- * should probably never be accessed directly -- use the public access
- * methods instead.
- * @see #y
- * @see #set_y
- */
- protected int _y;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Width of the object. Like all instance variables of this class, this
- * variable should probably never be accessed directly -- use the public
- * access methods instead.
- * @see #w
- * @see #set_w
- */
- protected int _w;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Height of the object. Like all instance variables of this class, this
- * variable should probably never be accessed directly -- use the public
- * access methods instead.
- * @see #h
- * @see #set_h
- */
- protected int _h;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Encoding of constraint on x. This instance variable should never be
- * set directly.
- * @see sub_arctic.constraints.constraint
- * @see #x_constraint
- * @see #set_x_constraint
- */
- protected int _x_constraint;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Encoding of constraint on y. This instance variable should never be
- * set directly.
- * @see sub_arctic.constraints.constraint
- * @see #y_constraint
- * @see #set_y_constraint
- */
- protected int _y_constraint;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Encoding of constraint on w. This instance variable should never be
- * set directly.
- * @see sub_arctic.constraints.constraint
- * @see #w_constraint
- * @see #set_w_constraint
- */
- protected int _w_constraint;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Encoding of constraint on h. This instance variable should never be
- * set directly.
- * @see sub_arctic.constraints.constraint
- * @see #h_constraint
- * @see #set_h_constraint
- */
- protected int _h_constraint;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Encoding of constraint on visible. This instance variable should never be
- * set directly.
- * @see sub_arctic.constraints.constraint
- * @see #visible_constraint
- * @see #set_visible_constraint
- */
- protected int _visible_constraint;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Encoding of constraint on enabled. This instance variable should never be
- * set directly.
- * @see sub_arctic.constraints.constraint
- * @see #enabled_constraint
- * @see #set_enabled_constraint
- */
- protected int _enabled_constraint;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Encoding of constraint on part_a. This instance variable should never be
- * set directly.
- * @see sub_arctic.constraints.constraint
- * @see #part_a_constraint
- * @see #set_part_a_constraint
- */
- protected int _part_a_constraint;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Encoding of constraint on part_b. This instance variable should never be
- * set directly.
- * @see sub_arctic.constraints.constraint
- * @see #part_b_constraint
- * @see #set_part_b_constraint
- */
- protected int _part_b_constraint;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Parent of this object. Can be null if object is not currently installed
- * in an interactor tree, or if this is a top_level interactor. This
- * instance variable should never be set directly.
- * @see #parent
- * @see #set_parent
- */
- protected interactor _parent;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Index of this object within the parent's child list. This instance
- * variable should never be set directly.
- * @see #child_index
- * @see #set_child_index
- */
- protected int _child_index;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Child interactors of this object. _child_list will be null for
- * interactor classes that do not support children (in that case, the
- * SUPPORTS_CHILDREN bit in _flags should also be 0). Interactor
- * classes with FIXED_CHILDREN set to 1 will always have the same
- * number of children and attempting to assign outside that range will
- * cause an error. In general, entries may be null.
- *
- * @see #num_children
- * @see #child
- * @see #set_child
- * @see #add_child
- * @see #insert_child
- * @see #remove_child
- * @see #find_child
- * @see #move_child_to_top
- * @see #move_child_to_bottom
- * @see #move_child_upward
- * @see #move_child_downward
- */
- protected Vector _child_list;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Small bitset of flags indicating facts about this interactor. See
- * interactor_consts.java for possible values and their meaning. Flag
- * values are normally tested and set by flag_is_set(), set_flag_bit(),
- * and clear_flag_bit().
- *
- * @see sub_arctic.lib.interactor_consts
- * @see #flag_is_set
- * @see #set_flag_bit
- * @see #clear_flag_bit
- */
- protected int _flags = 0;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Small bitset of flags indicating facts about the constraints of this
- * interactor. See interactor_consts.java for possible values and their
- * meaning. Flag values are normally tested and set by
- * constraint_flag_is_set(), set_constraint_flag_bit(), and
- * clear_constraint_flag_bit().
- *
- * @see sub_arctic.lib.interactor_consts
- * @see #constraint_flag_is_set
- * @see #set_constraint_flag_bit
- * @see #clear_constraint_flag_bit
- */
- protected int _constraint_flags = 0;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Information we are holding for the user or application. This object
- * is attached to the interactor, but otherwise the toolkit itself does
- * not touch it. This allows for example, callback objects to retrieve
- * application specific information related to this object.
- *
- * @see #user_info
- * @see #set_user_info
- */
- protected Object _user_info;
-
- /*---------------------------------------------------------------------*/
- /* Constructors and init routines */
- /*---------------------------------------------------------------------*/
-
- /**
- * Full constructor.
- *
- * @param int x_v x position of this interactor within its parent's
- * coordinate system.
- * @param int y_v y position of this interactor within its parent's
- * coordinate system.
- * @param int w_v width of this interactor.
- * @param int h_v height of this interactor.
- */
- public base_interactor(int x_v, int y_v, int w_v, int h_v)
- {
- _parent = null;
- _child_list = null;
- _x = x_v;
- _y = y_v;
- _w = w_v;
- _h = h_v;
- _x_constraint = std_constraint_consts.NO_CONSTRAINT.encoding();
- _y_constraint = std_constraint_consts.NO_CONSTRAINT.encoding();
- _w_constraint = std_constraint_consts.NO_CONSTRAINT.encoding();
- _h_constraint = std_constraint_consts.NO_CONSTRAINT.encoding();
- _visible_constraint = std_constraint_consts.NO_CONSTRAINT.encoding();
- _enabled_constraint = std_constraint_consts.NO_CONSTRAINT.encoding();
- _part_a_constraint = std_constraint_consts.NO_CONSTRAINT.encoding();
- _part_b_constraint = std_constraint_consts.NO_CONSTRAINT.encoding();
- _flags = IS_VISIBLE | IS_ENABLED | DAMAGED;
- _constraint_flags = 0;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Constructor that assumes a (temporary) default size.
- *
- * @param int x_v x position of this interactor within its parent's
- * coordinate system.
- * @param int y_v y position of this interactor within its parent's
- * coordinate system.
- */
- public base_interactor(int x_v, int y_v)
- {
- /* Choose a small size we are unlikely to get otherwise by accident */
- this(x_v, y_v, 13, 17);
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Constructor that assumes a position of 0,0, and a (temporary) default
- * size.
- */
- public base_interactor()
- {
- this(0, 0);
- }
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Helper method to set up object to support an expandable set of children.
- * This will normally be called from the constructor of a subclass that
- * wants to support children (by default, base_interactor does not). The
- * size_hint indicates how much storage to initially allocate in the child
- * list Vector (however, num_children() initially returns 0 regardless of
- * what is given here).
- *
- * @param int size_hint hint for initial size allocation for the child vector.
- */
- protected void setup_for_children(int size_hint)
- {
- _flags |= SUPPORTS_CHILDREN;
- _child_list = new Vector(size_hint);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Default initial allocation for child lists */
- protected static final int default_child_hint = 3;
-
- /** Helper method to set up object to support children. This will normally
- * be called from the constructor of a subclass that wants to support
- * children (by default, base_interactor does not).
- */
- protected void setup_for_children()
- {
- setup_for_children(default_child_hint);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Helper method to set up object to support a fixed set of children.
- * This will normally be called from the constructor of a subclass that
- * wants to support children (by default base_interactor does not), but
- * which either assigns specific meanings/roles to specific children, or for
- * some other reason limits the number of children it will support. This
- * method allocates the given number of slots for children and sets them
- * each to null.
- *
- * int number the number of children this object will have.
- */
- protected void setup_for_fixed_children(int number)
- {
- _flags |= SUPPORTS_CHILDREN | FIXED_CHILDREN;
- _child_list = new Vector(number);
- _child_list.setSize(number);
- }
-
- /*---------------------------------------------------------------------*/
- /* Basic object geometry */
- /*---------------------------------------------------------------------*/
-
- /**
- * Position of the top-left corner of this object in the parent coordinate
- * system. If either coordinate is controlled by a constraint, it will be
- * brought up to date before this value is returned.
- * @return Point the position of the object.
- */
- public Point pos() {return new Point(x(), y());}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * X position of the top-left corner of this object in the parent coordinate
- * system. If this coordinate is controlled by a constraint, it will be
- * brought up to date before this value is returned.
- * @return int the x position of the object.
- */
- public int x()
- {
- /* make sure its up to date, then return it */
- eval_x();
- return _x;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Y position of the top-left corner of this object in the parent coordinate
- * system. If this coordinate is controlled by a constraint, it will be
- * brought up to date before this value is returned.
- * @return int the y position of the object.
- */
- public int y()
- {
- /* make sure its up to date, then return it */
- eval_y();
- return _y;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Size of the object. If either the width or height of the object is
- * controlled by a constraint, it will be brought up to date before this
- * value is returned.
- * @return Dimension the size of the object.
- */
- public Dimension size() {return new Dimension(w(),h());};
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Width of the object. If this value is controlled by a constraint, it will
- * be brought up to date before being returned.
- * @return int the width of the object.
- */
- public int w()
- {
- /* make sure its up to date, then return it */
- eval_w();
- return _w;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Height of the object. If this value is controlled by a constraint, it
- * will be brought up to date before being returned.
- * @return int the height of the object.
- */
- public int h()
- {
- /* make sure its up to date, then return it */
- eval_h();
- return _h;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Bounding rectangle of the object (in parent's coordinate system).
- * @return Rectangle the bounding rectangle of the object.
- */
- public Rectangle bound()
- {
- return new Rectangle(x(), y(), w(), h());
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Get the specified component (X, Y, W, or H) or of object's geometry. This
- * also now works for VISIBLE, ENABLED, PART_A, and PART_B.
- * @param what_code part number whose value is being requested.
- * @return int the value of the requested part (after brining any attached
- * constraints up-to-date).
- */
- public int get_part(int what_code)
- {
- switch (what_code)
- {
- case X: return x();
- case Y: return y();
- case W: return w();
- case H: return h();
- case VISIBLE: return visible()?1:0 ;
- case ENABLED: return enabled()?1:0;
- case PART_A: return part_a();
- case PART_B: return part_b();
- default:
- throw new sub_arctic_error("Unrecognized part code " + what_code +
- " passed to get_part()");
- }
- }
-
- //had:
- //* @exception bad_value if the given part number is unknown to this object.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set position of this object in parent coordinate system.
- *
- * @param int yv y coordinate of the position.
- * @param int xv x coordinate of the position.
- */
- public void set_pos(int xv, int yv)
- {
- set_x(xv);
- set_y(yv);
- }
-
- //had:
- //* @exception cannot_assign if either the x or y coordinate of the object
- //* is constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set position of this object in parent coordinate system.
- *
- * @param Point p the new position.
- */
- public void set_pos(Point p)
- {
- set_x(p.x);
- set_y(p.y);
- }
-
- //had:
- //* @exception cannot_assign if either the x or y coordinate of the object
- //* is constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set x value directly bypassing the constraint system (but doing movement
- * damage). This should normally only be done by the constraint system
- * or some other part of the system which takes care of marking things
- * out-of-date, etc. itself.
- *
- * @param int v the new value for x.
- */
- protected void set_raw_x(int v)
- {
- /* don't do anything unless this is a change */
- if (v != _x)
- {
- /* damage our old position */
- damage_self();
-
- /* move */
- _x = v;
-
- /* damage our new position */
- damage_self();
- }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set x component of position in parent coordinate system.
- * @param int v the new value for x.
- */
- public void set_x(int v)
- {
- /* if this has a constraint throw an exception */
- if ((active_constraints() & X) != 0)
- throw new sub_arctic_error(
- "Attempt to assign value to constrained x coordinate");
-
- /* don't do anything unless this is a change */
- if (v != _x)
- {
- set_raw_x(v);
- mark_x_ood();
- }
- }
-
- //had:
- //* @exception cannot_assign if a constraint is attached to this coordinate.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set y value directly bypassing the constraint system (but doing movement
- * damage). This should normally only be done by the constraint system
- * or some other part of the system which takes care of marking things
- * out-of-date, etc. itself.
- *
- * @param int v the new value for y.
- */
- protected void set_raw_y(int v)
- {
- /* don't do anything unless this is a change */
- if (v != _y)
- {
- /* damage our old position */
- damage_self();
-
- /* move */
- _y = v;
-
- /* damage our new position */
- damage_self();
- }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set y component of position in parent coordinate system.
- * @param int v the new value for y.
- */
- public void set_y(int v)
- {
- /* if this has a constraint throw an exception */
- if ((active_constraints() & Y) != 0)
- throw new sub_arctic_error(
- "Attempt to assign value to constrained y coordinate");
-
- /* don't do anything unless this is a change */
- if (v != _y)
- {
- set_raw_y(v);
- mark_y_ood();
- }
- }
-
- //had:
- //* @exception cannot_assign if a constraint is attached to this coordinate.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set the size of the object.
- * @param int wv the new value for w.
- * @param int hv the new value for h.
- */
- public void set_size(int wv, int hv)
- {
- set_w(wv);
- set_h(hv);
- }
-
- //had:
- //* @exception cannot_assign if a constraint is attached to either coordinate.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set intrinsic size. This method is called by subclasses to establish or
- * change the size of the interactor when its size is considered to be
- * intrinsically constrained. This method marks values out of date, but
- * does not declare damage for the object.
- *
- * @param int wv the new value for w.
- * @param int hv the new value for h.
- */
- protected void set_intrinsic_size(int wv, int hv)
- {
- set_intrinsic_w(wv);
- set_intrinsic_h(hv);
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Set w value directly bypassing the constraint system (but doing movement
- * damage). This should normally only be done by the constraint system
- * or some other part of the system which takes care of marking things
- * out-of-date, etc. itself.
- *
- * @param int v the new value for w.
- */
- protected void set_raw_w(int v)
- {
- /* don't do anything unless this is a change */
- if (v != _w)
- {
- /* damage our old position */
- damage_self();
-
- /* move */
- _w = v;
-
- /* damage our new position */
- damage_self();
- }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set width of object.
- * @param int v the new value for y.
- */
- public void set_w(int v)
- {
- /* if this has a constraint throw an exception */
- if ((active_constraints() & W) != 0)
- throw new sub_arctic_error(
- "Attempt to assign value to constrained width");
-
- /* don't do anything unless this is a change */
- if (v != _w)
- {
- set_raw_w(v);
- mark_w_ood();
- }
- }
-
- //had:
- //* @exception cannot_assign if a constraint is attached to this coordinate.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set intrinsic width. This method is called by subclasses to establish or
- * change the width of the interactor when its width is considered to be
- * intrinsically constrained. This method marks values out of date, but
- * does not declare damage for the object.
- *
- * @param int wv new value for w.
- */
- protected void set_intrinsic_w(int wv)
- {
- /* if the width is not declared as intrinsic, throw an exception */
- if ((W & intrinsic_constraints()) == 0)
- throw new sub_arctic_error("Value is not intrinsically constrained");
-
- if (wv != _w)
- {
- set_raw_w(wv);
- mark_w_ood();
- }
- }
-
- //had:
- //* @exception cannot_assign if the width is not intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set h value directly bypassing the constraint system (but doing movement
- * damage). This should normally only be done by the constraint system
- * or some other part of the system which takes care of marking things
- * out-of-date, etc. itself.
- *
- * @param int v the new value for the height.
- */
- protected void set_raw_h(int v)
- {
- /* don't do anything unless this is a change */
- if (v != _h)
- {
- /* damage our old position */
- damage_self();
-
- /* move */
- _h = v;
-
- /* damage our new position */
- damage_self();
- }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set height of object.
- * @param int v the new value for the height.
- */
- public void set_h(int v)
- {
- /* if this has a constraint throw an exception */
- if ((active_constraints() & H) != 0)
- throw new sub_arctic_error(
- "Attempt to assign value to constrained height");
-
- /* don't do anything unless this is a change */
- if (v != _h)
- {
- set_raw_h(v);
- mark_h_ood();
- }
- }
-
- //had:
- //* @exception cannot_assign if the height is controlled by a constraint.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set intrinsic height. This method is called by subclasses to establish or
- * change the height of the interactor when its width is considered to be
- * intrinsically constrained. This method marks values out of date, but
- * does not declare damage for the object.
- *
- * @param int hv the new value for the height.
- */
- protected void set_intrinsic_h(int hv)
- {
- /* if the height is not declared as intrinsic, throw an exception */
- if ((H & intrinsic_constraints()) == 0)
- throw new sub_arctic_error("Value is not intrinsically constrained");
-
- if (hv != _h)
- {
- set_raw_h(hv);
- mark_h_ood();
- }
- }
-
- //had:
- //* @exception cannot_assign if the height is not intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate if the object considers itself visible. If a constraint is
- * attached the value will be brought up-to-date with respect to the
- * constraint first.
- * @return boolean the visibility status of the object
- */
- public boolean visible()
- {
- /* make sure its up to date, then return the value */
- eval_visible();
- return flag_is_set(IS_VISIBLE);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set visible value directly bypassing the constraint system (but doing
- * screen damage). This should normally only be done by the constraint
- * system or some other part of the system which takes care of marking
- * things out-of-date, etc. itself.
- *
- * @param boolean v the new visibility status.
- */
- protected void set_raw_visible(boolean v)
- {
- /* don't do anything unless this is a change */
- if (v != flag_is_set(IS_VISIBLE))
- {
- /* change */
- set_flag_bit(IS_VISIBLE, v);
-
- /* damage our image */
- damage_self();
- }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set the visibility of the interactor.
- * @param boolean v the new visibility status.
- */
- public void set_visible(boolean v)
- {
- /* if this has a constraint throw an exception */
- if ((active_constraints() & VISIBLE) != 0)
- throw new sub_arctic_error(
- "Attempt to assign value to constrained visible coordinate");
-
- if (v != flag_is_set(IS_VISIBLE))
- {
- set_raw_visible(v);
- mark_visible_ood();
- }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate if object is enabled. If a constraint is attached the value
- * will be brought up-to-date with respect to the constraint first.<p>
- *
- * Note: currently setting an object disabled will keep it from being
- * picked by the normal picking mechanism. This will (normally) disable
- * positional inputs and as a side effect most focus based input (unless the
- * the object is already the focus). However, since enabled status was
- * added after many of the core interactor classes were created, for the
- * most part the interactors in the library do not yet properly reflect the
- * enable/disable status in their visual appearance. This is an important
- * deficiency which we hope to correct in future releases.
- *
- * @return boolean the enable status of the interactor.
- */
- public boolean enabled()
- {
- /* make sure its up to date, then return the value */
- eval_enabled();
- return flag_is_set(IS_ENABLED);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set enabled value directly bypassing the constraint system (but doing
- * screen damage). This should normally only be done by the constraint
- * system or some other part of the system which takes care of marking
- * things out-of-date, etc. itself.
- *
- * @param boolean v the new enable status.
- */
- protected void set_raw_enabled(boolean v)
- {
- /* don't do anything unless this is a change */
- if (v != flag_is_set(IS_ENABLED))
- {
- /* change */
- set_flag_bit(IS_ENABLED, v);
-
- /* damage our image */
- damage_self();
- }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set the enabled status of the interactor.
- * @param boolean v new value of enabled.
- */
- public void set_enabled(boolean v)
- {
- /* if this has a constraint throw an exception */
- if ((active_constraints() & ENABLED) != 0)
- throw new sub_arctic_error(
- "Attempt to assign value to constrained enabled coordinate");
-
- if (v != enabled())
- {
- set_raw_enabled(v);
- mark_enabled_ood();
- }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return the value of part_a. Part_a is a generic value that may be
- * maintained by an interactor to represent some specific semantically
- * meaningful part of its state that it wants to make available for use
- * in the (lightweight) constraint system. For example, sliders make
- * their "thumb value" available as part_a. Here in the base class,
- * part_a is not implemented (it is intrinsically constrained to 0).
- * see the commented out sample code in the source for details of how
- * to implement a custom part_a for interactor subclasses. Alternately,
- * you can inherit from the interactor_with_parts or parent_with_parts
- * classes rather than base_interactor.
- *
- * @see sub_arctic.lib.interactor_with_parts
- * @see sub_arctic.lib.parent_with_parts
- * @return int the value of part_a (after constraint evaluation if necessary).
- */
- public int part_a()
- {
- return 0;
-
- /* in a typical subclass you would want to do something like this
- * (substituting the actual storage location for _part_a below). */
- // eval_part_a();
- // return _part_a;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set part_a value directly bypassing the constraint system. This should
- * normally only be done by the constraint system or some other part of
- * the system which takes care of marking things out-of-date, etc. itself.<p>
- *
- * Here in the base class we have not implemented part_a, so this has no
- * effect. In subclasses, this should first test if this is a change.
- * if it is, then this should modify the value and (in most cases) call
- * damage_self(). See the commented out sample code in the source for
- * complete details. Better yet you can just inherit an implementation
- * from interactor_with_parts or parent_with_parts.
- *
- * @see sub_arctic.lib.interactor_with_parts
- * @see sub_arctic.lib.parent_with_parts
- * @param int v the new value for part_a
- */
- protected void set_raw_part_a(int v)
- {
- /* here we do nothing */
-
- /* in a typical subclass you would want to do something like this
- * (substituting the actual storage location for _part_a below). */
-
- // /* don't do anything unless this is a change */
- // if (v != _part_a)
- // {
- // /* change the value and damage our image */
- // _part_a = v;
- // damage_self();
- // }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set part_a of object. If part is controlled by a constraint, an
- * exception is thrown. Here in the base class this is always the case.<p>
- *
- * For subclasses implementing part_a see the commented out sample code
- * in the source or inherit from interactor_with_parts or parent_with_parts.
- *
- * @param int v the new value for part_a
- */
- public void set_part_a(int v)
- {
- /* here we just throw the exception */
- throw new sub_arctic_error(
- "Attempt to assign value to constrained part_a");
-
- /* in a typical subclass you would want to do something like this
- * (substituting the actual storage location for _part_a below). */
-
- // /* if this has a constraint throw an exception */
- // if ((active_constraints() & PART_A) != 0)
- // throw new sub_arctic_error(
- // "Attempt to assign value to constrained part_a");
- //
- // /* don't do anything unless this is a change */
- // if (v != _part_a)
- // {
- // set_raw_part_a(v);
- // mark_part_a_ood();
- // }
- }
-
- //had:
- //* @exception cannot_assign if part_a is constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return the value of part_b. Part_b is a generic value that may be
- * maintained by an interactor to represent some specific semantically
- * meaningful part of its state that it wants to make available for use
- * in the (lightweight) constraint system. For example, sliders make
- * their "thumb value" available as part_b. Here in the base class,
- * part_b is not implemented (it is intrinsically constrained to 0).
- * see the commented out sample code in the source for details of how
- * to implement a custom part_b for interactor subclasses. Alternately,
- * you can inherit from the interactor_with_parts or parent_with_parts
- * classes rather than base_interactor.
- *
- * @see sub_arctic.lib.interactor_with_parts
- * @see sub_arctic.lib.parent_with_parts
- * @return int the value of part_b (after constraint evaluation if necessary).
- */
- public int part_b()
- {
- return 0;
-
- /* in a typical subclass you would want to do something like this
- * (substituting the actual storage location for _part_b below). */
- // eval_part_b();
- // return _part_b;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set part_b value directly bypassing the constraint system. This should
- * normally only be done by the constraint system or some other part of
- * the system which takes care of marking things out-of-date, etc. itself.<p>
- *
- * Here in the base class we have not implemented part_b, so this has no
- * effect. In subclasses, this should first test if this is a change.
- * if it is, then this should modify the value and (in most cases) call
- * damage_self(). See the commented out sample code in the source for
- * complete details. Better yet you can just inherit an implementation
- * from interactor_with_parts or parent_with_parts.
- *
- * @see sub_arctic.lib.interactor_with_parts
- * @see sub_arctic.lib.parent_with_parts
- * @param int v the new value for part_b
- */
- protected void set_raw_part_b(int v)
- {
- /* here we do nothing */
-
- /* in a typical subclass you would want to do something like this
- * (substituting the actual storage location for _part_b below). */
-
- // /* don't do anything unless this is a change */
- // if (v != _part_b)
- // {
- // /* change the value and damage our image */
- // _part_b = v;
- // damage_self();
- // }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set part_b of object. If part is controlled by a constraint, an
- * exception is thrown. Here in the base class this is always the case.<p>
- *
- * For subclasses implementing part_b see the commented out sample code
- * in the source or inherit from interactor_with_parts or parent_with_parts.
- *
- * @param int v the new value for part_b
- */
- public void set_part_b(int v)
- {
- /* here we just throw the exception */
- throw new sub_arctic_error(
- "Attempt to assign value to constrained part_b");
-
- /* in a typical subclass you would want to do something like this
- * (substituting the actual storage location for _part_b below). */
-
- // /* if this has a constraint throw an exception */
- // if ((active_constraints() & PART_B) != 0)
- // throw new sub_arctic_error(
- // "Attempt to assign value to constrained part_b");
- //
- // /* don't do anything unless this is a change */
- // if (v != _part_b)
- // {
- // set_raw_part_b(v);
- // mark_part_b_ood();
- // }
- }
-
- //had:
- //* @exception cannot_assign if part_b is constrained.
- //* @exception general
-
- /*---------------------------------------------------------------------*/
- /* Coordinate system transformations */
- /*---------------------------------------------------------------------*/
-
- /**
- * Transform a point in the local coordinate space into the global space
- * (that is the coordinate system of the top_level object which roots the
- * interactor tree this object is in).
- *
- * @param int xv x coordinate of point to transform.
- * @param int yv y coordinate of point to transform.
- * @return Point resulting point.
- */
- public Point local_to_global(int xv, int yv)
- {
- Point result = new Point(xv, yv);
-
- /* walk up the parent chain applying translations */
- for (interactor i = this; i != null; i = i.parent())
- result = i.into_parent(result);
- return result;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Transform a point in the local coordinate space into the global space
- * (that is the coordinate system of the top_level object which roots the
- * interactor tree this object is in).
- *
- * @param Point local_pt point to transform.
- * @return Point resulting point.
- */
- public Point local_to_global(Point local_pt)
- {
- Point result = new Point(local_pt.x, local_pt.y);
-
- /* walk up the parent chain applying translations */
- for (interactor i = this; i != null; i = i.parent())
- result = i.into_parent(result);
- return result;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Transform a point in global coordinate space (that is the coordinate
- * system of the top_level object which roots the interactor tree this
- * object is in) into the local space of the object.
- *
- * @param int xv x coordinate of point to transform.
- * @param int yv y coordinate of point to transform.
- * @return Point resulting point.
- */
- public Point global_to_local(int xv, int yv)
- {
- /* if we are the tool then local is global */
- interactor p = parent();
- if (p == null)
- return new Point(xv, yv);
- else
- /* recursively convert into parent's coords, then into ours */
- return into_local(p.global_to_local(new Point(xv,yv)));
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Transform a point in global coordinate space (that is the coordinate
- * system of the top_level object which roots the interactor tree this
- * object is in) into the local space of the object.
- *
- * @param Point global_pt point to transform.
- * @return Point resulting point.
- */
- public Point global_to_local(Point global_pt)
- {
- /* if we are the tool then local is global */
- interactor p = parent();
- if (p == null)
- return new Point(global_pt.x, global_pt.y);
- else
- /* recursively convert into parent's coords, then into ours */
- return into_local(p.global_to_local(global_pt));
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Transform a point from parent's coordinate space to local coordinates of
- * this object.
- *
- * @param int xv x coordinate of point to transform.
- * @param int yv y coordinate of point to transform.
- * @return Point resulting point.
- */
- public Point into_local(int xv, int yv)
- {
- Point result = new Point(xv, yv);
- result.x = result.x - x();
- result.y = result.y - y();
- return result;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Transform a point from parent's coordinate space to local coordinates of
- * this object.
- *
- * @param Point parent_pt point to transform.
- * @return Point resulting point.
- */
- public Point into_local(Point parent_pt)
- {
- Point result = new Point(parent_pt.x, parent_pt.y);
- result.x = result.x - x();
- result.y = result.y - y();
- return result;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Transform an x value from parent's coordinate space to local coords.
- *
- * @param int xv x coordinate of to transform.
- * @return int resulting x coordinate.
- */
- public int x_into_local(int xv)
- {
- return xv - x();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Transform an y value from parent's coordinate space to local coords.
- *
- * @param int yv y coordinate of to transform.
- * @return int resulting y coordinate.
- */
- public int y_into_local(int yv)
- {
- return yv - y();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Transform a local point into the parent's coordinate space.
- *
- * @param int xv x coordinate of point to transform.
- * @param int yv y coordinate of point to transform.
- * @return Point resulting point.
- */
- public Point into_parent(int xv, int yv)
- {
- Point result = new Point(xv, yv);
- result.x = result.x + x();
- result.y = result.y + y();
- return result;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Transform a local point into the parent's coordinate space.
- *
- * @param Point local_pt point to transform.
- * @return Point resulting point.
- */
- public Point into_parent(Point local_pt)
- {
- Point result = new Point(local_pt.x, local_pt.y);
- result.x = result.x + x();
- result.y = result.y + y();
- return result;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Transform an x value form local coordinates into the parent's coordinate
- * space.
- *
- * @param int xv x coordinate of to transform.
- * @return int resulting x coordinate.
- */
- public int x_into_parent(int xv)
- {
- return xv + x();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Transform an y value form local coordinates into the parent's coordinate
- * space.
- *
- * @param int yv y coordinate of to transform.
- * @return int resulting y coordinate.
- */
- public int y_into_parent(int yv)
- {
- return yv + y();
- }
-
- /*---------------------------------------------------------------------*/
- /* Hierarchy management */
- /*---------------------------------------------------------------------*/
-
- /**
- * Return the parent of this interactor.
- * @return interactor the parent of this interactor or null if this object
- * is an orphan or is a top_level (root) interactor.
- */
- public interactor parent() {return _parent;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set the parent of this interactor. <p>
- *
- * <b>Warning</b>: this method should be protected (but isn't since various
- * implementations don't allow protected in interfaces). This method should
- * not be invoked from "outside the system". Always use the normal child
- * manipulation routines instead.<p>
- *
- * @param interactor par new parent for this object.
- */
- public void set_parent(interactor par)
- {
- /* if we are actually changing something */
- if (par != _parent)
- {
- /* set our new parent and damage our bound so we get drawn right */
- _parent = par;
- damage_self();
- }
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Retrieve the top_level interactor (if any) that this object is installed
- * (perhaps several levels down) under. This top_level interactor provides
- * the "global" coordinate space for this interactor. Null is returned if
- * this object is not currently installed somewhere under a top_level
- * interactor.<p>
- *
- * @return top_level the top_level object we are installed under or null if
- * there is no such object.
- */
- public top_level get_top_level()
- {
- interactor parnt;
-
- /* walk up the parent tree till we get to the top */
- for (parnt = this; parnt.parent() != null; parnt = parnt.parent())
- /* keep walking up */;
-
- /* if we got to a top_level interactor then use that */
- if (parnt instanceof top_level)
- return (top_level)parnt;
- else
- return null;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Retrieve the AWT component that this sub_arctic object is drawn within.
- * If this object is not part of an active interface, null will be returned.
- * <p>
- * @result Component the AWT component that this sub_arctic object is drawn
- * within or null if the object is "floating".
- */
- public Component get_awt_component()
- {
- top_level top = get_top_level();
- if (top != null)
- return top.awt_parent();
- else
- return null;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return the child index of this interactor (within its parent).
- * This value is obviously not going to be correct for orphan objects.
- * @return int index of this interactor within its parent's child list.
- */
- public int child_index() { return _child_index; }
-
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set the child index of this interactor (within its parent). <p>
- *
- * <b>Warning</b>: this method should be protected (but isn't since various
- * implementations don't allow protected in interfaces). This method should
- * not be invoked except from the within the normal child manipulation
- * routines.Always use those routines instead.<p>
- *
- * @param int indx the new index of the child.
- */
- public void set_child_index(int indx) {_child_index = indx;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return the previous sibling of this object (or null if there is none).
- * @return interactor the child before this one in its parent's child list or
- * null if there is no such object.
- */
- public interactor prev_sibling()
- {
- if (parent() == null || child_index() == 0)
- return null;
- else
- return parent().child(child_index()-1);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return the next sibling of this object (or null if there is none).
- * @return interactor the child after this one in its parent's child list or
- * null if there is no such object.
- */
- public interactor next_sibling()
- {
- if (parent() == null || child_index() == parent().num_children()-1)
- return null;
- else
- return parent().child(child_index()+1);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate whether this interactor supports children. Interactors that
- * support children will have their SUPPORTS_CHILDREN flag set.
- * @return boolean indicating whether this object supports children.
- */
- public boolean supports_children()
- {
- return flag_is_set(SUPPORTS_CHILDREN);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate whether this interactor uses a fixed set of children. This is
- * done if the interactor assigns fixed roles/meanings to particular
- * children, or for some other reason limits its total number of children.
- * If this is not set, then the child list is expandable and the system
- * will move entries over to fill in null children (although you cannot rely
- * on this behavior since it is possible to explicitly set a child at a
- * given index to null and sneak nulls into the child list in other ways).
- * If this is set, then removed children will be set to null, and the child
- * list will not be otherwise modified. In addition, if this is set, then
- * operations that would normally reorder children throw an exception
- * instead. An object which uses fixed children will have its
- * FIXED_CHILDREN flag set.
- *
- * @return boolean indicating whether this object supports fixed children.
- */
- public boolean fixed_children()
- {
- return flag_is_set(FIXED_CHILDREN);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate the number of children this interactor currently has. For
- * interactors with fixed children, the interactor will always have this
- * this number, hence it is also the maximum number of children.
- * Interactors that do not support children always return 0. Note: there
- * may be null children in the child list but they are counted as children
- * here.
- *
- * @return int number of slots in this object's child list.
- */
- public int num_children()
- {
- if (supports_children())
- return _child_list.size();
- else
- return 0;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return the child at the given index int the child list (whose first
- * element is at index 0). If the index given is beyond the range of the
- * current child list, or the interactor does not support children, then
- * null is returned. Requests for negative children cause an exception.
- * Note that child lists may contain null children.
- *
- * @param int i the index of the requested child.
- * @return interactor the child object at the requested index.
- */
- public interactor child(int i)
- {
- if (i < 0) throw new sub_arctic_error("Negative index passed to child()");
- if (i < num_children())
- return (interactor)_child_list.elementAt(i);
- else
- return null;
- }
-
- //had:
- //* @exception index_bounds if a negative child index is supplied.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set the child at the given index replacing any child that was previously
- * there. The child list will be expanded as necessary to accommodate the
- * given child. If the child list is expanded, missing children will be
- * set to null.
- *
- * @param int at_indx position in the child list to replace.
- * @param interactor chld the child object to place at that position.
- */
- public void set_child(int at_indx, interactor chld)
- {
- /* if we don't support children, throw an exception */
- if (!supports_children())
- throw new sub_arctic_error("This object does not support children");
-
- /* if they already have a parent, remove them from it */
- if (chld != null && chld.parent() != null)
- chld.parent().remove_child(chld);
-
- /* make sure we have space for the child in our list */
- if (at_indx >= _child_list.size() && !fixed_children())
- _child_list.setSize(at_indx+1);
-
- /* set the child */
- _child_list.setElementAt(chld, at_indx);
-
- if (chld != null)
- {
- /* set childs notion of its index */
- chld.set_child_index(at_indx);
-
- /* set us as its parent and mark out of date */
- chld.set_parent(this);
- chld.mark_reparented_ood();
- }
-
- // note: child list never gets smaller, may want to address this later
- // instead of an explicit test of supports_children(), just do it but
- // catch the null pointer exception and rethrow it as an error
- }
-
- //has:
- //* @exception op_not_supported if this operation is invoked on an object
- //* which does not support children or which
- //* would require expanding the child list of an
- //* object which has fixed children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Add a child to the end of the child list.
- * @param interactor chld the child to add.
- */
- public void add_child(interactor chld)
- {
- /* adding null is a no-op */
- if (chld == null) return;
-
- /* if we don't support children, throw an exception */
- if (!supports_children())
- throw new sub_arctic_error("This object does not support children");
-
- /* don't allow add_child for fixed children (must use set_child()) */
- if (fixed_children())
- throw new sub_arctic_error( "This object has fixed children and " +
- "does not support add_child (use set_child() instead).");
-
- /* if they already have a parent, remove them from it */
- if (chld.parent() != null) chld.parent().remove_child(chld);
-
- /* add the child and set its index */
- _child_list.addElement(chld);
- chld.set_child_index(_child_list.size()-1);
-
- /* set us as its parent and mark out-of-date */
- chld.set_parent(this);
- chld.mark_reparented_ood();
- }
-
- //has:
- //* @exception op_not_supported if the object does not support children or
- //* supports only fixed children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Insert a child at the given location, moving current children at or
- * after that index further down in the list.
- */
- public void insert_child(int at_indx, interactor chld)
- {
- interactor a_child;
-
- /* inserting null is a no-op */
- if (chld == null) return;
-
- /* if we don't support children, throw an exception */
- if (!supports_children())
- throw new sub_arctic_error("This object does not support children");
-
- /* if we only support fixed children, throw an exception */
- if (fixed_children())
- throw new sub_arctic_error(
- "This object has fixed children and does not support child insert");
-
- /* insert the child */
- _child_list.insertElementAt(chld, at_indx);
-
- /* set us as its parent */
- chld.set_parent(this);
-
- /* renumber the trailing children */
- for (int i = at_indx; i < _child_list.size(); i++)
- {
- a_child = (interactor)_child_list.elementAt(i);
- if (a_child != null) a_child.set_child_index(i);
- }
-
- /* mark out-of-date */
- chld.mark_reparented_ood();
- }
-
- //has:
- //* @exception op_not_supported if the object does not support children or
- //* supports only fixed children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Remove the child found at the given index and return it. For
- * interactors with fixed children, the child slot at the index is set
- * to null. For other interactors, later children are moved over in the
- * list to fill in the gap.
- *
- * @param int at_indx the index to remove the child from.
- */
- public interactor remove_child(int at_indx)
- {
- interactor chld;
-
- /* if we don't support children, throw an exception */
- if (!supports_children())
- throw new sub_arctic_error("This object does not support children");
-
- /* if the child is out of bounds just return */
- if (at_indx < 0 || at_indx >= _child_list.size()) return null;
-
- /* get the result interactor */
- interactor result = (interactor)_child_list.elementAt(at_indx);
-
- if (result != null)
- {
- /* damage it to account for the screen area of our soon to be
- * missing child */
- result.damage_self();
-
- /* mark out-of-date for the same reason */
- result.mark_reparented_ood();
- }
-
- /* remove the child and renumber if needed */
- if (fixed_children())
- _child_list.setElementAt(null, at_indx);
- else
- {
- _child_list.removeElementAt(at_indx);
- for (int i = at_indx; i < _child_list.size(); i++)
- {
- chld = ((interactor)_child_list.elementAt(i));
- if (chld != null) chld.set_child_index(i);
- }
- }
-
- /* set its parent to null */
- if (result != null) result.set_parent(null);
-
- return result;
- }
-
- //had:
- //* @exception op_not_supported if the object does not support children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Remove the given child from the child list. For interactors with
- * fixed children, the child slot is set to null. For other interactors,
- * later children are moved up in the list to fill in the gap. If the
- * child is not in the child list, nothing happens.
- *
- * @param interactor the_child the child to be removed.
- */
- public void remove_child(interactor the_child)
- {
- /* if we don't support children, throw an exception */
- if (!supports_children())
- throw new sub_arctic_error("This object does not support children");
-
- /* find the element's index and remove it using that */
- int indx = find_child(the_child);
- if (indx >= 0) remove_child(indx);
- }
-
- //had:
- //* @exception op_not_supported if the object does not support children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Find the given child in the child list and return its index. If the
- * child is no in the child list -1 is returned.
- *
- * @param interactor the_child the child we are searching for.
- * @return int the index of that child in the child list or -1 if the child
- * is not found.
- */
- public int find_child(interactor the_child)
- {
- if (!supports_children())
- throw new sub_arctic_error("This object does not support children");
- return _child_list.indexOf(the_child);
- }
-
- //has:
- //* @exception op_not_supported if this object does not support children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Move the child currently at the given index in the child list to the
- * top in drawing order (which is last in the list).
- *
- * @param int chld_indx the index of the child to move.
- */
- public void move_child_to_top(int chld_indx)
- {
- interactor the_child, chld;
-
- if (!supports_children())
- throw new sub_arctic_error("This object does not support children");
-
- if (flag_is_set(FIXED_CHILDREN))
- throw new sub_arctic_error(
- "This object does not support reordering children");
-
- if (chld_indx >= 0 && chld_indx < _child_list.size()-1)
- {
- /* damage our screen extent */
- damage_self();
-
- /* extract the child and mark it out-of-date so we hit old siblings */
- the_child = (interactor)_child_list.elementAt(chld_indx);
- if (the_child != null) the_child.mark_reparented_ood();
-
- /* move the child */
- _child_list.removeElementAt(chld_indx);
- _child_list.addElement(the_child);
-
- /* renumber everyone */
- for (int i = 0; i < _child_list.size(); i++)
- {
- chld = ((interactor)_child_list.elementAt(i));
- if (chld != null) chld.set_child_index(i);
- }
-
- /* inform the new siblings about the change */
- if (the_child != null) the_child.mark_reparented_ood();
- }
- }
-
- //had:
- //* @exception op_not_supported if the object does not support children or
- //* supports only fixed children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Move the given child to the top of the child list in drawing order
- * (which is last in the list). If the child is not in the list, nothing
- * happens.
- *
- * @param interactor the_child the child to move.
- */
- public void move_child_to_top(interactor the_child)
- {
- int indx = find_child(the_child);
- if (indx >= 0) move_child_to_top(indx);
- }
-
- //had:
- //* @exception op_not_supported if the object does not support children or
- //* supports only fixed children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Move the child currently at the given index in the child list to the
- * bottom in drawing order (which is first in the list).
- *
- * @param int chld_indx the index of the child to move.
- */
- public void move_child_to_bottom(int chld_indx)
- {
- interactor the_child, chld;
-
- if (!supports_children())
- throw new sub_arctic_error("This object does not support children");
-
- if (flag_is_set(FIXED_CHILDREN))
- throw new sub_arctic_error(
- "This object does not support reordering children");
-
- if (chld_indx > 0 && chld_indx < _child_list.size())
- {
- /* damage our screen extent */
- damage_self();
-
- /* extract the child and mark it out-of-date so we hit old siblings */
- the_child = (interactor)_child_list.elementAt(chld_indx);
- if (the_child != null) the_child.mark_reparented_ood();
-
- /* move the child */
- _child_list.removeElementAt(chld_indx);
- _child_list.insertElementAt(the_child,0);
-
- /* renumber everyone */
- for (int i = 0; i < _child_list.size(); i++)
- {
- chld = ((interactor)_child_list.elementAt(i));
- if (chld != null) chld.set_child_index(i);
- }
-
- /* inform the new siblings about the change */
- if (the_child != null) the_child.mark_reparented_ood();
- }
- }
-
- //had:
- //* @exception op_not_supported if the object does not support children or
- //* supports only fixed children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Move the given child to the bottom of the child list in drawing order
- * (which is first in the list). If the child is not in the list, nothing
- * happens.
- *
- * @param interactor the_child the child to move.
- */
- public void move_child_to_bottom(interactor the_child)
- {
- int indx = find_child(the_child);
- if (indx >= 0) move_child_to_bottom(indx);
- }
-
- //had:
- //* @exception op_not_supported if the object does not support children or
- //* supports only fixed children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Move the child currently at the given index in the child list up one
- * position in drawing order (which is one position further into the list).
- *
- * @param int chld_indx the index of the child to move.
- */
- public void move_child_upward(int chld_indx)
- {
- interactor the_child, chld;
-
- if (!supports_children())
- throw new sub_arctic_error("This object does not support children");
-
- if (flag_is_set(FIXED_CHILDREN))
- throw new sub_arctic_error(
- "This object does not support reordering children");
-
- if (chld_indx >= 0 && chld_indx < _child_list.size()-1)
- {
- /* damage our screen extent */
- damage_self();
-
- /* extract the child and mark it out-of-date so we hit old siblings */
- the_child = (interactor)_child_list.elementAt(chld_indx);
- if (the_child != null) the_child.mark_reparented_ood();
-
- /* move the child */
- _child_list.removeElementAt(chld_indx);
- _child_list.insertElementAt(the_child, chld_indx+1);
-
- /* renumber everyone */
- for (int i = 0; i < _child_list.size(); i++)
- {
- chld = ((interactor)_child_list.elementAt(i));
- if (chld != null) chld.set_child_index(i);
- }
-
- /* inform the new siblings about the change */
- if (the_child != null) the_child.mark_reparented_ood();
- }
- }
-
- //had:
- //* @exception op_not_supported if the object does not support children or
- //* supports only fixed children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Move the given child up one position in drawing order of the child list
- * (which is later in the list). If the child is not in the list, nothing
- * happens.
- *
- * @param interactor the_child the child to move.
- */
- public void move_child_upward(interactor the_child)
- {
- int indx = find_child(the_child);
- if (indx > 0) move_child_upward(indx);
- }
-
- //had:
- //* @exception op_not_supported if the object does not support children or
- //* supports only fixed children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Move the child currently at the given index in the child list down one
- * position in drawing order (which is one position earlier in the list).
- *
- * @param int chld_indx the index of the child to move.
- */
- public void move_child_downward(int chld_indx)
- {
- interactor the_child, chld;
-
- if (!supports_children())
- throw new sub_arctic_error("This object does not support children");
-
- if (fixed_children())
- throw new sub_arctic_error(
- "This object does not support reordering children");
-
- if (chld_indx > 0 && chld_indx < _child_list.size())
- {
- /* damage our screen extent */
- damage_self();
-
- /* extract the child and mark it out-of-date so we hit old siblings */
- the_child = (interactor)_child_list.elementAt(chld_indx);
- if (the_child != null) the_child.mark_reparented_ood();
-
- /* move the child */
- _child_list.removeElementAt(chld_indx);
- _child_list.insertElementAt(the_child, chld_indx-1);
-
- /* renumber everyone */
- for (int i = 0; i < _child_list.size(); i++)
- {
- chld = ((interactor)_child_list.elementAt(i));
- if (chld != null) chld.set_child_index(i);
- }
-
- /* inform the new siblings about the change */
- if (the_child != null) the_child.mark_reparented_ood();
- }
- }
-
- //had:
- //* @exception op_not_supported if the object does not support children or
- //* supports only fixed children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Move the given child down one position in drawing order of the child list
- * (which is earlier in the list). If the child is not in the list, nothing
- * happens.
- *
- * @param interactor the_child the child to move.
- */
- public void move_child_downward(interactor the_child)
- {
- int indx = find_child(the_child);
- if (indx > 0) move_child_downward(indx);
- }
-
- //had:
- //* @exception op_not_supported if the object does not support children or
- //* supports only fixed children.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Move this object to the top of its parent's drawing order (last in
- * its child list).
- */
- public void move_to_top()
- {
- if (parent() != null) parent().move_child_to_top(this);
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Move this object to the bottom of its parent's drawing order (first in
- * its child list).
- */
- public void move_to_bottom()
- {
- if (parent() != null) parent().move_child_to_bottom(this);
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Move this object one position higher in its parent's drawing order
- * (which is one position further into its child list).
- */
- public void move_upward()
- {
- if (parent() != null) parent().move_child_upward(this);
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Move this object one position lower in its parent's drawing order
- * (which is one position earlier in its child list).
- */
- public void move_downward()
- {
- if (parent() != null) parent().move_child_downward(this);
- }
-
- //had:
- //* @exception general
-
- /*---------------------------------------------------------------------*/
- /* Layout */
- /*---------------------------------------------------------------------*/
-
- /**
- * Indicate which parts (coordinates/sizes/values) of this object are
- * intrinsically constrained by the internals of the object. For, example
- * an icon object with a fixed size image would intrinsically constrain
- * its width and height. The result is reported as an integer formed from
- * or-ing together zero or more of the constants: X, Y, W, H, VISIBLE,
- * ENABLED, PART_A or PART_B (for the icon described above that would be
- * W | H).
- *
- * @return int bitset indicating which parts of the object are intrinsically
- * constrained.
- */
- public int intrinsic_constraints()
- {
- /* by default PART_A and PART_B are constrained to be 0 */
- return PART_A | PART_B;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate which parts (coordinates/sizes/values) of this object are
- * currently constrained. This always includes the intrinsic constraints,
- * but may also indicate other constraints that have been applied to the
- * object. The result is reported as an integer formed from or-ing
- * together zero or more of the constants: X, Y, W, H, VISIBLE, ENABLED,
- * PART_A and PART_B. Values that are constrained may not be assigned to
- * directly (an exception will be thrown).
- *
- * @param int bitset indicating which parts of the object are constrained.
- */
- public int active_constraints()
- {
- int result = intrinsic_constraints();
-
- /* figure out which constraints are active */
- if (!std_constraint_impl.the_impl().is_none(_x_constraint)) result |= X;
- if (!std_constraint_impl.the_impl().is_none(_y_constraint)) result |= Y;
- if (!std_constraint_impl.the_impl().is_none(_w_constraint)) result |= W;
- if (!std_constraint_impl.the_impl().is_none(_h_constraint)) result |= H;
- if (!std_constraint_impl.the_impl().is_none(_visible_constraint))
- result |= VISIBLE;
- if (!std_constraint_impl.the_impl().is_none(_enabled_constraint))
- result |= ENABLED;
- if (!std_constraint_impl.the_impl().is_none(_part_a_constraint))
- result |= PART_A;
- if (!std_constraint_impl.the_impl().is_none(_part_b_constraint))
- result |= PART_B;
- return result;
-
- // later might want to consider burning a few flag bits to cache this
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate whether a specific part is currently constrained. The query
- * argument should be one of the constants: X, Y, W, H, VISIBLE, ENABLED,
- * PART_A, or PART_B. Values that are constrained may not be assigned to
- * (an exception will be thrown).
- *
- * @param int coord_code the object part we are enquiring about.
- * @return boolean indicating whether it is constrained.
- */
- public boolean is_constrained(int coord_code)
- {
- switch (coord_code)
- {
- case X: return !std_constraint_impl.the_impl().is_none(_x_constraint);
- case Y: return !std_constraint_impl.the_impl().is_none(_y_constraint);
- case W: return !std_constraint_impl.the_impl().is_none(_w_constraint);
- case H: return !std_constraint_impl.the_impl().is_none(_h_constraint);
- case VISIBLE:
- return !std_constraint_impl.the_impl().is_none(_visible_constraint);
- case ENABLED:
- return !std_constraint_impl.the_impl().is_none(_enabled_constraint);
- case PART_A:
- return !std_constraint_impl.the_impl().is_none(_part_a_constraint);
- case PART_B:
- return !std_constraint_impl.the_impl().is_none(_part_b_constraint);
- default: return false;
- }
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return a constraint object representing the constraint (if any) attached
- * to the specified part (X, Y, W, H, VISIBLE, ENABLED, PART_A, or PART_B).
- * @param int coord_code the code for the object part in question.
- * @return constraint the constraint attached to the given part.
- */
- public constraint constraint_on(int coord_code)
- {
- switch (coord_code)
- {
- case X: return x_constraint();
- case Y: return y_constraint();
- case W: return w_constraint();
- case H: return h_constraint();
- case VISIBLE: return visible_constraint();
- case ENABLED: return enabled_constraint();
- case PART_A: return part_a_constraint();
- case PART_B: return part_b_constraint();
- default:
- throw new sub_arctic_error(
- "Unrecognized coordinate code " + coord_code +
- "passed to constraint_on()");
- }
- }
-
- //had:
- //* @exception bad_value if an unrecognized part code is given.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return a constraint object representing the constraint (if any) attached
- * to x.
- * @return constraint the constraint attached to x.
- */
- public constraint x_constraint()
- {
- return new std_constraint(_x_constraint, std_encoding_consts.HORIZONTAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return a constraint object representing the constraint (if any) attached
- * to y.
- * @return constraint the constraint attached to x.
- */
- public constraint y_constraint()
- {
- return new std_constraint(_y_constraint, std_encoding_consts.VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return a constraint object representing the constraint (if any) attached
- * to w.
- * @return constraint the constraint attached to w.
- */
- public constraint w_constraint()
- {
- return new std_constraint(_w_constraint, std_encoding_consts.HORIZONTAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return a constraint object representing the constraint (if any) attached
- * to h.
- * @return constraint the constraint attached to h.
- */
- public constraint h_constraint()
- {
- return new std_constraint(_h_constraint, std_encoding_consts.VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return a constraint object representing the constraint (if any) attached
- * to visible.
- * @return constraint the constraint attached to visible.
- */
- public constraint visible_constraint()
- {
- return new std_constraint(_visible_constraint,
- ((_constraint_flags & VISIBLE_IS_HORIZONTAL)!= 0)?
- std_encoding_consts.HORIZONTAL : std_encoding_consts.VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return a constraint object representing the constraint (if any) attached
- * to enabled.
- * @return constraint the constraint attached to enabled.
- */
- public constraint enabled_constraint()
- {
- return new std_constraint(_enabled_constraint,
- ((_constraint_flags & ENABLED_IS_HORIZONTAL)!= 0)?
- std_encoding_consts.HORIZONTAL : std_encoding_consts.VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return a constraint object representing the constraint (if any) attached
- * to part_a.
- * @return constraint the constraint attached to part_a.
- */
- public constraint part_a_constraint()
- {
- return new std_constraint(_part_a_constraint,
- ((_constraint_flags & PART_A_IS_HORIZONTAL) != 0)?
- std_encoding_consts.HORIZONTAL : std_encoding_consts.VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return a constraint object representing the constraint (if any) attached
- * to part_b.
- * @return constraint the constraint attached to part_a.
- */
- public constraint part_b_constraint()
- {
- return new std_constraint(_part_b_constraint,
- ((_constraint_flags & PART_B_IS_HORIZONTAL) != 0)?
- std_encoding_consts.HORIZONTAL : std_encoding_consts.VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a constraint on the given value (one of X, Y, W, H, VISIBLE,
- * ENABLED, PART_A, or PART_B). This replaces any constraint currently in
- * place. However, an attempt to replace an intrinsic constraint will
- * result in an exception.
- *
- * @param int coord_code code for the part whose constraint we
- * replace.
- * @param constraint a_constraint the constraint to replace it with.
- */
- public void set_constraint(int coord_code, constraint a_constraint)
- {
- switch (coord_code)
- {
- case X: set_x_constraint(a_constraint); break;
- case Y: set_y_constraint(a_constraint); break;
- case W: set_w_constraint(a_constraint); break;
- case H: set_h_constraint(a_constraint); break;
- case VISIBLE: set_visible_constraint(a_constraint); break;
- case ENABLED: set_enabled_constraint(a_constraint); break;
- case PART_A: set_part_a_constraint(a_constraint); break;
- case PART_B: set_part_b_constraint(a_constraint); break;
- default:
- throw new sub_arctic_error("Unrecognized coordinate code " +
- coord_code + "passed to set_constraint()");
- }
- }
-
- //had:
- //* @exception cannot_constrain if the given part is intrinsically constrained
- //* @exception bad_value if an unrecognized part code is given.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish an "external" or "heavyweight" constraint on the given value (one
- * of X, Y, W, H, VISIBLE, ENABLED, PART_A, PART_B). This replaces any
- * constraint currently in place. However, an attempt to replace an
- * intrinsic constraint will result in an exception.
- *
- * @param int coord_code code for the part whose constraint we
- * replace.
- * @param constraint a_constraint the constraint to replace it with.
- */
- public void set_constraint(int code, value_provider ext_obj, int ext_part)
- {
- switch (code)
- {
- case X: set_x_constraint(ext_obj, ext_part); break;
- case Y: set_y_constraint(ext_obj, ext_part); break;
- case W: set_w_constraint(ext_obj, ext_part); break;
- case H: set_h_constraint(ext_obj, ext_part); break;
- case VISIBLE: set_visible_constraint(ext_obj, ext_part); break;
- case ENABLED: set_enabled_constraint(ext_obj, ext_part); break;
- case PART_A: set_part_a_constraint(ext_obj, ext_part); break;
- case PART_B: set_part_b_constraint(ext_obj, ext_part); break;
- default:
- throw new sub_arctic_error("Unrecognized coordinate code " + code +
- "passed to set_constraint()");
- }
- }
-
- //had:
- //* @exception cannot_constrain if the given part is intrinsically constrained
- //* @exception bad_value if an unrecognized part code is given.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a constraint on the x value of this object. This
- * replaces any constraint currently in place. However, an attempt to
- * replace an intrinsic constraint will result in an exception. Only
- * horizontally oriented constraints can be attached to x (if a vertically
- * oriented value is need, use an external constraint).
- *
- * @param constraint a_constraint the constraint to replace it with.
- */
- public void set_x_constraint(constraint a_constraint)
- {
- /* if its intrinsic throw an exception */
- if ((X & intrinsic_constraints()) != 0)
- throw new sub_arctic_error(
- "Attempt to override an intrinsic constraint on x");
-
- /* if its the wrong orientation, throw an exception */
- if ((a_constraint.orientation() & std_encoding_consts.VERTICAL) != 0)
- throw new sub_arctic_error("Can't attach vertically oriented constraint to x");
-
- /* if we have an existing external constraint, drop it */
- if (x_constraint().is_external())
- manager.drop_extern_constraint(this, X);
-
- /* assign to the constraint encoding, then mark the value out-of-date */
- _x_constraint = a_constraint.encoding();
- if (!a_constraint.is_none())
- mark_x_ood();
- }
-
- //had:
- //* @exception cannot_constrain if x is intrinsically constrained
- //* @exception bad_value if a vertically oriented constraint is used.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish an "external" or "heavyweight" constraint on the x value of
- * this object. This attaches a value exported by a particular part of
- * some value_provider object and replaces any constraint currently in
- * place. However, an attempt to replace an intrinsic constraint will
- * result in an exception.
- *
- * @param value_provider ext_obj the external object providing the value.
- * @param int ext_part the part number of the part of that object
- * providing the value.
- */
- public void set_x_constraint(value_provider ext_obj, int ext_part)
- {
- if (ext_obj == null)
- throw new sub_arctic_error("Null external constraint passed to " +
- "set_x_constraint()");
-
- /* set the constraint encoding */
- set_x_constraint(std_function.external());
-
- /* establish an association with the external provider */
- manager.establish_extern_constraint(this,X, ext_obj,ext_part);
-
- /* mark the value out-of-date */
- mark_x_ood();
- }
-
- //had:
- //* @exception cannot_constrain if x is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a standard external constraint on the x value of this object.
- * This replaces any constraint currently in place. However, an attempt to
- * replace an intrinsic constraint will result in an exception.
- *
- * @param std_ext_constraint ext_cnstr the constraint to attach.
- */
- public void set_x_constraint(std_ext_constraint ext_cnstr)
- {
- /* use arbitrary extern API with part 0, then set us up as self */
- set_x_constraint(ext_cnstr, 0);
- ext_cnstr.set_self_obj(this);
- ext_cnstr.set_orientation(std_encoding_consts.HORIZONTAL);
- }
-
- //had:
- //* @exception cannot_constrain if x is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a constraint on the y value of this object. This
- * replaces any constraint currently in place. However, an attempt to
- * replace an intrinsic constraint will result in an exception. Only
- * vertically oriented constraints can be attached to y (if a horizontally
- * oriented value is need, use an external constraint).
- *
- * @param constraint a_constraint the constraint to replace it with.
- */
- public void set_y_constraint(constraint a_constraint)
- {
- /* if its intrinsic throw an exception */
- if ((Y & intrinsic_constraints()) != 0)
- throw new sub_arctic_error(
- "Attempt to override an intrinsic constraint on y");
-
- /* if its the wrong orientation, throw an exception */
- if ((a_constraint.orientation() & std_encoding_consts.HORIZONTAL) != 0)
- throw new sub_arctic_error(
- "Can't attach horizontally oriented constraint to y");
-
- /* if we have an existing external constraint, drop it */
- if (y_constraint().is_external())
- manager.drop_extern_constraint(this, Y);
-
- /* assign to the constraint encoding, then mark the value out-of-date */
- _y_constraint = a_constraint.encoding();
- if (!a_constraint.is_none())
- mark_y_ood();
- }
-
- //had:
- //* @exception cannot_constrain if y is intrinsically constrained
- //* @exception bad_value if a horizontally oriented constraint is used.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish an "external" or "heavyweight" constraint on the y value of
- * this object. This attaches a value exported by a particular part of
- * some value_provider object and replaces any constraint currently in
- * place. However, an attempt to replace an intrinsic constraint will
- * result in an exception.
- *
- * @param value_provider ext_obj the external object providing the value.
- * @param int ext_part the part number of the part of that object
- * providing the value.
- */
- public void set_y_constraint(value_provider ext_obj, int ext_part)
- {
- if (ext_obj == null)
- throw new sub_arctic_error("Null external constraint passed to " +
- "set_y_constraint()");
-
- /* set the constraint encoding */
- set_y_constraint(std_function.external());
-
- /* establish an association with the external provider */
- manager.establish_extern_constraint(this,Y, ext_obj,ext_part);
-
- /* mark the value out-of-date */
- mark_y_ood();
- }
-
- //had:
- //* @exception cannot_constrain if y is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a standard external constraint on the y value of this object.
- * This replaces any constraint currently in place. However, an attempt to
- * replace an intrinsic constraint will result in an exception.
- *
- * @param std_ext_constraint ext_cnstr the constraint to attach.
- */
- public void set_y_constraint(std_ext_constraint ext_cnstr)
- {
- /* use arbitrary extern API with part 0, then set us up as self */
- set_y_constraint(ext_cnstr, 0);
- ext_cnstr.set_self_obj(this);
- ext_cnstr.set_orientation(std_encoding_consts.VERTICAL);
- }
-
- //had:
- //* @exception cannot_constrain if y is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a constraint on the w value of this object. This
- * replaces any constraint currently in place. However, an attempt to
- * replace an intrinsic constraint will result in an exception. Only
- * horizontally oriented constraints can be attached to w (if a vertically
- * oriented value is need, use an external constraint).
- *
- * @param constraint a_constraint the constraint to replace it with.
- */
- public void set_w_constraint(constraint a_constraint)
- {
- /* if its intrinsic throw an exception */
- if ((W & intrinsic_constraints()) != 0)
- throw new sub_arctic_error(
- "Attempt to override an intrinsic constraint on w");
-
- /* if its the wrong orientation, throw an exception */
- if ((a_constraint.orientation() & std_encoding_consts.VERTICAL) != 0)
- throw new sub_arctic_error(
- "Can't attach vertically oriented constraint to w");
-
- /* if we have an existing external constraint, drop it */
- if (w_constraint().is_external())
- manager.drop_extern_constraint(this, W);
-
- /* assign to the constraint encoding, then mark the value out-of-date */
- _w_constraint = a_constraint.encoding();
- if (!a_constraint.is_none())
- mark_w_ood();
- }
-
- //had:
- //* @exception cannot_constrain if w is intrinsically constrained
- //* @exception bad_value if a vertically oriented constraint is used.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish an "external" or "heavyweight" constraint on the w value of
- * this object. This attaches a value exported by a particular part of
- * some value_provider object and replaces any constraint currently in
- * place. However, an attempt to replace an intrinsic constraint will
- * result in an exception.
- *
- * @param value_provider ext_obj the external object providing the value.
- * @param int ext_part the part number of the part of that object
- * providing the value.
- */
- public void set_w_constraint(value_provider ext_obj, int ext_part)
- {
- if (ext_obj == null)
- throw new sub_arctic_error("Null external constraint passed to " +
- "set_w_constraint()");
-
- /* set the constraint encoding */
- set_w_constraint(std_function.external());
-
- /* establish an association with the external provider */
- manager.establish_extern_constraint(this,W, ext_obj,ext_part);
-
- /* mark the value out-of-date */
- mark_w_ood();
- }
-
- //had:
- //* @exception cannot_constrain if w is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a standard external constraint on the w value of this object.
- * This replaces any constraint currently in place. However, an attempt to
- * replace an intrinsic constraint will result in an exception.
- *
- * @param std_ext_constraint ext_cnstr the constraint to attach.
- */
- public void set_w_constraint(std_ext_constraint ext_cnstr)
- {
- /* use arbitrary extern API with part 0, then set us up as self */
- set_w_constraint(ext_cnstr, 0);
- ext_cnstr.set_self_obj(this);
- ext_cnstr.set_orientation(std_encoding_consts.HORIZONTAL);
- }
-
- //had:
- //* @exception cannot_constrain if w is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a constraint on the h value of this object. This
- * replaces any constraint currently in place. However, an attempt to
- * replace an intrinsic constraint will result in an exception. Only
- * vertically oriented constraints can be attached to h (if a horizontally
- * oriented value is need, use an external constraint).
- *
- * @param constraint a_constraint the constraint to replace it with.
- */
- public void set_h_constraint(constraint a_constraint)
- {
- /* if its intrinsic throw an exception */
- if ((H & intrinsic_constraints()) != 0)
- throw new sub_arctic_error(
- "Attempt to override an intrinsic constraint on h");
-
- /* if its the wrong orientation, throw an exception */
- if ((a_constraint.orientation() & std_encoding_consts.HORIZONTAL) != 0)
- throw new sub_arctic_error(
- "Can't attach horizontally oriented constraint to h");
-
- /* if we have an existing external constraint, drop it */
- if (h_constraint().is_external())
- manager.drop_extern_constraint(this, H);
-
- /* assign to the constraint encoding, then mark the value out-of-date */
- _h_constraint = a_constraint.encoding();
- if (!a_constraint.is_none())
- mark_h_ood();
- }
-
- //had:
- //* @exception cannot_constrain if h is intrinsically constrained
- //* @exception bad_value if a horizontally oriented constraint is used.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish an "external" or "heavyweight" constraint on the h value of
- * this object. This attaches a value exported by a particular part of
- * some value_provider object and replaces any constraint currently in
- * place. However, an attempt to replace an intrinsic constraint will
- * result in an exception.
- *
- * @param value_provider ext_obj the external object providing the value.
- * @param int ext_part the part number of the part of that object
- * providing the value.
- */
- public void set_h_constraint(value_provider ext_obj, int ext_part)
- {
- if (ext_obj == null)
- throw new sub_arctic_error("Null external constraint passed to " +
- "set_h_constraint()");
-
- /* set the constraint encoding */
- set_h_constraint(std_function.external());
-
- /* establish an association with the external provider */
- manager.establish_extern_constraint(this,H, ext_obj,ext_part);
-
- /* mark the value out-of-date */
- mark_h_ood();
- }
-
- //had:
- //* @exception cannot_constrain if h is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a standard external constraint on the h value of this object.
- * This replaces any constraint currently in place. However, an attempt to
- * replace an intrinsic constraint will result in an exception.
- *
- * @param std_ext_constraint ext_cnstr the constraint to attach.
- */
- public void set_h_constraint(std_ext_constraint ext_cnstr)
- {
- /* use arbitrary extern API with part 0, then set us up as self */
- set_h_constraint(ext_cnstr, 0);
- ext_cnstr.set_self_obj(this);
- ext_cnstr.set_orientation(std_encoding_consts.VERTICAL);
- }
-
- //had:
- //* @exception cannot_constrain if h is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a constraint on the visible value of this object. This
- * replaces any constraint currently in place. However, an attempt to
- * replace an intrinsic constraint will result in an exception.
- *
- * @param constraint a_constraint the constraint to replace it with.
- */
- public void set_visible_constraint(constraint a_constraint)
- {
- /* if its intrinsic throw an exception */
- if ((VISIBLE & intrinsic_constraints()) != 0)
- throw new sub_arctic_error(
- "Attempt to override an intrinsic constraint on visible");
-
- /* if we have an existing external constraint, drop it */
- if (visible_constraint().is_external())
- manager.drop_extern_constraint(this, VISIBLE);
-
- /* assign to the constraint encoding, then mark the value out-of-date */
- _visible_constraint = a_constraint.encoding();
- if ((a_constraint.orientation() & std_encoding_consts.HORIZONTAL) != 0)
- _constraint_flags |= VISIBLE_IS_HORIZONTAL;
- else
- _constraint_flags &= ~VISIBLE_IS_HORIZONTAL;
- if (!a_constraint.is_none())
- mark_visible_ood();
- }
-
- //had:
- //* @exception cannot_constrain if visible is intrinsically constrained
- //* @exception bad_value
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish an "external" or "heavyweight" constraint on the visible value
- * of this object. This attaches a value exported by a particular part of
- * some value_provider object and replaces any constraint currently in
- * place. However, an attempt to replace an intrinsic constraint will
- * result in an exception.
- *
- * @param value_provider ext_obj the external object providing the value.
- * @param int ext_part the part number of the part of that object
- * providing the value.
- */
- public void set_visible_constraint(value_provider ext_obj, int ext_part)
- {
- if (ext_obj == null)
- throw new sub_arctic_error("Null external constraint passed to " +
- "set_visible_constraint()");
-
- /* set the constraint encoding */
- set_visible_constraint(std_function.external());
-
- /* establish an association with the external provider */
- manager.establish_extern_constraint(this,VISIBLE, ext_obj,ext_part);
-
- /* mark the value out-of-date */
- mark_visible_ood();
- }
-
- //had:
- //* @exception cannot_constrain if visible is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a standard external constraint on the visible value of this
- * object. This replaces any constraint currently in place. However, an
- * attempt to replace an intrinsic constraint will result in an exception.
- *
- * @param std_ext_constraint ext_cnstr the constraint to attach.
- */
- public void set_visible_constraint(std_ext_constraint ext_cnstr)
- {
- /* use arbitrary extern API with part 0, then set us up as self */
- set_visible_constraint(ext_cnstr, 0);
- ext_cnstr.set_self_obj(this);
- }
-
- //had:
- //* @exception cannot_constrain if visible is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a constraint on the enabled value of this object. This
- * replaces any constraint currently in place. However, an attempt to
- * replace an intrinsic constraint will result in an exception.
- *
- * @param constraint a_constraint the constraint to replace it with.
- */
- public void set_enabled_constraint(constraint a_constraint)
- {
- /* if its intrinsic throw an exception */
- if ((ENABLED & intrinsic_constraints()) != 0)
- throw new sub_arctic_error(
- "Attempt to override an intrinsic constraint on enabled");
-
- /* if we have an existing external constraint, drop it */
- if (enabled_constraint().is_external())
- manager.drop_extern_constraint(this, ENABLED);
-
- /* assign to the constraint encoding, then mark the value out-of-date */
- _enabled_constraint = a_constraint.encoding();
- if ((a_constraint.orientation() & std_encoding_consts.HORIZONTAL) != 0)
- _constraint_flags |= ENABLED_IS_HORIZONTAL;
- else
- _constraint_flags &= ~ENABLED_IS_HORIZONTAL;
- if (!a_constraint.is_none())
- mark_enabled_ood();
- }
-
- //had:
- //* @exception cannot_constrain if enabled is intrinsically constrained
- //* @exception bad_value
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish an "external" or "heavyweight" constraint on the enabled value
- * of this object. This attaches a value exported by a particular part of
- * some value_provider object and replaces any constraint currently in
- * place. However, an attempt to replace an intrinsic constraint will
- * result in an exception.
- *
- * @param value_provider ext_obj the external object providing the value.
- * @param int ext_part the part number of the part of that object
- * providing the value.
- */
- public void set_enabled_constraint(value_provider ext_obj, int ext_part)
- {
- if (ext_obj == null)
- throw new sub_arctic_error("Null external constraint passed to " +
- "set_enabled_constraint()");
-
- /* set the constraint encoding */
- set_enabled_constraint(std_function.external());
-
- /* establish an association with the external provider */
- manager.establish_extern_constraint(this,ENABLED, ext_obj,ext_part);
-
- /* mark the value out-of-date */
- mark_enabled_ood();
- }
-
- //had:
- //* @exception cannot_constrain if enabled is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a standard external constraint on the enabled value of this
- * object. This replaces any constraint currently in place. However, an
- * attempt to replace an intrinsic constraint will result in an exception.
- *
- * @param std_ext_constraint ext_cnstr the constraint to attach.
- */
- public void set_enabled_constraint(std_ext_constraint ext_cnstr)
- {
- /* use arbitrary extern API with part 0, then set us up as self */
- set_enabled_constraint(ext_cnstr, 0);
- ext_cnstr.set_self_obj(this);
- }
-
- //had:
- //* @exception cannot_constrain if enabled is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a constraint on the part_a value of this object. This
- * replaces any constraint currently in place. However, an attempt to
- * replace an intrinsic constraint will result in an exception.
- *
- * @param constraint a_constraint the constraint to replace it with.
- */
- public void set_part_a_constraint(constraint a_constraint)
- {
- /* if its intrinsic throw an exception */
- if ((PART_A & intrinsic_constraints()) != 0)
- throw new sub_arctic_error(
- "Attempt to override an intrinsic constraint on part_a");
-
- /* if we have an existing external constraint, drop it */
- if (part_a_constraint().is_external())
- manager.drop_extern_constraint(this, PART_A);
-
- /* assign to the constraint encoding, then mark the value out-of-date */
- _part_a_constraint = a_constraint.encoding();
- if ((a_constraint.orientation() & std_encoding_consts.HORIZONTAL) != 0)
- _constraint_flags |= PART_A_IS_HORIZONTAL;
- else
- _constraint_flags &= ~PART_A_IS_HORIZONTAL;
- if (!a_constraint.is_none())
- mark_part_a_ood();
- }
-
- //had:
- //* @exception cannot_constrain if part_a is intrinsically constrained
- //* @exception bad_value
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish an "external" or "heavyweight" constraint on the part_a value of
- * this object. This attaches a value exported by a particular part of
- * some value_provider object and replaces any constraint currently in
- * place. However, an attempt to replace an intrinsic constraint will
- * result in an exception.
- *
- * @param value_provider ext_obj the external object providing the value.
- * @param int ext_part the part number of the part of that object
- * providing the value.
- */
- public void set_part_a_constraint(value_provider ext_obj, int ext_part)
- {
- if (ext_obj == null)
- throw new sub_arctic_error("Null external constraint passed to " +
- "set_part_a_constraint()");
-
- /* set the constraint encoding */
- set_part_a_constraint(std_function.external());
-
- /* establish an association with the external provider */
- manager.establish_extern_constraint(this,PART_A, ext_obj,ext_part);
-
- /* mark the value out-of-date */
- mark_part_a_ood();
- }
-
- //had:
- //* @exception cannot_constrain if part_a is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a standard external constraint on the part_a value of this
- * object. This replaces any constraint currently in place. However, an
- * attempt to replace an intrinsic constraint will result in an exception.
- *
- * @param std_ext_constraint ext_cnstr the constraint to attach.
- */
- public void set_part_a_constraint(std_ext_constraint ext_cnstr)
- {
- /* use arbitrary extern API with part 0, then set us up as self */
- set_part_a_constraint(ext_cnstr, 0);
- ext_cnstr.set_self_obj(this);
- }
-
- //had:
- //* @exception cannot_constrain if part_a is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a constraint on the part_b value of this object. This
- * replaces any constraint currently in place. However, an attempt to
- * replace an intrinsic constraint will result in an exception.
- *
- * @param constraint a_constraint the constraint to replace it with.
- */
- public void set_part_b_constraint(constraint a_constraint)
- {
- /* if its intrinsic throw an exception */
- if ((PART_B & intrinsic_constraints()) != 0)
- throw new sub_arctic_error(
- "Attempt to override an intrinsic constraint on part_b");
-
- /* if we have an existing external constraint, drop it */
- if (part_b_constraint().is_external())
- manager.drop_extern_constraint(this, PART_B);
-
- /* assign to the constraint encoding, then mark the value out-of-date */
- _part_b_constraint = a_constraint.encoding();
- if ((a_constraint.orientation() & std_encoding_consts.HORIZONTAL) != 0)
- _constraint_flags |= PART_B_IS_HORIZONTAL;
- else
- _constraint_flags &= ~PART_B_IS_HORIZONTAL;
- if (!a_constraint.is_none())
- mark_part_b_ood();
- }
-
- //had:
- //* @exception cannot_constrain if part_b is intrinsically constrained
- //* @exception bad_value
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish an "external" or "heavyweight" constraint on the part_b value of
- * this object. This attaches a value exported by a particular part of
- * some value_provider object and replaces any constraint currently in
- * place. However, an attempt to replace an intrinsic constraint will
- * result in an exception.
- *
- * @param value_provider ext_obj the external object providing the value.
- * @param int ext_part the part number of the part of that object
- * providing the value.
- */
- public void set_part_b_constraint(value_provider ext_obj, int ext_part)
- {
- if (ext_obj == null)
- throw new sub_arctic_error("Null external constraint passed to " +
- "set_part_b_constraint()");
-
- /* set the constraint encoding */
- set_part_b_constraint(std_function.external());
-
- /* establish an association with the external provider */
- manager.establish_extern_constraint(this,PART_B, ext_obj,ext_part);
-
- /* mark the value out-of-date */
- mark_part_b_ood();
- }
-
- //had:
- //* @exception cannot_constrain if part_b is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish a standard external constraint on the part_b value of this
- * object. This replaces any constraint currently in place. However, an
- * attempt to replace an intrinsic constraint will result in an exception.
- *
- * @param std_ext_constraint ext_cnstr the constraint to attach.
- */
- public void set_part_b_constraint(std_ext_constraint ext_cnstr)
- {
- /* use arbitrary extern API with part 0, then set us up as self */
- set_part_b_constraint(ext_cnstr, 0);
- ext_cnstr.set_self_obj(this);
- }
-
- //had:
- //* @exception cannot_constrain if part_b is intrinsically constrained.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate which values are currently marked as potentially out of
- * date with respect to their constraints. Typically this information
- * is needed only by the constraint system, since values are generally
- * brought up to date whenever they are requested. <p>
- *
- * @returns int a bitset indicating the parts of this object which are
- * currently marked out-of-date.
- */
- public int marked_ood()
- {
- return _constraint_flags & OOD_BITS;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Mark the given value as out of date. This will recursively mark
- * anything that directly or indirectly depends on the given value. This
- * should normally only be called by the constraint system, since setting
- * values via set_*() will automatically call this routine.
- *
- * @param int the part to mark out-of-date. This should be one of the
- * values: X, Y, W, H, ENABLED, PART_A, or PART_B.
- */
- public void mark_ood(int coord_code)
- {
- switch (coord_code)
- {
- case X: mark_x_ood(); break;
- case Y: mark_y_ood(); break;
- case W: mark_w_ood(); break;
- case H: mark_h_ood(); break;
- case VISIBLE: mark_visible_ood(); break;
- case ENABLED: mark_enabled_ood(); break;
- case PART_A: mark_part_a_ood(); break;
- case PART_B: mark_part_a_ood(); break;
- default:
- throw new sub_arctic_error("Unrecognized coordinate code " +
- coord_code + "passed to mark_ood()");
- }
- }
-
- //had:
- //* @exception bad_value if an unrecognized part code is given.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Mark all geometric parts of this object out of date. This happens for
- * example when we reparent it.
- */
- public void mark_all_ood()
- {
- mark_x_ood(); mark_y_ood();
- mark_w_ood(); mark_h_ood();
- mark_visible_ood();
- mark_enabled_ood();
- mark_part_a_ood();
- mark_part_b_ood();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Mark x value and anything that directly or indirectly depends on it as
- * out-of-date.
- */
- public void mark_x_ood()
- {
- /* Don't mark twice */
- if ((_constraint_flags & X_OOD) != 0) return;
-
- /* mark the value */
- _constraint_flags |= X_OOD;
-
- /* inform things that might depend on it that this is out-of-date */
- ood_inform_all(X);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Mark y value and anything that directly or indirectly depends on it as
- * out-of-date.
- */
- public void mark_y_ood()
- {
- /* Don't mark twice */
- if ((_constraint_flags & Y_OOD) != 0) return;
-
- /* mark the value */
- _constraint_flags |= Y_OOD;
-
- /* inform things that might depend on it that this is out-of-date */
- ood_inform_all(Y);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Mark w value and anything that directly or indirectly depends on it as
- * out-of-date.
- */
- public void mark_w_ood()
- {
- /* Don't mark twice */
- if ((_constraint_flags & W_OOD) != 0) return;
-
- /* mark the value */
- _constraint_flags |= W_OOD;
-
- /* inform things that might depend on it that this is out-of-date */
- ood_inform_all(W);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Mark h value and anything that directly or indirectly depends on it as
- * out-of-date.
- */
- public void mark_h_ood()
- {
- /* Don't mark twice */
- if ((_constraint_flags & H_OOD) != 0) return;
-
- /* mark the value */
- _constraint_flags |= H_OOD;
-
- /* inform things that might depend on it that this is out-of-date */
- ood_inform_all(H);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Mark visible value and anything that directly or indirectly depends on
- * it as out-of-date.
- */
- public void mark_visible_ood()
- {
- /* Don't mark twice */
- if ((_constraint_flags & VISIBLE_OOD) != 0) return;
-
- /* mark the value */
- _constraint_flags |= VISIBLE_OOD;
-
- /* inform things that might depend on it that this is out-of-date */
- ood_inform_all(VISIBLE);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Mark enabled value and anything that directly or indirectly depends on
- * it as out-of-date.
- */
- public void mark_enabled_ood()
- {
- /* Don't mark twice */
- if ((_constraint_flags & ENABLED_OOD) != 0) return;
-
- /* mark the value */
- _constraint_flags |= ENABLED_OOD;
-
- /* inform things that might depend on it that this is out-of-date */
- ood_inform_all(ENABLED);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Mark part_a value and anything that directly or indirectly depends on it
- * as out-of-date.
- */
- public void mark_part_a_ood()
- {
- /* Don't mark twice */
- if ((_constraint_flags & PART_A_OOD) != 0) return;
-
- /* mark the value */
- _constraint_flags |= PART_A_OOD;
-
- /* inform things that might depend on it that this is out-of-date */
- ood_inform_all(PART_A);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Mark part_b value and anything that directly or indirectly depends on it
- * as out-of-date.
- */
- public void mark_part_b_ood()
- {
- /* Don't mark twice */
- if ((_constraint_flags & PART_B_OOD) != 0) return;
-
- /* mark the value */
- _constraint_flags |= PART_B_OOD;
-
- /* inform things that might depend on it that this is out-of-date */
- ood_inform_all(PART_B);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Tell all potentially dependent objects about an out of date part. This is
- * used by the lightweight constraint system to infer dependency edges that
- * are not explicitly stored. Basically we tell everyone that might have a
- * dependency edge from us (all the local neighborhood) and they work out
- * whether they have the edge or not based on the attached constraint. If
- * they do have the edge they mark themselves out-of-date, otherwise they
- * ignore this.
- *
- * @param int which_part the code of the part of this object which is
- * informing all the others that it is out-of-date.
- */
- protected void ood_inform_all(int which_part)
- {
- interactor ch;
- boolean have_ext = false;
- Vector notify_list;
- consumer_part_ref notif;
-
- /* tell other parts of same object */
- inform_ood(std_encoding_consts.OBJCODE_SELF, which_part, 0);
-
- /* tell the parent */
- if (parent() != null)
- parent().inform_ood(std_encoding_consts.OBJCODE_SOME_CHILD,
- which_part, child_index());
-
- /* tell the next and previous siblings */
- if (next_sibling() != null)
- next_sibling().inform_ood(std_encoding_consts.OBJCODE_PREV_SIBLING,
- which_part,0);
- if (prev_sibling() != null)
- prev_sibling().inform_ood(std_encoding_consts.OBJCODE_NEXT_SIBLING,
- which_part,0);
-
- /* tell the children */
- for (int i=0; i<num_children(); i++)
- {
- ch = child(i);
- if (ch != null)
- ch.inform_ood(std_encoding_consts.OBJCODE_PARENT,which_part, 0);
- }
-
- /* determine if we need to tell an external object */
- switch (which_part)
- {
- case X: have_ext = constraint_flag_is_set(X_HAS_EXT_NOTIFY); break;
- case Y: have_ext = constraint_flag_is_set(Y_HAS_EXT_NOTIFY); break;
- case W: have_ext = constraint_flag_is_set(W_HAS_EXT_NOTIFY); break;
- case H: have_ext = constraint_flag_is_set(H_HAS_EXT_NOTIFY); break;
- case VISIBLE:
- have_ext = constraint_flag_is_set(VISIBLE_HAS_EXT_NOTIFY);
- break;
- case ENABLED:
- have_ext = constraint_flag_is_set(ENABLED_HAS_EXT_NOTIFY);
- break;
- case PART_A:
- have_ext = constraint_flag_is_set(PART_A_HAS_EXT_NOTIFY);
- break;
- case PART_B:
- have_ext = constraint_flag_is_set(PART_B_HAS_EXT_NOTIFY);
- break;
- }
-
- /* if we do, talk to the manager to get our notify list */
- if (have_ext)
- {
- /* get the list */
- notify_list = manager.get_ood_notify(this, which_part);
- if (notify_list != null)
- {
- /* walk down the list and notify everyone who wants to hear */
- for (int i = 0; i < notify_list.size(); i++)
- {
- notif = (consumer_part_ref)notify_list.elementAt(i);
- notif.obj.value_ood(notif.part_num, this, which_part);
- }
- }
- }
- }
-
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Mark all our geometric parts out-of-date and tell all potentially
- * dependent objects that all our parts are out-of-date (this gets done
- * when we move around in the hierarchy). This affects, x, y, w, and h,
- * but not visible, enabled, part_a, or part_b.
- */
- public void mark_reparented_ood()
- {
- /* make sure we propagate past even if we are already marked */
- if ((marked_ood() & X) != 0) ood_inform_all(X); else mark_x_ood();
- if ((marked_ood() & Y) != 0) ood_inform_all(Y); else mark_y_ood();
- if ((marked_ood() & W) != 0) ood_inform_all(W); else mark_w_ood();
- if ((marked_ood() & H) != 0) ood_inform_all(H); else mark_h_ood();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Inform the object that the indicated part of a potentially related object
- * is out-of-date (this is called from ood_inform_all()). The related
- * object can be one of OBJCODE_SELF, OBJCODE_PARENT, OBJCODE_SOME_CHILD,
- * OBJCODE_NEXT_SIBLING, or OBJCODE_PREV_SIBLING, and the indicated part
- * can be X, Y, W, H, VISIBLE, ENABLED, PART_A, or PART_B. <p>
- *
- * The nth_child parameter is used only if OBJCODE_SOME_CHILD is passed,
- * in which case it indicates the index of the child in question.
- * If parts of this object are actually dependent upon the given part they
- * are marked out-of-date and the mark out-of-date traversal is continued
- * recursively from them. If not, we do nothing.
- *
- * @see #ood_inform_all
- * @param int from_type the type of object we are being informed by (must be
- * one of OBJCODE_SELF, OBJCODE_PARENT,
- * OBJCODE_SOME_CHILD, OBJCODE_NEXT_SIBLING, or
- * OBJCODE_PREV_SIBLING).
- * @param int from_part the part code of the part of that object which is
- * informing us that it is out-of-date.
- * @param int nth_child if from_type is OBJCODE_SOME_CHILD, this parameter
- * indicates which child it is (otherwise it is ignored).
- */
- public void inform_ood(
- int from_type,
- int from_part,
- int nth_child)
- {
-
- /* only need to inform components with matching h/v orientation */
- if (from_part == X || from_part == W)
- {
- /* if x depends on that part, mark it */
- if (std_constraint_impl.the_impl().depends_on(
- _x_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.HORIZONTAL))
- mark_x_ood();
-
- /* if w depends on that part, mark it */
- if (std_constraint_impl.the_impl().depends_on(
- _w_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.HORIZONTAL))
- mark_w_ood();
-
- /* if visible is horizontal and depends on that part, mark it */
- if ((_constraint_flags & VISIBLE_IS_HORIZONTAL) != 0 &&
- std_constraint_impl.the_impl().depends_on(
- _visible_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.HORIZONTAL))
- mark_visible_ood();
-
- /* if enabled is horizontal and depends on that part, mark it */
- if ((_constraint_flags & ENABLED_IS_HORIZONTAL) != 0 &&
- std_constraint_impl.the_impl().depends_on(
- _enabled_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.HORIZONTAL))
- mark_enabled_ood();
-
- /* if part_a is horizontal and depends on that part, mark it */
- if ((_constraint_flags & PART_A_IS_HORIZONTAL) != 0 &&
- std_constraint_impl.the_impl().depends_on(
- _part_a_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.HORIZONTAL))
- mark_part_a_ood();
-
- /* if part_b is horizontal and depends on that part, mark it */
- if ((_constraint_flags & PART_B_IS_HORIZONTAL) != 0 &&
- std_constraint_impl.the_impl().depends_on(
- _part_b_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.HORIZONTAL))
- mark_part_b_ood();
- }
- else if (from_part == Y || from_part == H)
- {
- /* if y depends on that part, mark it */
- if (std_constraint_impl.the_impl().depends_on(
- _y_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.VERTICAL))
- mark_y_ood();
-
- /* if h depends on that part, mark it */
- if (std_constraint_impl.the_impl().depends_on(
- _h_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.VERTICAL))
- mark_h_ood();
-
- /* if visible is vertical and depends on that part, mark it */
- if ((_constraint_flags & VISIBLE_IS_HORIZONTAL) == 0 &&
- std_constraint_impl.the_impl().depends_on(
- _visible_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.VERTICAL))
- mark_visible_ood();
-
- /* if enabled is vertical and depends on that part, mark it */
- if ((_constraint_flags & ENABLED_IS_HORIZONTAL) == 0 &&
- std_constraint_impl.the_impl().depends_on(
- _enabled_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.VERTICAL))
- mark_enabled_ood();
-
- /* if part_a is vertical and depends on that part, mark it */
- if ((_constraint_flags & PART_A_IS_HORIZONTAL) == 0 &&
- std_constraint_impl.the_impl().depends_on(
- _part_a_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.VERTICAL))
- mark_part_a_ood();
-
- /* if part_b is vertical and depends on that part, mark it */
- if ((_constraint_flags & PART_B_IS_HORIZONTAL) == 0 &&
- std_constraint_impl.the_impl().depends_on(
- _part_b_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.VERTICAL))
- mark_part_b_ood();
- }
- else /* not oriented */
- {
- /* if x depends on that part, mark it */
- if (std_constraint_impl.the_impl().depends_on(
- _x_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.HORIZONTAL))
- mark_x_ood();
-
- /* if w depends on that part, mark it */
- if (std_constraint_impl.the_impl().depends_on(
- _w_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.HORIZONTAL))
- mark_w_ood();
-
- /* if y depends on that part, mark it */
- if (std_constraint_impl.the_impl().depends_on(
- _y_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.VERTICAL))
- mark_y_ood();
-
- /* if h depends on that part, mark it */
- if (std_constraint_impl.the_impl().depends_on(
- _h_constraint, this, from_type, from_part,
- nth_child, std_encoding_consts.VERTICAL))
- mark_h_ood();
-
- /* if visible depends on that part, mark it */
- if (std_constraint_impl.the_impl().depends_on(
- _visible_constraint, this, from_type, from_part,
- nth_child, 0))
- mark_visible_ood();
-
- /* if enabled depends on that part, mark it */
- if (std_constraint_impl.the_impl().depends_on(
- _enabled_constraint, this, from_type, from_part,
- nth_child, 0))
- mark_enabled_ood();
-
- /* if part_a depends on that part, mark it */
- if (std_constraint_impl.the_impl().depends_on(
- _part_a_constraint, this, from_type, from_part,
- nth_child, 0))
- mark_part_a_ood();
-
- /* if part_b depends on that part, mark it */
- if (std_constraint_impl.the_impl().depends_on(
- _part_b_constraint, this, from_type, from_part,
- nth_child, 0))
- mark_part_b_ood();
- }
- }
-
- //had:
- //* @exception bad_value if an unrecognized or illegal type or part code is
- //* passed.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Handle a cycle detected in constraints on a given part of this object.
- * If this routine returns true, then evaluation proceeds. If this returns
- * false then, the current value of the attribute (which may have been set
- * by this routine) is left in place but marked up-to-date. By default, we
- * call manager.handle_cycle() which provides a global policy for handling
- * cycles (manager.handle_cycle() defaults to ignoring the cycle, which
- * amounts to breaking the cycle "once-around", its also possible to print
- * a debugging message, or a stack trace and/or force an error exit).
- *
- * @see sub_arctic.lib.manager#handle_cycle
- * @param int part_code the part of this object that involves a cycle.
- * @return boolean indicating whether we should proceed with evaluation.
- */
- public boolean handle_cycle(int part_code)
- {
- /* by default, we pass this off to the manager to apply the global
- * handling policy.
- */
- return manager.handle_cycle(this, part_code);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Bring the indicated value up to date with respect to any defining
- * constraints. This routine does not typically need to be called
- * explicitly since normal requests for values do evaluations before
- * returning.
- *
- * @param int coord_code the part whose value should be evaluated.
- */
- public void eval(int coord_code)
- {
- switch (coord_code)
- {
- case X: eval_x(); break;
- case Y: eval_y(); break;
- case W: eval_w(); break;
- case H: eval_h(); break;
- case VISIBLE: eval_visible(); break;
- case ENABLED: eval_enabled(); break;
- case PART_A: eval_part_a(); break;
- case PART_B: eval_part_b(); break;
- default:
- throw new sub_arctic_error("Unrecognized coordinate code " +
- coord_code + "passed to eval()");
- }
- }
-
- //had:
- //* @exception bad_value if an unrecognized part code is provided.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Bring x up to date with respect to any defining constraint. */
- public void eval_x()
- {
- int v;
-
- /* if we are already in process, we have a cycle. invoke the cycle
- * handler and if it returns true, we press on, otherwise, we clean
- * up and bail out */
- if ((_constraint_flags & X_IN_PROCESS) != 0)
- {
- /* no longer in process once this is done (do this here so if
- * handle_cycle() inadvertently evals across the same cycle
- * we don't get into an infinite loop).
- */
- _constraint_flags &= ~X_IN_PROCESS;
-
- /* use our local cycle handler -- if it returns false, bail out*/
- if (!handle_cycle(X))
- {
- _constraint_flags &= ~X_OOD;
- return;
- }
- }
-
- /* if its already up to date we are done */
- if ((_constraint_flags & X_OOD) == 0) return;
-
- /* value will be up to date after this */
- _constraint_flags &= ~X_OOD;
-
- /* if we have a constraint, do the evaluation */
- if (!std_constraint_impl.the_impl().is_none(_x_constraint))
- /* we are in process until we get back from evaluation */
- _constraint_flags |= X_IN_PROCESS;
-
- /* do the evaluation */
- v = std_constraint_impl.the_impl().eval(_x_constraint, this, X,
- std_encoding_consts.HORIZONTAL);
-
- /* we are no longer in process */
- _constraint_flags &= ~X_IN_PROCESS;
-
- /* actually set the value */
- set_raw_x(v);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Bring y up to date with respect to any defining constraint. */
- public void eval_y()
- {
- int v;
-
- /* if we are already in process, we have a cycle. invoke the cycle
- * handler and if it returns true, we press on, otherwise, we clean
- * up and bail out */
- if ((_constraint_flags & Y_IN_PROCESS) != 0)
- {
- /* no longer in process once this is done (do this here so if
- * handle_cycle() inadvertently evals across the same cycle
- * we don't get into an infinite loop).
- */
- _constraint_flags &= ~Y_IN_PROCESS;
-
- /* use our local cycle handler -- if it returns false, bail out*/
- if (!handle_cycle(Y))
- {
- _constraint_flags &= ~Y_OOD;
- return;
- }
- }
-
- /* if its already up to date we are done */
- if ((_constraint_flags & Y_OOD) == 0) return;
-
- /* value will be up to date after this */
- _constraint_flags &= ~Y_OOD;
-
- /* if we have a constraint, do the evaluation */
- if (!std_constraint_impl.the_impl().is_none(_y_constraint))
- /* we are in process until we get back from evaluation */
- _constraint_flags |= Y_IN_PROCESS;
-
- /* do the evaluation */
- v = std_constraint_impl.the_impl().eval(_y_constraint, this, Y,
- std_encoding_consts.VERTICAL);
-
- /* we are no longer in process */
- _constraint_flags &= ~Y_IN_PROCESS;
-
- /* actually set the value */
- set_raw_y(v);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Bring w up to date with respect to any defining constraint. */
- public void eval_w()
- {
- int v;
-
- /* if we are already in process, we have a cycle. invoke the cycle
- * handler and if it returns true, we press on, otherwise, we clean
- * up and bail out */
- if ((_constraint_flags & W_IN_PROCESS) != 0)
- {
- /* no longer in process once this is done (do this here so if
- * handle_cycle() inadvertently evals across the same cycle
- * we don't get into an infinite loop).
- */
- _constraint_flags &= ~W_IN_PROCESS;
-
- /* use our local cycle handler -- if it returns false, bail out*/
- if (!handle_cycle(W))
- {
- _constraint_flags &= ~W_OOD;
- return;
- }
- }
-
- /* if its already up to date we are done */
- if ((_constraint_flags & W_OOD) == 0) return;
-
- /* value will be up to date after this */
- _constraint_flags &= ~W_OOD;
-
- /* if we have a constraint, do the evaluation */
- if (!std_constraint_impl.the_impl().is_none(_w_constraint))
- /* we are in process until we get back from evaluation */
- _constraint_flags |= W_IN_PROCESS;
-
- /* do the evaluation */
- v = std_constraint_impl.the_impl().eval(_w_constraint, this, W,
- std_encoding_consts.HORIZONTAL);
-
- /* we are no longer in process */
- _constraint_flags &= ~W_IN_PROCESS;
-
- /* actually set the value */
- set_raw_w(v);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Bring h up to date with respect to any defining constraint. */
- public void eval_h()
- {
- int v;
-
- /* if we are already in process, we have a cycle. invoke the cycle
- * handler and if it returns true, we press on, otherwise, we clean
- * up and bail out */
- if ((_constraint_flags & H_IN_PROCESS) != 0)
- {
- /* no longer in process once this is done (do this here so if
- * handle_cycle() inadvertently evals across the same cycle
- * we don't get into an infinite loop).
- */
- _constraint_flags &= ~H_IN_PROCESS;
-
- /* use our local cycle handler -- if it returns false, bail out*/
- if (!handle_cycle(H))
- {
- _constraint_flags &= ~H_OOD;
- return;
- }
- }
-
- /* if its already up to date we are done */
- if ((_constraint_flags & H_OOD) == 0) return;
-
- /* value will be up to date after this */
- _constraint_flags &= ~H_OOD;
-
- /* if we have a constraint, do the evaluation */
- if (!std_constraint_impl.the_impl().is_none(_h_constraint))
- /* we are in process until we get back from evaluation */
- _constraint_flags |= H_IN_PROCESS;
-
- /* do the evaluation */
- v = std_constraint_impl.the_impl().eval(_h_constraint, this, H,
- std_encoding_consts.VERTICAL);
-
- /* we are no longer in process */
- _constraint_flags &= ~H_IN_PROCESS;
-
- /* actually set the value */
- set_raw_h(v);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Bring visible up to date with respect to any defining constraint. */
- public void eval_visible()
- {
- int hv;
- boolean val;
-
- /* if we are already in process, we have a cycle. invoke the cycle
- * handler and if it returns true, we press on, otherwise, we clean
- * up and bail out */
- if ((_constraint_flags & VISIBLE_IN_PROCESS) != 0)
- {
- /* no longer in process once this is done (do this here so if
- * handle_cycle() inadvertently evals across the same cycle
- * we don't get into an infinite loop).
- */
- _constraint_flags &= ~VISIBLE_IN_PROCESS;
-
- /* use our local cycle handler -- if it returns false, bail out*/
- if (!handle_cycle(VISIBLE))
- {
- _constraint_flags &= ~VISIBLE_OOD;
- return;
- }
- }
-
- /* if its already up to date we are done */
- if ((_constraint_flags & VISIBLE_OOD) == 0) return;
-
- /* value will be up to date after this */
- _constraint_flags &= ~VISIBLE_OOD;
-
- /* if we have a constraint, do the evaluation */
- if (!std_constraint_impl.the_impl().is_none(_visible_constraint))
- /* we are in process until we get back from evaluation */
- _constraint_flags |= VISIBLE_IN_PROCESS;
-
- /* do the evaluation */
- if ((_constraint_flags & VISIBLE_IS_HORIZONTAL) != 0)
- hv = std_encoding_consts.HORIZONTAL;
- else
- hv = std_encoding_consts.VERTICAL;
- val = std_constraint_impl.the_impl().eval(
- _visible_constraint, this, VISIBLE, hv) != 0;
-
- /* we are no longer in process */
- _constraint_flags &= ~VISIBLE_IN_PROCESS;
-
- /* actally set the value */
- set_raw_visible(val);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Bring enabled up to date with respect to any defining constraint. */
- public void eval_enabled()
- {
- int hv;
- boolean val;
-
- /* if we are already in process, we have a cycle. invoke the cycle
- * handler and if it returns true, we press on, otherwise, we clean
- * up and bail out */
- if ((_constraint_flags & ENABLED_IN_PROCESS) != 0)
- {
- /* no longer in process once this is done (do this here so if
- * handle_cycle() inadvertently evals across the same cycle
- * we don't get into an infinite loop).
- */
- _constraint_flags &= ~ENABLED_IN_PROCESS;
-
- /* use our local cycle handler -- if it returns false, bail out*/
- if (!handle_cycle(ENABLED))
- {
- _constraint_flags &= ~ENABLED_OOD;
- return;
- }
- }
-
- /* if its already up to date we are done */
- if ((_constraint_flags & ENABLED_OOD) == 0) return;
-
- /* value will be up to date after this */
- _constraint_flags &= ~ENABLED_OOD;
-
- /* if we have a constraint, do the evaluation */
- if (!std_constraint_impl.the_impl().is_none(_enabled_constraint))
- /* we are in process until we get back from evaluation */
- _constraint_flags |= ENABLED_IN_PROCESS;
-
- /* do the evaluation */
- if ((_constraint_flags & ENABLED_IS_HORIZONTAL) != 0)
- hv = std_encoding_consts.HORIZONTAL;
- else
- hv = std_encoding_consts.VERTICAL;
- val = std_constraint_impl.the_impl().eval(
- _enabled_constraint, this, ENABLED, hv) != 0;
-
- /* we are no longer in process */
- _constraint_flags &= ~ENABLED_IN_PROCESS;
-
- /* actually set the value */
- set_raw_enabled(val);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Bring part_a up to date with respect to any defining constraint. */
- public void eval_part_a()
- {
- int hv, val;
-
- /* if we are already in process, we have a cycle. invoke the cycle
- * handler and if it returns true, we press on, otherwise, we clean
- * up and bail out */
- if ((_constraint_flags & PART_A_IN_PROCESS) != 0)
- {
- /* no longer in process once this is done (do this here so if
- * handle_cycle() inadvertently evals across the same cycle
- * we don't get into an infinite loop).
- */
- _constraint_flags &= ~PART_A_IN_PROCESS;
-
- /* use our local cycle handler -- if it returns false, bail out*/
- if (!handle_cycle(PART_A))
- {
- _constraint_flags &= ~PART_A_OOD;
- return;
- }
- }
-
- /* if its already up to date we are done */
- if ((_constraint_flags & PART_A_OOD) == 0) return;
-
- /* value will be up to date after this */
- _constraint_flags &= ~PART_A_OOD;
-
- /* if we have a constraint, do the evaluation */
- if (!std_constraint_impl.the_impl().is_none(_part_a_constraint))
- /* we are in process until we get back from evaluation */
- _constraint_flags |= PART_A_IN_PROCESS;
-
- /* do the evaluation */
- if ((_constraint_flags & PART_A_IS_HORIZONTAL) != 0)
- hv = std_encoding_consts.HORIZONTAL;
- else
- hv = std_encoding_consts.VERTICAL;
- val = std_constraint_impl.the_impl().eval(
- _part_a_constraint, this, PART_A, hv);
-
- /* we are no longer in process */
- _constraint_flags &= ~PART_A_IN_PROCESS;
-
- /* actually set the value */
- set_raw_part_a(val);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Bring part_b up to date with respect to any defining constraint. */
- public void eval_part_b()
- {
- int hv, val;
-
- /* if we are already in process, we have a cycle. invoke the cycle
- * handler and if it returns true, we press on, otherwise, we clean
- * up and bail out */
- if ((_constraint_flags & PART_B_IN_PROCESS) != 0)
- {
- /* no longer in process once this is done (do this here so if
- * handle_cycle() inadvertently evals across the same cycle
- * we don't get into an infinite loop).
- */
- _constraint_flags &= ~PART_B_IN_PROCESS;
-
- /* use our local cycle handler -- if it returns false, bail out*/
- if (!handle_cycle(PART_B))
- {
- _constraint_flags &= ~PART_B_OOD;
- return;
- }
- }
-
- /* if its already up to date we are done */
- if ((_constraint_flags & PART_B_OOD) == 0) return;
-
- /* value will be up to date after this */
- _constraint_flags &= ~PART_B_OOD;
-
- /* if we have a constraint, do the evaluation */
- if (!std_constraint_impl.the_impl().is_none(_part_b_constraint))
- /* we are in process until we get back from evaluation */
- _constraint_flags |= PART_B_IN_PROCESS;
-
- /* do the evaluation */
- if ((_constraint_flags & PART_B_IS_HORIZONTAL) != 0)
- hv = std_encoding_consts.HORIZONTAL;
- else
- hv = std_encoding_consts.VERTICAL;
- val = std_constraint_impl.the_impl().eval(
- _part_b_constraint, this, PART_B, hv);
-
- /* we are no longer in process */
- _constraint_flags &= ~PART_B_IN_PROCESS;;
-
- /* actually set the value */
- set_raw_part_b(val);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Get the external value provider (if any) associated with the given
- * part value (X, Y, W, H, VISIBLE, ENABLED, PART_A, or PART_B). Returns
- * null if there is no external provider.
- *
- * @param int for_part the part we are asking about.
- * @return provider_part_ref the external value provider associated with that
- * part, or null if there is none.
- */
- public provider_part_ref get_external_constraint(int for_part)
- {
- /* the manager maintains associations, ask them */
- return manager.find_extern_constraint(this, for_part);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Get an up-to-date copy of a particular part value(X, Y, W, H, VISIBLE,
- * ENABLED, PART_A, or PART_B). An Integer object will be returned.
- *
- * @param int part_number the part being requested.
- * @return Object an Integer object containing the value of the requested
- * part.
- */
- public Object get_value(int part_number)
- {
- switch (part_number)
- {
- case X: return new Integer(x());
- case Y: return new Integer(y());
- case W: return new Integer(w());
- case H: return new Integer(h());
- case VISIBLE: return new Integer(visible()?1:0);
- case ENABLED: return new Integer(enabled()?1:0);
- case PART_A: return new Integer(part_a());
- case PART_B: return new Integer(part_b());
- default:
- throw new sub_arctic_error("Unknown part_number " + part_number +
- " passed to base_interactor.get_value()");
- }
- }
-
- //had:
- //* @exception bad_value if an unrecognized part is requested.
- //* @exception general
-
- // we have a problem here in that the constants here are really bit
- // bit positions, not part numbers. Need to separate those two notions
- // at some point.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Register something as interested in (dependent on) one of the parts
- * (X, Y, W, H, VISIBLE, ENABLED, PART_A, or PART_B) of this object. The
- * entity registered is a part within a value_consumer object (typically
- * an external_constraint). Whenever the part value in question is marked
- * out-of-date, the value_ood() method is invoked on each currently
- * registered (object,part) pair.
- *
- * @param int on_part_num the part of this object that the
- * dependency is being attached to.
- * @param value_consumer dep_obj the object that is dependent.
- * @param int dep_part the part within that object which is
- * dependent.
- */
- public void attach_dependent(
- int on_part_num,
- value_consumer dep_obj,
- int dep_part)
- {
- /* set flag to indicate we have an external notify to do */
- switch (on_part_num)
- {
- case X: set_constraint_flag_bit(X_HAS_EXT_NOTIFY); break;
- case Y: set_constraint_flag_bit(Y_HAS_EXT_NOTIFY); break;
- case W: set_constraint_flag_bit(W_HAS_EXT_NOTIFY); break;
- case H: set_constraint_flag_bit(H_HAS_EXT_NOTIFY); break;
- case VISIBLE: set_constraint_flag_bit(VISIBLE_HAS_EXT_NOTIFY); break;
- case ENABLED: set_constraint_flag_bit(ENABLED_HAS_EXT_NOTIFY); break;
- case PART_A: set_constraint_flag_bit(PART_A_HAS_EXT_NOTIFY); break;
- case PART_B: set_constraint_flag_bit(PART_B_HAS_EXT_NOTIFY); break;
- default:
- throw new sub_arctic_error("Unknown part_number " + on_part_num +
- " passed to base_interactor.attach_dependent()");
- }
-
- /* the manager maintains our notify list for us, have them handle it */
- manager.add_to_ood_notify(this, on_part_num, dep_obj, dep_part);
- }
-
- //had:
- //* @exception bad_value if an unrecognized part code is given.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Remove an (object,part) pair from the dependent (interested in) list
- * associated with a particular part of this object.
- *
- * @param int on_part_num the part of this object that the
- * dependency is attached to.
- * @param value_consumer dep_obj the object that was dependent.
- * @param int dep_part the part within that object which was
- * dependent.
- */
- public void detach_dependent(
- int on_part_num,
- value_consumer dep_obj,
- int dep_part)
- {
- boolean empty;
-
- if (on_part_num < X || on_part_num > PART_B)
- throw new sub_arctic_error("Unknown part_number " + on_part_num +
- " passed to base_interactor.detach_dependent()");
-
- /* the manager maintains our notify list for us, have them handle it */
- empty = manager.remove_ood_notify(this, on_part_num, dep_obj, dep_part);
-
- /* if the notify list is now empty, remove our flag */
- if (empty)
- switch (on_part_num)
- {
- case X: clear_constraint_flag_bit(X_HAS_EXT_NOTIFY); break;
- case Y: clear_constraint_flag_bit(Y_HAS_EXT_NOTIFY); break;
- case W: clear_constraint_flag_bit(W_HAS_EXT_NOTIFY); break;
- case H: clear_constraint_flag_bit(H_HAS_EXT_NOTIFY); break;
- case VISIBLE:
- clear_constraint_flag_bit(VISIBLE_HAS_EXT_NOTIFY);
- break;
- case ENABLED:
- clear_constraint_flag_bit(ENABLED_HAS_EXT_NOTIFY);
- break;
- case PART_A:
- clear_constraint_flag_bit(PART_A_HAS_EXT_NOTIFY);
- break;
- case PART_B:
- clear_constraint_flag_bit(PART_B_HAS_EXT_NOTIFY);
- break;
- }
- }
-
- //had:
- //* @exception bad_value if an unrecognized part code is given.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate that a part value (X, Y, W, H, VISIBLE, ENABLED, PART_A, or
- * PART_B) with an external constraint attached should be marked out-of-date
- * because something it depends on (externally) is out-of-date.
- *
- * @param int for_part_here part within this object that should be
- * marked out-of-date.
- * @param value_provider prov_obj object that we depend on.
- * @param int prov_part part within that object that is
- */
- public void value_ood(
- int for_part_here,
- value_provider prov_obj,
- int prov_part)
- {
- switch (for_part_here)
- {
- case X: mark_x_ood(); break;
- case Y: mark_y_ood(); break;
- case W: mark_w_ood(); break;
- case H: mark_h_ood(); break;
- case VISIBLE: mark_visible_ood(); break;
- case ENABLED: mark_enabled_ood(); break;
- case PART_A: mark_part_a_ood(); break;
- case PART_B: mark_part_b_ood(); break;
- default:
- throw new sub_arctic_error("Unknown part_number " + for_part_here +
- " passed to base_interactor.value_ood()");
- }
- }
-
- //had:
- //* @exception bad_value if an unrecognized part code is given.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * A custom function accessible in the constraint system. This function
- * is accessible from the (lightweight) constraint system and can be
- * overridden by particular subclasses to perform custom computations
- * associated with that class. This version is passed a single parameter
- * value derived from a depended upon object, plus a constant value taken
- * from the constraint. <p>
- *
- * <b>Important note</b>: for the constraint system to work correctly, this
- * function must compute its value solely on its parameters and not access
- * additional information from this object or other objects (since the
- * attribute constrained to the result of this function will not hear about
- * changes and be properly updated).
- *
- * @param int val1 a value from a depended upon object.
- * @param int const_val a constant value taken from the constraint.
- * @returns int by default this returns the sum of the two values. More
- * interesting functions will be provided by subclasses.
- */
- public int custom_fun1(int val1, int const_val) {return val1 + const_val;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * A custom function accessible in the constraint system. This function
- * is accessible from the (lightweight) constraint system and can be
- * overridden by particular subclasses to perform custom computations
- * associated with that class. This version is passed two parameter values
- * derived from a depended upon object, plus a constant value taken from the
- * constraint. <p>
- *
- * <b>Important note</b>: for the constraint system to work correctly, this
- * function must compute its value solely on its parameters and not access
- * additional information from this object or other objects (since the
- * attribute constrained to the result of this function will not hear about
- * changes and be properly updated).
- *
- * @param int val1 a value from a depended upon object.
- * @param int val2 another value from a depended upon object.
- * @param int const_val a constant value taken from the constraint.
- * @returns int by default this returns the sum of the three values. More
- * interesting functions will be provided by subclasses.
- */
- public int custom_fun2(int val1, int val2, int const_val)
- {return val1 + val2 + const_val;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Do the constraint evaluation necessary to make sure all visible objects
- * in the subtree rooted at this object have up-to-date bounds (and other
- * information) prior to drawing. This routine implements the "configure"
- * pass which occurs right before the pass that does the actual drawing.<p>
- *
- * <b>Important note</b>: In addition to the work done here in the base class
- * (which should almost always be done by invoking super() from any subclass
- * implementations), each subclass should also be certain to update anything
- * which could effect its bounds here, and <b>not</b> in draw_self_local().
- * So for example if the height of an object depends on a font that might
- * have changed, the potentially new height must be computed and set here
- * and not in draw_self_local(). In general, for things to work out right
- * it must be the case that this object's bound is correct once this method
- * returns. The reason for this is that by the time draw_self_local() is
- * called, the clipping region corresponding to the bound of this object
- * will have already been set and changing the bound then will not modify
- * the clipping region accordingly (so the drawing may be incorrect).
- */
- public void configure()
- {
- interactor chld;
-
- /* if we are not visible, bail out early */
- if (!visible()) return;
-
- /* eval all the local coordinates */
- eval_x(); eval_y();
- eval_w(); eval_h();
-
- /* bring enabled, part_a, and part_b up to date */
- enabled(); part_a(); part_b();
-
- /* walk down the children and recursively configure them */
- for (int i = 0; i<num_children(); i++)
- {
- chld = child(i);
- if (chld != null) chld.configure();
- }
- }
-
- /*---------------------------------------------------------------------*/
- /* Picking */
- /*---------------------------------------------------------------------*/
-
- /**
- * Determine if the given point (in the local coordinates of this object)
- * is inside the extent of this object's normal bound. You should <b>not</b>
- * normally override this routine to handle picking of non-rectangular
- * objects. Do that in picked_by() instead.
- *
- * @see #picked_by
- * @param int pt_x x coordinate of the query point.
- * @param int pt_y y coordinate of the query point.
- * @return boolean indicating whether the point is inside the objects
- * bounding box.
- */
- public boolean inside_bounds(int pt_x, int pt_y)
- {
- return (new Rectangle(0,0,w(),h())).inside(pt_x,pt_y);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Determine if the given point (in the local coordinates of this object)
- * is inside the extent of the object picking purposes. Be default, this
- * method just checks the normal bound (bounding box), however, it can
- * be overridden to support accurate picking of non-rectangular objects.
- *
- * @see #inside_bounds
- * @param int pt_x x coordinate of the query point.
- * @param int pt_y y coordinate of the query point.
- * @return boolean indicating whether the point is inside the objects
- * bounding box.
- */
- public boolean picked_by(int pt_x, int pt_y)
- {
- return inside_bounds(pt_x, pt_y);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Determine if this object and/or any of its decedent objects is "picked"
- * by the the given point. If it is, it must add itself to the end of the
- * given given pick_collection by calling report_pick(). If not, it should
- * leave the pick_collector as is.<p>
-
- * This method is also responsible for recursively invoking itself as
- * appropriate for its children (this is usually done using the
- * pick_within_children() utility routine). By default we pick against any
- * children first (since they are by default drawn last) and then this
- * object. However, if the drawing order is changed from the default, this
- * method must be changed to reflect (the reverse of) that non-standard order.
- * For example, if this object does drawing both under and on top of its
- * children, two sets of part specific tests would typically be needed, one
- * before recursively picking the children, and one after.
- *
- * @see #pick_within_children
- * @param int pt_x x coordinate of the query point.
- * @param int pt_y y coordinate of the query point.
- * @param pick_collector pick_list object that collects and returns pick
- * results.
- */
- public void pick(int pt_x, int pt_y, pick_collector pick_list)
- {
- /* don't pick anything unless we are enabled and its inside our bounds */
- if (enabled() && visible() && picked_by(pt_x, pt_y))
- {
- /* do child picks first (since they were drawn "over" us) */
- pick_within_children(pt_x, pt_y, pick_list);
-
- /* now pick us (since we were drawn first) */
- pick_list.report_pick(this);
- }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Utility routine to perform pick over children. The point is given in
- * local coordinates of the parent object.
- *
- * @param int pt_x x coordinate of the query point.
- * @param int pt_y y coordinate of the query point.
- * @param pick_collector pick_list object that collects and returns pick
- * results.
- */
- protected void pick_within_children(
- int pt_x,
- int pt_y,
- pick_collector pick_list)
- {
- Point child_point;
- interactor ch;
-
- for (int i = num_children()-1; i >= 0; i--)
- {
- ch = child(i);
- if (ch != null)
- {
- child_point = ch.into_local(new Point(pt_x, pt_y));
- ch.pick(child_point.x, child_point.y, pick_list);
- }
- }
- }
-
- //has:
- //* @exception general
-
- /*---------------------------------------------------------------------*/
- /* Generic traversal support */
- /*---------------------------------------------------------------------*/
-
- /**
- * Do a traversal of the interactor tree to collect nodes meeting some
- * criteria (or perform actions on qualifying nodes). Traversals are
- * given a specialized "kind" so that subclasses can recognize and
- * override behavior for certain traversals, while keeping default behavior
- * for the rest. In addition, several traversal orders are provided.
- * Qualification for collection (or action) is done by an inclusion test
- * predicate object. This predicate is given the interactor in question
- * as well as some (optional) data specific to the predicate. This
- * data is passed in from the root of the traversal and (optionally)
- * transformed from parent to child values as the traversal proceeds.
- * Objects are collected (along with optional additional data) by adding
- * them to a pick_collector object. Recursive traversal is stopped when
- * either leaves are reached or the continue_test predicate for an
- * interior node fails (in which case its children will not be visited).<p>
- *
- * Examples of possible traversals include:<br>
- * Replacement for the normal pick operation:<br>
- * <pre>
- * traverse_and_collect(pick_trav, TRAV_DRAW, pt_inside_bounds, pt_inside_bounds,
- * coord_parent_to_local, pick_pt, result);
- * </pre>
- * and a tree dump:<br>
- * <pre>
- * traverse_and_collect(dump_trav, TRAV_PRE, dump_interactor, incr_int,
- * null, new Integer(0), result)
- * </pre>
- * where dump_interactor printed to the node to System.out at the indentation
- * level of its Integer parameter, but always returns false
- *
- * @param traversal_kind a unique integer (i.e., generated by
- * manager.unique_int()) that represents the kind
- * of traversal being performed.
- * @param traversal_order one of TRAV_DRAW, TRAV_PICK, TRAV_PRE, or
- * TRAV_POST indicating drawing order, pick order,
- * left-to-right pre-order, or left-to-right
- * post-order traversal.
- * @param inclusion_test an interactor predicate object which is to
- * perform the inclusion test for this traversal.
- * If the traversal is being done for its action
- * side-effects (rather than a collection, per se)
- * then this object's test() method should perform
- * that action on selected nodes. A null
- * inclusion_test is treated as a function that
- * selects everything (always returns true).
- * @param continue_test an interactor_predicate object which determines
- * if the given object's children are traversed.
- * If this method returns false, then the children
- * will not be visited. A null continue_test is
- * is treated as a function that always returns
- * true.
- * @param xform_parent_to_child object containing a method to transform the
- * parameters data (passed to the inclusion_test)
- * from its parent condition to the condition
- * suitable for use by a given child. This can
- * be used, for example, to transform a point from
- * the parent's coordinates into those of a child.
- * A null object is treated as the identity
- * transformation (i.e. uses the parent's
- * parameters directly for all children).
- *
- * @param parameters the initial parameters data passed to the
- * inclusion_test at the root, then transformed by
- * xform_parent_to_child for recursive calls on
- * children.
- * @param collection_result a pick_collector object which holds a list of
- * interactors collected by this traversal (and
- * optional associated data). If an object
- * determines that it should be a part of the
- * collection of this traversal, it should add
- * itself to this collection by calling its
- * report_pick() method.
- */
- public void traverse_and_collect(
- int traversal_kind,
- int traversal_order,
- interactor_pred inclusion_test,
- interactor_pred continue_test,
- traversal_xform xform_parent_to_child,
- Object parameters,
- pick_collector collection_result)
- {
- int i;
- interactor ch;
-
- /* here we are providing the default, so we do all kinds the same */
-
- /* select control flow for the order they want */
- switch(traversal_order)
- {
- default:
- /* if they provide a nonsensical order we throw bad_value */
- throw new sub_arctic_error("Unrecognized traversal order (" +
- traversal_order + ")");
-
- /* default drawing order is parent, then children, left-to-right */
- case TRAV_DRAW:
- case TRAV_PRE:
- /* test this object for inclusion */
- traverse_and_collect_parent(
- traversal_kind, inclusion_test, parameters, collection_result);
-
- /* now do children left-to-right */
- traverse_and_collect_children(traversal_kind, traversal_order,
- true, inclusion_test, continue_test, xform_parent_to_child,
- parameters, collection_result);
- break;
-
- /* default pick order is children right-to-left, then parent */
- case TRAV_PICK:
- /* do children right-to-left */
- traverse_and_collect_children(traversal_kind, traversal_order,
- false, inclusion_test, continue_test, xform_parent_to_child,
- parameters, collection_result);
-
- /* now test this object for inclusion */
- traverse_and_collect_parent(
- traversal_kind, inclusion_test, parameters, collection_result);
- break;
-
- case TRAV_POST:
- /* do children left-to-right */
- traverse_and_collect_children(traversal_kind, traversal_order,
- true, inclusion_test, continue_test, xform_parent_to_child,
- parameters, collection_result);
-
- /* now test this object for inclusion */
- traverse_and_collect_parent(
- traversal_kind, inclusion_test, parameters, collection_result);
- break;
- }
- }
-
- //had:
- //* @exception sub_arctic.exception.bad_value thrown when an improperly typed
- //* value is passed in the parameters parameter or for traversal_order.
- //* @exception sub_arctic.exception.general a "place-holder" to cover
- //* additional exceptions that subclasses might want to throw.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Helper routine for traverse_and_collect() -- this does test on a single
- * (parent) object.
- *
- * @see #traverse_and_collect
- * @param int traversal_kind the identifier for this traversal
- * type.
- * @param interactor_pred inclusion_test the predicate we are testing this
- * object against.
- * @param Object parameters the additional parameters to be
- * passed to that predicate.
- * @param pick_collector collection_result the object that collects and
- * returns any objects which are
- * selected.
- */
- protected void traverse_and_collect_parent(
- int traversal_kind,
- interactor_pred inclusion_test,
- Object parameters,
- pick_collector collection_result)
- {
- /* here we are providing the default, so we do all kinds the same */
-
- /* test this object for inclusion */
- if (inclusion_test == null || inclusion_test.test(this, parameters))
- {
- if (collection_result != null)
- collection_result.report_pick(this, parameters);
- }
- }
-
- //had:
- //* @exception sub_arctic.exception.bad_value thrown when an improperly typed
- //* value is passed in the parameters parameter or for traversal_order.
- //* @exception sub_arctic.exception.general a "place-holder" to cover
- //* additional exceptions that subclasses might want to throw.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Helper routine for traverse_and_collect() -- does recursive traversal
- * of children in either left-to-right or right-to-left order.
- *
- * @see #traverse_and_collect
- * @param int traversal_kind the traversal type id.
- * @param int traversal_order traversal order we are to use.
- * @param boolean l_to_r true for left-to-right
- * traversal, false for
- * right-to-left.
- * @param interactor_pred inclusion_test the inclusion test for the
- * traversal (see
- * traverse_and_collect()).
- * @param interactor_pred continue_test the continue test for the
- * traversal(see
- * traverse_and_collect()).
- * @param traversal_xform xform_parent_to_child the parameter transformer
- * for the traversal(see
- * traverse_and_collect()).
- * @param Object parameters the parameters passed to the
- * inclusion and continue test
- * predicates.
- * @param pick_collector collection_result the object which collects and
- * returns the selected objects.
- */
- public void traverse_and_collect_children(
- int traversal_kind,
- int traversal_order,
- boolean l_to_r,
- interactor_pred inclusion_test,
- interactor_pred continue_test,
- traversal_xform xform_parent_to_child,
- Object parameters,
- pick_collector collection_result)
- {
- int i;
- interactor ch;
- Object ch_parms;
-
- /* if the continue test fails we bail out now */
- if (continue_test != null && !continue_test.test(this, parameters))
- return;
-
- /* walk over child list forward or backwards as needed */
- for (i = (l_to_r) ? 0 : (num_children()-1); // begin at start or end
- (l_to_r) ? (i < num_children()) : (i >= 0); // go to start or end
- i += ((l_to_r) ? 1 : -1)) // incr or decr
- {
- /* pull out the child and if its not null recurse on it */
- ch = child(i);
- if (ch != null)
- {
- /* transform the parameters into those for the child */
- if (xform_parent_to_child != null)
- ch_parms = xform_parent_to_child.xform(parameters, ch, i);
- else
- ch_parms = parameters;
-
- /* recursively traverse the child */
- ch.traverse_and_collect(traversal_kind, traversal_order,
- inclusion_test, continue_test, xform_parent_to_child,
- ch_parms, collection_result);
- }
- }
- }
-
- //had:
- //* @exception sub_arctic.exception.bad_value thrown when an improperly typed
- //* value is passed in the parameters parameter or for traversal_order.
- //* @exception sub_arctic.exception.general a "place-holder" to cover
- //* additional exceptions that subclasses might want to throw.
-
- /*---------------------------------------------------------------------*/
- /* Status */
- /*---------------------------------------------------------------------*/
-
- /**
- * Determine if a particular bit (or bits) is set in the flag set for the
- * interactor. In the case of testing for multiple flag bits, they must
- * all be set to get a result of true. See interactor_consts for
- * possible values that can be queried.
- *
- * @see sub_arctic.lib.interactor_consts
- * @param int mask_value the flag bit or bits we are enquiring about.
- * @return boolean indicating whether the bit or bits are (all) set.
- */
- public final boolean flag_is_set(int mask_value)
- {
- return (_flags & mask_value) == mask_value;
- }
-
- // why are these final?
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set the given flag bit(s) to the given value. See interactor_consts for
- * possible values that can be set.
- *
- * @see sub_arctic.lib.interactor_consts
- * @param int mask_value the bit or bits to be modified within the flags.
- * @param boolean v the value to set those bits to.
- */
- protected final void set_flag_bit(int mask_value, boolean v)
- {
- if (v)
- _flags |= (mask_value & 0xffffffff);
- else
- _flags &= ~mask_value;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set the given flag bit(s) to true. See interactor_consts for
- * possible values that can be set.
- *
- * @see sub_arctic.lib.interactor_consts
- * @param int mask_value the bit or bits to be modified within the flags.
- */
- protected final void set_flag_bit(int mask_value)
- {
- _flags |= (mask_value & 0xffffffff);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set the given flag bit(s) to false. See interactor_consts for
- * possible values that can be set.
- *
- * @see sub_arctic.lib.interactor_consts
- * @param int mask_value the bit or bits to be modified within the flags.
- */
- protected final void clear_flag_bit(int mask_value)
- {
- _flags &= ~mask_value;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Determine if a particular bit (or bits) is set in the constraint_flag
- * set for the interactor. In the case of testing for multiple
- * constraint_flag bits, they must all be set to get a result of true.
- * See interactor_consts for possible values that can be queried.
- */
- public final boolean constraint_flag_is_set(int mask_value)
- {
- return (_constraint_flags & mask_value) == mask_value;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set the given constraint_flag bit(s) to the given value. See
- * interactor_consts for possible values that can be set.
- *
- * @see sub_arctic.lib.interactor_consts
- * @param int mask_value the bit or bits to be modified within the flags.
- * @param boolean v the value to set those bits to.
- */
- protected final void set_constraint_flag_bit(int mask_value, boolean v)
- {
- if (v)
- _constraint_flags |= (mask_value & 0xffffffff);
- else
- _constraint_flags &= ~mask_value;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set the given constraint_flag bit(s) to true. See interactor_consts for
- * possible values that can be set.
- *
- * @see sub_arctic.lib.interactor_consts
- * @param int mask_value the bit or bits to be modified within the flags.
- */
- protected final void set_constraint_flag_bit(int mask_value)
- {
- _constraint_flags |= (mask_value & 0xffffffff);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set the given constraint_flag bit(s) to false. See interactor_consts for
- * possible values that can be set.
- *
- * @see sub_arctic.lib.interactor_consts
- * @param int mask_value the bit or bits to be modified within the flags.
- */
- protected final void clear_constraint_flag_bit(int mask_value)
- {
- _constraint_flags &= ~mask_value;
- }
-
- /*---------------------------------------------------------------------*/
- /* Output */
- /*---------------------------------------------------------------------*/
-
- /**
- * Given a drawable surface set up for the parent coordinate space,
- * create a new drawable set up for the local coordinate space.
- * This surface will have a translation installed corresponding to the
- * local origin, and will clip to the extent of the local object.
- *
- * @param drawable parent_draw the drawable set up for the parent.
- * @return drawable a new drawable set up for the child.
- */
- protected drawable enter_local_coordinates(drawable parent_draw)
- {
- drawable result;
-
- /* make a copy of the drawable for use in local coords */
- result = parent_draw.copy();
-
- /* apply transformation to get from parent to local coords */
- result.translate(x(), y());
-
- /* clip to local bounds */
- result.clipRect(0, 0, w(), h());
-
- return result;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Do the work to exit the local coordinate system. Here this does
- * nothing since we just revert to the original parent drawable.
- * However, this is here as a useful hook for subclasses that need to do
- * something else at this point.
- *
- * @param drawable parent_draw the drawable used by our parent.
- * @param drawable local_draw the drawable derived from it used by us.
- */
- protected void exit_local_coords(drawable parent_draw, drawable local_draw)
- {
- /* here do nothing */
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Do a trivial reject test that indicates whether the given bounding
- * box is entirely outside the clipping region of the given drawable
- * object. Returns true if nothing inside the box will survive the clip
- * and hence need not be drawn. This can also be used for optimizing
- * drawing by testing whether an expensive object is completely clipped
- * away before trying to draw it.
- *
- * @param drawable d the drawable whose current clipping we are
- * testing against.
- * @param Rectangle bounding_box the bounding box we are comparing that with.
- */
- public static boolean trivial_reject(drawable d, Rectangle bounding_box)
- {
- Rectangle clip = d.getClipRect();
- return !clip.intersects(bounding_box);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Do a trivial reject test that indicates whether the bounds of this object
- * are entirely outside the clipping region of the given drawable object.
- * The drawable object is assumed to be configured for our parent's
- * coordinate system. Returns true if nothing inside our bounds will
- * survive the clip and hence need not be drawn. This test is used in
- * draw_self() to avoid drawing anything for the object if none of it
- * could show up anyway.
- *
- * @see #draw_self
- * @param drawable d the drawable whose current clipping we are
- * testing against.
- * @param Rectangle bounding_box the bounding box we are comparing that with.
- */
- public boolean trivial_reject(drawable d)
- {
- return trivial_reject(d, bound());
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Draw the object's current appearance. The drawable object passed in
- * is still set up in the parent's coordinate system. This routine normally
- * sets up the transformation for the local coordinate system, then calls
- * draw_self_local(). Consequently, most interactors do not override this
- * routine, but instead override draw_self_local().
- *
- * @see #draw_self_local
- * @param drawable parent_d a drawable (still set up for the parent) to
- * produce output on.
- */
- public void draw_self(drawable parent_d)
- {
- drawable local_d;
-
- /* only draw if we are visible and trivial reject test indicates it
- * might actually appear */
- if (visible() && !trivial_reject(parent_d))
- {
- /* save the graphics state and do the translation into local coords */
- local_d = enter_local_coordinates(parent_d);
-
- /* do the actual drawing */
- draw_self_local(local_d);
-
- /* restore the graphics state and undo the translation */
- exit_local_coords(parent_d, local_d);
- }
-
- /* damage is now fixed */
- damage_fixed();
- }
-
- //has:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Draw the object's current appearance (along with that of its children).
- * The drawable object passed in will be set up for the local coordinate
- * system. Most interactors override this routine to provide a custom
- * appearance, but this routine is not called directly to produce output
- * (that is done with draw_self()).<p>
- *
- * Normal drawing order with respect to children is to draw the this object
- * (the parent) first, then draw the children (so they appear on top).
- * Drawing children (in normal low to high index order) can be done by the
- * draw_children() utility routine. Note that if normal drawing order is
- * overridden changes also must be made to the picking routines (pick()
- * and pick_within_children()) as well.
- *
- * @see #draw_self
- * @see #draw_children
- * @see #pick
- * @see #pick_within_children
- * @param drawable d a drawable object (set up for this object) to produce
- * output on.
- */
- protected void draw_self_local(drawable d)
- {
- /* in base class we draw nothing (for ourselves) */
-
- /* draw any children we have */
- draw_children(d);
- }
-
- //has:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Helper routine to draw the children of this interactor in normal (low to
- * high index) drawing order. This simply calls draw_self() for each child
- * in order. Note that if normal drawing order is overridden changes also
- * must be made to the picking routines (pick() and pick_within_children())
- * as well.
- *
- * @see #draw_self
- * @see #draw_self_local
- * @see #pick
- * @see #pick_within_children
- * @param drawable d a drawable object (set up for this object) to produce
- * output on.
- */
- protected void draw_children(drawable d)
- {
- interactor chld;
-
- /* walk down the children and draw them all in order. */
- for (int i=0; i<num_children(); i++)
- {
- chld = child(i);
- if (chld != null) chld.draw_self(d);
- }
- }
-
- //has:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate that any previous damage to the object's appearance has been
- * fixed (by redrawing it). This is normally called automatically by
- * draw_self and need not be called elsewhere.
- */
- protected void damage_fixed()
- {
- clear_flag_bit(DAMAGED);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate that the object has been modified in such as way that its
- * appearance within the given area of the screen (expressed in local
- * coordinates) might change and needs to be redrawn. This does not
- * update any attributes controlling size and position of this object
- * or any other object up the parent chain, but instead uses existing
- * values (reflecting the existing sizes and positions). If you need to
- * damage this object's updated position, explicitly update it first.
- *
- * @param Point top_left top left corner of the damaged rectangle.
- * @param Dimension sz size of the damaged rectangle.
- */
- public void damage_self(Point top_left, Dimension sz)
- {
- Point parent_tl;
- interactor p;
-
- /* mark us as damaged */
- set_flag_bit(DAMAGED);
-
- /* convert to parent's coords and tell them about it */
- p = parent();
- if (p != null)
- {
- /* put into coords of parent and pass damage up */
- top_left.x = top_left.x + _x;
- top_left.y = top_left.y + _y;
- p.damage_from_child(top_left,sz);
- }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate that the object has been modified in such as way that its
- * appearance within the given area of the screen (expressed in local
- * coordinates) might change and needs to be redrawn. This does not
- * update any attributes controlling size and position of this object
- * or any other object up the parent chain, but instead uses existing
- * values (reflecting the existing sizes and positions). If you need to
- * damage this object's updated position, explicitly update it first.
- *
- * @param int left left edge of the damaged rectangle.
- * @param int top top edge of the damaged rectangle.
- * @param int wid width of the damaged rectangle.
- * @param int hi height of the damaged rectangle.
- */
- public void damage_self(int left, int top, int wid, int hi)
- {
- Point parent_tl;
- interactor p;
-
- /* mark us as damaged */
- set_flag_bit(DAMAGED);
-
- /* convert to parent's coords and tell them about it */
- p = parent();
- if (p != null)
- {
- /* put into coords of parent and pass damage up */
- left = left + _x;
- top = top + _y;
- p.damage_from_child(new Point(left,top), new Dimension(wid,hi));
- }
- }
-
- //has:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate that the object has been modified in such as way that any or
- * all of its appearance may change and its area of the screen needs
- * to be redrawn.
- */
- public void damage_self()
- {
- damage_self(new Point(0,0),new Dimension(_w,_h));
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate that a change to a child (or grandchild, etc.) affects the
- * given screen region (expressed in the coordinates of this object).
- * This is responsible for passing damage up the tree.
- *
- * @param Point top_left top left corner of the damaged rectangle.
- * @param Dimension sz size of the damaged rectangle.
- */
- public void damage_from_child(Point top_left, Dimension sz)
- {
- /* just pass on the damage */
- damage_self(top_left, sz);
- }
-
- //had:
- //* @exception general
-
- /*---------------------------------------------------------------------*/
- /* Feature points */
- /*---------------------------------------------------------------------*/
-
- /**
- * The number of "feature points" of an object. Feature points are points
- * within an object which are interesting for alignment, snapping or
- * other purposes. They are used by the move_drag and snap_drag agents.<p>
- *
- * Feature points are expressed in the local coordinates of the object in
- * question. Objects by default provide 5 points corresponding to their
- * corners and center. Constants representing indexes for these standard
- * points are defined in interactor_consts. Additional points with
- * specialized meanings may be provided by subclasses.
- *
- * @see sub_arctic.input.move_drag_focus_agent
- * @see sub_arctic.input.move_draggable
- * @see sub_arctic.input.move_drag_filter
- * @see sub_arctic.input.std_drag_filters
- * @see sub_arctic.input.snap_drag_agent
- * @see sub_arctic.input.snap_draggable
- * @see sub_arctic.input.snap_targetable
- * @see sub_arctic.lib.interactor_consts
- *
- * @return int the number of feature points this object has.
- */
- public int num_feature_points() { return 5; }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Access to the "feature points" of an object (by index). Feature points
- * are points within an object which are interesting for alignment,
- * snapping or other purposes. They are used by the move_drag and
- * snap_drag agents. <p>
- *
- * Feature points are expressed in the local coordinates of the object in
- * question. Objects by default provide 5 points corresponding to their
- * corners and center. Constants representing indexes for these standard
- * points are defined in interactor_consts. Additional points with
- * specialized meanings may be provided by subclasses. If an index out of
- * range is given the top-left corner (index FEATURE_TOP_LEFT which is
- * always 0,0) is returned.
- *
- * @see sub_arctic.input.move_drag_focus_agent
- * @see sub_arctic.input.move_draggable
- * @see sub_arctic.input.move_drag_filter
- * @see sub_arctic.input.std_drag_filters
- * @see sub_arctic.input.snap_drag_agent
- * @see sub_arctic.input.snap_draggable
- * @see sub_arctic.input.snap_targetable
- * @see sub_arctic.lib.interactor_consts
- *
- * @param int indx the index of the requested feature point.
- * @return Point the location of the requested feature point in local
- * coordinates.
- */
- public Point feature_point(int indx)
- {
- switch(indx)
- {
- default:
- case FEATURE_TOP_LEFT:
- return new Point(0,0);
-
- case FEATURE_TOP_RIGHT:
- return new Point(w()-1,0);
-
- case FEATURE_BOTTOM_LEFT:
- return new Point(0,h()-1);
-
- case FEATURE_BOTTOM_RIGHT:
- return new Point(w()-1,h()-1);
-
- case FEATURE_CENTER:
- return new Point(w()/2,h()/2);
- }
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate whether the indicated "feature point" of an object is
- * considered to be enabled. Feature points are points within an object
- * which are interesting for alignment, snapping or other purposes. They are
- * used by the move_drag and snap_drag agents. <p>
- *
- * Feature points are expressed in the local coordinates of the object in
- * question. Objects by default provide 5 points corresponding to their
- * corners and center. Constants representing indexes for these standard
- * points are defined in interactor_consts. Additional points with
- * specialized meanings may be provided by subclasses. <p>
- *
- * By default all standard feature points are always enabled. If an index
- * out of range is given false will always be returned.
- *
- * @see sub_arctic.input.move_drag_focus_agent
- * @see sub_arctic.input.move_draggable
- * @see sub_arctic.input.move_drag_filter
- * @see sub_arctic.input.std_drag_filters
- * @see sub_arctic.input.snap_drag_agent
- * @see sub_arctic.input.snap_draggable
- * @see sub_arctic.input.snap_targetable
- * @see sub_arctic.lib.interactor_consts
- *
- * @param int indx the index of the feature point in question.
- * @return boolean indicating whether it is enabled.
- */
- public boolean feature_point_enabled(int indx)
- {
- return (indx >= 0) && (indx < FIRST_FREE_FEATURE);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Indicate the current "feature point" of an object. This point will be
- * used by the move_drag agent to control dragging. Feature points are
- * points within an object which are interesting for alignment, snapping
- * or other purposes. The current feature point is used by the move_drag
- * agent. See that agent for complete details.
- *
- * Feature points are expressed in the local coordinates of the object in
- * question. Objects by default provide 5 points corresponding to their
- * corners and center. Constants representing indexes for these standard
- * points are defined in interactor_consts. Additional points with
- * specialized meanings may be provided by subclasses. <p>
- *
- * Note: this routine and the ones that use it ignore the enable status
- * of the point as returned by feature_point_enabled(). This routine
- * defaults to the top left corner of the object.
- *
- * @see sub_arctic.input.move_drag_focus_agent
- * @see sub_arctic.input.move_draggable
- * @see sub_arctic.input.move_drag_filter
- * @see sub_arctic.input.std_drag_filters
- * @see sub_arctic.lib.interactor_consts
- *
- * @return the index of the current feature point.
- */
- public int drag_feature_point()
- {
- /* defaults to top-left */
- return FEATURE_TOP_LEFT;
- }
-
- /*---------------------------------------------------------------------*/
- /* Support for common input protocols */
- /*---------------------------------------------------------------------*/
-
- /**
- * Default action for entering a focus set. Several of the focus agents
- * handle focus entry in custom ways (and do not call this routine) and
- * many objects don't need to do anything special when they enter the focus
- * set since they requested the focus themselves. So we provide a default
- * here for ignoring the dispatch. This is only relevant for objects
- * implementing the focusable interface (or one of the other input dispatch
- * protocol interfaces derived from it), but its easy enough to do here and
- * saves a bit of coding in subclasses.
- *
- * @see sub_arctic.input.focusable
- * @see sub_arctic.input.focus_dispatch_agent
- *
- * @param event cause_evt the event that caused the focus.
- * @param focus_dispatch_agent of_agent the agent doing the focus.
- * @param Object user_info uninterpreted information that was
- * given to the agent when the focus
- * was requested.
- */
- public void focus_set_enter(
- event cause_evt,
- focus_dispatch_agent of_agent,
- Object user_info)
- {
- /* ignore this by default */
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Default action for exiting a focus set. Several of the focus agents
- * handle focus entry in custom ways (and do not call this routine) and
- * many objects don't need to do anything special when they enter the focus
- * set since they requested the focus themselves. So we provide a default
- * here for ignoring the dispatch. This is only relevant for objects
- * implementing the focusable interface (or one of the other input dispatch
- * protocol interfaces derived from it), but its easy enough to do here and
- * saves a bit of coding in subclasses.
- *
- * @see sub_arctic.input.focusable
- * @see sub_arctic.input.focus_dispatch_agent
- *
- * @param event cause_evt the event that caused the focus.
- * @param focus_dispatch_agent of_agent the agent doing the focus.
- * @param Object user_info uninterpreted information that was
- * given to the agent when the focus
- * was requested.
- */
- public void focus_set_exit(
- event cause_evt,
- focus_dispatch_agent of_agent,
- Object user_info)
- {
- /* ignore this by default */
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Default point filter. Point filters are used by the move_drag agent
- * to limit the area of a drag or transform the path of a drag. Here we
- * use the identity filter, so it imposes no limit or translation.
- * A collection of useful filters that can be called from subclass
- * specializations of this method can be found in std_drag_filters.
- *
- * @see sub_arctic.input.move_drag_filter
- * @see sub_arctic.input.move_drag_focus_agent
- * @see sub_arctic.input.move_draggable
- * @see sub_arctic.input.std_drag_filters
- * @see sub_arctic.lib.interactor_consts
- *
- * @param original_pt the point to be filtered (in parent's coords).
- * @param drag_obj the object being dragged.
- * @param feature_pt the feature point within the object being dragged
- * that is being filtered (in object's coords).
- * @return the location of the filtered point
- */
- public Point filter_pt(Point original_pt, interactor obj, Point feature_pt)
- {
- return original_pt;
- }
-
- /*---------------------------------------------------------------------*/
- /* User Info */
- /*---------------------------------------------------------------------*/
-
- /**
- * Access to uninterpreted "user information" that we are holding for the
- * user of this object. This information is for use of the user or
- * application only and is typically used to associated application specific
- * information with a particular interactor object. This information can be
- * entered using set_user_info(). It is not modified by the toolkit, and
- * can later be retrieved with this routine as needed.
- *
- * @see #set_user_info
- * @returns Object the user info object attached to this interactor.
- */
- public Object user_info() {return _user_info;}
-
- /**
- * Set the uninterpreted "user information" that we are holding for the
- * user of this object. This information is for use of the user or
- * application only and is typically used to associated application specific
- * information with a particular interactor object. This information can be
- * entered using this routine. It is not modified by the toolkit, and can
- * later be retrieved with user_info() as needed.
- *
- * @see #user_info
- * @param Object user_inf the object to associate with this interactor.
- */
- public void set_user_info(Object user_inf) {_user_info = user_inf;}
-
- /*---------------------------------------------------------------------*/
- /* Debugging */
- /*---------------------------------------------------------------------*/
-
- /**
- * Convert a flag set into a human readable string.
- * @return String displaying the values of the flag set.
- */
- public String flag_string()
- {
- StringBuffer result = new StringBuffer();
-
- if (constraint_flag_is_set(IS_VISIBLE)) result.append("IS_VISIBLE ");
- if (constraint_flag_is_set(IS_ENABLED)) result.append("IS_ENABLED ");
- if (constraint_flag_is_set(SUPPORTS_CHILDREN))
- result.append("SUPPORTS_CHILDREN ");
- if (flag_is_set(FIXED_CHILDREN)) result.append("FIXED_CHILDREN ");
- if (flag_is_set(DAMAGED)) result.append("DAMAGED ");
-
- return result.toString();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- /**
- * Convert a constraint flag set into a human readable string.
- * @return String displaying the values of the flag set.
- */
- public String constraint_flag_string()
- {
- StringBuffer result = new StringBuffer();
-
- if (constraint_flag_is_set(X_OOD)) result.append("X_OOD ");
- if (constraint_flag_is_set(Y_OOD)) result.append("Y_OOD ");
- if (constraint_flag_is_set(W_OOD)) result.append("W_OOD ");
- if (constraint_flag_is_set(H_OOD)) result.append("H_OOD ");
- if (constraint_flag_is_set(VISIBLE_OOD)) result.append("VISIBLE_OOD ");
- if (constraint_flag_is_set(ENABLED_OOD)) result.append("ENABLED_OOD ");
- if (constraint_flag_is_set(PART_A_OOD)) result.append("PART_A_OOD ");
- if (constraint_flag_is_set(PART_B_OOD)) result.append("PART_B_OOD ");
- if (constraint_flag_is_set(X_IN_PROCESS)) result.append("X_IN_PROCESS ");
- if (constraint_flag_is_set(Y_IN_PROCESS)) result.append("Y_IN_PROCESS ");
- if (constraint_flag_is_set(W_IN_PROCESS)) result.append("W_IN_PROCESS ");
- if (constraint_flag_is_set(H_IN_PROCESS)) result.append("H_IN_PROCESS ");
- if (constraint_flag_is_set(VISIBLE_IN_PROCESS))
- result.append("VISIBLE_IN_PROCESS ");
- if (constraint_flag_is_set(ENABLED_IN_PROCESS))
- result.append("ENABLED_IN_PROCESS ");
- if (constraint_flag_is_set(PART_A_IN_PROCESS))
- result.append("PART_A_IN_PROCESS ");
- if (constraint_flag_is_set(PART_B_IN_PROCESS))
- result.append("PART_B_IN_PROCESS ");
- if (constraint_flag_is_set(X_HAS_EXT_NOTIFY))
- result.append("X_HAS_EXT_NOTIFY ");
- if (constraint_flag_is_set(Y_HAS_EXT_NOTIFY))
- result.append("Y_HAS_EXT_NOTIFY ");
- if (constraint_flag_is_set(W_HAS_EXT_NOTIFY))
- result.append("W_HAS_EXT_NOTIFY ");
- if (constraint_flag_is_set(H_HAS_EXT_NOTIFY))
- result.append("H_HAS_EXT_NOTIFY ");
- if (constraint_flag_is_set(VISIBLE_HAS_EXT_NOTIFY))
- result.append("VISIBLE_HAS_EXT_NOTIFY ");
- if (constraint_flag_is_set(ENABLED_HAS_EXT_NOTIFY))
- result.append("ENABLED_HAS_EXT_NOTIFY ");
- if (constraint_flag_is_set(PART_A_HAS_EXT_NOTIFY))
- result.append("PART_A_HAS_EXT_NOTIFY ");
- if (constraint_flag_is_set(PART_B_HAS_EXT_NOTIFY))
- result.append("PART_B_HAS_EXT_NOTIFY ");
-
- if (flag_is_set(VISIBLE_IS_HORIZONTAL))
- result.append("VISIBLE_IS_HORIZONTAL ");
- if (flag_is_set(ENABLED_IS_HORIZONTAL))
- result.append("ENABLED_IS_HORIZONTAL ");
- if (flag_is_set(PART_A_IS_HORIZONTAL))
- result.append("PART_A_IS_HORIZONTAL ");
- if (flag_is_set(PART_B_IS_HORIZONTAL))
- result.append("PART_B_IS_HORIZONTAL ");
-
- return result.toString();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Convert to a human readable string.
- * @return String a human readable dump of the object.
- */
- public String toString()
- {
- StringBuffer result = new StringBuffer();
-
- /* Do a minimal dump */
- result.append(getClass().getName());
- result.append(":[x="); result.append(x());
- result.append(", y="); result.append(y());
- result.append(", w="); result.append(w());
- result.append(", h="); result.append(h());
- result.append(", flags={");
- result.append(flag_string());
- result.append(constraint_flag_string());
- result.append("}]");
-
- return result.toString();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Convert to a small tag string which indicates the type of interactor
- * along with a (hopefully unique) integer (its hashCode) that can
- * be used to identify it during debugging.
- * @return String an terse identifying tag string for the object.
- */
- public String tag_str()
- {
- return getClass().getName() + ":" + hashCode();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- }
- /*=========================== 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/
-
- ========================================================================*/
-