src/authoring/entities/data/EntityLoader.java
public Entity buildEntity(int ID, String entityName, double x, double y) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, ClassNotFoundException {
		Element root = getRootElement(new File(DATA_PREFIX + entityName + XML_EXTENSION));
		String type = extractTypeFromRoot(root);
		Entity entity = (Entity) Class.forName(ENTITY_PREFIX + type).getDeclaredConstructors()[0].newInstance(ID, type);
		NodeList nList = root.getChildNodes();
		List<Component> compsToAdd = new ArrayList<>();
		ComponentBuilder cb = new ComponentBuilder();
		for (int i = 0; i < nList.getLength(); i++) {
			Element e = (Element) nList.item(i);
			compsToAdd.add(cb.build(ID, e));
		}
		// ALWAYS have to add X and Y positions
		compsToAdd.add(new XPosition(ID,x));
		compsToAdd.add(new YPosition(ID,y));
		entity.addAll(compsToAdd);
		return entity;
	}
/**
	 * Get and build an entity that is represented by a given XML File.
	 * @param entityName the name of the entity to pull the xml file for
	 * @param ID the ID of the entity to create
	 * @param type the type of entity to instantiate
	 * @return an Entity object represented by the xml file
	 * @throws ClassNotFoundException 
	 * @throws SecurityException 
	 * @throws InvocationTargetException 
	 * @throws IllegalArgumentException 
	 * @throws IllegalAccessException 
	 * @throws InstantiationException 
	 */
Get and build an entity that is represented by a given XML File.
Get and build an entity that is represented by a given XML File .
public Entity buildEntity(int ID, String entityName, double x, double y) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, ClassNotFoundException {
		Element root = getRootElement(new File(DATA_PREFIX + entityName + XML_EXTENSION));
		String type = extractTypeFromRoot(root);
		Entity entity = (Entity) Class.forName(ENTITY_PREFIX + type).getDeclaredConstructors()[0].newInstance(ID, type);
		NodeList nList = root.getChildNodes();
		List<Component> compsToAdd = new ArrayList<>();
		ComponentBuilder cb = new ComponentBuilder();
		for (int i = 0; i < nList.getLength(); i++) {
			Element e = (Element) nList.item(i);
			compsToAdd.add(cb.build(ID, e));
		}
		compsToAdd.add(new XPosition(ID,x));
		compsToAdd.add(new YPosition(ID,y));
		entity.addAll(compsToAdd);
		return entity;
	}
public Entity buildEntity ( int ID , String entityName , double x , double y ) throws InstantiationException , IllegalAccessException , IllegalArgumentException , InvocationTargetException , SecurityException , ClassNotFoundException { Element root = getRootElement ( new File ( DATA_PREFIX + entityName + XML_EXTENSION ) ) ; String type = extractTypeFromRoot ( root ) ; Entity entity = ( Entity ) Class . forName ( ENTITY_PREFIX + type ) . getDeclaredConstructors ( ) [ 0 ] . newInstance ( ID , type ) ; NodeList nList = root . getChildNodes ( ) ; List < Component > compsToAdd = new ArrayList < > ( ) ; ComponentBuilder cb = new ComponentBuilder ( ) ; for ( int i = 0 ; i < nList . getLength ( ) ; i ++ ) { Element e = ( Element ) nList . item ( i ) ; compsToAdd . add ( cb . build ( ID , e ) ) ; } compsToAdd . add ( new XPosition ( ID , x ) ) ; compsToAdd . add ( new YPosition ( ID , y ) ) ; entity . addAll ( compsToAdd ) ; return entity ; }
Get and build an entity that is represented by a given XML File.
Get and build an entity that is represented by a given XML File .
// ALWAYS have to add X and Y positions