Browse Source

Temporary file directory changed

Martin Herbers 6 years ago
parent
commit
a293c8a56c

+ 54 - 55
src/controller/Export.java

@@ -2,7 +2,6 @@ package controller;
 
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -55,13 +54,13 @@ public class Export {
 		//comFolder changes the directory to the .exe on Windows or the binary file in MacOs. Not needed in Linux
 		String comFolder = "cd " + pathComma + settings.getOpenSCADPath() + pathComma;
 		//Line for the full non-conductive object
-		String comLine =  start + "openscad "+ (System.getProperty("os.name").toLowerCase().contains("mac")?"-W -n --args ":"") +"-o " + pathComma + System.getProperty("user.dir") + File.separator + "output.stl"+ pathComma + " ";
+		String comLine =  start + "openscad "+ (System.getProperty("os.name").toLowerCase().contains("mac")?"-W -n --args ":"") +"-o " + pathComma + Main.olipPath + "output.stl"+ pathComma + " ";
 		//Line for all conductive parts
-		String comLine2 = start + "openscad "+ (System.getProperty("os.name").toLowerCase().contains("mac")?"-W -n --args ":"") +"-o " + pathComma + System.getProperty("user.dir") + File.separator + "output_conductive.stl" + pathComma + " ";
+		String comLine2 = start + "openscad "+ (System.getProperty("os.name").toLowerCase().contains("mac")?"-W -n --args ":"") +"-o " + pathComma + Main.olipPath + "output_conductive.stl" + pathComma + " ";
 		//Line for the non-conductive part for cross-section view
-		String comLine3 = start + "openscad "+ (System.getProperty("os.name").toLowerCase().contains("mac")?"-W -n --args ":"") +"-o " + pathComma + System.getProperty("user.dir") + File.separator + "output_crossSection.stl" + pathComma + " ";
+		String comLine3 = start + "openscad "+ (System.getProperty("os.name").toLowerCase().contains("mac")?"-W -n --args ":"") +"-o " + pathComma + Main.olipPath + "output_crossSection.stl" + pathComma + " ";
 		//Line for the conducive parts for cross-section view
-		String comLine4 = start + "openscad "+ (System.getProperty("os.name").toLowerCase().contains("mac")?"-W -n --args ":"") +"-o " + pathComma + System.getProperty("user.dir") + File.separator + "output_crossSection_conductive.stl" + pathComma + " ";
+		String comLine4 = start + "openscad "+ (System.getProperty("os.name").toLowerCase().contains("mac")?"-W -n --args ":"") +"-o " + pathComma + Main.olipPath + "output_crossSection_conductive.stl" + pathComma + " ";
 		//Instructions that will be added to the .txt file
 		List<String> instructions = null;
 		//Specification of the selected object, used for the android app to show the correct shape
@@ -71,7 +70,7 @@ public class Export {
 		
 		//If weight is selected...
 		if (settings.isWeight()) {
-			tempFile = new File("weight.scad");
+			tempFile = new File(Main.olipPath + "weight.scad");
 			//Copy the .scad file
 			try {
 				InputStream in = Export.class.getResourceAsStream("/OpenSCADFiles/weight.scad");
@@ -89,16 +88,16 @@ public class Export {
 			}
 			//Add the necessary variables to the command line arguments
 			int walls = Math.round(settings.getWeight()/27);
-			comLine += "-D numberSupports=" + walls + " -D conductive=false -D crossSection=false -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "weight.scad" + pathComma;
-			comLine2+= "-D numberSupports=" + walls + " -D conductive=true -D crossSection=false -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "weight.scad" + pathComma;
-			comLine3+= "-D numberSupports=" + walls + " -D conductive=false -D crossSection=true -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "weight.scad" + pathComma;
-			comLine4+= "-D numberSupports=" + walls + " -D conductive=true -D crossSection=true -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "weight.scad" + pathComma;
+			comLine += "-D numberSupports=" + walls + " -D conductive=false -D crossSection=false -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+			comLine2+= "-D numberSupports=" + walls + " -D conductive=true -D crossSection=false -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+			comLine3+= "-D numberSupports=" + walls + " -D conductive=false -D crossSection=true -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+			comLine4+= "-D numberSupports=" + walls + " -D conductive=true -D crossSection=true -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
 			instructions = Instructions.getWeightInstruction();
 			android = Specifications.getWeightSpecs();
 		}
 		
 		else if (settings.isAcceleration()) {
-				tempFile = new File("acceleration.scad");
+				tempFile = new File(Main.olipPath + "acceleration.scad");
 				try {
 					InputStream in = Export.class.getResourceAsStream("/OpenSCADFiles/acceleration.scad");
 					OutputStream out = new FileOutputStream(tempFile);
@@ -115,16 +114,16 @@ public class Export {
 				}
 				
 			double height = (settings.getAcceleration()<8?10:18);//TODO function from acceleration to wall height? linear? exponential? something else?
-			comLine += "-D wallHeight=" + height + " -D conductive=false -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "acceleration.scad" + pathComma;
-			comLine2+= "-D wallHeight=" + height + " -D conductive=true -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "acceleration.scad" + pathComma;
-			comLine3+= "-D wallHeight=" + height + " -D conductive=false -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "acceleration.scad" + pathComma;
-			comLine4+= "-D wallHeight=" + height + " -D conductive=true -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "acceleration.scad" + pathComma;
+			comLine += "-D wallHeight=" + height + " -D conductive=false -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+			comLine2+= "-D wallHeight=" + height + " -D conductive=true -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+			comLine3+= "-D wallHeight=" + height + " -D conductive=false -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+			comLine4+= "-D wallHeight=" + height + " -D conductive=true -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
 			instructions = Instructions.getAccelerationInstruction();
 			android = Specifications.getAccelerationSpecs();
 		}
 		
 		else if (settings.isSqueeze()) {
-				tempFile = new File("squeeze.scad");
+				tempFile = new File(Main.olipPath + "squeeze.scad");
 				try {
 					InputStream in = Export.class.getResourceAsStream("/OpenSCADFiles/squeeze.scad");
 					OutputStream out = new FileOutputStream(tempFile);
@@ -140,17 +139,17 @@ public class Export {
 					e.printStackTrace();
 				}
 				
-			comLine += "-D conductive=false -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "squeeze.scad" + pathComma;
-			comLine2+= "-D conductive=true -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "squeeze.scad" + pathComma;
-			comLine3+= "-D conductive=false -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "squeeze.scad" + pathComma;
-			comLine4+= "-D conductive=true -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "squeeze.scad" + pathComma;
+			comLine += "-D conductive=false -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+			comLine2+= "-D conductive=true -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+			comLine3+= "-D conductive=false -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+			comLine4+= "-D conductive=true -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
 			instructions = Instructions.getSqueezeInstruction();
 			android = Specifications.getSqueezeSpecs();
 		}
 		
 		else if (settings.isTemperature()) {
 			if (settings.getTemperature() == Temp.OVER0) {
-					tempFile = new File("iceMelting.scad");
+					tempFile = new File(Main.olipPath + "iceMelting.scad");
 					try {
 						InputStream in = Export.class.getResourceAsStream("/OpenSCADFiles/iceMelting.scad");
 						OutputStream out = new FileOutputStream(tempFile);
@@ -166,15 +165,15 @@ public class Export {
 						e.printStackTrace();
 					}
 				
-				comLine += "-D conductive=false -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "iceMelting.scad" + pathComma;
-				comLine2+= "-D conductive=true -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "iceMelting.scad" + pathComma; 
-				comLine3+= "-D conductive=false -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "iceMelting.scad" + pathComma; 
-				comLine4+= "-D conductive=true -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "iceMelting.scad" + pathComma;
+				comLine += "-D conductive=false -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+				comLine2+= "-D conductive=true -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+				comLine3+= "-D conductive=false -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+				comLine4+= "-D conductive=true -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
 				instructions = Instructions.getTemperatureMeltInstruction();
 				android = Specifications.getTemperatureMeltSpecs();
 			}
 			else {
-					tempFile = new File("iceFreezing.scad");
+					tempFile = new File(Main.olipPath + "iceFreezing.scad");
 					try {
 						InputStream in = Export.class.getResourceAsStream("/OpenSCADFiles/iceFreezing.scad");
 						OutputStream out = new FileOutputStream(tempFile);
@@ -190,10 +189,10 @@ public class Export {
 						e.printStackTrace();
 					}
 					
-				comLine += "-D conductive=false -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "iceFreezing.scad" + pathComma;  
-				comLine2+= "-D conductive=true -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "iceFreezing.scad" + pathComma;  
-				comLine3+= "-D conductive=false -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "iceFreezing.scad" + pathComma;   
-				comLine4+= "-D conductive=true -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "iceFreezing.scad" + pathComma;  
+				comLine += "-D conductive=false -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+				comLine2+= "-D conductive=true -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+				comLine3+= "-D conductive=false -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+				comLine4+= "-D conductive=true -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
 				instructions = Instructions.getTemperatureFreezeInstruction();
 				android = Specifications.getTemperatureFreezeSpecs();
 			}
@@ -201,7 +200,7 @@ public class Export {
 		
 		else if (settings.isTilt()) {
 			if (settings.getTilting().equals(Tilt.FLIP)) {
-					tempFile = new File("flip.scad");
+					tempFile = new File(Main.olipPath + "flip.scad");
 					try {
 						InputStream in = Export.class.getResourceAsStream("/OpenSCADFiles/flip.scad");
 						OutputStream out = new FileOutputStream(tempFile);
@@ -217,16 +216,16 @@ public class Export {
 						e.printStackTrace();
 					}
 					
-				comLine += "-D conductive=false -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "flip.scad" + pathComma;   
-				comLine2+= "-D conductive=true -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "flip.scad" + pathComma;  
-				comLine3+= "-D conductive=false -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "flip.scad" + pathComma;   
-				comLine4+= "-D conductive=true -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "flip.scad" + pathComma; 
+				comLine += "-D conductive=false -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+				comLine2+= "-D conductive=true -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+				comLine3+= "-D conductive=false -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+				comLine4+= "-D conductive=true -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
 				instructions = Instructions.getFlipInstruction();
 				android = Specifications.getFlipSpecs();
 			}
 			
 			else {
-					tempFile = new File("tilt.scad");
+					tempFile = new File(Main.olipPath + "tilt.scad");
 					try {
 						InputStream in = Export.class.getResourceAsStream("/OpenSCADFiles/tilt.scad");
 						OutputStream out = new FileOutputStream(tempFile);
@@ -242,10 +241,10 @@ public class Export {
 						e.printStackTrace();
 					}
 					
-				comLine += "-D conductive=false -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "tilt.scad" + pathComma;   
-				comLine2+= "-D conductive=true -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "tilt.scad" + pathComma;    
-				comLine3+= "-D conductive=false -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "tilt.scad" + pathComma; 
-				comLine4+= "-D conductive=true -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + System.getProperty("user.dir") + File.separator + "tilt.scad" + pathComma;  
+				comLine += "-D conductive=false -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+				comLine2+= "-D conductive=true -D crossSection=false -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+				comLine3+= "-D conductive=false -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
+				comLine4+= "-D conductive=true -D crossSection=true -D fillLater="+ settings.getFill() +" -D sizeScreen=" + settings.getSizeScreen() + " -D sizeFinger=" + settings.getSizeFinger() + " " + pathComma + tempFile.toString() + pathComma;
 				instructions = Instructions.getTiltInstruction();
 				android = Specifications.getTiltSpecs();
 			}
@@ -280,7 +279,7 @@ public class Export {
 		arguments[2] = (System.getProperty("os.name").contains("Linux")?"":comFolder) + 
 				(System.getProperty("os.name").contains("Linux")?comLine.substring(3):comLine) +
 				comLine2 + comLine4 + comLine3;
-		
+
 		//Run the command line
 		try {
 			Process p = Runtime.getRuntime().exec(arguments);
@@ -294,34 +293,34 @@ public class Export {
 		} catch (IOException e1) {
 			e1.printStackTrace();
 		}
-    
+
 		//Create the instructions .txt file
-	    Path file = Paths.get("instructions.txt");
+	    Path file = Paths.get(Main.olipPath + "instructions.txt");
 	    try {
 			Files.write(file, instructions, Charset.forName("UTF-8"));
 		} catch (IOException e) {
 			e.printStackTrace();
 		}
 	    //Create the objectSpecs.txt file
-	    Path output = Paths.get("objectSpecs.txt");
+	    Path output = Paths.get(Main.olipPath + "objectSpecs.txt");
 	    try {
 			Files.write(output, android, Charset.forName("UTF-8"));
 		} catch (IOException e) {
 			e.printStackTrace();
 		}
-	    
+
 	    //Delete all created files after closing the programm. If you want permanent files, either use the "save object" button or copy the files before closing the programm.
-	    File f1 = new File(System.getProperty("user.dir") + File.separator + "output.stl");
+	    File f1 = new File(Main.olipPath + "output.stl");
 		f1.deleteOnExit();
-		File f2 = new File(System.getProperty("user.dir") + File.separator + "output_conductive.stl");
+		File f2 = new File(Main.olipPath + "output_conductive.stl");
 		f2.deleteOnExit();
-		File f3 = new File(System.getProperty("user.dir") + File.separator + "output_crossSection.stl");
+		File f3 = new File(Main.olipPath + "output_crossSection.stl");
 		f3.deleteOnExit();
-		File f4 = new File(System.getProperty("user.dir") + File.separator + "output_crossSection_conductive.stl");
+		File f4 = new File(Main.olipPath + "output_crossSection_conductive.stl");
 		f4.deleteOnExit();
-		File f5 = new File(System.getProperty("user.dir") + File.separator + "instructions.txt");
+		File f5 = new File(Main.olipPath + "instructions.txt");
 		f5.deleteOnExit();
-		File f6 = new File(System.getProperty("user.dir") + File.separator + "objectSpecs.txt");
+		File f6 = new File(Main.olipPath + "objectSpecs.txt");
 		f6.deleteOnExit();
 		
 		//Delete the OpenSCAD file
@@ -334,16 +333,16 @@ public class Export {
 	 */
 	public static void saveFilesTo(File folder) {
 		try {
-			File output = new File(new java.io.File( "." ).getCanonicalPath() + File.separator + "output.stl");
+			File output = new File(Main.olipPath + "output.stl");
 			Files.copy(output.toPath(), new File(folder.getAbsolutePath() + File.separator + "output.stl").toPath(), StandardCopyOption.REPLACE_EXISTING);
 			
-			File outputCond = new File(new java.io.File( "." ).getCanonicalPath() + File.separator + "output_conductive.stl");
+			File outputCond = new File(Main.olipPath + "output_conductive.stl");
 			Files.copy(outputCond.toPath(), new File(folder.getAbsolutePath() + File.separator + "output_conductive.stl").toPath(), StandardCopyOption.REPLACE_EXISTING);
 			
-			File instructions = new File(new java.io.File( "." ).getCanonicalPath() + File.separator + "instructions.txt");
+			File instructions = new File(Main.olipPath + "instructions.txt");
 			Files.copy(instructions.toPath(), new File(folder.getAbsolutePath() + File.separator + "instructions.txt").toPath(), StandardCopyOption.REPLACE_EXISTING);
 			
-			File android = new File(new java.io.File( "." ).getCanonicalPath() + File.separator + "objectSpecs.txt");
+			File android = new File(Main.olipPath + "objectSpecs.txt");
 			Files.copy(android.toPath(), new File(folder.getAbsolutePath() + File.separator + "objectSpecs.txt").toPath(), StandardCopyOption.REPLACE_EXISTING);
 	
 		} catch (IOException e) {

+ 4 - 2
src/controller/SettingsController.java

@@ -7,6 +7,7 @@ import java.nio.file.Files;
 import java.util.List;
 
 import model.Settings;
+import ui.Main;
 
 /**
  * Save and Load functions for the settings.ini
@@ -22,7 +23,8 @@ public class SettingsController {
 	 */
 	public static void saveSettings() {
 		try {
-			File file = new File(new java.io.File( "." ).getCanonicalPath() + File.separator + "settings.ini");
+			File file = new File(Main.olipPath + "settings.ini");
+			new File(Main.olipPath).mkdirs();
 			PrintWriter writer = new PrintWriter(file);
 			writer.print("[Settings]\r\n");
 			writer.print("Fill=" + settings.getFill() + "\r\n");
@@ -40,7 +42,7 @@ public class SettingsController {
 	 */
 	public static void loadSettings() {
 		try {
-			File file = new File(new java.io.File( "." ).getCanonicalPath() + File.separator + "settings.ini");
+			File file = new File(Main.olipPath + "settings.ini");
 			if (file.exists()) {
 				List<String> lines = Files.readAllLines(file.toPath());
 				settings.setFill(Boolean.parseBoolean(lines.get(1).substring(lines.get(1).indexOf('=')+1)));

+ 13 - 20
src/model/Specifications.java

@@ -21,86 +21,79 @@ import java.util.List;
 
 public class Specifications {
 	public static List<String> getSqueezeSpecs() {
-		List<String> squeeze = Arrays.asList( 
+		return Arrays.asList(
 				"Name:Pressure",
 				"Shape:[C;0;0;26][R;0;" + (Settings.getSettings().getSizeScreen() + 12) + ";" + (Settings.getSettings().getSizeScreen() + 4) + ";" + (Settings.getSettings().getSizeScreen() + 4) + "]",
 				"Contact:[R;0;" + (Settings.getSettings().getSizeScreen() + 12) + ";" + Settings.getSettings().getSizeScreen() + ";" + Settings.getSettings().getSizeScreen() + "]",
 				"ButtonTrue:The object got squeezed!",
 				"ButtonFalse:The object didn't get squeezed."
 			 );
-		return squeeze;
 	}
 	
 	public static List<String> getWeightSpecs() {
-		List<String> weight = Arrays.asList( 
+
+		return Arrays.asList(
 				"Name:Load " + (Settings.getSettings().getWeight()/10.0f) + "kg",
 				"Shape:[R;0;0;20;61]",
 				"Contact:[C;0;1;" + Settings.getSettings().getSizeScreen() + "]",
 				"ButtonTrue:A weight of more than " + (Settings.getSettings().getWeight()/10.0f) + " Kg was applied!",
 				"ButtonFalse:A weight of less than " + (Settings.getSettings().getWeight()/10.0f) + " Kg was applied."
 			 );
-	
-		return weight;
 	}
 			
 	public static List<String> getTemperatureMeltSpecs() {
-		List<String> temperatureMelt = Arrays.asList( 
+
+		return Arrays.asList(
 				"Name:Rising Temperature",
 				"Shape:[R;0;0;20;42][R;0;-20;10;2]",
 				"Contact:[C;0;3;" + Settings.getSettings().getSizeScreen() + "]",
 				"ButtonTrue:The object was stored above 0�C!",
 				"ButtonFalse:The object was cooled the whole time."
 			);
-		
-		return temperatureMelt;
 	}
 	
 	public static List<String> getTemperatureFreezeSpecs() {
-		List<String> temperatureFreeze = Arrays.asList(
+
+		return Arrays.asList(
 				"Name:Falling Temperature",
 				"Shape:[R;0;0;20;43][C;10;-8;6]",
 				"Contact:[C;0;7;" + Settings.getSettings().getSizeScreen() + "]",
 				"ButtonTrue:The object was stored below 0�C!",
 				"ButtonFalse:The object was above 0�C the whole time."
 				);
-		
-		return temperatureFreeze;
 	}
 
 	public static List<String> getAccelerationSpecs() {
-		List<String> acceleration = Arrays.asList( 
+
+		return Arrays.asList(
 				"Name:Acceleration " + Settings.getSettings().getAcceleration() + "m/s�",
 				"Shape:[R;0;0;20;40][C;0;-10;6][C;0;10;6]",
 				"Contact:[C;0;10;" + Settings.getSettings().getSizeScreen() + "]",
 				"ButtonTrue:The object was accelerated with " + Settings.getSettings().getAcceleration() + "m/s�!",
 				"ButtonFalse:The object was accelerated with less than " + Settings.getSettings().getAcceleration() + "m/s�."
 			 );
-	
-		return acceleration;	
 	}
 	
 	public static List<String> getFlipSpecs() {
-		List<String> flip =  Arrays.asList( 
+
+		return Arrays.asList(
 				"Name:Flip",
 				"Shape:[C;0;0;34]",
 				"Contact:[C;0;0;" + Settings.getSettings().getSizeScreen() + "]",
 				"ButtonTrue:The object got flipped!",
 				"ButtonFalse:The object didn't get flipped."
 			 );
-	
-		return flip;
 	}
 	
 	public static List<String> getTiltSpecs() {
-		List<String> tilt =  Arrays.asList( 
+
+		return Arrays.asList(
 				"Name:Tilt",
 				"Shape:[R;0;0;18;30]",
 				"Contact:[C;0;8;" + Settings.getSettings().getSizeScreen() + "]",
 				"ButtonTrue:The object got tilted!",
 				"ButtonFalse:The object didn't get tilted."
 			);
-	
-		return tilt;
 	}
 	
 	//ADD CODE HERE FOR ADDITIONAL INTERACTION

+ 58 - 56
src/ui/Main.java

@@ -39,8 +39,6 @@ import java.util.Collections;
 
 public class Main extends Application {
 
-	private static Main window;
-
     //Save the last x/y value of the mouse, used for rotating the object in the javaFX panel
     private int lastX = 0;
     private int lastY = 0;
@@ -412,7 +410,7 @@ public class Main extends Application {
 			Task task = new Task() {
 
 				@Override
-				protected Void call() throws Exception {
+				protected Void call() {
 					Export.createSTL();
 					return null;
 				}
@@ -433,7 +431,7 @@ public class Main extends Application {
 			Task task2 = new Task() {
 
 				@Override
-				protected Void call() throws Exception {
+				protected Void call() {
 					while (!finished) {
 						try {
 							Thread.sleep(100);
@@ -465,6 +463,7 @@ public class Main extends Application {
 		saveObjectButton.setContentDisplay(ContentDisplay.LEFT);
 		saveObjectButton.setOnAction(event -> {
 			DirectoryChooser chooser = new DirectoryChooser();
+			chooser.setTitle("Save to Folder");
 			Platform.runLater(() -> {
 				File file = chooser.showDialog(primaryStage);
 
@@ -593,54 +592,57 @@ public class Main extends Application {
         }
     }
 
+    public static String olipPath;
 
     public static void main(String[] args) {
+
+    	if (System.getProperty("os.name").toLowerCase().contains("windows"))
+    		olipPath = System.getenv("AppData") + File.separator + "Olip" + File.separator;
+    	else
+    		olipPath = System.getProperty("user.home") + "/Library/Application Support/Olip/";
+
         //Load the settings.ini
-        try {
-            File file = new File(new java.io.File( "." ).getCanonicalPath() + File.separator + "settings.ini");
-            if (file.exists())
-                SettingsController.loadSettings();
-            else {
-                //If there isn't a settings.ini file, create a new one and search if OpenSCAD is installed.
-                //Windows: exe typically under the given path.
-                if (System.getProperty("os.name").toLowerCase().contains("windows")) {
-                    File openscadexe = new File("C:\\Program Files\\OpenSCAD\\openscad.exe");
-                    if (openscadexe.exists())
-                        Controller.getC().setOpenSCADPath(openscadexe.toPath().getParent());
-                    else {
-                        notDetected();
-                    }
-                }
-                //Linux: OpenSCAD is visible globally, so check via command line
-                else if (System.getProperty("os.name").toLowerCase().contains("linux")) {
-                    try {
-                        Process p = Runtime.getRuntime().exec("which openscad");
-                        p.waitFor();
-                        BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
-                        String s = in.readLine();
-                        if (s != null) {
-                            Controller.getC().setOpenSCADPath(new File(s).toPath());
-                        }
-                        else {
-                            notDetected();
-                        }
-                    } catch (IOException | InterruptedException e1) {
-                        e1.printStackTrace();
-                    }
-                }
-                //MacOS: OpenSCAD is installed as an app, so look for in in the application folder
-                else if (System.getProperty("os.name").toLowerCase().contains("mac")) {
-                    File openscadapp = new File("/Applications/OpenSCAD.app");
-                    if (openscadapp.exists())
-                        Controller.getC().setOpenSCADPath(new File(openscadapp.toPath().toString() + "/Contents/MacOS/").toPath());
-                    else
-                        notDetected();
-                }
-                SettingsController.saveSettings();
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
+		File file = new File(olipPath + "settings.ini");
+		if (file.exists())
+			SettingsController.loadSettings();
+		else {
+			//If there isn't a settings.ini file, create a new one and search if OpenSCAD is installed.
+			//Windows: exe typically under the given path.
+			if (System.getProperty("os.name").toLowerCase().contains("windows")) {
+				File openscadexe = new File("C:\\Program Files\\OpenSCAD\\openscad.exe");
+				if (openscadexe.exists())
+					Controller.getC().setOpenSCADPath(openscadexe.toPath().getParent());
+				else {
+					notDetected();
+				}
+			}
+			//Linux: OpenSCAD is visible globally, so check via command line
+			else if (System.getProperty("os.name").toLowerCase().contains("linux")) {
+				try {
+					Process p = Runtime.getRuntime().exec("which openscad");
+					p.waitFor();
+					BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
+					String s = in.readLine();
+					if (s != null) {
+						Controller.getC().setOpenSCADPath(new File(s).toPath());
+					}
+					else {
+						notDetected();
+					}
+				} catch (IOException | InterruptedException e1) {
+					e1.printStackTrace();
+				}
+			}
+			//MacOS: OpenSCAD is installed as an app, so look for in in the application folder
+			else if (System.getProperty("os.name").toLowerCase().contains("mac")) {
+				File openscadapp = new File("/Applications/OpenSCAD.app");
+				if (openscadapp.exists())
+					Controller.getC().setOpenSCADPath(new File(openscadapp.toPath().toString() + "/Contents/MacOS/").toPath());
+				else
+					notDetected();
+			}
+			SettingsController.saveSettings();
+		}
 
         launch(args);
     }
@@ -850,11 +852,11 @@ public class Main extends Application {
         String fileName;
 
         switch (viewMode) {
-            case VIEW_ALL: fileName = "output.stl"; break;
-            case VIEW_CONDUCTIVE: fileName = "output_conductive.stl"; break;
-            case VIEW_NON_CONDUCTIVE: fileName = "output.stl"; break;
-            case VIEW_CROSS_SECTION: fileName = "output_crosssection.stl"; break;
-            default: fileName = "output.stl";
+            case VIEW_ALL: fileName = Main.olipPath + "output.stl"; break;
+            case VIEW_CONDUCTIVE: fileName = Main.olipPath + "output_conductive.stl"; break;
+            case VIEW_NON_CONDUCTIVE: fileName = Main.olipPath + "output.stl"; break;
+            case VIEW_CROSS_SECTION: fileName = Main.olipPath + "output_crosssection.stl"; break;
+            default: fileName = Main.olipPath + "output.stl";
         }
 
         stlimport.read(new File(fileName));
@@ -876,9 +878,9 @@ public class Main extends Application {
         if (viewMode == VIEW_ALL || viewMode == VIEW_CROSS_SECTION) {
             String fileName2;
             if (viewMode == VIEW_ALL)
-                fileName2 = "output_conductive.stl";
+                fileName2 = Main.olipPath + "output_conductive.stl";
             else
-                fileName2 = "output_crosssection_conductive.stl";
+                fileName2 = Main.olipPath + "output_crosssection_conductive.stl";
             stlimport.read(new File(fileName2));
             Mesh mesh2 = stlimport.getImport();
             MeshView meshView2 = new MeshView(mesh2);

+ 1 - 17
src/ui/SettingsWindow.java

@@ -12,12 +12,9 @@ import javafx.scene.control.CheckBox;
 import javafx.scene.control.Label;
 import javafx.scene.control.ScrollBar;
 import javafx.stage.DirectoryChooser;
-import javafx.stage.FileChooser;
 import javafx.stage.Stage;
 
-import javax.swing.*;
 import java.io.File;
-import java.io.IOException;
 
 public class SettingsWindow {
 
@@ -99,14 +96,6 @@ public class SettingsWindow {
 								Platform.runLater(() -> scadPath.setText(file.toPath().toString()));
 							}
 						});
-			/*	JFileChooser chooser = new JFileChooser();
-				chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
-				chooser.showOpenDialog(null);
-
-				if (chooser.getSelectedFile() != null && chooser.getSelectedFile().isDirectory()) {
-					Controller.getC().setOpenSCADPath(chooser.getSelectedFile().toPath());
-					Platform.runLater(() -> scadPath.setText(chooser.getSelectedFile().toPath().toString()));
-				}*/
 				return null;
 			}
 		};
@@ -121,12 +110,7 @@ public class SettingsWindow {
 
 	@FXML
 	protected void cancelSettings() {
-		File file = null;
-		try {
-			file = new File(new File( "." ).getCanonicalPath() + File.separator + "settings.ini");
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
+		File file = new File(Main.olipPath + "settings.ini");
 		if (file.exists())
 			SettingsController.loadSettings();
 		stage.close();

+ 0 - 13
src/ui/UIController.java

@@ -6,11 +6,8 @@ import javafx.fxml.FXMLLoader;
 import javafx.scene.Parent;
 import javafx.scene.Scene;
 import javafx.scene.control.Label;
-import javafx.scene.control.TitledPane;
 import javafx.scene.image.Image;
 import javafx.scene.image.ImageView;
-import javafx.scene.layout.VBox;
-import javafx.scene.paint.Color;
 import javafx.stage.Stage;
 
 import java.io.IOException;
@@ -40,16 +37,6 @@ public class UIController  {
 		}
 	}
 
-	@FXML
-	protected void exit() {
-		try {
-			Platform.exit();
-		}
-		catch (Exception e1) {
-			e1.printStackTrace();
-		}
-	}
-
 	private void setLegend() {
 
 		Image imgBlue = new Image(getClass().getResource("/pictures/lightBlue.PNG").toString());	//Was blue