View Javadoc
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 * Title: Câmera Virtual - LIVES 24 * Description: Câmera Virtual para Controle via LabVIEW 25 * Copyright: Copyright (c) 2001 26 * Company: Centro de Educação em Informática - SENAC - SP 27 */ 28 29 import camera3d.VcObject; 30 import camera3d.TransformMode; 31 32 /*** 33 * Action for changing the scale of one VcObject. 34 * 35 * @author Fábio Roberto de Miranda 36 * @version 1.0 37 */ 38 public class ScalingAction extends TransformAction { 39 private static final double MINIMUM_SCALE = 0.01; 40 private static final double MAXIMUM_SCALE = 100; 41 42 /*** 43 * Creates scaling action given VcObject to act upon and transformation type. 44 * @param v VcObject affected by action. 45 * @param mode can be either absolute or relative. 46 */ 47 public ScalingAction(VcObject v, TransformMode mode){ 48 super(v, mode); 49 } 50 51 52 /*** 53 * Sets new scale values in all three axis. 54 */ 55 public void setScalingValues(double x, double y, double z){ 56 this.x = x; 57 if(x > MAXIMUM_SCALE) this.x = MAXIMUM_SCALE; 58 if(x < MINIMUM_SCALE) this.x = MINIMUM_SCALE; 59 this.y = y; 60 if(y > MAXIMUM_SCALE) this.y = MAXIMUM_SCALE; 61 if(y < MINIMUM_SCALE) this.y = MINIMUM_SCALE; 62 this.z = z; 63 if(z > MAXIMUM_SCALE) this.z = MAXIMUM_SCALE; 64 if(z < MINIMUM_SCALE) this.z = MINIMUM_SCALE; 65 //debugln("__scaling: X=="+this.x +" Y== "+this.y+" Z== "+this.z ); 66 } 67 68 public void doAction(ActionExecutor executor){ 69 //debugln("Interpreting scaling action"); 70 VcObject vcObj = getVcObject(); 71 72 if(getTransformMode()==TransformMode.ABSOLUTE) { 73 //debugln("__scaling2: X=="+this.x +" Y== "+this.y+" Z== "+this.z ); 74 vcObj.setAbsoluteScale(this.x, this.y, this.z); 75 } 76 else if(getTransformMode()==TransformMode.RELATIVE){ 77 //debugln("__scaling2: X=="+this.x +" Y== "+this.y+" Z== "+this.z ); 78 vcObj.setRelativeScale(this.x, this.y, this.z); 79 } 80 } 81 /*** 82 * Tries to combine the effect of this action and of inputAction into one single 83 * ScalingAction. When optimization is performed only this action should be executed, 84 * and not the inputAction. 85 * return true if optimization was performed, false otherwise. 86 */ 87 public boolean optimize(VcAction inputAction){ 88 if(!canOptimize(inputAction)) return false; 89 else{ 90 TransformAction transformAction = (TransformAction) inputAction; 91 if(transformAction.getTransformMode()==TransformMode.ABSOLUTE){ 92 x = transformAction.x; 93 y = transformAction.y; 94 z = transformAction.z; 95 setTransformMode(TransformMode.ABSOLUTE); 96 }else{ 97 x = x * transformAction.x; 98 y = y * transformAction.y; 99 z = z * transformAction.z; 100 } 101 return true; 102 } 103 } 104 105 }

This page was automatically generated by Maven