create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / gui / dialogs / motor / thrustcurve / ThrustCurveMotorComparator.java
1 package net.sf.openrocket.gui.dialogs.motor.thrustcurve;
2
3 import java.util.Comparator;
4
5 import net.sf.openrocket.motor.ThrustCurveMotor;
6
7 /**
8  * Compares two ThrustCurveMotor objects for quality.
9  * 
10  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
11  */
12 public class ThrustCurveMotorComparator implements Comparator<ThrustCurveMotor> {
13         
14
15         @Override
16         public int compare(ThrustCurveMotor o1, ThrustCurveMotor o2) {
17                 return calculateGoodness(o2) - calculateGoodness(o1);
18         }
19         
20         
21         private int calculateGoodness(ThrustCurveMotor motor) {
22                 /*
23                  * 10 chars of comments correspond to one thrust point, max ten points.
24                  */
25                 int commentLength = Math.min(motor.getDescription().length(), 100);
26                 return motor.getTimePoints().length * 10 + commentLength;
27         }
28         
29
30 }