Fix TabbedImagePanel initialization
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
package app;
|
package app;
|
||||||
|
|
||||||
|
import app.shared.INavigator;
|
||||||
|
import app.shared.ImageSaveHandler;
|
||||||
|
import app.shared.SwingNavigator;
|
||||||
import app.state.*;
|
import app.state.*;
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
@@ -12,7 +15,6 @@ import presenters.filtering.local.LocalFilteringPresenter;
|
|||||||
import presenters.morphology.BasicMorphologyPresenter;
|
import presenters.morphology.BasicMorphologyPresenter;
|
||||||
import presenters.morphology.ComplexMorphologyPresenter;
|
import presenters.morphology.ComplexMorphologyPresenter;
|
||||||
import presenters.outline.LinearOutlinePresenter;
|
import presenters.outline.LinearOutlinePresenter;
|
||||||
import presenters.outline.NonLinearOutlineListener;
|
|
||||||
import presenters.outline.NonLinearOutlinePresenter;
|
import presenters.outline.NonLinearOutlinePresenter;
|
||||||
import services.GlobalFilteringService;
|
import services.GlobalFilteringService;
|
||||||
import services.ImageService;
|
import services.ImageService;
|
||||||
@@ -51,6 +53,7 @@ public class AppModule extends AbstractModule {
|
|||||||
//--- Application layer ---
|
//--- Application layer ---
|
||||||
bind(EventBus.class).in(Scopes.SINGLETON);
|
bind(EventBus.class).in(Scopes.SINGLETON);
|
||||||
bind(INavigator.class).to(SwingNavigator.class).in(Scopes.SINGLETON);
|
bind(INavigator.class).to(SwingNavigator.class).in(Scopes.SINGLETON);
|
||||||
|
bind(ImageSaveHandler.class).in(Scopes.SINGLETON);
|
||||||
|
|
||||||
//--- UI layer ---
|
//--- UI layer ---
|
||||||
bind(INavBar.class).to(NavBar.class);
|
bind(INavBar.class).to(NavBar.class);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package app;
|
package app.shared;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides some endpoints to browse between views
|
* Provides some endpoints to browse between views
|
||||||
44
src/main/java/app/shared/ImageSaveHandler.java
Normal file
44
src/main/java/app/shared/ImageSaveHandler.java
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package app.shared;
|
||||||
|
|
||||||
|
import app.state.AppState;
|
||||||
|
import domain.image.Image;
|
||||||
|
import infrastructure.image.io.ImageSaver;
|
||||||
|
import infrastructure.ui.ImageMapper;
|
||||||
|
import jakarta.inject.Inject;
|
||||||
|
import services.ImageService;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles application-level image saving and registration.
|
||||||
|
*
|
||||||
|
* @author Laurent Crema
|
||||||
|
*/
|
||||||
|
public class ImageSaveHandler {
|
||||||
|
|
||||||
|
private final AppState appState;
|
||||||
|
private final ImageService imageService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public ImageSaveHandler(AppState appState, ImageService imageService) {
|
||||||
|
this.appState = appState;
|
||||||
|
this.imageService = imageService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save an image to a system file.
|
||||||
|
*/
|
||||||
|
public void save(BufferedImage bufferedImage) throws IOException {
|
||||||
|
Image image = ImageMapper.fromBufferedImage(bufferedImage);
|
||||||
|
this.imageService.saveImage(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register an image in the application state.
|
||||||
|
*/
|
||||||
|
public void register(BufferedImage bufferedImage) {
|
||||||
|
Image image = ImageMapper.fromBufferedImage(bufferedImage);
|
||||||
|
appState.setImage(image);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package app;
|
package app.shared;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
import domain.image.processing.complex.ComplexMatrix;
|
|
||||||
import ui.abstractions.AbstractView;
|
import ui.abstractions.AbstractView;
|
||||||
import ui.implementation.views.DoubleMatrix;
|
import ui.implementation.views.DoubleMatrix;
|
||||||
import ui.implementation.views.fitering.global.IdealFilteringView;
|
import ui.implementation.views.fitering.global.IdealFilteringView;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package presenters;
|
package presenters;
|
||||||
|
|
||||||
import app.INavigator;
|
import app.shared.INavigator;
|
||||||
import app.state.AppState;
|
import app.state.AppState;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import domain.common.Mode;
|
import domain.common.Mode;
|
||||||
|
|||||||
@@ -24,23 +24,18 @@ public class ImagePanel extends JPanel {
|
|||||||
private int offsetX;
|
private int offsetX;
|
||||||
private int offsetY;
|
private int offsetY;
|
||||||
|
|
||||||
|
|
||||||
public ImagePanel() {
|
public ImagePanel() {
|
||||||
this(image -> {});
|
this(image -> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ImagePanel(BufferedImage image) {
|
|
||||||
this();
|
|
||||||
loadImage(image);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImagePanel(BufferedImage image, Consumer<BufferedImage> onSave) {
|
public ImagePanel(BufferedImage image, Consumer<BufferedImage> onSave) {
|
||||||
this(onSave);
|
this(onSave);
|
||||||
loadImage(image);
|
loadImage(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImagePanel(Consumer<BufferedImage> onSave) {
|
public ImagePanel(Consumer<BufferedImage> onSave) {
|
||||||
setLayout(new OverlayLayout(this));
|
setLayout(null);
|
||||||
|
|
||||||
SaveButton saveButton = new SaveButton(
|
SaveButton saveButton = new SaveButton(
|
||||||
() -> {
|
() -> {
|
||||||
@@ -50,11 +45,23 @@ public class ImagePanel extends JPanel {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
add(saveButton);
|
||||||
buttonPanel.setOpaque(false);
|
|
||||||
buttonPanel.add(saveButton);
|
|
||||||
|
|
||||||
add(buttonPanel);
|
addComponentListener(new java.awt.event.ComponentAdapter() {
|
||||||
|
@Override
|
||||||
|
public void componentResized(java.awt.event.ComponentEvent e) {
|
||||||
|
int margin = 10;
|
||||||
|
|
||||||
|
Dimension size = saveButton.getPreferredSize();
|
||||||
|
|
||||||
|
saveButton.setBounds(
|
||||||
|
getWidth() - size.width - margin,
|
||||||
|
getHeight() - size.height - margin,
|
||||||
|
size.width,
|
||||||
|
size.height
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadImage(BufferedImage image) {
|
public void loadImage(BufferedImage image) {
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ public class TabbedImagePanel extends JTabbedPane {
|
|||||||
addTab(title, panel);
|
addTab(title, panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addPreviewTab(String title, ImagePanel panel) {
|
||||||
|
tabs.put(title, panel);
|
||||||
|
addTab(title, panel);
|
||||||
|
}
|
||||||
|
|
||||||
public void loadImage(String title, Image image) {
|
public void loadImage(String title, Image image) {
|
||||||
BufferedImage bufferedImage = ImageMapper.toBufferedImage(image);
|
BufferedImage bufferedImage = ImageMapper.toBufferedImage(image);
|
||||||
tabs.get(title).loadImage(bufferedImage);
|
tabs.get(title).loadImage(bufferedImage);
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package ui.implementation.components.image;
|
||||||
|
|
||||||
|
import app.shared.ImageSaveHandler;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
public class TabbedPanelFactory {
|
||||||
|
|
||||||
|
private final ImageSaveHandler saveHandler;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public TabbedPanelFactory(ImageSaveHandler saveHandler) {
|
||||||
|
this.saveHandler = saveHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TabbedImagePanel createTabbedImagePanel(String... tabsTitle) {
|
||||||
|
TabbedImagePanel tabbedPanel = new TabbedImagePanel();
|
||||||
|
for (String tabTitle : tabsTitle) {
|
||||||
|
ImagePanel panel = new ImagePanel(saveHandler::register);
|
||||||
|
tabbedPanel.addPreviewTab(tabTitle, panel);
|
||||||
|
}
|
||||||
|
return tabbedPanel;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@ import jakarta.inject.Inject;
|
|||||||
import presenters.doubleMatrix.DoubleMatrixPresenter;
|
import presenters.doubleMatrix.DoubleMatrixPresenter;
|
||||||
import ui.abstractions.AbstractView;
|
import ui.abstractions.AbstractView;
|
||||||
import ui.implementation.components.image.ImagePanel;
|
import ui.implementation.components.image.ImagePanel;
|
||||||
|
import ui.implementation.components.image.TabbedImagePanel;
|
||||||
|
import ui.implementation.components.image.TabbedPanelFactory;
|
||||||
import ui.implementation.components.intent.FileChooser;
|
import ui.implementation.components.intent.FileChooser;
|
||||||
import ui.abstractions.IDoubleMatrix;
|
import ui.abstractions.IDoubleMatrix;
|
||||||
|
|
||||||
@@ -20,16 +22,17 @@ import javax.swing.event.ChangeEvent;
|
|||||||
*/
|
*/
|
||||||
public class DoubleMatrix extends AbstractView implements IDoubleMatrix
|
public class DoubleMatrix extends AbstractView implements IDoubleMatrix
|
||||||
{
|
{
|
||||||
|
private static final String MODULE_TAB_TILE = "Module";
|
||||||
|
private static final String PHASE_TAB_TILE = "Phase";
|
||||||
|
private static final String REAL_TAB_TILE = "Partie réelle";
|
||||||
|
private static final String IMAGINARY_TAB_TILE = "Partie imaginaire";
|
||||||
|
|
||||||
private double normalizedWhite;
|
private double normalizedWhite;
|
||||||
private double normalizedBlack;
|
private double normalizedBlack;
|
||||||
|
|
||||||
private boolean isUpdating = false;
|
private boolean isUpdating = false;
|
||||||
|
|
||||||
private JTabbedPane modeTab;
|
private TabbedImagePanel modeTab;
|
||||||
private ImagePanel modulePreviewContainer;
|
|
||||||
private ImagePanel phasePreviewContainer;
|
|
||||||
private ImagePanel realPreviewContainer;
|
|
||||||
private ImagePanel imaginaryPreviewContainer;
|
|
||||||
|
|
||||||
private JSlider whiteSlider;
|
private JSlider whiteSlider;
|
||||||
private JTextField whiteTextField;
|
private JTextField whiteTextField;
|
||||||
@@ -40,20 +43,21 @@ public class DoubleMatrix extends AbstractView implements IDoubleMatrix
|
|||||||
private JLabel minLabel;
|
private JLabel minLabel;
|
||||||
|
|
||||||
private final DoubleMatrixPresenter presenter;
|
private final DoubleMatrixPresenter presenter;
|
||||||
|
private final TabbedPanelFactory tabbedPanelFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DoubleMatrix(DoubleMatrixPresenter presenter)
|
public DoubleMatrix(
|
||||||
|
DoubleMatrixPresenter presenter,
|
||||||
|
TabbedPanelFactory tabbedPanelFactory
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this.presenter = presenter;
|
this.presenter = presenter;
|
||||||
|
this.tabbedPanelFactory = tabbedPanelFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initComponents() {
|
public void initComponents() {
|
||||||
this.presenter.setView(this);
|
this.presenter.setView(this);
|
||||||
this.modulePreviewContainer = new ImagePanel();
|
|
||||||
this.phasePreviewContainer = new ImagePanel();
|
|
||||||
this.realPreviewContainer = new ImagePanel();
|
|
||||||
this.imaginaryPreviewContainer = new ImagePanel();
|
|
||||||
|
|
||||||
blackSlider = buildSlider();
|
blackSlider = buildSlider();
|
||||||
whiteSlider = buildSlider();
|
whiteSlider = buildSlider();
|
||||||
@@ -115,13 +119,15 @@ public class DoubleMatrix extends AbstractView implements IDoubleMatrix
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JTabbedPane buildModeTab(){
|
private TabbedImagePanel buildModeTab(){
|
||||||
|
|
||||||
|
TabbedImagePanel modeTabs = tabbedPanelFactory.createTabbedImagePanel(
|
||||||
|
MODULE_TAB_TILE,
|
||||||
|
PHASE_TAB_TILE,
|
||||||
|
REAL_TAB_TILE,
|
||||||
|
IMAGINARY_TAB_TILE
|
||||||
|
);
|
||||||
|
|
||||||
JTabbedPane modeTabs = new JTabbedPane();
|
|
||||||
modeTabs.addTab("Module", modulePreviewContainer);
|
|
||||||
modeTabs.addTab("Phase", phasePreviewContainer);
|
|
||||||
modeTabs.addTab("Partie réelle", realPreviewContainer);
|
|
||||||
modeTabs.addTab("Partie imaginaire", imaginaryPreviewContainer);
|
|
||||||
modeTabs.addChangeListener(e -> {
|
modeTabs.addChangeListener(e -> {
|
||||||
switch (modeTabs.getSelectedIndex()) {
|
switch (modeTabs.getSelectedIndex()) {
|
||||||
case 0 -> presenter.loadModule();
|
case 0 -> presenter.loadModule();
|
||||||
@@ -265,27 +271,27 @@ public class DoubleMatrix extends AbstractView implements IDoubleMatrix
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateModule(GrayScaleMatrix source, GrayScaleMatrix matrix) {
|
public void updateModule(GrayScaleMatrix source, GrayScaleMatrix matrix) {
|
||||||
updatePreview(modulePreviewContainer, source, matrix);
|
updatePreview(MODULE_TAB_TILE, source, matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePhase(GrayScaleMatrix source, GrayScaleMatrix matrix) {
|
public void updatePhase(GrayScaleMatrix source, GrayScaleMatrix matrix) {
|
||||||
updatePreview(phasePreviewContainer, source, matrix);
|
updatePreview(PHASE_TAB_TILE, source, matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateReal(GrayScaleMatrix source, GrayScaleMatrix matrix) {
|
public void updateReal(GrayScaleMatrix source, GrayScaleMatrix matrix) {
|
||||||
updatePreview(realPreviewContainer, source, matrix);
|
updatePreview(REAL_TAB_TILE, source, matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateImaginary(GrayScaleMatrix source, GrayScaleMatrix matrix) {
|
public void updateImaginary(GrayScaleMatrix source, GrayScaleMatrix matrix) {
|
||||||
updatePreview(imaginaryPreviewContainer, source, matrix);
|
updatePreview(IMAGINARY_TAB_TILE, source, matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePreview(ImagePanel imagePanel, GrayScaleMatrix source, GrayScaleMatrix matrix) {
|
private void updatePreview(String tabTitle, GrayScaleMatrix source, GrayScaleMatrix matrix) {
|
||||||
try {
|
try {
|
||||||
imagePanel.loadImage(matrix);
|
modeTab.loadImage(tabTitle, matrix.toImage());
|
||||||
updateLabels(source.getMinValue(), source.getMaxValue());
|
updateLabels(source.getMinValue(), source.getMaxValue());
|
||||||
updateTextFields(
|
updateTextFields(
|
||||||
presenter.getValueAt(source, normalizedBlack),
|
presenter.getValueAt(source, normalizedBlack),
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import ui.implementation.components.controls.IntensitySlider;
|
|||||||
import ui.implementation.components.controls.SaveButton;
|
import ui.implementation.components.controls.SaveButton;
|
||||||
import ui.abstractions.IGlobalFilteringView;
|
import ui.abstractions.IGlobalFilteringView;
|
||||||
import ui.implementation.components.image.TabbedImagePanel;
|
import ui.implementation.components.image.TabbedImagePanel;
|
||||||
|
import ui.implementation.components.image.TabbedPanelFactory;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
@@ -16,6 +17,7 @@ public class IdealFilteringView extends AbstractView implements IGlobalFiltering
|
|||||||
|
|
||||||
private final static String LOW_PASS_TAB_TITLE = "Passe-bas";
|
private final static String LOW_PASS_TAB_TITLE = "Passe-bas";
|
||||||
private final static String HIGH_PASS_TAB_TITLE = "Passe-haut";
|
private final static String HIGH_PASS_TAB_TITLE = "Passe-haut";
|
||||||
|
private final TabbedPanelFactory tabbedPanelFactory;
|
||||||
|
|
||||||
private TabbedImagePanel modeTab;
|
private TabbedImagePanel modeTab;
|
||||||
private IntensitySlider intensitySlider;
|
private IntensitySlider intensitySlider;
|
||||||
@@ -24,8 +26,12 @@ public class IdealFilteringView extends AbstractView implements IGlobalFiltering
|
|||||||
private boolean isUpdating;
|
private boolean isUpdating;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public IdealFilteringView(GlobalFilteringPresenter presenter) {
|
public IdealFilteringView(
|
||||||
|
GlobalFilteringPresenter presenter,
|
||||||
|
TabbedPanelFactory tabbedPanelFactory
|
||||||
|
) {
|
||||||
this.presenter = presenter;
|
this.presenter = presenter;
|
||||||
|
this.tabbedPanelFactory = tabbedPanelFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -143,11 +149,10 @@ public class IdealFilteringView extends AbstractView implements IGlobalFiltering
|
|||||||
this.intensitySlider = new IntensitySlider(0, 1000);
|
this.intensitySlider = new IntensitySlider(0, 1000);
|
||||||
this.intensitySlider.setOrientation(JSlider.VERTICAL);
|
this.intensitySlider.setOrientation(JSlider.VERTICAL);
|
||||||
|
|
||||||
this.modeTab = new TabbedImagePanel();
|
this.modeTab = tabbedPanelFactory.createTabbedImagePanel(
|
||||||
this.modeTab.addPreviewTab(LOW_PASS_TAB_TITLE);
|
LOW_PASS_TAB_TITLE,
|
||||||
this.modeTab.addPreviewTab(HIGH_PASS_TAB_TITLE);
|
HIGH_PASS_TAB_TITLE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
buildLayout(modeTab, intensityLabel, intensitySlider);
|
buildLayout(modeTab, intensityLabel, intensitySlider);
|
||||||
setTitle("Filtre idéal");
|
setTitle("Filtre idéal");
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import ui.abstractions.IGlobalFilteringView;
|
|||||||
import ui.implementation.components.controls.IntensitySlider;
|
import ui.implementation.components.controls.IntensitySlider;
|
||||||
import ui.implementation.components.controls.SaveButton;
|
import ui.implementation.components.controls.SaveButton;
|
||||||
import ui.implementation.components.image.TabbedImagePanel;
|
import ui.implementation.components.image.TabbedImagePanel;
|
||||||
|
import ui.implementation.components.image.TabbedPanelFactory;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
@@ -16,6 +17,7 @@ public class NonIdealFilteringView extends AbstractView implements IGlobalFilter
|
|||||||
|
|
||||||
private final static String LOW_PASS_TAB_TITLE = "Passe-bas";
|
private final static String LOW_PASS_TAB_TITLE = "Passe-bas";
|
||||||
private final static String HIGH_PASS_TAB_TITLE = "Passe-haut";
|
private final static String HIGH_PASS_TAB_TITLE = "Passe-haut";
|
||||||
|
private final TabbedPanelFactory tabbedPanelFactory;
|
||||||
|
|
||||||
private TabbedImagePanel modeTab;
|
private TabbedImagePanel modeTab;
|
||||||
private IntensitySlider intensitySlider;
|
private IntensitySlider intensitySlider;
|
||||||
@@ -26,8 +28,12 @@ public class NonIdealFilteringView extends AbstractView implements IGlobalFilter
|
|||||||
private boolean isUpdating;
|
private boolean isUpdating;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NonIdealFilteringView(GlobalFilteringPresenter presenter) {
|
public NonIdealFilteringView(
|
||||||
|
GlobalFilteringPresenter presenter,
|
||||||
|
TabbedPanelFactory tabbedPanelFactory
|
||||||
|
) {
|
||||||
this.presenter = presenter;
|
this.presenter = presenter;
|
||||||
|
this.tabbedPanelFactory = tabbedPanelFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildLayout(JTabbedPane modeTab) {
|
private void buildLayout(JTabbedPane modeTab) {
|
||||||
@@ -168,9 +174,10 @@ public class NonIdealFilteringView extends AbstractView implements IGlobalFilter
|
|||||||
this.orderSlider = new IntensitySlider(0, 10);
|
this.orderSlider = new IntensitySlider(0, 10);
|
||||||
this.orderSlider.setOrientation(JSlider.VERTICAL);
|
this.orderSlider.setOrientation(JSlider.VERTICAL);
|
||||||
|
|
||||||
this.modeTab = new TabbedImagePanel();
|
this.modeTab = tabbedPanelFactory.createTabbedImagePanel(
|
||||||
this.modeTab.addPreviewTab(LOW_PASS_TAB_TITLE);
|
LOW_PASS_TAB_TITLE,
|
||||||
this.modeTab.addPreviewTab(HIGH_PASS_TAB_TITLE);
|
HIGH_PASS_TAB_TITLE
|
||||||
|
);
|
||||||
|
|
||||||
buildLayout(modeTab);
|
buildLayout(modeTab);
|
||||||
setTitle("Filtre non-idéal");
|
setTitle("Filtre non-idéal");
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import ui.abstractions.AbstractView;
|
|||||||
import ui.abstractions.ILocalFilteringView;
|
import ui.abstractions.ILocalFilteringView;
|
||||||
import ui.implementation.components.controls.SaveButton;
|
import ui.implementation.components.controls.SaveButton;
|
||||||
import ui.implementation.components.image.TabbedImagePanel;
|
import ui.implementation.components.image.TabbedImagePanel;
|
||||||
|
import ui.implementation.components.image.TabbedPanelFactory;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -16,6 +17,7 @@ public class LocalFilteringView extends AbstractView implements ILocalFilteringV
|
|||||||
private static final String MEAN_TAB_TITLE = "Moyenneur";
|
private static final String MEAN_TAB_TITLE = "Moyenneur";
|
||||||
|
|
||||||
private final LocalFilteringPresenter presenter;
|
private final LocalFilteringPresenter presenter;
|
||||||
|
private final TabbedPanelFactory tabbedPanelFactory;
|
||||||
|
|
||||||
private TabbedImagePanel modeTab;
|
private TabbedImagePanel modeTab;
|
||||||
|
|
||||||
@@ -26,15 +28,17 @@ public class LocalFilteringView extends AbstractView implements ILocalFilteringV
|
|||||||
private JTextField meanSizeField;
|
private JTextField meanSizeField;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public LocalFilteringView(LocalFilteringPresenter presenter) {
|
public LocalFilteringView(
|
||||||
|
LocalFilteringPresenter presenter,
|
||||||
|
TabbedPanelFactory tabbedPanelFactory
|
||||||
|
) {
|
||||||
this.presenter = presenter;
|
this.presenter = presenter;
|
||||||
|
this.tabbedPanelFactory = tabbedPanelFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initComponents() {
|
public void initComponents() {
|
||||||
modeTab = new TabbedImagePanel();
|
modeTab = tabbedPanelFactory.createTabbedImagePanel(CONVOLUTION_TAB_TITLE, MEAN_TAB_TITLE);
|
||||||
modeTab.addPreviewTab(CONVOLUTION_TAB_TITLE);
|
|
||||||
modeTab.addPreviewTab(MEAN_TAB_TITLE);
|
|
||||||
|
|
||||||
convolutionSizeField = new JTextField("3", 5);
|
convolutionSizeField = new JTextField("3", 5);
|
||||||
JButton createMaskButton = new JButton("Créer le masque");
|
JButton createMaskButton = new JButton("Créer le masque");
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import presenters.morphology.BasicMorphologyPresenter;
|
|||||||
import ui.abstractions.AbstractView;
|
import ui.abstractions.AbstractView;
|
||||||
import ui.abstractions.IBasicMorphologyView;
|
import ui.abstractions.IBasicMorphologyView;
|
||||||
import ui.implementation.components.image.TabbedImagePanel;
|
import ui.implementation.components.image.TabbedImagePanel;
|
||||||
|
import ui.implementation.components.image.TabbedPanelFactory;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -18,23 +19,29 @@ public class BasicMorphologyView extends AbstractView implements IBasicMorpholog
|
|||||||
private static final String CLOSING_TAB_TITLE = "Fermeture";
|
private static final String CLOSING_TAB_TITLE = "Fermeture";
|
||||||
|
|
||||||
private final BasicMorphologyPresenter presenter;
|
private final BasicMorphologyPresenter presenter;
|
||||||
|
private final TabbedPanelFactory tabbedPanelFactory;
|
||||||
|
|
||||||
private TabbedImagePanel modeTab;
|
private TabbedImagePanel modeTab;
|
||||||
private JSpinner maskSizeSpinner;
|
private JSpinner maskSizeSpinner;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BasicMorphologyView(BasicMorphologyPresenter presenter) {
|
public BasicMorphologyView(
|
||||||
|
BasicMorphologyPresenter presenter,
|
||||||
|
TabbedPanelFactory tabbedPanelFactory
|
||||||
|
|
||||||
|
) {
|
||||||
this.presenter = presenter;
|
this.presenter = presenter;
|
||||||
|
this.tabbedPanelFactory = tabbedPanelFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initComponents() {
|
public void initComponents() {
|
||||||
modeTab = new TabbedImagePanel();
|
modeTab = tabbedPanelFactory.createTabbedImagePanel(
|
||||||
|
EROSION_TAB_TITLE,
|
||||||
modeTab.addPreviewTab(EROSION_TAB_TITLE);
|
DILATION_TAB_TITLE,
|
||||||
modeTab.addPreviewTab(DILATION_TAB_TITLE);
|
OPENING_TAB_TITLE,
|
||||||
modeTab.addPreviewTab(OPENING_TAB_TITLE);
|
CLOSING_TAB_TITLE
|
||||||
modeTab.addPreviewTab(CLOSING_TAB_TITLE);
|
);
|
||||||
|
|
||||||
maskSizeSpinner = new JSpinner(
|
maskSizeSpinner = new JSpinner(
|
||||||
new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 2)
|
new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 2)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import presenters.morphology.ComplexMorphologyPresenter;
|
|||||||
import ui.abstractions.AbstractView;
|
import ui.abstractions.AbstractView;
|
||||||
import ui.abstractions.IComplexMorphologyView;
|
import ui.abstractions.IComplexMorphologyView;
|
||||||
import ui.implementation.components.image.TabbedImagePanel;
|
import ui.implementation.components.image.TabbedImagePanel;
|
||||||
|
import ui.implementation.components.image.TabbedPanelFactory;
|
||||||
import ui.implementation.components.intent.FileChooser;
|
import ui.implementation.components.intent.FileChooser;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -22,6 +23,7 @@ public class ComplexMorphologyView extends AbstractView implements IComplexMorph
|
|||||||
private static final String MEDIAN_TAB_TITLE = "Filtre médian";
|
private static final String MEDIAN_TAB_TITLE = "Filtre médian";
|
||||||
|
|
||||||
private final ComplexMorphologyPresenter presenter;
|
private final ComplexMorphologyPresenter presenter;
|
||||||
|
private final TabbedPanelFactory tabbedPanelFactory;
|
||||||
|
|
||||||
private TabbedImagePanel modeTab;
|
private TabbedImagePanel modeTab;
|
||||||
|
|
||||||
@@ -30,22 +32,25 @@ public class ComplexMorphologyView extends AbstractView implements IComplexMorph
|
|||||||
private JSpinner iterationsSpinner;
|
private JSpinner iterationsSpinner;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ComplexMorphologyView(ComplexMorphologyPresenter presenter) {
|
public ComplexMorphologyView(
|
||||||
|
ComplexMorphologyPresenter presenter,
|
||||||
|
TabbedPanelFactory tabbedPanelFactory
|
||||||
|
|
||||||
|
) {
|
||||||
this.presenter = presenter;
|
this.presenter = presenter;
|
||||||
|
this.tabbedPanelFactory = tabbedPanelFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initComponents() {
|
public void initComponents() {
|
||||||
modeTab = new TabbedImagePanel();
|
modeTab = tabbedPanelFactory.createTabbedImagePanel(
|
||||||
|
DILATION_TAB_TITLE,
|
||||||
modeTab.addPreviewTab(DILATION_TAB_TITLE);
|
RECONSTRUCTION_TAB_TITLE,
|
||||||
modeTab.addPreviewTab(RECONSTRUCTION_TAB_TITLE);
|
MEDIAN_TAB_TITLE
|
||||||
modeTab.addPreviewTab(MEDIAN_TAB_TITLE);
|
|
||||||
|
|
||||||
iterationsSpinner = new JSpinner(
|
|
||||||
new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
iterationsSpinner = new JSpinner(new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1));
|
||||||
|
|
||||||
maskButton = new JButton("Choisir...");
|
maskButton = new JButton("Choisir...");
|
||||||
maskLabel = new JLabel("Aucun masque");
|
maskLabel = new JLabel("Aucun masque");
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import presenters.outline.LinearOutlinePresenter;
|
|||||||
import ui.abstractions.AbstractView;
|
import ui.abstractions.AbstractView;
|
||||||
import ui.abstractions.ILinearOutlineView;
|
import ui.abstractions.ILinearOutlineView;
|
||||||
import ui.implementation.components.image.TabbedImagePanel;
|
import ui.implementation.components.image.TabbedImagePanel;
|
||||||
|
import ui.implementation.components.image.TabbedPanelFactory;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
@@ -17,23 +18,28 @@ public class LinearOutlineView extends AbstractView implements ILinearOutlineVie
|
|||||||
private static final String LAPLACIAN8_TAB_TITLE = "Laplacien 8";
|
private static final String LAPLACIAN8_TAB_TITLE = "Laplacien 8";
|
||||||
|
|
||||||
private final LinearOutlinePresenter presenter;
|
private final LinearOutlinePresenter presenter;
|
||||||
|
private final TabbedPanelFactory tabbedPanelFactory;
|
||||||
|
|
||||||
private TabbedImagePanel modeTab;
|
private TabbedImagePanel modeTab;
|
||||||
private JComboBox<String> directionComboBox;
|
private JComboBox<String> directionComboBox;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public LinearOutlineView(LinearOutlinePresenter presenter) {
|
public LinearOutlineView(
|
||||||
|
LinearOutlinePresenter presenter,
|
||||||
|
TabbedPanelFactory tabbedPanelFactory
|
||||||
|
) {
|
||||||
|
this.tabbedPanelFactory = tabbedPanelFactory;
|
||||||
this.presenter = presenter;
|
this.presenter = presenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initComponents() {
|
public void initComponents() {
|
||||||
modeTab = new TabbedImagePanel();
|
modeTab = tabbedPanelFactory.createTabbedImagePanel(
|
||||||
|
PREWITT_TAB_TITLE,
|
||||||
modeTab.addPreviewTab(PREWITT_TAB_TITLE);
|
SOBEL_TAB_TITLE,
|
||||||
modeTab.addPreviewTab(SOBEL_TAB_TITLE);
|
LAPLACIAN4_TAB_TITLE,
|
||||||
modeTab.addPreviewTab(LAPLACIAN4_TAB_TITLE);
|
LAPLACIAN8_TAB_TITLE
|
||||||
modeTab.addPreviewTab(LAPLACIAN8_TAB_TITLE);
|
);
|
||||||
|
|
||||||
directionComboBox = new JComboBox<>( new String[]{ "Horizontale", "Verticale" } );
|
directionComboBox = new JComboBox<>( new String[]{ "Horizontale", "Verticale" } );
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import presenters.outline.NonLinearOutlinePresenter;
|
|||||||
import ui.abstractions.AbstractView;
|
import ui.abstractions.AbstractView;
|
||||||
import ui.abstractions.INonLinearOutlineView;
|
import ui.abstractions.INonLinearOutlineView;
|
||||||
import ui.implementation.components.image.TabbedImagePanel;
|
import ui.implementation.components.image.TabbedImagePanel;
|
||||||
|
import ui.implementation.components.image.TabbedPanelFactory;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
@@ -17,22 +18,28 @@ public class NonLinearOutlineView extends AbstractView implements INonLinearOutl
|
|||||||
private static final String NON_LINEAR_LAPLACIAN_TAB_TITLE = "Laplacien non-linéaire";
|
private static final String NON_LINEAR_LAPLACIAN_TAB_TITLE = "Laplacien non-linéaire";
|
||||||
|
|
||||||
private final NonLinearOutlinePresenter presenter;
|
private final NonLinearOutlinePresenter presenter;
|
||||||
|
private final TabbedPanelFactory tabbedPanelFactory;
|
||||||
|
|
||||||
private TabbedImagePanel modeTab;
|
private TabbedImagePanel modeTab;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NonLinearOutlineView(NonLinearOutlinePresenter presenter) {
|
public NonLinearOutlineView(
|
||||||
|
NonLinearOutlinePresenter presenter,
|
||||||
|
TabbedPanelFactory tabbedPanelFactory
|
||||||
|
|
||||||
|
) {
|
||||||
this.presenter = presenter;
|
this.presenter = presenter;
|
||||||
|
this.tabbedPanelFactory = tabbedPanelFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initComponents() {
|
public void initComponents() {
|
||||||
modeTab = new TabbedImagePanel();
|
modeTab = tabbedPanelFactory.createTabbedImagePanel(
|
||||||
|
EROSION_GRADIENT_TAB_TITLE,
|
||||||
modeTab.addPreviewTab(EROSION_GRADIENT_TAB_TITLE);
|
DILATION_GRADIENT_TAB_TITLE,
|
||||||
modeTab.addPreviewTab(DILATION_GRADIENT_TAB_TITLE);
|
BEUCHER_GRADIENT_TAB_TITLE,
|
||||||
modeTab.addPreviewTab(BEUCHER_GRADIENT_TAB_TITLE);
|
NON_LINEAR_LAPLACIAN_TAB_TITLE
|
||||||
modeTab.addPreviewTab(NON_LINEAR_LAPLACIAN_TAB_TITLE);
|
);
|
||||||
|
|
||||||
JButton applyButton = new JButton("Appliquer");
|
JButton applyButton = new JButton("Appliquer");
|
||||||
applyButton.addActionListener(e -> applyOutline());
|
applyButton.addActionListener(e -> applyOutline());
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import presenters.threshold.ThresholdingPresenter;
|
|||||||
import ui.abstractions.AbstractView;
|
import ui.abstractions.AbstractView;
|
||||||
import ui.abstractions.IThresholdingView;
|
import ui.abstractions.IThresholdingView;
|
||||||
import ui.implementation.components.image.TabbedImagePanel;
|
import ui.implementation.components.image.TabbedImagePanel;
|
||||||
|
import ui.implementation.components.image.TabbedPanelFactory;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ public class ThresholdingView extends AbstractView implements IThresholdingView
|
|||||||
private static final String AUTOMATIC_TAB_TITLE = "Automatique";
|
private static final String AUTOMATIC_TAB_TITLE = "Automatique";
|
||||||
|
|
||||||
private final ThresholdingPresenter presenter;
|
private final ThresholdingPresenter presenter;
|
||||||
|
private final TabbedPanelFactory tabbedPanelFactory;
|
||||||
|
|
||||||
private TabbedImagePanel modeTab;
|
private TabbedImagePanel modeTab;
|
||||||
|
|
||||||
@@ -28,17 +30,21 @@ public class ThresholdingView extends AbstractView implements IThresholdingView
|
|||||||
private JLabel threshold2ValueLabel;
|
private JLabel threshold2ValueLabel;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ThresholdingView(ThresholdingPresenter presenter) {
|
public ThresholdingView(
|
||||||
|
ThresholdingPresenter presenter,
|
||||||
|
TabbedPanelFactory tabbedPanelFactory
|
||||||
|
) {
|
||||||
this.presenter = presenter;
|
this.presenter = presenter;
|
||||||
|
this.tabbedPanelFactory = tabbedPanelFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initComponents() {
|
public void initComponents() {
|
||||||
modeTab = new TabbedImagePanel();
|
modeTab = tabbedPanelFactory.createTabbedImagePanel(
|
||||||
|
SIMPLE_TAB_TITLE,
|
||||||
modeTab.addPreviewTab(SIMPLE_TAB_TITLE);
|
DOUBLE_TAB_TITLE,
|
||||||
modeTab.addPreviewTab(DOUBLE_TAB_TITLE);
|
AUTOMATIC_TAB_TITLE
|
||||||
modeTab.addPreviewTab(AUTOMATIC_TAB_TITLE);
|
);
|
||||||
|
|
||||||
thresholdSlider = createThresholdSlider(128);
|
thresholdSlider = createThresholdSlider(128);
|
||||||
threshold1Slider = createThresholdSlider(85);
|
threshold1Slider = createThresholdSlider(85);
|
||||||
@@ -208,17 +214,11 @@ public class ThresholdingView extends AbstractView implements IThresholdingView
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateValueLabels() {
|
private void updateValueLabels() {
|
||||||
thresholdValueLabel.setText(
|
thresholdValueLabel.setText(String.valueOf(thresholdSlider.getValue()));
|
||||||
String.valueOf(thresholdSlider.getValue())
|
|
||||||
);
|
|
||||||
|
|
||||||
threshold1ValueLabel.setText(
|
threshold1ValueLabel.setText(String.valueOf(threshold1Slider.getValue()));
|
||||||
String.valueOf(threshold1Slider.getValue())
|
|
||||||
);
|
|
||||||
|
|
||||||
threshold2ValueLabel.setText(
|
threshold2ValueLabel.setText(String.valueOf(threshold2Slider.getValue()));
|
||||||
String.valueOf(threshold2Slider.getValue())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user