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
23
24
25 import camera3d.VcObject;
26 import camera3d.TransformMode;
27
28 /***
29 * Abstract superclass to all actions that affect a VcObject's transform.
30 *
31 * @author Fábio Roberto de Miranda
32 * @version 1.0
33 */
34 public abstract class TransformAction extends VcObjectChangeAction implements OptimizableAction {
35
36 double x;
37 double y;
38 double z;
39
40
41 TransformMode mode;
42 VcObject vcObject;
43
44 public TransformAction(VcObject v, TransformMode mode) {
45 this.vcObject = v;
46 this.mode = mode;
47 }
48
49 public TransformAction() {
50 }
51
52 /***
53 * Returns a flag indicating whether this action and inputAction can be merged into
54 * one single action with equivalent effects. That happens when the two actions have
55 * the same class and affect the same object.
56 * @return true if the actions can be optimized, false otherwise.
57 */
58 public boolean canOptimize(VcAction inputAction){
59 if(!getClass().equals(inputAction.getClass())) return false;
60 TransformAction transformAction = (TransformAction) inputAction;
61 if(!(transformAction.getVcObject()==this.vcObject)) return false;
62 return true;
63 }
64
65 public abstract boolean optimize(VcAction action);
66
67
68 public void setVcObject(VcObject v){
69 this.vcObject = v;
70 }
71
72 public VcObject getVcObject(){
73 return this.vcObject;
74 }
75
76 public void setTransformMode(TransformMode mode){
77 this.mode = mode;
78 }
79
80 public TransformMode getTransformMode(){
81 return this.mode;
82 }
83
84 }
This page was automatically generated by Maven