From: kruland2607 Date: Sat, 4 Aug 2012 03:09:36 +0000 (+0000) Subject: Add factory method which constructs a user material which uses a localizable key. X-Git-Tag: upstream/12.09^2~74 X-Git-Url: https://git.gag.com/?p=debian%2Fopenrocket;a=commitdiff_plain;h=eaf924173a9253c8ed192d656982a99e87255de9 Add factory method which constructs a user material which uses a localizable key. git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@950 180e2498-e6e9-4542-8430-84ac67f01cd8 --- diff --git a/core/src/net/sf/openrocket/material/Material.java b/core/src/net/sf/openrocket/material/Material.java index f52acf51..912e85cc 100644 --- a/core/src/net/sf/openrocket/material/Material.java +++ b/core/src/net/sf/openrocket/material/Material.java @@ -215,6 +215,26 @@ public abstract class Material implements Comparable { } } + /** + * 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;