Add factory method which constructs a user material which uses a localizable key.
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sat, 4 Aug 2012 03:09:36 +0000 (03:09 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sat, 4 Aug 2012 03:09:36 +0000 (03:09 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@950 180e2498-e6e9-4542-8430-84ac67f01cd8

core/src/net/sf/openrocket/material/Material.java

index f52acf51df97664c53e6425bac569f306188eda2..912e85cc076f63afdeed7a5cc1f4ab61dab1098c 100644 (file)
@@ -215,6 +215,26 @@ public abstract class Material implements Comparable<Material> {
                }
        }
        
+       /**
+        * Return a new user defined material of the specified type and localizable key.
+        */
+       public static Material newUserMaterialWithKey(Type type, String key, double density) {
+               switch (type) {
+               case LINE:
+                       return new Material.Line(null, key, density, true);
+                       
+               case SURFACE:
+                       return new Material.Surface(null, key, density, true);
+                       
+               case BULK:
+                       return new Material.Bulk(null, key, density, true);
+                       
+               default:
+                       throw new IllegalArgumentException("Unknown material type: " + type);
+               }
+       }
+       
+       
        
        public String toStorableString() {
                return getType().name() + "|" + key + "|" + name.replace('|', ' ') + '|' + density;