Import from internal git
This commit is contained in:
49
src/main/java/app/AppModule.java
Normal file
49
src/main/java/app/AppModule.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package app;
|
||||
|
||||
import app.state.AppState;
|
||||
import app.state.DoubleMatrixState;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Scopes;
|
||||
import presenters.DoubleMatrixPresenter;
|
||||
import presenters.MainPresenter;
|
||||
import presenters.NavPresenter;
|
||||
import services.ImageService;
|
||||
import ui.implementation.components.nav.NavBar;
|
||||
import ui.implementation.views.DoubleMatrix;
|
||||
import ui.implementation.views.MainView;
|
||||
import ui.interfaces.IDoubleMatrix;
|
||||
import ui.interfaces.IMainView;
|
||||
import ui.interfaces.INavBar;
|
||||
|
||||
/**
|
||||
* @author Laurent Crema
|
||||
*/
|
||||
public class AppModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
||||
//--- States ---
|
||||
bind(AppState.class).in(Scopes.SINGLETON);
|
||||
bind(DoubleMatrixState.class);
|
||||
|
||||
//--- Application layer ---
|
||||
bind(EventBus.class).in(Scopes.SINGLETON);
|
||||
bind(INavigator.class).to(SwingNavigator.class).in(Scopes.SINGLETON);
|
||||
|
||||
//--- UI layer ---
|
||||
bind(INavBar.class).to(NavBar.class);
|
||||
bind(IMainView.class).to(MainView.class);
|
||||
bind(IDoubleMatrix.class).to(DoubleMatrix.class);
|
||||
|
||||
//--- Presentation layer ---
|
||||
bind(MainPresenter.class);
|
||||
bind(NavPresenter.class);
|
||||
bind(DoubleMatrixPresenter.class);
|
||||
|
||||
//--- Service layer layer ---
|
||||
bind(ImageService.class);
|
||||
|
||||
}
|
||||
}
|
||||
7
src/main/java/app/INavigator.java
Normal file
7
src/main/java/app/INavigator.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package app;
|
||||
|
||||
public interface INavigator {
|
||||
|
||||
void showFourier();
|
||||
|
||||
}
|
||||
23
src/main/java/app/SwingNavigator.java
Normal file
23
src/main/java/app/SwingNavigator.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package app;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import ui.implementation.views.DoubleMatrix;
|
||||
|
||||
public class SwingNavigator implements INavigator {
|
||||
|
||||
private final Provider<DoubleMatrix> doubleMatrixProvider;
|
||||
|
||||
@Inject
|
||||
public SwingNavigator(
|
||||
Provider<DoubleMatrix> doubleMatrixProvider
|
||||
) {
|
||||
this.doubleMatrixProvider = doubleMatrixProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showFourier() {
|
||||
DoubleMatrix doubleMatrix = doubleMatrixProvider.get();
|
||||
doubleMatrix.setVisible(true);
|
||||
}
|
||||
}
|
||||
37
src/main/java/app/state/AppState.java
Normal file
37
src/main/java/app/state/AppState.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package app.state;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import domain.common.Mode;
|
||||
import domain.events.ImageChangedEvent;
|
||||
import domain.events.ModeChangedEvent;
|
||||
import domain.image.Image;
|
||||
|
||||
@Singleton
|
||||
public class AppState extends State {
|
||||
|
||||
private Mode mode;
|
||||
private Image rgbImage;
|
||||
|
||||
@Inject
|
||||
public AppState(EventBus eventBus) {
|
||||
super(eventBus);
|
||||
}
|
||||
|
||||
public void setMode(Mode mode) {
|
||||
this.mode = mode;
|
||||
this.eventBus.post(new ModeChangedEvent(mode));
|
||||
}
|
||||
|
||||
public void setImage(Image image) {
|
||||
this.rgbImage = image;
|
||||
this.eventBus.post(new ImageChangedEvent(image));
|
||||
}
|
||||
|
||||
public Image getImage(){
|
||||
return this.rgbImage;
|
||||
}
|
||||
|
||||
public Mode getMode() { return this.mode; }
|
||||
}
|
||||
49
src/main/java/app/state/DoubleMatrixState.java
Normal file
49
src/main/java/app/state/DoubleMatrixState.java
Normal file
@@ -0,0 +1,49 @@
|
||||
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;
|
||||
|
||||
public class DoubleMatrixState extends State {
|
||||
|
||||
private ComplexMatrix fourier;
|
||||
private GrayScaleMatrix module;
|
||||
private GrayScaleMatrix phase;
|
||||
private GrayScaleMatrix real;
|
||||
private GrayScaleMatrix imaginary;
|
||||
|
||||
@Inject
|
||||
public DoubleMatrixState() { super(new EventBus()); }
|
||||
|
||||
public ComplexMatrix getFourier() {
|
||||
return fourier;
|
||||
}
|
||||
|
||||
public void setFourier(ComplexMatrix fourier) {
|
||||
this.fourier = fourier;
|
||||
this.eventBus.post(new ComplexMatrixChanged(fourier));
|
||||
}
|
||||
|
||||
public void setModule(GrayScaleMatrix matrix) {
|
||||
this.module = matrix;
|
||||
this.eventBus.post(new ModuleChangedEvent(matrix));
|
||||
}
|
||||
|
||||
public void setPhase(GrayScaleMatrix matrix) {
|
||||
this.phase = matrix;
|
||||
this.eventBus.post(new PhaseChangedEvent(matrix));
|
||||
}
|
||||
|
||||
public void setReal(GrayScaleMatrix matrix) {
|
||||
this.real = matrix;
|
||||
this.eventBus.post(new RealChangedEvent(matrix));
|
||||
}
|
||||
|
||||
public void setImaginary(GrayScaleMatrix matrix) {
|
||||
this.imaginary = matrix;
|
||||
this.eventBus.post(new ImaginaryChangedEvent(matrix));
|
||||
}
|
||||
}
|
||||
16
src/main/java/app/state/State.java
Normal file
16
src/main/java/app/state/State.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package app.state;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
public abstract class State {
|
||||
|
||||
protected EventBus eventBus;
|
||||
|
||||
public State(EventBus eventBus) {
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
|
||||
public void register(Object obj) {
|
||||
eventBus.register(obj);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user