sub_arctic.test
Class circ_lens

java.lang.Object
  |
  +--sub_arctic.lib.min_interactor
        |
        +--sub_arctic.lib.base_interactor
              |
              +--sub_arctic.lib.base_parent_interactor
                    |
                    +--sub_arctic.test.circ_lens

public class circ_lens
extends base_parent_interactor
implements pressable, move_draggable

Class to implement dragging and drawing for a circular semantic lens. When this object is drawn, it does a traversal of the subtree rooted at the parent of this object. That traversal does an alternate rendering (semantic redraw) of the subtree within the bounds of this object. This redraw can be done on top of the normal draw (by setting clear_back false, which is the default), or the normal drawing can be cleared and replaced the alternate rendering. Alternate renderings are done via a "interactor_predicate" object that parameterizes this object and is passed to a traverse_and_collect() of the parent.

This object does a drawing trick to turn a fixed size square lens into a circular lens. Basically we draw the square lens a little smaller than our size, then draw a circular ring image over it such that the bound of the smaller square fits between the inner and outer diameters of the ring. This way we only see the lens inside the ring, and none of the lens is seen outside the ring.

This implementation uses a fixed image for the ring and hence has a fixed size. This should eventually be replaced by a programmatic construction of an arbitrary sized ring (although that probably wouldn't look as good as the prepared image). As with other lenses, for complete operation, this object should be placed under a semantic_lens_parent object (the object will work with other parents, but redraw anomalies for dynamically moving objects within the lens can occur).

See Also:
semantic_lens, semantic_lens_parent, sem_draw_context, sem_draw_continue, base_interactor#traverse_and_collect

Field Summary
protected  boolean _clear_back
          Indication of whether we clear our background first, or draw over the top of the objects that were drawn before us.
protected  interactor_pred _draw_obj
          The "predicate" object that does the specialized drawing for this lens.
protected static loaded_image _ring_image
           
protected  int _sem_draw_kind
          Identifier for the particular kind of semantic redraw pass being done here.
protected static int lens_size
          size of (square) drawing area
protected static int lens_top_left
          position of top and left of drawing area
protected static int ring_image_height
           
protected static int ring_image_width
           
protected static int sem_draw_trav_id
          unique identifier for sem_draw traversals
 
Fields inherited from class sub_arctic.lib.base_interactor
_child_index, _child_list, _clip_bounds, _constraint_flags, _enabled_constraint, _flags, _h, _h_constraint, _parent, _part_a_constraint, _part_b_constraint, _user_data, _visible_constraint, _w, _w_constraint, _x, _x_constraint, _y, _y_constraint, default_child_hint
 
Constructor Summary
circ_lens(interactor_pred draw_action, int draw_kind)
          Simplest constructor.
circ_lens(int xv, int yv, interactor_pred draw_action, boolean clr_back, int draw_kind)
          Full constructor.
 
Method Summary
 boolean clear_back()
          Indication of whether we clear our background first, or draw over the top of the objects that were drawn before us.
 boolean drag_end(event evt, int x_pos, int y_pos, int start_x, int start_y, int grab_x, int grab_y, java.lang.Object user_info)
          Handle input corresponding to the end of a move-drag.
 boolean drag_feedback(event evt, int x_pos, int y_pos, int start_x, int start_y, int grab_x, int grab_y, java.lang.Object user_info)
          Handle a movement during a move-drag.
 boolean drag_start(event evt, int xv, int yv, int gx, int gy, java.lang.Object user_info)
          Handle the start of a move-drag to the object.
 interactor_pred draw_obj()
          The "predicate" object that does the specialized drawing for this lens.
protected  void draw_self_local(drawable d)
          Override draw_self to do a semantic lens.
 void pick(int pt_x, int pt_y, pick_collector pick_list)
          Override pick to just grad ring.
 boolean press(event evt, java.lang.Object user_info)
          Handle mouse button press input to the object by making us the move-drag drag focus.
 boolean release(event evt, java.lang.Object user_info)
          Companion to press -- here we ignore the releases.
static loaded_image ring_image()
           
 int sem_draw_kind()
          Identifier for the particular kind of semantic redraw pass being done here.
 void set_clear_back(boolean v)
          Set whether we clear our background first, or draw over the top of the objects that were drawn before us.
 void set_draw_obj(interactor_pred dobj)
          Set the "predicate" object that does the specialized drawing for this lens.
 
Methods inherited from class sub_arctic.lib.base_interactor
active_constraints, add_child, add_user_datum, attach_dependent, bound, callback_obj, child_index, child, clear_child_list, clear_constraint_flag_bit, clear_flag_bit, configure, constraint_flag_is_set, constraint_flag_string, constraint_on, custom_fun1, custom_fun2, damage_fixed, damage_from_child, damage_self, damage_self, damage_self, damage_self, damage_self, detach_dependent, do_action, do_action, do_callback, do_callback, drag_feature_point, draw_children, draw_self, enabled_constraint, enabled, enter_local_coordinates, eval_enabled, eval_h, eval_part_a, eval_part_b, eval_visible, eval_w, eval_x, eval_y, eval, exit_local_coords, feature_point_enabled, feature_point, filter_pt, find_child, first_callback_num, fixed_children, flag_is_set, flag_string, focus_set_enter, focus_set_exit, get_awt_component, get_external_constraint, get_part, get_top_level, get_value, global_to_local, global_to_local, h_constraint, h, handle_cycle, inform_ood, insert_child, inside_bounds, into_local, into_local, into_parent, into_parent, intrinsic_constraints, is_constrained, last_callback_num, local_to_global, local_to_global, mark_all_ood, mark_enabled_ood, mark_h_ood, mark_ood, mark_part_a_ood, mark_part_b_ood, mark_reparented_ood, mark_visible_ood, mark_w_ood, mark_x_ood, mark_y_ood, marked_ood, move_child_downward, move_child_downward, move_child_to_bottom, move_child_to_bottom, move_child_to_top, move_child_to_top, move_child_upward, move_child_upward, move_downward, move_to_bottom, move_to_top, move_upward, new_look_configure, next_sibling, num_actions, num_children, num_feature_points, ood_inform_all, parent, part_a_constraint, part_a, part_b_constraint, part_b, pick_within_children, picked_by, pos, prev_sibling, register_resource_names, remove_child, remove_child, remove_user_datum, restyle_look_resources, restyle, set_callback_obj, set_child_index, set_child, set_constraint_flag_bit, set_constraint_flag_bit, set_constraint, set_constraint, set_enabled_constraint, set_enabled_constraint, set_enabled_constraint, set_enabled, set_flag_bit, set_flag_bit, set_h_constraint, set_h_constraint, set_h_constraint, set_h, set_intrinsic_h, set_intrinsic_size, set_intrinsic_w, set_parent, set_part_a_constraint, set_part_a_constraint, set_part_a_constraint, set_part_a, set_part_b_constraint, set_part_b_constraint, set_part_b_constraint, set_part_b, set_pos, set_pos, set_raw_enabled, set_raw_h, set_raw_part_a, set_raw_part_b, set_raw_visible, set_raw_w, set_raw_x, set_raw_y, set_size, set_style_lock, set_user_info, set_visible_constraint, set_visible_constraint, set_visible_constraint, set_visible, set_w_constraint, set_w_constraint, set_w_constraint, set_w, set_x_constraint, set_x_constraint, set_x_constraint, set_x, set_y_constraint, set_y_constraint, set_y_constraint, set_y, setup_for_children, setup_for_children, setup_for_fixed_children, size, style_change_local, style_change, supports_children, tag_str, toString, traverse_and_collect_children, traverse_and_collect_parent, traverse_and_collect, trivial_reject, trivial_reject, user_data, user_info, value_ood, visible_constraint, visible, w_constraint, w, x_constraint, x_into_local, x_into_parent, x, y_constraint, y_into_local, y_into_parent, y
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sem_draw_trav_id

protected static final int sem_draw_trav_id
unique identifier for sem_draw traversals

_clear_back

protected boolean _clear_back
Indication of whether we clear our background first, or draw over the top of the objects that were drawn before us.

_draw_obj

protected interactor_pred _draw_obj
The "predicate" object that does the specialized drawing for this lens. This object must be expecting a sem_draw_context object for a parameter, and should normally return false in all cases.
See Also:
sem_draw_context

_sem_draw_kind

protected int _sem_draw_kind
Identifier for the particular kind of semantic redraw pass being done here.

lens_top_left

protected static final int lens_top_left
position of top and left of drawing area

lens_size

protected static final int lens_size
size of (square) drawing area

ring_image_width

protected static int ring_image_width

ring_image_height

protected static int ring_image_height

_ring_image

protected static loaded_image _ring_image
Constructor Detail

circ_lens

public circ_lens(int xv,
                 int yv,
                 interactor_pred draw_action,
                 boolean clr_back,
                 int draw_kind)
Full constructor.
Parameters:
int - x x position of the lens
int - y y position of the lens
interactor_pred - draw_action a "predicate" object which does the specialized drawing of an object for this lens
boolean - clr_back do we clear the background before we draw
int - draw_kind identifier that indicates the kind of semantic redraw that we are doing

circ_lens

public circ_lens(interactor_pred draw_action,
                 int draw_kind)
Simplest constructor. Defaults to 0,0 with non-cleared background.
Parameters:
interactor_pred - draw_action a "predicate" object which does the specialized drawing of an object for this lens
int - draw_kind identifier that indicates the kind of semantic redraw that we are doing
Method Detail

clear_back

public boolean clear_back()
Indication of whether we clear our background first, or draw over the top of the objects that were drawn before us.
Returns:
boolean indicating whether we clear our background.

set_clear_back

public void set_clear_back(boolean v)
Set whether we clear our background first, or draw over the top of the objects that were drawn before us.
Parameters:
boolean - v indicating whether we should clear our background.

draw_obj

public interactor_pred draw_obj()
The "predicate" object that does the specialized drawing for this lens. This object must be expecting a sem_draw_context object for a parameter, and should normally return false in all cases.
Returns:
interactor_pred the current predicate.
See Also:
sem_draw_context

set_draw_obj

public void set_draw_obj(interactor_pred dobj)
Set the "predicate" object that does the specialized drawing for this lens. This object must be expecting a sem_draw_context object for a parameter, and should normally return false in all cases.
Parameters:
interactor_pred - dobj the drawing "predicate" object.

sem_draw_kind

public int sem_draw_kind()
Identifier for the particular kind of semantic redraw pass being done here.
Returns:
int a unique identifier for this kind of redraw.

pick

public void pick(int pt_x,
                 int pt_y,
                 pick_collector pick_list)
Override pick to just grad ring.
Parameters:
int - pt_x x coordinate of picking point
int - pt_y y coordinate of picking point
pick_collector - pick_list result list
Overrides:
pick in class base_interactor

press

public boolean press(event evt,
                     java.lang.Object user_info)
Handle mouse button press input to the object by making us the move-drag drag focus.
Specified by:
press in interface pressable
Parameters:
event - evt the press event.
Object - user_info the information associated with this object at pick time.
Returns:
boolean indicating whether the event was consumed.

release

public boolean release(event evt,
                       java.lang.Object user_info)
Companion to press -- here we ignore the releases.
Specified by:
release in interface pressable
Parameters:
event - evt the release event.
Object - user_info information associated with this object at pick time.
Returns:
boolean indicating whether we consumed this input (here always false).

drag_start

public boolean drag_start(event evt,
                          int xv,
                          int yv,
                          int gx,
                          int gy,
                          java.lang.Object user_info)
Handle the start of a move-drag to the object.
Specified by:
drag_start in interface move_draggable
Parameters:
event - evt the event "causing" the drag.
int - xv the x location of the object at start of drag (in parent's coordinates).
int - yv the y location of the object at start of drag (in parent's coordinates).
int - gx initial grab location within the object.
int - gy initial grab location within the object.
Object - user_info the information associated with this object when it requested drag focus.
Returns:
boolean indicating whether the input was consumed.

drag_feedback

public boolean drag_feedback(event evt,
                             int x_pos,
                             int y_pos,
                             int start_x,
                             int start_y,
                             int grab_x,
                             int grab_y,
                             java.lang.Object user_info)
Handle a movement during a move-drag. Here we just set our position to follow the event location.
Specified by:
drag_feedback in interface move_draggable
Parameters:
event - evt the event "causing" the drag.
int - x_pos the x position this object should move to.
int - y_pos the y position this object should move to.
int - start_x the x location of the object at start of drag (in parent's coordinates).
int - start_x the y location of the object at start of drag (in parent's coordinates).
int - grab_x initial grab location within the object.
int - grab_y initial grab location within the object.
Object - user_info the information associated with this object when it requested drag focus.
Returns:
boolean indicating whether the input was consumed.

drag_end

public boolean drag_end(event evt,
                        int x_pos,
                        int y_pos,
                        int start_x,
                        int start_y,
                        int grab_x,
                        int grab_y,
                        java.lang.Object user_info)
Handle input corresponding to the end of a move-drag. In addition to normal dragging, we force the object back inside its parent if it is too far outside.
Specified by:
drag_end in interface move_draggable
Parameters:
event - evt the event "causing" the drag.
int - x_pos the x position this object should move to.
int - y_pos the y position this object should move to.
int - start_x the x location of the object at start of drag (in parent's coordinates).
int - start_x the y location of the object at start of drag (in parent's coordinates).
int - grab_x initial grab location within the object.
int - grab_y initial grab location within the object.
Object - user_info the information associated with this object when it requested drag focus.
Returns:
boolean indicating whether the input was consumed.

draw_self_local

protected void draw_self_local(drawable d)
Override draw_self to do a semantic lens. This works by going up one level to the parent, then doing a sem_draw traversal from there down. the sem_draw traversal draws a semantically modified rendition of the sub-tree on our drawable.

Note, this drawing is done inside our bounds, but the drawing corresponding to each individual object found in the traversal starting from our parent is not limited to their bounds. This requires special processing in damage_self within our parent.

For this lens we draw in an areas smaller than our bounds and then then cover the corners of the lens with a ring image sized such that the inner diameter of the ring is the same as the width of the smaller drawing areas, while the outer diameter of the ring is big enough to completely cover the corner. This gives the illusion of a circular lens even though we can't draw one directly.

Parameters:
drawable - d the drawing surface we draw on.
Overrides:
draw_self_local in class base_interactor
See Also:
semantic_draw_parent, sem_draw_context, sem_draw_continue, sem_draw_to_child, base_interactor#traverse_and_collect

ring_image

public static loaded_image ring_image()