Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/xerox/VTM/engine/CameraManager.java


1   /*   FILE: CameraManager.java
2    *   DATE OF CREATION:   Jul 11 2000
3    *   AUTHOR :            Emmanuel Pietriga (emmanuel.pietriga@xrce.xerox.com)
4    *   MODIF:              Tue Aug 05 09:53:41 2003 by Emmanuel Pietriga (emmanuel@w3.org, emmanuel@claribole.net)
5    *   Copyright (c) Xerox Corporation, XRCE/Contextual Computing, 2002. All Rights Reserved
6    *
7    * This library is free software; you can redistribute it and/or
8    * modify it under the terms of the GNU Lesser General Public
9    * License as published by the Free Software Foundation; either
10   * version 2.1 of the License, or (at your option) any later version.
11   * 
12   * This library is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15   * Lesser General Public License for more details.
16   *
17   * For full terms see the file COPYING.
18   */
19  
20  package com.xerox.VTM.engine;
21  
22  import com.xerox.VTM.engine.*;
23  import java.util.Vector;
24  
25    /**
26     * The Camera Manager is in charge of all cameras of a virtual space (there is one camera manager per virtual space)
27     * when a camera is destroyed, its index is not reused for another one - so if camera number #3 is removed and then a new camera is added it will be assigned number #4 even though there is no camera at index #3 any longer
28     * @author Emmanuel Pietriga
29     **/
30  
31  class CameraManager {
32  
33      /**owning virtual space*/
34      VirtualSpace parentSpace;
35  
36      /**next camera will have index ... in this virtual space - a camera can only belong to one virtual space*/
37      private int nextcIndex=0;
38  
39      /**list of cameras in this virtual space*/
40      Camera[] cameraList;
41  
42      public CameraManager(VirtualSpace vs){
43    parentSpace=vs;
44    cameraList=new Camera[0];
45    nextcIndex=0;
46      }
47      
48      /**return i-th camera in this virtual space*/
49      Camera getCamera(int i) {
50    if (i<cameraList.length){return cameraList[i];}
51    else return null;
52      }
53  
54      /** add a camera to the owning virtual space*/
55      Camera addCamera(){
56    Camera c=new Camera(0,0,100,100,nextcIndex++);
57    Camera[] newList=new Camera[nextcIndex];
58    System.arraycopy(cameraList,0,newList,0,cameraList.length);
59    newList[cameraList.length]=c;
60    cameraList=newList;
61    return c;
62      }
63      
64      /** remove a camera from owning virtual space
65       *@param i index of camera in virtual space
66       */
67      void removeCamera(int i){
68    cameraList[i]=null;
69      }
70  
71  }