1   /*****************************************************************************
2    *                   Virtual Mockup for Machine Vision
3    *  Copyright (C) 2001-2003 Fabio R. de Miranda, Joćo E. Kogler Jr., 
4    *                         Carlos S. Santos.
5    *   Virtual Mockup for Machine Vision Project funded by SENAC-SP
6    *
7    * Permission is granted to redistribute and/or modify this
8    * software 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 software 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 (http://www.gnu.org/copyleft/lesser.html)
16   * for more details.
17   *
18   *****************************************************************************/
19  
20  package camera3d.action;
21  
22  import camera3d.Viewport;
23  import camera3d.VcView;
24  
25  /*
26   * This class changes the camera associated with a given viewport.
27   * It can be used in one of two ways: By supplying references to desired viewport and
28   * views to change or by their names.
29   */
30  public class ViewChangeAction extends GUIAction {
31  
32      String viewportName;
33      String viewName;
34      Viewport viewport = null;
35      VcView view = null;
36      VcView oldView = null;
37  
38      public ViewChangeAction(String viewportName, String viewName) {
39          this.viewportName = viewportName;
40          this.viewName = viewName;
41      }
42  
43      public ViewChangeAction(Viewport viewport, VcView view){
44          this.viewport = viewport;
45          this.view = view;
46      }
47  
48      public void doAction(ActionExecutor executor){
49          debugln("ViewChangeAction: doAction called");
50          Viewport viewport = getViewport();
51          VcView view = getVcView();
52          if ((view!=null)&&(viewport!=null)){
53              oldView = viewport.getView();
54              viewport.setView(view);
55          }
56      }
57  
58      public void undoAction(ActionExecutor executor){
59          Viewport viewport = getViewport();
60          if ((oldView!=null)&&(viewport!=null)){
61              viewport.setView(oldView);
62          }
63      }
64  
65      public String getViewName(){
66          return this.viewName;
67      }
68  
69      public String getViewportName(){
70          return this.viewportName;
71      }
72  
73      public Viewport getViewport(){
74          return this.viewport;
75      }
76  
77      public VcView getVcView(){
78          return this.view;
79      }
80  }
This page was automatically generated by Maven