X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=core%2Fsrc%2Fnet%2Fsf%2Fopenrocket%2Fmaterial%2FMaterial.java;h=055fc336b60768060132e3399f7a5472bb377305;hb=ff8b5f95a1b3025b288bde304045a16faa474eb8;hp=00be68b1c3cdce191dfe53b035d13d31fc086a60;hpb=8654c7d5a9d56274a296500d40c7f74229cdf6f1;p=debian%2Fopenrocket diff --git a/core/src/net/sf/openrocket/material/Material.java b/core/src/net/sf/openrocket/material/Material.java index 00be68b1..055fc336 100644 --- a/core/src/net/sf/openrocket/material/Material.java +++ b/core/src/net/sf/openrocket/material/Material.java @@ -1,5 +1,7 @@ package net.sf.openrocket.material; +import net.sf.openrocket.l10n.Translator; +import net.sf.openrocket.startup.Application; import net.sf.openrocket.unit.Unit; import net.sf.openrocket.unit.UnitGroup; import net.sf.openrocket.util.MathUtil; @@ -16,16 +18,18 @@ import net.sf.openrocket.util.MathUtil; public abstract class Material implements Comparable { + private static final Translator trans = Application.getTranslator(); + public enum Type { - LINE("Line", UnitGroup.UNITS_DENSITY_LINE), - SURFACE("Surface", UnitGroup.UNITS_DENSITY_SURFACE), - BULK("Bulk", UnitGroup.UNITS_DENSITY_BULK); + LINE("Databases.materials.types.Line", UnitGroup.UNITS_DENSITY_LINE), + SURFACE("Databases.materials.types.Surface", UnitGroup.UNITS_DENSITY_SURFACE), + BULK("Databases.materials.types.Bulk", UnitGroup.UNITS_DENSITY_BULK); private final String name; private final UnitGroup units; - private Type(String name, UnitGroup units) { - this.name = name; + private Type(String nameKey, UnitGroup units) { + this.name = trans.get(nameKey); this.units = units; } @@ -43,7 +47,7 @@ public abstract class Material implements Comparable { ///// Definitions of different material types ///// public static class Line extends Material { - public Line(String name, double density, boolean userDefined) { + Line(String name, double density, boolean userDefined) { super(name, density, userDefined); } @@ -55,7 +59,7 @@ public abstract class Material implements Comparable { public static class Surface extends Material { - public Surface(String name, double density, boolean userDefined) { + Surface(String name, double density, boolean userDefined) { super(name, density, userDefined); } @@ -71,7 +75,7 @@ public abstract class Material implements Comparable { } public static class Bulk extends Material { - public Bulk(String name, double density, boolean userDefined) { + Bulk(String name, double density, boolean userDefined) { super(name, density, userDefined); } @@ -82,20 +86,26 @@ public abstract class Material implements Comparable { } - + private final String name; private final double density; private final boolean userDefined; - public Material(String name, double density, boolean userDefined) { + /** + * Constructor for materials. + * + * @param name ignored when defining system materials. + * @param key ignored when defining user materials. + * @param density + * @param userDefined true if this is a user defined material, false if it is a system material. + */ + private Material(String name, double density, boolean userDefined) { this.name = name; - this.density = density; this.userDefined = userDefined; + this.density = density; } - - public double getDensity() { return density; } @@ -159,10 +169,15 @@ public abstract class Material implements Comparable { /** - * Return a new material of the specified type. + * Return a new material. The name is used as-is, without any translation. + * + * @param type the material type + * @param name the material name + * @param density the material density + * @param userDefined whether the material is user-defined or not + * @return the new material */ - public static Material newMaterial(Type type, String name, double density, - boolean userDefined) { + public static Material newMaterial(Type type, String name, double density, boolean userDefined) { switch (type) { case LINE: return new Material.Line(name, density, userDefined); @@ -178,7 +193,6 @@ public abstract class Material implements Comparable { } } - public String toStorableString() { return getType().name() + "|" + name.replace('|', ' ') + '|' + density; }