| Home >> All >> feynman >> framework >> [ system Javadoc ] |
Source code: feynman/framework/system/CartesianObjectFactory.java
1 /* 2 * $Header: /cvsroot/feynman/src/feynman/framework/system/CartesianObjectFactory.java,v 1.1.1.1 2002/11/12 02:25:43 wesley_bailey Exp $ 3 * $Revision: 1.1.1.1 $ 4 * $Date: 2002/11/12 02:25:43 $ 5 * $Copyright: Copyright (C) 2002 Path Integral Software $ 6 */ 7 package feynman.framework.system; 8 9 import feynman.framework.simulation.Simulation; 10 11 /** 12 * Factory class that implements <b>PhysicalObjectFactory</b>. Use 13 * this class to create object that are used in the study of Cartesian 14 * Coordinate Systems. To do this first indicate in the 15 * <em>Simulation.properties</em> the usage of the Factory and a corresponding 16 * <em>PhysicalObject</em> in the following manner: 17 * <p/> 18 * <pre> 19 * # Use the cartesian coordinate system. 20 * PhysicalObjectFactoryClass=feynman.framework.CartesianObjectFactory 21 * 22 * # User defined class of the PhysicalObject to use in the PhysicalSystem 23 * PhysicalObjectClass=CartesianParticle 24 * </pre> 25 * 26 * @author Wes Bailey 27 * @version $Revision: 1.1.1.1 $ $Date: 2002/11/12 02:25:43 $ 28 */ 29 public class CartesianObjectFactory implements PhysicalObjectFactory { 30 31 // Create an instance of the class. 32 private static final CartesianObjectFactory INSTANCE = new CartesianObjectFactory(); 33 34 // Implement a singleton. 35 private CartesianObjectFactory() { 36 // singleton 37 } 38 39 /** 40 * Use this method to retrieve an instance of the Factory. 41 * <br> 42 * <b>Note: </b> This method is used internally and should never be 43 * used for a user specific implementation. 44 */ 45 public static final CartesianObjectFactory getInstance() { 46 return INSTANCE; 47 } 48 49 /** 50 * Factory method for generating <b>PhysicalObject</b>s in the Cartesian 51 * Coordinate System. 52 */ 53 public PhysicalObject create(Simulation sim) throws PhysicalObjectFactoryException { 54 55 try { 56 // Get an instance of the user specified PhysicalObject. 57 Class clazz = Class.forName(sim.getPhysicalObjectClass()); 58 PhysicalObject po = (PhysicalObject) clazz.newInstance(); 59 60 // Ensure the user has specified a CartesianObject. 61 if (po instanceof CartesianObject) { 62 return po; 63 } else { 64 throw new PhysicalObjectFactoryException(clazz.getName() + "is not a CartesianObject"); 65 } 66 } 67 catch (ClassNotFoundException e) { 68 throw new PhysicalObjectFactoryException(e.toString()); 69 } 70 catch (InstantiationException e) { 71 throw new PhysicalObjectFactoryException(e.toString()); 72 } 73 catch (IllegalAccessException e) { 74 throw new PhysicalObjectFactoryException(e.toString()); 75 } 76 77 } 78 79 }