Fixed jdk7 problem in Multislider and NPE when there is no motor in the

ThrustCurveMotorSelectionPanel.
This commit is contained in:
kruland2607 2013-10-09 14:00:33 -05:00
parent 7687568f81
commit e4afa7961e
2 changed files with 498 additions and 480 deletions

View File

@ -461,7 +461,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
List<ThrustCurveMotor> getFilteredCurves() {
List<ThrustCurveMotor> motors = selectedMotorSet.getMotors();
if (hideSimilarBox.isSelected()) {
if (hideSimilarBox.isSelected() && selectedMotor != null) {
List<ThrustCurveMotor> filtered = new ArrayList<ThrustCurveMotor>(motors.size());
for (int i = 0; i < motors.size(); i++) {
ThrustCurveMotor m = motors.get(i);
@ -469,7 +469,6 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
filtered.add(m);
continue;
}
double similarity = MotorCorrelation.similarity(selectedMotor, m);
log.debug("Motor similarity: " + similarity);
if (similarity < MOTOR_SIMILARITY_THRESHOLD) {

View File

@ -311,7 +311,17 @@ public class MultiSlider extends JSlider {
* description: The sliders BoundedRangeModel.
*/
public void setModel(BoundedRangeModel newModel) {
// Hack around jdk 7 problem: http://code.google.com/p/geoviz/issues/detail?id=80
try
{
setModelAt(getCurrentThumbIndex(), newModel);
}
catch (Exception e)
{
this.sliderModel = newModel;
}
}
/***
@ -392,7 +402,16 @@ public class MultiSlider extends JSlider {
* @see #setValue
*/
public int getValue() {
// Hack around jdk 7 problem: http://code.google.com/p/geoviz/issues/detail?id=80
try
{
return getValueAt(getCurrentThumbIndex());
}
catch (Exception e)
{
return 0;
}
}
/***