1 package net.sf.openrocket.gui.dialogs.motor.thrustcurve;
3 import java.text.Collator;
4 import java.util.Comparator;
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;
17 * Enum defining the table columns.
20 enum ThrustCurveMotorColumns {
22 MANUFACTURER("TCurveMotorCol.MANUFACTURER", 100) {
24 public String getValue(ThrustCurveMotorSet m) {
25 return m.getManufacturer().getDisplayName();
29 public Comparator<?> getComparator() {
30 return Collator.getInstance();
34 DESIGNATION("TCurveMotorCol.DESIGNATION") {
36 public String getValue(ThrustCurveMotorSet m) {
37 return m.getDesignation();
41 public Comparator<?> getComparator() {
42 return new DesignationComparator();
46 TYPE("TCurveMotorCol.TYPE") {
48 public String getValue(ThrustCurveMotorSet m) {
49 return m.getType().getName();
53 public Comparator<?> getComparator() {
54 return Collator.getInstance();
58 DIAMETER("TCurveMotorCol.DIAMETER") {
60 public Object getValue(ThrustCurveMotorSet m) {
61 return new Value(m.getDiameter(), UnitGroup.UNITS_MOTOR_DIMENSIONS);
65 public Comparator<?> getComparator() {
66 return ValueComparator.INSTANCE;
70 LENGTH("TCurveMotorCol.LENGTH") {
72 public Object getValue(ThrustCurveMotorSet m) {
73 return new Value(m.getLength(), UnitGroup.UNITS_MOTOR_DIMENSIONS);
77 public Comparator<?> getComparator() {
78 return ValueComparator.INSTANCE;
83 private final String title;
84 private final int width;
85 private static final Translator trans = Application.getTranslator();
87 ThrustCurveMotorColumns(String title) {
91 ThrustCurveMotorColumns(String title, int width) {
97 public abstract Object getValue(ThrustCurveMotorSet m);
99 public abstract Comparator<?> getComparator();
101 public String getTitle() {
102 return trans.get(title);
105 public int getWidth() {
109 public String getToolTipText(ThrustCurveMotor m) {
110 String tip = "<html>";
111 tip += "<b>" + m.toString() + "</b>";
112 tip += " (" + m.getMotorType().getDescription() + ")<br><hr>";
114 String desc = m.getDescription().trim();
115 if (desc.length() > 0) {
116 tip += "<i>" + desc.replace("\n", "<br>") + "</i><br><hr>";
119 tip += (trans.get("TCurveMotor.ttip.diameter") + " " +
120 UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit().toStringUnit(m.getDiameter()) +
122 tip += (trans.get("TCurveMotor.ttip.length") + " " +
123 UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit().toStringUnit(m.getLength()) +
125 tip += (trans.get("TCurveMotor.ttip.maxThrust") + " " +
126 UnitGroup.UNITS_FORCE.getDefaultUnit().toStringUnit(m.getMaxThrustEstimate()) +
128 tip += (trans.get("TCurveMotor.ttip.avgThrust") + " " +
129 UnitGroup.UNITS_FORCE.getDefaultUnit().toStringUnit(m.getAverageThrustEstimate()) +
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) +
140 tip += (trans.get("TCurveMotor.ttip.emptyMass") + " " +
141 UnitGroup.UNITS_MASS.getDefaultUnit()
142 .toStringUnit(m.getEmptyCG().weight));