home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime for java / imagecompositing / src / profileswcontroller.java < prev   
Encoding:
Java Source  |  2000-06-23  |  1.2 KB  |  44 lines

  1. /*
  2.  * QuickTime for Java SDK Sample Code
  3.  
  4.    Usage subject to restrictions in SDK License Agreement
  5.  * Copyright: © 1996-1999 Apple Computer, Inc.
  6.  
  7.  */
  8. import quicktime.app.actions.*;
  9. import quicktime.app.anim.*;
  10. import quicktime.qd.*;
  11. import quicktime.*;
  12.  
  13. import java.awt.event.*;
  14. // we use this to profile the dragging around of Sprites
  15.  
  16. // this is particular useful if the rate of the compositor is zero
  17. // and the only rendering work that a compositor does is
  18. // in response to user interaction - in this case mouseDragging
  19.  
  20. public class ProfileSWController extends SWController {
  21.     public ProfileSWController (MouseResponder mr, boolean wholespace) throws QTException {
  22.         super (mr, wholespace);
  23.     }
  24.     
  25.     
  26.     int profileCount = 0;
  27.     long startTime, stopTime;
  28.     boolean isProfiling;
  29.  
  30.     public void mouseDragged (MouseEvent e) {
  31.         isProfiling = profileCount++ % 20 == 0;
  32.         if (isProfiling)
  33.             startTime = System.currentTimeMillis();    
  34.         
  35.         super.mouseDragged (e);
  36.         
  37.         if (isProfiling) {
  38.             stopTime = System.currentTimeMillis();
  39.             if (((SWCompositor)getSpace()).getTimer().getRate() == 0)
  40.                 System.out.println ("mouseDragged:" + (stopTime - startTime) + " msecs");
  41.         }
  42.     }
  43. }
  44.