home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.test;
- import sub_arctic.lib.*;
- import sub_arctic.output.*;
- import sub_arctic.input.*;
- import sub_arctic.anim.*;
-
- import java.net.URL;
- import java.net.MalformedURLException;
-
- /**
- * We have actually made the whole applet the animatable object, but
- * you can make individual interactors animatable as well..
- */
- public class permanent_test extends interactor_applet {
- /**
- * Hold the images
- */
- loaded_image boom[];
- /**
- * Sequence size is number of images.
- */
- int sequence_size;
- /**
- * Where is the sequence?
- */
- String sequence_name;
- /**
- * Current image number
- */
- int current_image=0;
- /**
- * Before the UI gets built load the images
- */
- public void pre_build_ui() {
- String name,sequence_size;
- int size;
- /**
- * Get parameters from the HTML file
- */
- sequence_name=getParameter("SEQUENCENAME");
- sequence_size=getParameter("SEQUENCESIZE");
- try {
- size=(new Integer(sequence_size)).intValue();
- } catch (NumberFormatException e) {
- size=0;
- }
- /* allocate space */
- boom=new loaded_image[size];
- try {
- /* loop over them */
- for (int i=0; i<size; ++i) {
- name=sequence_name + (i+1) + ".gif";
- System.out.println("loading image... " + name);
- boom[i]=manager.load_doc_image(this,name);
- }
- } catch (MalformedURLException e) {
- manager.handle_unexpected_exception(e);
- }
- }
- /**
- * This is the icon
- */
- animated_icon the_icon;
- /**
-
- * Construct the UI... just a single object.
- */
- public void build_ui(base_parent_interactor tl) {
- continuous_transition pt;
- /* start in 5 seconds */
- continuous_interval pi=new continuous_interval(time_interval.now()+5000);
- /* make the icon */
- the_icon=new animated_icon(boom);
- /* make the transition */
- pt=new continuous_transition(the_icon, pi, 100);
- manager.animation.schedule_transition(pt);
- /* put it in the parent */
- tl.add_child(the_icon);
- /* set the constraints on location */
- the_icon.set_x(tl.w()/2);
- the_icon.set_y(tl.h()/2);
- }
- }
-
- /**
- * This is an animated icon which can display an array of images.
- * We are expecting that you will use an a
- */
- class animated_icon extends icon implements animatable, move_press_draggable {
- /* images to display */
- loaded_image[] img;
- /* number in the sequence */
- int current=0;
- /* construct one */
- public animated_icon(loaded_image[] images) {
- super(images[0]);
- img=images;
- }
- /**
- * Go to the next image
- */
- public void next_image() {
- ++current;
- if (current==img.length) current=0;
- set_image(img[current]);
- }
- /* Don't bother doing anything here, we'll just do it all
- * in the step function
- */
- public void start_transition(transition trans, trajectory traj,
- double start_t, Object start_obj, event e,
- Object user_info) {}
-
- /**
- * We ignore all the parameters and just draw the next image
- */
- public void transition_step(transition trans, trajectory traj,
- double start_t, Object start_obj,
- double end_t, Object end_obj,
- event e, Object user_info) {
- /* update image */
- next_image();
- }
- /*
- * since we are using a permanent transition, this never
- * gets called
- */
- public void end_transition(transition trans, trajectory traj,
- double start_t, Object start_obj,
- double end_t, Object end_obj,
- event e, Object user_info) {
- }
- /* just place the object */
- public boolean drag_start(
- event evt,
- int x, int y,
- int grab_x, int grab_y,
- Object user_info) {
- set_x(x);
- set_y(y);
- return true;
- }
- /* just place it */
- public boolean drag_end(
- event evt,
- int x, int y,
- int start_x, int start_y,
- int grab_x, int grab_y,
- Object user_info) {
- set_x(x);
- set_y(y);
- return true;
- }
- /* just place it */
- public boolean drag_feedback(
- event evt,
- int x, int y,
- int start_x, int start_y,
- int grab_x, int grab_y,
- Object user_info) {
- set_x(x);
- set_y(y);
- return true;
- }
- }
- /*=========================== 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/
-
- ========================================================================*/
-