[#1204] Fix overrideCGX slider length
This commit is contained in:
parent
930881dae6
commit
e7e96ca715
@ -6,7 +6,6 @@ import java.awt.Container;
|
|||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -340,15 +339,30 @@ public class RocketComponentConfig extends JPanel {
|
|||||||
// Calculate suitable length for slider
|
// Calculate suitable length for slider
|
||||||
DoubleModel length;
|
DoubleModel length;
|
||||||
if (component instanceof ComponentAssembly) {
|
if (component instanceof ComponentAssembly) {
|
||||||
double l = 0;
|
|
||||||
|
|
||||||
Iterator<RocketComponent> iterator = component.iterator(false);
|
Iterator<RocketComponent> iterator = component.iterator(false);
|
||||||
|
double minL = Double.MAX_VALUE;
|
||||||
|
double maxL = Double.MIN_VALUE;
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
RocketComponent c = iterator.next();
|
RocketComponent c = iterator.next();
|
||||||
if (c.getAxialMethod() == AxialMethod.AFTER)
|
|
||||||
l += c.getLength();
|
double compPos = c.getAxialOffset(AxialMethod.ABSOLUTE);
|
||||||
|
if (compPos < minL) {
|
||||||
|
minL = compPos;
|
||||||
}
|
}
|
||||||
length = new DoubleModel(l);
|
|
||||||
|
double compLen = c.getLength();
|
||||||
|
if (c instanceof FinSet) {
|
||||||
|
compLen = ((FinSet) c).getInstanceBoundingBox().span().x;
|
||||||
|
}
|
||||||
|
if (compPos + compLen > maxL) {
|
||||||
|
maxL = compPos + compLen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
length = new DoubleModel(maxL - minL);
|
||||||
|
} else if (component instanceof FinSet) {
|
||||||
|
double compLen = ((FinSet) component).getInstanceBoundingBox().span().x;
|
||||||
|
length = new DoubleModel(compLen);
|
||||||
} else {
|
} else {
|
||||||
length = new DoubleModel(component, "Length", UnitGroup.UNITS_LENGTH, 0);
|
length = new DoubleModel(component, "Length", UnitGroup.UNITS_LENGTH, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user