home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / TEST / SEM_LENS.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  4.6 KB  |  140 lines

  1. /*
  2.  * $Id: sem_lens_test.java,v 1.16 1996/10/03 19:46:51 hudson Exp $
  3.  * $Author: hudson $
  4.  */
  5.  
  6. package sub_arctic.test;
  7.  
  8. import sub_arctic.lib.*;
  9. import sub_arctic.input.*;
  10. import sub_arctic.output.drawable;
  11. import sub_arctic.constraints.std_function;
  12.  
  13. import java.awt.Font; // almost didn't need any AWT!
  14.  
  15. public class sem_lens_test extends interactor_applet implements callback_object{
  16.   public static final int angle_default=25;
  17.   public static final int length_default=20;
  18.   public static final String msg_length="Arrow Head Length: ";
  19.   public static final String msg_angle="Arrow Head Angle: ";
  20.   /* where we know how many arrowheads we need */
  21.   int arrowheads;
  22.   /* do something clever when we get a click */
  23.   public void callback(interactor from_obj, 
  24.                event      evt,
  25.                int        callback_num, 
  26.                Object     callback_info) {
  27.     int i;
  28.     line_display l;
  29.     /* is it a toggle?  */
  30.     if (from_obj instanceof toggle) {
  31.       lp.set_arrow_heads(((Integer)from_obj.user_info()).intValue());
  32.     } else {
  33.       /* its a slider */
  34.       /* loop over all children */
  35.       angle_label.set_text(msg_angle + angle_scale.value());
  36.       length_label.set_text(msg_length + length_scale.value());
  37.       for (i=0; i<lp.num_children();++i) {
  38.     l=(line_display)lp.child(i);
  39.     l.set_arrow_head_length(length_scale.value());
  40.     l.set_arrow_head_angle(angle_scale.value());
  41.       }
  42.     }
  43.       
  44.   }
  45.   /* this is where we hold the line_parent */
  46.   line_parent lp;
  47.   /* angle slider */
  48.   scale angle_scale;
  49.   scale length_scale;
  50.   label angle_label;
  51.   label length_label;
  52.   static String[] arrowhead_labels= {"No Arrow Heads", "One Arrow Head",
  53.                      "Two Arrow Heads"};
  54.   /*
  55.    * Set things up ... 
  56.    */
  57.   public void build_ui(base_parent_interactor top) {
  58.     base_parent_interactor group;
  59.     semantic_lens_parent slp;
  60.     text_toggle_collection s1;
  61.     column c;
  62.  
  63.     /* initialize arrow heads */
  64.     arrowheads=1;
  65.     /* width and height are bogus */
  66.     c=new column(0,0,10,10,10,3,true,true,true,column.CENTER_JUSTIFIED,
  67.          null);
  68.  
  69.     group = new base_parent_interactor(0,0, size().width, size().height);
  70.     slp = new semantic_lens_parent(0,0, size().width, size().height);
  71.     slp.set_w_constraint(std_function.offset(PARENT.W(),0));
  72.     slp.set_h_constraint(std_function.offset(PARENT.H(),0));
  73.     slp.add_child(group);
  74.     top.add_child(slp);
  75.  
  76.     s1=new text_toggle_collection(arrowhead_labels,true,150,this);
  77.     /* put the toggle for 1 arrow head on */
  78.     s1.nth_toggle(1).set_cur_state(1);
  79.     /* now build a slider and a label for angle*/
  80.     angle_label=new label(msg_angle + angle_default,
  81.               new Font("Helvetica",Font.BOLD, 16));
  82.     angle_scale=new scale(0,0,200,1,89,angle_default,10,this);
  83.     /* now build a slider and a label for length*/
  84.     length_label=new label(msg_length+ length_default,
  85.                new Font("Helvetica",Font.BOLD, 16));
  86.     length_scale=new scale(0,0,200,1,100,length_default,10,this);
  87.       
  88.       /* put all these interactors in the column */
  89.     c.add_child(s1);
  90.     c.add_child(angle_label);
  91.     c.add_child(angle_scale);
  92.     c.add_child(length_label);
  93.     c.add_child(length_scale);
  94.     /* make it fill */
  95.     c.set_h_constraint(std_function.offset(PARENT.Y2(),0));
  96.     group.add_child(c);
  97.     /* put the line parent in */
  98.     lp=new line_parent();
  99.     group.add_child(lp);
  100.     /* now build the constraints for lp... abut against the column */
  101.     lp.set_x_constraint(std_function.offset(PREV_SIBLING.X2(), 0));
  102.     lp.set_y_constraint(std_function.offset(PREV_SIBLING.Y(), 0));
  103.     /* initialize lp to be right */
  104.     lp.set_arrow_head_length(angle_default);
  105.     lp.set_arrow_head_angle(length_default);
  106.     /* width and height fill */
  107.     lp.set_w_constraint(std_function.fill(PREV_SIBLING.X2(),NEXT_SIBLING.X(),0));
  108.     lp.set_h_constraint(std_function.offset(PARENT.Y2(),0));
  109.  
  110.     /******** the only actual new test here (the rest is background) ******/
  111.     slp.add_child(new semantic_lens(100,20, 200,200, new nametag_sem_draw(), 
  112.                     false, "Interactor-Scope", null, null, nametag_sem_draw.id));
  113.  
  114.   }
  115. }
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124. /*=========================== COPYRIGHT NOTICE ===========================
  125.  
  126. This file is part of the subArctic user interface toolkit.
  127.  
  128. Copyright (c) 1996 Scott Hudson and Ian Smith
  129. All rights reserved.
  130.  
  131. The subArctic system is freely available for most uses under the terms
  132. and conditions described in 
  133.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  134. and appearing in full in the lib/interactor.java source file.
  135.  
  136. The current release and additional information about this software can be 
  137. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  138.  
  139. ========================================================================*/
  140.