Add linear outline machinery
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
package presenters.outline;
|
||||
|
||||
import domain.image.Image;
|
||||
|
||||
public interface LinearOutlineListener {
|
||||
|
||||
}
|
||||
void onPrewittChanged(Image image);
|
||||
|
||||
void onSobelChanged(Image image);
|
||||
|
||||
void onLaplacian4Changed(Image image);
|
||||
|
||||
void onLaplacian8Changed(Image image);
|
||||
}
|
||||
@@ -2,8 +2,10 @@ package presenters.outline;
|
||||
|
||||
import app.state.AppState;
|
||||
import app.state.LinearOutlineState;
|
||||
import domain.image.Image;
|
||||
import jakarta.inject.Inject;
|
||||
import services.OutlineService;
|
||||
import ui.abstractions.ILinearOutlineView;
|
||||
|
||||
public class LinearOutlinePresenter implements LinearOutlineListener {
|
||||
|
||||
@@ -11,6 +13,8 @@ public class LinearOutlinePresenter implements LinearOutlineListener {
|
||||
private final LinearOutlineState outlineState;
|
||||
private final OutlineService outlineService;
|
||||
|
||||
private ILinearOutlineView view;
|
||||
|
||||
@Inject
|
||||
public LinearOutlinePresenter(
|
||||
AppState appState,
|
||||
@@ -20,24 +24,76 @@ public class LinearOutlinePresenter implements LinearOutlineListener {
|
||||
this.appState = appState;
|
||||
this.outlineState = outlineState;
|
||||
this.outlineService = outlineService;
|
||||
|
||||
outlineState.subscribe(this);
|
||||
}
|
||||
|
||||
public void setView(Object o) {
|
||||
public void setView(ILinearOutlineView view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
view = null;
|
||||
outlineState.unsubscribe(this);
|
||||
}
|
||||
|
||||
public void computePrewittGradient(int direction) {
|
||||
Image image = appState.getImage();
|
||||
|
||||
Image result = outlineService.prewittGradient(image, direction);
|
||||
|
||||
outlineState.setPrewitt(result);
|
||||
}
|
||||
|
||||
public void computeSobelGradient(int direction) {
|
||||
Image image = appState.getImage();
|
||||
|
||||
Image result = outlineService.sobelGradient(image, direction);
|
||||
|
||||
outlineState.setSobel(result);
|
||||
}
|
||||
|
||||
public void computeLaplacian4() {
|
||||
Image image = appState.getImage();
|
||||
|
||||
Image result = outlineService.laplacian4(image);
|
||||
|
||||
outlineState.setLaplacian4(result);
|
||||
}
|
||||
|
||||
public void computeLaplacian8() {
|
||||
Image image = appState.getImage();
|
||||
|
||||
Image result = outlineService.laplacian8(image);
|
||||
|
||||
outlineState.setLaplacian8(result);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrewittChanged(Image image) {
|
||||
if (view != null) {
|
||||
view.updatePrewitt(image);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSobelChanged(Image image) {
|
||||
if (view != null) {
|
||||
view.updateSobel(image);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLaplacian4Changed(Image image) {
|
||||
if (view != null) {
|
||||
view.updateLaplacian4(image);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLaplacian8Changed(Image image) {
|
||||
if (view != null) {
|
||||
view.updateLaplacian8(image);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user