summaryrefslogtreecommitdiff
path: root/tags/host/0.8.1/src/org/reprap/machines/MachineFactory.java
blob: eef3eb81eb740356d12d1c3d37b34a16d0701ad1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package org.reprap.machines;

import org.reprap.Preferences;
import org.reprap.Printer;
import org.reprap.ReprapException;

/**
 * Returns an appropriate Printer object based on the current properties
 */
public class MachineFactory {

	/**
	 * 
	 */
	private MachineFactory() {
	}
	
	/**
	 * Currently this just always assumes we're building
	 * a 3-axis cartesian printer.  It should build an
	 * appropriate type based on the local configuration.
	 * @return new machine
	 * @throws Exception
	 */
	static public Printer create() throws Exception {
		
		
		Preferences prefs = Preferences.getGlobalPreferences();

		String geometry = prefs.loadString("Geometry");
		
		if (geometry.compareToIgnoreCase("cartesian") == 0)
		  	return new Reprap(prefs);
		else if (geometry.compareToIgnoreCase("nullcartesian") == 0)
		    return new NullCartesianMachine(prefs);		
		else
			throw new ReprapException("Invalid geometry in properties file");
		
	}
	
}