import net.sf.openrocket.file.GeneralMotorLoader;
import net.sf.openrocket.material.Material;
-import net.sf.openrocket.rocketcomponent.Motor;
+import net.sf.openrocket.material.MaterialStorage;
+import net.sf.openrocket.motor.Motor;
import net.sf.openrocket.util.JarUtil;
import net.sf.openrocket.util.MathUtil;
+import net.sf.openrocket.util.Prefs;
/**
}
}
- // TODO: HIGH: Move materials into data files
static {
+ // Add default materials
BULK_MATERIAL.add(new Material.Bulk("Acrylic", 1190, false));
BULK_MATERIAL.add(new Material.Bulk("Balsa", 170, false));
BULK_MATERIAL.add(new Material.Bulk("Birch", 670, false));
BULK_MATERIAL.add(new Material.Bulk("Cardboard", 680, false));
BULK_MATERIAL.add(new Material.Bulk("Carbon fiber", 1780, false));
BULK_MATERIAL.add(new Material.Bulk("Cork", 240, false));
+ BULK_MATERIAL.add(new Material.Bulk("Depron", 40, false));
BULK_MATERIAL.add(new Material.Bulk("Fiberglass", 1850, false));
BULK_MATERIAL.add(new Material.Bulk("Kraft phenolic",950, false));
BULK_MATERIAL.add(new Material.Bulk("Maple", 755, false));
BULK_MATERIAL.add(new Material.Bulk("Polystyrene", 1050, false));
BULK_MATERIAL.add(new Material.Bulk("PVC", 1390, false));
BULK_MATERIAL.add(new Material.Bulk("Spruce", 450, false));
+ // TODO: CRITICAL: Add styrofoam
BULK_MATERIAL.add(new Material.Bulk("Quantum tubing",1050, false));
SURFACE_MATERIAL.add(new Material.Surface("Ripstop nylon", 0.067, false));
LINE_MATERIAL.add(new Material.Line("Tubular nylon (11 mm, 7/16 in)", 0.013, false));
LINE_MATERIAL.add(new Material.Line("Tubular nylon (14 mm, 9/16 in)", 0.016, false));
LINE_MATERIAL.add(new Material.Line("Tubular nylon (25 mm, 1 in)", 0.029, false));
+
+
+ // Add user-defined materials
+ for (Material m: Prefs.getUserMaterials()) {
+ switch (m.getType()) {
+ case LINE:
+ LINE_MATERIAL.add(m);
+ break;
+
+ case SURFACE:
+ SURFACE_MATERIAL.add(m);
+ break;
+
+ case BULK:
+ BULK_MATERIAL.add(m);
+ break;
+
+ default:
+ System.err.println("ERROR: Unknown material type " + m);
+ }
+ }
+
+ // Add database storage listener
+ MaterialStorage listener = new MaterialStorage();
+ LINE_MATERIAL.addDatabaseListener(listener);
+ SURFACE_MATERIAL.addDatabaseListener(listener);
+ BULK_MATERIAL.addDatabaseListener(listener);
+ }
+
+
+ /*
+ * Used just for ensuring initialization of the class.
+ */
+ public static void fakeMethod() {
+
}
* Find a material from the database or return a new material if the specified
* material with the specified density is not found.
*
- * @param type the material type.
- * @param name the material name.
- * @param density the density of the material.
- * @return the material object from the database or a new material.
+ * @param type the material type.
+ * @param name the material name.
+ * @param density the density of the material.
+ * @param userDefined whether a newly created material should be user-defined.
+ * @return the material object from the database or a new material.
*/
- public static Material findMaterial(Material.Type type, String name, double density) {
+ public static Material findMaterial(Material.Type type, String name, double density,
+ boolean userDefined) {
Database<Material> db;
switch (type) {
case BULK:
return m;
}
}
- return Material.newMaterial(type, name, density);
+ return Material.newMaterial(type, name, density, userDefined);
}
boolean match = true;
if (type != null && type != m.getMotorType())
match = false;
- else if (manufacturer != null && !manufacturer.equalsIgnoreCase(m.getManufacturer()))
+ else if (manufacturer != null && !m.getManufacturer().matches(manufacturer))
match = false;
else if (designation != null && !designation.equalsIgnoreCase(m.getDesignation()))
match = false;