refactor(renderer): simplify G2DDrawControl constructor and initialize customControlConfigurations lazily

This commit is contained in:
extio-de
2026-01-04 14:58:07 +01:00
parent af82b8dc9d
commit 96f338bc24

View File

@@ -86,11 +86,10 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
private final Area2 tempArea = new Area2(MutableCoordI2.create(), MutableCoordI2.create()); private final Area2 tempArea = new Area2(MutableCoordI2.create(), MutableCoordI2.create());
private final List<CustomControlConfiguration<? extends G2DBaseControlImpl>> customControlConfigurations; private List<CustomControlConfiguration<? extends G2DBaseControlImpl>> customControlConfigurations;
public G2DDrawControl(final List<CustomControlConfiguration<? extends G2DBaseControlImpl>> customControlConfigurations) { public G2DDrawControl() {
super(RenderingBoLayer.UI0); super(RenderingBoLayer.UI0);
this.customControlConfigurations = customControlConfigurations;
} }
@Override @Override
@@ -204,6 +203,10 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
} }
} }
if (this.customControlConfigurations == null) {
this.customControlConfigurations = List.copyOf( this.rendererData.getApplicationContext().getBeansOfType(CustomControlConfiguration.class).values());
}
var control = (G2DBaseControlImpl) CACHED_CONTROLS.get(this.id); var control = (G2DBaseControlImpl) CACHED_CONTROLS.get(this.id);
if (control == null) { if (control == null) {
if (this.clazz == null) { if (this.clazz == null) {
@@ -244,12 +247,10 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
control = new G2DTooltipControl(); control = new G2DTooltipControl();
} }
else { else {
if (this.customControlConfigurations != null) { for (final var customControlConfiguration : this.customControlConfigurations) {
for (final var customControlConfiguration : this.customControlConfigurations) { if (customControlConfiguration.getControlClass().equals(this.clazz)) {
if (customControlConfiguration.getControlClass().equals(this.clazz)) { control = customControlConfiguration.createControl();
control = customControlConfiguration.createControl(); break;
break;
}
} }
} }
@@ -339,12 +340,10 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
((TextfieldControl) control).setCustomData(this.textfieldData); ((TextfieldControl) control).setCustomData(this.textfieldData);
} }
else { else {
if (this.customControlConfigurations != null) { for (final var customControlConfiguration : this.customControlConfigurations) {
for (final var customControlConfiguration : this.customControlConfigurations) { if (customControlConfiguration.getControlClass().equals(this.clazz)) {
if (customControlConfiguration.getControlClass().equals(this.clazz)) { ((CustomControlConfiguration) customControlConfiguration).setCustomData(control, this.customData);
((CustomControlConfiguration) customControlConfiguration).setCustomData(control, this.customData); break;
break;
}
} }
} }
} }
@@ -376,6 +375,7 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
this.tooltip = o.tooltip; this.tooltip = o.tooltip;
this.visibleArea = o.visibleArea; this.visibleArea = o.visibleArea;
this.controlArea = o.controlArea; this.controlArea = o.controlArea;
this.customControlConfigurations = o.customControlConfigurations;
} }
} }
@@ -404,6 +404,7 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
this.tooltip = null; this.tooltip = null;
this.visibleArea = null; this.visibleArea = null;
this.controlArea = null; this.controlArea = null;
this.customControlConfigurations = null;
} }
@Override @Override