Skip to content

Commit

Permalink
MIP rebuild resets the image preset #528
Browse files Browse the repository at this point in the history
  • Loading branch information
nroduit committed Apr 17, 2024
1 parent 3860a9f commit c7d4f12
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.weasis.core.api.util.ResourceUtil.OtherIcon;
import org.weasis.core.ui.docking.PluginTool;
import org.weasis.core.util.StringUtil;
import org.weasis.dicom.viewer2d.dockable.ImageTool;
import org.weasis.dicom.viewer3d.ActionVol;
import org.weasis.dicom.viewer3d.EventManager;
import org.weasis.dicom.viewer3d.Messages;
Expand Down Expand Up @@ -66,54 +67,7 @@ public Component getToolComponent() {

private JPanel getWindowLevelPanel() {
int gabY = 7;
JPanel winLevelPanel = GuiUtils.getVerticalBoxLayoutPanel();
winLevelPanel.setBorder(
BorderFactory.createCompoundBorder(
spaceY,
GuiUtils.getTitledBorder(
org.weasis.dicom.viewer2d.Messages.getString("ImageTool.wl"))));
EventManager.getInstance()
.getAction(ActionW.WINDOW)
.ifPresent(
sliderItem -> {
JSliderW windowSlider = sliderItem.createSlider(0, true);
GuiUtils.setPreferredWidth(windowSlider, 100);
winLevelPanel.add(windowSlider);
winLevelPanel.add(GuiUtils.boxVerticalStrut(gabY));
});

EventManager.getInstance()
.getAction(ActionW.LEVEL)
.ifPresent(
sliderItem -> {
JSliderW levelSlider = sliderItem.createSlider(0, true);
GuiUtils.setPreferredWidth(levelSlider, 100);
winLevelPanel.add(levelSlider);
winLevelPanel.add(GuiUtils.boxVerticalStrut(gabY));
});

EventManager.getInstance()
.getAction(ActionW.PRESET)
.ifPresent(
comboItem -> {
JLabel presetsLabel = new JLabel(ActionW.PRESET.getTitle() + StringUtil.COLON);
JComboBox<?> presetComboBox = comboItem.createCombo(160);
presetComboBox.setMaximumRowCount(10);
winLevelPanel.add(
GuiUtils.getHorizontalBoxLayoutPanel(5, presetsLabel, presetComboBox));
winLevelPanel.add(GuiUtils.boxVerticalStrut(gabY));
});

EventManager.getInstance()
.getAction(ActionW.LUT_SHAPE)
.ifPresent(
comboItem -> {
JLabel label = new JLabel(ActionW.LUT_SHAPE.getTitle() + StringUtil.COLON);
JComboBox<?> combo = comboItem.createCombo(140);
combo.setMaximumRowCount(10);
winLevelPanel.add(GuiUtils.getHorizontalBoxLayoutPanel(5, label, combo));
winLevelPanel.add(GuiUtils.boxVerticalStrut(gabY));
});
JPanel winLevelPanel = ImageTool.getWindowLevelPanel(EventManager.getInstance(), spaceY, false);

EventManager.getInstance()
.getAction(ActionVol.VOL_PRESET)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
import org.weasis.core.api.util.ResourceUtil.ActionIcon;
import org.weasis.core.api.util.ResourceUtil.OtherIcon;
import org.weasis.core.ui.docking.PluginTool;
import org.weasis.core.ui.editor.image.ImageViewerEventManager;
import org.weasis.core.util.StringUtil;
import org.weasis.dicom.codec.DicomImageElement;
import org.weasis.dicom.viewer2d.EventManager;
import org.weasis.dicom.viewer2d.Messages;
import org.weasis.dicom.viewer2d.ResetTools;
Expand All @@ -53,10 +55,10 @@ public ImageTool(String pluginName) {

private void init() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
add(getWindowLevelPanel());
add(getTransformPanel());
add(getSlicePanel());
add(getResetPanel());
add(getWindowLevelPanel(EventManager.getInstance(), spaceY, true));
add(getTransformPanel(spaceY));
add(getSlicePanel(spaceY));
add(getResetPanel(spaceY));
add(GuiUtils.boxYLastElement(3));
rootPane.setBorder(BorderFactory.createEmptyBorder()); // remove default line
}
Expand All @@ -66,7 +68,7 @@ public Component getToolComponent() {
return getToolComponentFromJScrollPane(rootPane);
}

public JPanel getResetPanel() {
public static JPanel getResetPanel(Border hspace) {
JComboBox<ResetTools> resetComboBox = new JComboBox<>(ResetTools.values());
JButton resetButton = new JButton(ActionW.RESET.getTitle());
resetButton.addActionListener(
Expand All @@ -87,15 +89,15 @@ public JPanel getResetPanel() {
JPanel panel = GuiUtils.getFlowLayoutPanel(resetComboBox, resetButton);
panel.setBorder(
BorderFactory.createCompoundBorder(
spaceY, GuiUtils.getTitledBorder(ActionW.RESET.getTitle())));
hspace, GuiUtils.getTitledBorder(ActionW.RESET.getTitle())));
return panel;
}

public JPanel getSlicePanel() {
public static JPanel getSlicePanel(Border hspace) {
JPanel framePanel = GuiUtils.getVerticalBoxLayoutPanel();
framePanel.setBorder(
BorderFactory.createCompoundBorder(
spaceY, GuiUtils.getTitledBorder(Messages.getString("cine"))));
hspace, GuiUtils.getTitledBorder(Messages.getString("cine"))));

EventManager.getInstance()
.getAction(ActionW.SCROLL_SERIES)
Expand Down Expand Up @@ -146,13 +148,14 @@ public JPanel getSlicePanel() {
return framePanel;
}

public JPanel getWindowLevelPanel() {
public static JPanel getWindowLevelPanel(
ImageViewerEventManager<DicomImageElement> manager, Border hspace, boolean all) {
int gabY = 7;
JPanel winLevelPanel = GuiUtils.getVerticalBoxLayoutPanel();
winLevelPanel.setBorder(
BorderFactory.createCompoundBorder(
spaceY, GuiUtils.getTitledBorder(Messages.getString("ImageTool.wl"))));
EventManager.getInstance()
hspace, GuiUtils.getTitledBorder(Messages.getString("ImageTool.wl"))));
manager
.getAction(ActionW.WINDOW)
.ifPresent(
sliderItem -> {
Expand All @@ -162,7 +165,7 @@ public JPanel getWindowLevelPanel() {
winLevelPanel.add(GuiUtils.boxVerticalStrut(gabY));
});

EventManager.getInstance()
manager
.getAction(ActionW.LEVEL)
.ifPresent(
sliderItem -> {
Expand All @@ -172,7 +175,7 @@ public JPanel getWindowLevelPanel() {
winLevelPanel.add(GuiUtils.boxVerticalStrut(gabY));
});

EventManager.getInstance()
manager
.getAction(ActionW.PRESET)
.ifPresent(
comboItem -> {
Expand All @@ -184,7 +187,7 @@ public JPanel getWindowLevelPanel() {
winLevelPanel.add(GuiUtils.boxVerticalStrut(gabY));
});

EventManager.getInstance()
manager
.getAction(ActionW.LUT_SHAPE)
.ifPresent(
comboItem -> {
Expand All @@ -195,44 +198,47 @@ public JPanel getWindowLevelPanel() {
winLevelPanel.add(GuiUtils.boxVerticalStrut(gabY));
});

EventManager.getInstance()
.getAction(ActionW.LUT)
.ifPresent(
comboItem -> {
JLabel lutLabel = new JLabel(ActionW.LUT.getTitle() + StringUtil.COLON);
JComboBox<?> lutComboBox = comboItem.createCombo(140);
JPanel lutPanel = GuiUtils.getHorizontalBoxLayoutPanel(5, lutLabel, lutComboBox);
EventManager.getInstance()
.getAction(ActionW.INVERT_LUT)
.ifPresent(
toggleButton -> {
FlatSVGIcon icon = ResourceUtil.getIcon(ActionIcon.INVERSE_LUT);
JToggleButton checkBox = toggleButton.createJToggleButton(icon);
checkBox.setPreferredSize(GuiUtils.getBigIconButtonSize(checkBox));
checkBox.setToolTipText(toggleButton.getActionW().getTitle());
lutPanel.add(checkBox);
});
winLevelPanel.add(lutPanel);
winLevelPanel.add(GuiUtils.boxVerticalStrut(gabY));
});
if (all) {
manager
.getAction(ActionW.LUT)
.ifPresent(
comboItem -> {
JLabel lutLabel = new JLabel(ActionW.LUT.getTitle() + StringUtil.COLON);
JComboBox<?> lutComboBox = comboItem.createCombo(140);
JPanel lutPanel = GuiUtils.getHorizontalBoxLayoutPanel(5, lutLabel, lutComboBox);
manager
.getAction(ActionW.INVERT_LUT)
.ifPresent(
toggleButton -> {
FlatSVGIcon icon = ResourceUtil.getIcon(ActionIcon.INVERSE_LUT);
JToggleButton checkBox = toggleButton.createJToggleButton(icon);
checkBox.setPreferredSize(GuiUtils.getBigIconButtonSize(checkBox));
checkBox.setToolTipText(toggleButton.getActionW().getTitle());
lutPanel.add(checkBox);
});
winLevelPanel.add(lutPanel);
winLevelPanel.add(GuiUtils.boxVerticalStrut(gabY));
});

EventManager.getInstance()
.getAction(ActionW.FILTER)
.ifPresent(
comboItem -> {
JLabel label = new JLabel(Messages.getString("ImageTool.filter") + StringUtil.COLON);
JComboBox<?> combo = comboItem.createCombo(160);
winLevelPanel.add(GuiUtils.getHorizontalBoxLayoutPanel(5, label, combo));
winLevelPanel.add(GuiUtils.boxVerticalStrut(5));
});
manager
.getAction(ActionW.FILTER)
.ifPresent(
comboItem -> {
JLabel label =
new JLabel(Messages.getString("ImageTool.filter") + StringUtil.COLON);
JComboBox<?> combo = comboItem.createCombo(160);
winLevelPanel.add(GuiUtils.getHorizontalBoxLayoutPanel(5, label, combo));
winLevelPanel.add(GuiUtils.boxVerticalStrut(5));
});
}
return winLevelPanel;
}

public JPanel getTransformPanel() {
public static JPanel getTransformPanel(Border hspace) {
JPanel transform = GuiUtils.getVerticalBoxLayoutPanel();
transform.setBorder(
BorderFactory.createCompoundBorder(
spaceY, GuiUtils.getTitledBorder(Messages.getString("ImageTool.transform"))));
hspace, GuiUtils.getTitledBorder(Messages.getString("ImageTool.transform"))));

EventManager.getInstance()
.getAction(ActionW.ZOOM)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.swing.JRadioButton;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeListener;
import org.weasis.core.api.gui.Insertable;
Expand All @@ -37,7 +38,9 @@
import org.weasis.core.util.StringUtil;
import org.weasis.dicom.codec.DicomImageElement;
import org.weasis.dicom.codec.utils.DicomMediaUtils;
import org.weasis.dicom.viewer2d.EventManager;
import org.weasis.dicom.viewer2d.Messages;
import org.weasis.dicom.viewer2d.dockable.ImageTool;

public class MipPopup {

Expand Down Expand Up @@ -72,6 +75,7 @@ static JSliderW createSlider(String title, DefaultBoundedRangeModel model) {
}

public static class MipDialog extends JDialog {
private final Border spaceY = GuiUtils.getEmptyBorder(15, 3, 0, 3);
final MipView view;
JSliderW frameSlider;
JSliderW thickness;
Expand Down Expand Up @@ -135,9 +139,11 @@ private void init() {
}
});

ActionListener close = e -> dispose();
ActionListener close = _ -> dispose();

JPanel contentPane = GuiUtils.getVerticalBoxLayoutPanel(framePanel);
JPanel contentPane =
GuiUtils.getVerticalBoxLayoutPanel(
framePanel, ImageTool.getWindowLevelPanel(EventManager.getInstance(), spaceY, false));
contentPane.setBorder(GuiUtils.getEmptyBorder(10, 15, 10, 15));

SliderCineListener sequence =
Expand Down Expand Up @@ -179,7 +185,7 @@ private void init() {

JButton btnExitMipMode = new JButton(Messages.getString("MipPopup.rebuild_series"));
btnExitMipMode.addActionListener(
e -> {
_ -> {
MipView.buildMip(view, true);
dispose();
});
Expand Down
Loading

0 comments on commit c7d4f12

Please sign in to comment.