sub_arctic.lib
Class oneline_text_display

java.lang.Object
  |
  +--sub_arctic.lib.min_interactor
        |
        +--sub_arctic.lib.base_interactor
              |
              +--sub_arctic.lib.oneline_text_display
Direct Known Subclasses:
label, oneline_text_edit

public class oneline_text_display
extends base_interactor

Single line text displayer. This class displays a single line of text with selection point or area in a fashion suitable for a text edit interactor. Selection positions in strings refer to the spaces before the characters (numbered from 0). So for example a selection from 0 to 0 places the cursor before the first character (the character at index 0) while a selection from 1 to 2 selects the second character (the character at index 1).


Field Summary
protected  color_pair _colors
          The color pair currently being used to display the text and background of the object.
protected  int _end_of_selection
          End of current selection.
protected  java.awt.Font _font
          Font that interactor displays in
protected  int _h_spacing
          Horizontal spacing
protected  java.awt.FontMetrics _metric
          Cached font metrics object for the current font
protected  int _start_of_selection
          Start of current selection.
protected  java.lang.String _text
          String currently being displayed.
protected  int _v_spacing
          Vertical spacing around the text (both top and bottom have this space)
protected  int _x_adjust
          Adjustment factor to keep the current selection (or part of it) inside the bounds of the object.
static int BOXED
          Constant used to store boxed flag within interactor flags
protected  boolean have_focus
           
static int NO_SELECTION
          Constant for a special selection position used to denote that there is no selection.
static int SELECT_END
          Constant used to denote that the selection as at the end of the text.
 
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
oneline_text_display(int xv, int yv, int wv, java.lang.String init_str, java.awt.Font fnt, boolean boxed)
          Full constructor with explicit width
oneline_text_display(int xv, int yv, java.lang.String init_str)
          Constructor with default font and boxed status but explicit position
oneline_text_display(int xv, int yv, java.lang.String init_str, java.awt.Font fnt, boolean boxed)
          Full constructor where width is determined by initial string
oneline_text_display(java.lang.String init_str)
          Constructor with all the defaults and a size which we assume you are going to control either control explicitly or via constraints.
 
Method Summary
 boolean boxed()
          Does the interactor have a box drawn around it
 color_pair colors()
          This function retreives the currently color_pair being used for displaying this objects foreground and background colors.
protected  void draw_self_local(drawable d)
          Draw the display.
 int end_of_selection()
          End of current selection.
 void ensure_inside(int pos)
          Compute the adjustment needed to make sure the given selection position (a character position, not a pixel position) is inside the object's display.
 java.awt.Font font()
          Font that interactor displays in...
 int h_spacing()
          This retrieves the horizontal spacing of this interactor.
 int intrinsic_constraints()
          Declare that our height is intrinsically constrained
 void set_boxed(boolean bxv)
          Set the flag indicating whether interactor is drawn with a surrounding box.
 void set_colors(color_pair p)
          You can call this function to set a pair of colors that are used to display the text background and the text of this object.
 void set_font(java.awt.Font fnt)
          Set font that interactor displays in
 void set_h_spacing(int n)
          Set the horizontal spacing of this interactor.
 void set_selection(int start_loc, int end_loc)
          Set the current selection.
 void set_text(java.lang.String txt)
          Set string displayed.
 void set_v_spacing(int n)
          Set the vertical spacing of this interactor.
 int start_of_selection()
          Start of current selection.
 java.lang.String text()
          String currently being displayed.
 int v_spacing()
          This retrieves the vertical spacing of this interactor.
 int x_adjust()
          Adjustment factor to keep the current selection (or part of it) inside the bounds of the object.
 
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, 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, pick, 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

have_focus

protected boolean have_focus

_v_spacing

protected int _v_spacing
Vertical spacing around the text (both top and bottom have this space)

_h_spacing

protected int _h_spacing
Horizontal spacing

_metric

protected java.awt.FontMetrics _metric
Cached font metrics object for the current font

_font

protected java.awt.Font _font
Font that interactor displays in

_colors

protected color_pair _colors
The color pair currently being used to display the text and background of the object.

_text

protected java.lang.String _text
String currently being displayed.

_x_adjust

protected int _x_adjust
Adjustment factor to keep the current selection (or part of it) inside the bounds of the object. This is set by ensure_inside().

NO_SELECTION

public static final int NO_SELECTION
Constant for a special selection position used to denote that there is no selection.

SELECT_END

public static final int SELECT_END
Constant used to denote that the selection as at the end of the text.

_start_of_selection

protected int _start_of_selection
Start of current selection. The special value NO_SELECTION denotes the fact that there is no current selection. Note: selection positions denote the space before the character at the given ordinal position. Consequently, 0 denotes the position before the beginning of the string, and text().length() denotes the position after the last character.

_end_of_selection

protected int _end_of_selection
End of current selection. The special value NO_SELECTION denotes the fact that there is no current selection. Note: selection positions denote the space before the character at the given ordinal position. Consequently, 0 denotes the position before the beginning of the string, and text().length() denotes the position after the last character.

BOXED

public static final int BOXED
Constant used to store boxed flag within interactor flags
Constructor Detail

oneline_text_display

public oneline_text_display(int xv,
                            int yv,
                            int wv,
                            java.lang.String init_str,
                            java.awt.Font fnt,
                            boolean boxed)
Full constructor with explicit width
Parameters:
int - xv the x coordinate of this object
int - yv the y coordinate of this object
int - wv the width of this object
String - init_str the initial string to display
Font - fnt the font to use
boolean - boxed true if you want a box around the object

oneline_text_display

public oneline_text_display(int xv,
                            int yv,
                            java.lang.String init_str,
                            java.awt.Font fnt,
                            boolean boxed)
Full constructor where width is determined by initial string
Parameters:
int - xv the x coordinate of this object
int - yv the y coordinate of this object
String - init_str the initial string to display
Font - fnt the font to use
boolean - boxed true if you want a box around the object

oneline_text_display

public oneline_text_display(int xv,
                            int yv,
                            java.lang.String init_str)
Constructor with default font and boxed status but explicit position
Parameters:
int - xv the x coordinate value of this object
int - yv the y coordinate value of this object
String - init_str the initial string to display

oneline_text_display

public oneline_text_display(java.lang.String init_str)
Constructor with all the defaults and a size which we assume you are going to control either control explicitly or via constraints.
Parameters:
the - initial string to display
Method Detail

v_spacing

public int v_spacing()
This retrieves the vertical spacing of this interactor.
Returns:
int the amount of space on the right and left of this interactor

set_v_spacing

public void set_v_spacing(int n)
Set the vertical spacing of this interactor.
Parameters:
int - n new amount of vertical space.

h_spacing

public int h_spacing()
This retrieves the horizontal spacing of this interactor.
Returns:
int the amount of space on the right and left of this interactor

set_h_spacing

public void set_h_spacing(int n)
Set the horizontal spacing of this interactor.
Parameters:
int - n new amount of horizontal space.

font

public java.awt.Font font()
Font that interactor displays in... if you don't set the font, you'll get the system's default font.
Returns:
Font the font this object is using

set_font

public void set_font(java.awt.Font fnt)
Set font that interactor displays in
Parameters:
Font - fnt the new font (use null for the system default font)

colors

public color_pair colors()
This function retreives the currently color_pair being used for displaying this objects foreground and background colors.
Returns:
color_pair the color pair currently in use (foreground color is the color of the text)

set_colors

public void set_colors(color_pair p)
You can call this function to set a pair of colors that are used to display the text background and the text of this object. The foreground color of the color_pair is the color of the text. If you set the color pair in use to null, the system will use the default system colors.
Parameters:
color_pair - p the new color pair to use for this interactor (null means to use the system defualt colors)

text

public java.lang.String text()
String currently being displayed.
Returns:
String the string that is being displayed

set_text

public void set_text(java.lang.String txt)
Set string displayed.
Parameters:
String - text the new string

x_adjust

public int x_adjust()
Adjustment factor to keep the current selection (or part of it) inside the bounds of the object. This is set by ensure_inside().

ensure_inside

public void ensure_inside(int pos)
Compute the adjustment needed to make sure the given selection position (a character position, not a pixel position) is inside the object's display. This routine gets called automatically when a single position selection is established. For a range selection, it must be called "manually" to indicate which end of the selection should be inside.

Parameters:
int - pos selection position that should be inside the display.

start_of_selection

public int start_of_selection()
Start of current selection. The special value NO_SELECTION denotes the fact that there is no current selection. Note: selection positions denote the space before the character at the given ordinal position. Consequently, 0 denotes the position before the beginning of the string, and text().length() denotes the position after the last character.
Returns:
the start of the selection or a special constant

end_of_selection

public int end_of_selection()
End of current selection. The special value NO_SELECTION denotes the fact that there is no current selection. Note: selection positions denote the space before the character at the given ordinal position. Consequently, 0 denotes the position before the beginning of the string, and text().length() denotes the position after the last character.
Returns:
the end of the selection or a special constant

set_selection

public void set_selection(int start_loc,
                          int end_loc)
Set the current selection. The special value NO_SELECTION is used to denote the fact that there is no current selection. If this value is applied to either the start or end of the selection, both values will be set to NO_SELECTION. The special value SELECT_END denotes a the position after the last character of the string (which will be computed and stored). Note: selection positions denote the space before the character at the given ordinal position. Consequently, 0 denotes the beginning of the string, and text().length() denotes the position after the last character.
Parameters:
int - start_loc the starting location of the selection
int - end_loc the ending location of the selection

boxed

public boolean boxed()
Does the interactor have a box drawn around it
Returns:
boolean true if the object does have a box around it

set_boxed

public void set_boxed(boolean bxv)
Set the flag indicating whether interactor is drawn with a surrounding box.
Parameters:
boolean - bxv true if you want a box around this object, false otherwise

intrinsic_constraints

public int intrinsic_constraints()
Declare that our height is intrinsically constrained
Returns:
int the constant H so everyone knows we have intrinsic height.
Overrides:
intrinsic_constraints in class base_interactor

draw_self_local

protected void draw_self_local(drawable d)
Draw the display.
Parameters:
drawable - d the surface to draw this object on
Overrides:
draw_self_local in class base_interactor