More localization updates by Ruslan Uss.
[debian/openrocket] / core / src / net / sf / openrocket / gui / dialogs / motor / thrustcurve / ThrustCurveMotorColumns.java
1 package net.sf.openrocket.gui.dialogs.motor.thrustcurve;
2
3 import java.text.Collator;
4 import java.util.Comparator;
5
6 import net.sf.openrocket.database.ThrustCurveMotorSet;
7 import net.sf.openrocket.l10n.Translator;
8 import net.sf.openrocket.motor.DesignationComparator;
9 import net.sf.openrocket.motor.ThrustCurveMotor;
10 import net.sf.openrocket.startup.Application;
11 import net.sf.openrocket.unit.UnitGroup;
12 import net.sf.openrocket.unit.Value;
13 import net.sf.openrocket.unit.ValueComparator;
14
15
16 /**
17  * Enum defining the table columns.
18  */
19
20 enum ThrustCurveMotorColumns {
21         //// Manufacturer
22         MANUFACTURER("TCurveMotorCol.MANUFACTURER", 100) {
23                 @Override
24                 public String getValue(ThrustCurveMotorSet m) {
25                         return m.getManufacturer().getDisplayName();
26                 }
27                 
28                 @Override
29                 public Comparator<?> getComparator() {
30                         return Collator.getInstance();
31                 }
32         },
33         //// Designation
34         DESIGNATION("TCurveMotorCol.DESIGNATION") {
35                 @Override
36                 public String getValue(ThrustCurveMotorSet m) {
37                         return m.getDesignation();
38                 }
39                 
40                 @Override
41                 public Comparator<?> getComparator() {
42                         return new DesignationComparator();
43                 }
44         },
45         //// Type
46         TYPE("TCurveMotorCol.TYPE") {
47                 @Override
48                 public String getValue(ThrustCurveMotorSet m) {
49                         return m.getType().getName();
50                 }
51                 
52                 @Override
53                 public Comparator<?> getComparator() {
54                         return Collator.getInstance();
55                 }
56         },
57         //// Diameter
58         DIAMETER("TCurveMotorCol.DIAMETER") {
59                 @Override
60                 public Object getValue(ThrustCurveMotorSet m) {
61                         return new Value(m.getDiameter(), UnitGroup.UNITS_MOTOR_DIMENSIONS);
62                 }
63                 
64                 @Override
65                 public Comparator<?> getComparator() {
66                         return ValueComparator.INSTANCE;
67                 }
68         },
69         //// Length
70         LENGTH("TCurveMotorCol.LENGTH") {
71                 @Override
72                 public Object getValue(ThrustCurveMotorSet m) {
73                         return new Value(m.getLength(), UnitGroup.UNITS_MOTOR_DIMENSIONS);
74                 }
75                 
76                 @Override
77                 public Comparator<?> getComparator() {
78                         return ValueComparator.INSTANCE;
79                 }
80         };
81         
82
83         private final String title;
84         private final int width;
85         private static final Translator trans = Application.getTranslator();
86         
87         ThrustCurveMotorColumns(String title) {
88                 this(title, 50);
89         }
90         
91         ThrustCurveMotorColumns(String title, int width) {
92                 this.title = title;
93                 this.width = width;
94         }
95         
96         
97         public abstract Object getValue(ThrustCurveMotorSet m);
98         
99         public abstract Comparator<?> getComparator();
100         
101         public String getTitle() {
102                 return trans.get(title);
103         }
104         
105         public int getWidth() {
106                 return width;
107         }
108         
109         public String getToolTipText(ThrustCurveMotor m) {
110                 String tip = "<html>";
111                 tip += "<b>" + m.toString() + "</b>";
112                 tip += " (" + m.getMotorType().getDescription() + ")<br><hr>";
113                 
114                 String desc = m.getDescription().trim();
115                 if (desc.length() > 0) {
116                         tip += "<i>" + desc.replace("\n", "<br>") + "</i><br><hr>";
117                 }
118                 
119                 tip += (trans.get("TCurveMotor.ttip.diameter") + " " +
120                                 UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit().toStringUnit(m.getDiameter()) +
121                                 "<br>");
122                 tip += (trans.get("TCurveMotor.ttip.length") + " " +
123                                 UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit().toStringUnit(m.getLength()) +
124                                 "<br>");
125                 tip += (trans.get("TCurveMotor.ttip.maxThrust") + " " +
126                                 UnitGroup.UNITS_FORCE.getDefaultUnit().toStringUnit(m.getMaxThrustEstimate()) +
127                                 "<br>");
128                 tip += (trans.get("TCurveMotor.ttip.avgThrust") + " " +
129                                 UnitGroup.UNITS_FORCE.getDefaultUnit().toStringUnit(m.getAverageThrustEstimate()) +
130                                 "<br>");
131                 tip += (trans.get("TCurveMotor.ttip.burnTime") + " " +
132                                 UnitGroup.UNITS_SHORT_TIME.getDefaultUnit()
133                                                 .toStringUnit(m.getBurnTimeEstimate()) + "<br>");
134                 tip += (trans.get("TCurveMotor.ttip.totalImpulse") + " " +
135                                 UnitGroup.UNITS_IMPULSE.getDefaultUnit()
136                                                 .toStringUnit(m.getTotalImpulseEstimate()) + "<br>");
137                 tip += (trans.get("TCurveMotor.ttip.launchMass") + " " +
138                                 UnitGroup.UNITS_MASS.getDefaultUnit().toStringUnit(m.getLaunchCG().weight) +
139                                 "<br>");
140                 tip += (trans.get("TCurveMotor.ttip.emptyMass") + " " +
141                                 UnitGroup.UNITS_MASS.getDefaultUnit()
142                                                 .toStringUnit(m.getEmptyCG().weight));
143                 return tip;
144         }
145         
146 }