refactor(renderer): Replace 'add' method with 'put' in RendererWorkingSet interface and implementations

This commit is contained in:
extio-de
2025-12-25 12:02:04 +01:00
parent b0bc14793f
commit c0b4c402c0
4 changed files with 33 additions and 33 deletions

View File

@@ -104,8 +104,8 @@ public class G2DRenderer implements Renderer {
EventQueue.invokeAndWait(() -> {
// this invokeAndWait() call is also important to wait until applyVideoOptions() has been completed, which also puts events to AWT event queue
LOGGER.debug("Viewport initialized");
this.rendererData.getRendererWorkingSet().add(this.rendererModuleId, this.rendererData.getRenderingBoPool().acquire("G2DRenderer_background", G2DDrawBackground.class));
this.rendererData.getRendererWorkingSet().add(this.rendererModuleId, this.rendererData.getRenderingBoPool().acquire("G2DRenderer_tooltip", G2DDrawControlTooltip.class));
this.rendererData.getRendererWorkingSet().put(this.rendererModuleId, this.rendererData.getRenderingBoPool().acquire("G2DRenderer_background", G2DDrawBackground.class));
this.rendererData.getRendererWorkingSet().put(this.rendererModuleId, this.rendererData.getRenderingBoPool().acquire("G2DRenderer_tooltip", G2DDrawControlTooltip.class));
});
}
catch (InvocationTargetException | InterruptedException e) {
@@ -255,14 +255,14 @@ public class G2DRenderer implements Renderer {
.setColor(RgbaColor.WHITE)
.setLayer(RenderingBoLayer.TOP)
.withPositionAbsoluteAnchorTopRight(100, 35);
this.rendererData.getRendererWorkingSet().add(this.rendererModuleId, drawFont);
this.rendererData.getRendererWorkingSet().put(this.rendererModuleId, drawFont);
this.fpsHistory.add(Integer.valueOf((int) this.frameDur));
final var drawFpsHistory = this.rendererData.getRenderingBoPool().acquire("g2DRenderer_fpsHistory", G2DDrawFpsHistory.class)
.setHistory(this.fpsHistory)
.setLayer(RenderingBoLayer.TOP)
.withPositionAbsoluteAnchorTopRight(100, 50);
this.rendererData.getRendererWorkingSet().add(this.rendererModuleId, drawFpsHistory);
this.rendererData.getRendererWorkingSet().put(this.rendererModuleId, drawFpsHistory);
}
private void frameCap() throws InterruptedException {

View File

@@ -8,9 +8,9 @@ import de.extio.game_engine.renderer.model.RenderingBo;
public interface RendererWorkingSet {
void add(String producerId, RenderingBo work);
void put(String producerId, RenderingBo work);
void add(String producerId, List<RenderingBo> work);
void put(String producerId, List<RenderingBo> work);
RenderingBo get(String producerId, String id);

View File

@@ -30,14 +30,14 @@ public class RendererWorkingSetImpl implements RendererWorkingSet {
}
@Override
public void add(final String producerId, final RenderingBo work) {
public void put(final String producerId, final RenderingBo work) {
this.getWorkingSetByProducer(producerId)
.next()
.put(work.getId(), work);
}
@Override
public void add(final String producerId, final List<RenderingBo> work) {
public void put(final String producerId, final List<RenderingBo> work) {
final var nextMap = this.getWorkingSetByProducer(producerId).next();
for (final RenderingBo bo : work) {
nextMap.put(bo.getId(), bo);