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)); false));
setters.put("Transition:foreshoulderradius", new DoubleSetter( 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( setters.put("Transition:foreshoulderlength", new DoubleSetter(
Reflection.findMethod(Transition.class, "setForeShoulderLength", double.class))); Reflection.findMethod(Transition.class, "setForeShoulderLength", double.class)));
setters.put("Transition:foreshoulderthickness", new DoubleSetter( setters.put("Transition:foreshoulderthickness", new DoubleSetter(
@ -243,7 +244,8 @@ class DocumentConfig {
Reflection.findMethod(Transition.class, "setForeShoulderCapped", boolean.class))); Reflection.findMethod(Transition.class, "setForeShoulderCapped", boolean.class)));
setters.put("Transition:aftshoulderradius", new DoubleSetter( 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( setters.put("Transition:aftshoulderlength", new DoubleSetter(
Reflection.findMethod(Transition.class, "setAftShoulderLength", double.class))); Reflection.findMethod(Transition.class, "setAftShoulderLength", double.class)));
setters.put("Transition:aftshoulderthickness", new DoubleSetter( setters.put("Transition:aftshoulderthickness", new DoubleSetter(

View File

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