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