Update architecture

This commit is contained in:
2026-09-22 13:30:03 +02:00
parent 8b1e6ae358
commit b177ea5a38
27 changed files with 792 additions and 374 deletions

View File

@@ -1,22 +1,32 @@
package app.state;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import domain.events.fourier.*;
import domain.image.GrayScaleMatrix;
import domain.image.processing.complex.ComplexMatrix;
import presenters.doubleMatrix.DoubleMatrixListener;
import java.util.ArrayList;
import java.util.List;
public class DoubleMatrixState extends State {
private ComplexMatrix fourier;
private GrayScaleMatrix module;
private GrayScaleMatrix phase;
private GrayScaleMatrix real;
private GrayScaleMatrix imaginary;
private final List<DoubleMatrixListener> listeners = new ArrayList<>();
@Inject
public DoubleMatrixState() { super(new EventBus()); }
public DoubleMatrixState() {}
public void subscribe(DoubleMatrixListener listener) {
listeners.add(listener);
}
public void unsubscribe(DoubleMatrixListener listener) {
listeners.remove(listener);
}
public ComplexMatrix getFourier() {
return fourier;
@@ -24,26 +34,42 @@ public class DoubleMatrixState extends State {
public void setFourier(ComplexMatrix fourier) {
this.fourier = fourier;
this.eventBus.post(new ComplexMatrixChanged(fourier));
listeners.forEach(listener -> listener.onFourierChanged(fourier));
}
public void setModule(GrayScaleMatrix matrix) {
this.module = matrix;
this.eventBus.post(new ModuleChangedEvent(matrix));
listeners.forEach(listener -> listener.onModuleChanged(matrix));
}
public void setPhase(GrayScaleMatrix matrix) {
this.phase = matrix;
this.eventBus.post(new PhaseChangedEvent(matrix));
listeners.forEach(listener -> listener.onPhaseChanged(matrix));
}
public void setReal(GrayScaleMatrix matrix) {
this.real = matrix;
this.eventBus.post(new RealChangedEvent(matrix));
listeners.forEach(listener -> listener.onRealChanged(matrix));
}
public void setImaginary(GrayScaleMatrix matrix) {
this.imaginary = matrix;
this.eventBus.post(new ImaginaryChangedEvent(matrix));
listeners.forEach(listener -> listener.onImaginaryChanged(matrix));
}
public GrayScaleMatrix getModule() {
return module;
}
public GrayScaleMatrix getPhase() {
return phase;
}
public GrayScaleMatrix getReal() {
return real;
}
public GrayScaleMatrix getImaginary() {
return imaginary;
}
}