Clamp shoulder thickness when radius changes

This commit is contained in:
SiboVG 2023-09-09 22:24:39 +02:00
parent a7a2f4acc9
commit e9264d9dcf
2 changed files with 29 additions and 7 deletions

View File

@ -234,7 +234,8 @@ class DocumentConfig {
false));
setters.put("Transition:foreshoulderradius", new DoubleSetter(
Reflection.findMethod(Transition.class, "setForeShoulderRadius", double.class)));
Reflection.findMethod(Transition.class, "setForeShoulderRadius", double.class, boolean.class),
null, null, false));
setters.put("Transition:foreshoulderlength", new DoubleSetter(
Reflection.findMethod(Transition.class, "setForeShoulderLength", double.class)));
setters.put("Transition:foreshoulderthickness", new DoubleSetter(
@ -243,7 +244,8 @@ class DocumentConfig {
Reflection.findMethod(Transition.class, "setForeShoulderCapped", boolean.class)));
setters.put("Transition:aftshoulderradius", new DoubleSetter(
Reflection.findMethod(Transition.class, "setAftShoulderRadius", double.class)));
Reflection.findMethod(Transition.class, "setAftShoulderRadius", double.class, boolean.class),
null, null, false));
setters.put("Transition:aftshoulderlength", new DoubleSetter(
Reflection.findMethod(Transition.class, "setAftShoulderLength", double.class)));
setters.put("Transition:aftshoulderthickness", new DoubleSetter(

View File

@ -119,7 +119,7 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
setForeShoulderRadius(getForeShoulderRadius());
setForeShoulderRadius(getForeShoulderRadius(), doClamping);
}
public void setForeRadius(double radius) {
@ -396,21 +396,31 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
return foreShoulderRadius;
}
public void setForeShoulderRadius(double foreShoulderRadius) {
public void setForeShoulderRadius(double foreShoulderRadius, boolean doClamping) {
for (RocketComponent listener : configListeners) {
if (listener instanceof Transition) {
((Transition) listener).setForeShoulderRadius(foreShoulderRadius);
((Transition) listener).setForeShoulderRadius(foreShoulderRadius, doClamping);
}
}
foreShoulderRadius = Math.min(foreShoulderRadius, getForeRadius());
if (MathUtil.equals(this.foreShoulderRadius, foreShoulderRadius))
return;
this.foreShoulderRadius = foreShoulderRadius;
if (doClamping) {
this.foreShoulderThickness = Math.min(this.foreShoulderRadius, this.foreShoulderThickness);
}
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
}
public void setForeShoulderRadius(double foreShoulderRadius) {
setForeShoulderRadius(foreShoulderRadius, true);
}
public double getForeShoulderThickness() {
return foreShoulderThickness;
}
@ -469,10 +479,10 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
return aftShoulderRadius;
}
public void setAftShoulderRadius(double aftShoulderRadius) {
public void setAftShoulderRadius(double aftShoulderRadius, boolean doClamping) {
for (RocketComponent listener : configListeners) {
if (listener instanceof Transition) {
((Transition) listener).setAftShoulderRadius(aftShoulderRadius);
((Transition) listener).setAftShoulderRadius(aftShoulderRadius, doClamping);
}
}
@ -480,11 +490,21 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
if (MathUtil.equals(this.aftShoulderRadius, aftShoulderRadius))
return;
this.aftShoulderRadius = aftShoulderRadius;
if (doClamping) {
this.aftShoulderThickness = Math.min(this.aftShoulderRadius, this.aftShoulderThickness);
}
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
}
public void setAftShoulderRadius(double aftShoulderRadius) {
setAftShoulderRadius(aftShoulderRadius, true);
}
public double getAftShoulderThickness() {
return aftShoulderThickness;
}