Skip to content

Commit

Permalink
Merge branch 'rt'
Browse files Browse the repository at this point in the history
# Conflicts:
#	weasis-parent/pom.xml
  • Loading branch information
nroduit committed Feb 16, 2024
2 parents 4f550ee + afd4d8a commit 443505e
Show file tree
Hide file tree
Showing 190 changed files with 6,239 additions and 4,380 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@ public SampleTool(Type type) {

@Override
public Component getToolComponent() {
JViewport viewPort = rootPane.getViewport();
if (viewPort == null) {
viewPort = new JViewport();
rootPane.setViewport(viewPort);
}
if (viewPort.getView() != this) {
viewPort.setView(this);
}
return rootPane;
return getToolComponentFromJScrollPane(rootPane);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,7 @@ public SampleTool(Type type) {

@Override
public Component getToolComponent() {
JViewport viewPort = rootPane.getViewport();
if (viewPort == null) {
viewPort = new JViewport();
rootPane.setViewport(viewPort);
}
if (viewPort.getView() != this) {
viewPort.setView(this);
}
return rootPane;
return getToolComponentFromJScrollPane(rootPane);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.Optional;
import javax.swing.BorderFactory;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
import org.weasis.acquire.Messages;
import org.weasis.acquire.dockable.components.AcquireActionButton;
import org.weasis.acquire.dockable.components.AcquireActionButtonsPanel;
Expand Down Expand Up @@ -64,13 +63,7 @@ public EditionTool(Type type) {

@Override
public Component getToolComponent() {
JViewport viewPort = rootPane.getViewport();
rootPane.setViewport(Optional.ofNullable(viewPort).orElseGet(JViewport::new));

if (viewPort != null && viewPort.getView() != this) {
viewPort.setView(this);
}
return rootPane;
return getToolComponentFromJScrollPane(rootPane);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@

import java.awt.event.KeyEvent;
import java.util.Hashtable;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Deactivate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.weasis.acquire.Messages;
import org.weasis.acquire.dockable.components.actions.calibrate.CalibrationPanel;
import org.weasis.base.viewer2d.EventManager;
Expand All @@ -29,6 +24,9 @@
import org.weasis.core.api.gui.util.Feature.BasicActionStateValue;
import org.weasis.core.api.gui.util.Feature.ComboItemListenerValue;
import org.weasis.core.api.gui.util.GuiUtils;
import org.weasis.core.api.media.data.ImageElement;
import org.weasis.core.ui.docking.ExtToolFactory;
import org.weasis.core.ui.editor.image.ImageViewerEventManager;
import org.weasis.core.ui.editor.image.MeasureToolBar;
import org.weasis.core.ui.model.graphic.Graphic;

Expand All @@ -40,9 +38,7 @@
@org.osgi.service.component.annotations.Component(
service = InsertableFactory.class,
property = {"org.weasis.base.viewer2d.View2dContainer=true"})
public class EditionToolFactory implements InsertableFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(EditionToolFactory.class);

public class EditionToolFactory extends ExtToolFactory<ImageElement> {
public static final BasicActionStateValue EDITION =
new BasicActionStateValue(
Messages.getString("edit"), "draw.edition", KeyEvent.VK_G, 0, null) { // NON-NLS
Expand All @@ -55,78 +51,64 @@ public boolean isDrawingAction() {
public static final ComboItemListenerValue<Graphic> DRAW_EDITION =
new ComboItemListenerValue<>("", Feature.DRAW_CMD_PREFIX + EDITION.cmd(), 0, 0, null);

private EditionTool toolPane = null;
public EditionToolFactory() {
super(EditionTool.BUTTON_NAME);
}

@Override
public Type getType() {
return Type.TOOL;
}

@Override
public Insertable createInstance(Hashtable<String, Object> properties) {
if (toolPane == null) {
EventManager eventManager = EventManager.getInstance();

// Remove actions which are not useful
eventManager.removeAction(ActionW.SCROLL_SERIES);
eventManager.removeAction(ActionW.WINLEVEL);
eventManager.removeAction(ActionW.WINDOW);
eventManager.removeAction(ActionW.LEVEL);
eventManager.removeAction(ActionW.ROTATION);
eventManager.removeAction(ActionW.FLIP);
eventManager.removeAction(ActionW.FILTER);
eventManager.removeAction(ActionW.INVERSE_STACK);
eventManager.removeAction(ActionW.INVERT_LUT);
eventManager.removeAction(ActionW.LUT);
eventManager.removeAction(ActionW.LAYOUT);
eventManager.removeAction(ActionW.SYNCH);
GuiUtils.getUICore()
.getSystemPreferences()
.setProperty("weasis.contextmenu.close", Boolean.FALSE.toString());

eventManager.setAction(new BasicActionState(EDITION));
eventManager.setAction(
new ComboItemListener<>(
DRAW_EDITION,
new Graphic[] {
MeasureToolBar.selectionGraphic, CalibrationPanel.CALIBRATION_LINE_GRAPHIC
}) {

@Override
public void itemStateChanged(Object object) {
// Do nothing
}
});
toolPane = new EditionTool(getType());
EventManager.getInstance().addSeriesViewerListener(toolPane);
}
return toolPane;
public boolean isComponentCreatedByThisFactory(Insertable tool) {
return tool instanceof EditionTool;
}

@Override
public void dispose(Insertable tool) {
if (toolPane != null) {
EventManager.getInstance().removeSeriesViewerListener(toolPane);
toolPane = null;
}
protected ImageViewerEventManager<ImageElement> getImageViewerEventManager() {
return EventManager.getInstance();
}

@Override
public boolean isComponentCreatedByThisFactory(Insertable tool) {
return tool instanceof EditionTool;
protected boolean isCompatible(Hashtable<String, Object> properties) {
return true;
}

// ================================================================================
// OSGI service implementation
// ================================================================================
@Override
protected Insertable getInstance(Hashtable<String, Object> properties) {
EventManager eventManager = EventManager.getInstance();

@Activate
protected void activate(ComponentContext context) {
LOGGER.info("Activate the TransformationTool panel");
}
// Remove actions which are not useful
eventManager.removeAction(ActionW.SCROLL_SERIES);
eventManager.removeAction(ActionW.WINLEVEL);
eventManager.removeAction(ActionW.WINDOW);
eventManager.removeAction(ActionW.LEVEL);
eventManager.removeAction(ActionW.ROTATION);
eventManager.removeAction(ActionW.FLIP);
eventManager.removeAction(ActionW.FILTER);
eventManager.removeAction(ActionW.INVERSE_STACK);
eventManager.removeAction(ActionW.INVERT_LUT);
eventManager.removeAction(ActionW.LUT);
eventManager.removeAction(ActionW.LAYOUT);
eventManager.removeAction(ActionW.SYNCH);
GuiUtils.getUICore()
.getSystemPreferences()
.setProperty("weasis.contextmenu.close", Boolean.FALSE.toString());

eventManager.setAction(new BasicActionState(EDITION));
eventManager.setAction(
new ComboItemListener<>(
DRAW_EDITION,
new Graphic[] {
MeasureToolBar.selectionGraphic, CalibrationPanel.CALIBRATION_LINE_GRAPHIC
}) {

@Deactivate
protected void deactivate(ComponentContext context) {
LOGGER.info("Deactivate the TransformationTool panel");
@Override
public void itemStateChanged(Object object) {
// Do nothing
}
});
return new EditionTool(getType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
*/
package org.weasis.acquire.dockable.components.actions.annotate;

import java.awt.Component;
import java.util.Optional;
import java.awt.Window;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
Expand All @@ -19,15 +18,16 @@
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SwingUtilities;
import javax.swing.border.Border;
import org.weasis.acquire.Messages;
import org.weasis.base.viewer2d.EventManager;
import org.weasis.core.api.gui.util.ActionW;
import org.weasis.core.api.gui.util.ComboItemListener;
import org.weasis.core.api.gui.util.GuiUtils;
import org.weasis.core.api.gui.util.ToggleButtonListener;
import org.weasis.core.api.image.util.Unit;
import org.weasis.core.ui.editor.image.dockable.MeasureTool;
import org.weasis.core.ui.pref.PreferenceDialog;
import org.weasis.core.ui.util.ColorLayerUI;
import org.weasis.core.util.StringUtil;

public class AnnotationOptionsPanel extends JPanel {
Expand All @@ -42,27 +42,38 @@ public AnnotationOptionsPanel() {

add(createLineStylePanel());

Optional<ComboItemListener<Unit>> spUnitAction =
EventManager.getInstance().getAction(ActionW.SPATIAL_UNIT);
spUnitAction.ifPresent(
comboItemListener -> {
JLabel label =
new JLabel(org.weasis.core.Messages.getString("MeasureTool.unit") + StringUtil.COLON);
JComboBox<?> unitComboBox = comboItemListener.createCombo(120);
unitComboBox.setSelectedItem(Unit.PIXEL);
add(GuiUtils.getFlowLayoutPanel(label, unitComboBox));
});
EventManager.getInstance()
.getAction(ActionW.DRAW_ONLY_ONCE)
.ifPresent(
b -> {
JCheckBox checkDraw = b.createCheckBox(ActionW.DRAW_ONLY_ONCE.getTitle());
checkDraw.setSelected(MeasureTool.viewSetting.isDrawOnlyOnce());
add(GuiUtils.getFlowLayoutPanel(checkDraw));
});

EventManager.getInstance()
.getAction(ActionW.SPATIAL_UNIT)
.ifPresent(
b -> {
JLabel labelUnit =
new JLabel(
org.weasis.core.Messages.getString("MeasureTool.unit") + StringUtil.COLON);
JComboBox<?> unitComboBox = b.createCombo(120);
unitComboBox.setSelectedItem(Unit.PIXEL);
add(GuiUtils.getFlowLayoutPanel(labelUnit, unitComboBox));
});

Optional<ToggleButtonListener> drawOnceAction =
EventManager.getInstance().getAction(ActionW.DRAW_ONLY_ONCE);
drawOnceAction.ifPresent(
toggleButtonListener -> {
JCheckBox checkDraw =
toggleButtonListener.createCheckBox(ActionW.DRAW_ONLY_ONCE.getTitle());
checkDraw.setSelected(MeasureTool.viewSetting.isDrawOnlyOnce());
checkDraw.setAlignmentX(Component.LEFT_ALIGNMENT);
add(GuiUtils.getFlowLayoutPanel(checkDraw));
final JButton btnGeneralOptions =
new JButton(org.weasis.core.Messages.getString("MeasureTool.more_options"));
btnGeneralOptions.addActionListener(
e -> {
Window win = SwingUtilities.getWindowAncestor(AnnotationOptionsPanel.this);
ColorLayerUI layer = ColorLayerUI.createTransparentLayerUI(win.getParent());
PreferenceDialog dialog = new PreferenceDialog(win);
dialog.showPage(MeasureTool.BUTTON_NAME);
ColorLayerUI.showCenterScreen(dialog, layer);
});
add(GuiUtils.getFlowLayoutPanel(btnGeneralOptions));
}

private JPanel createLineStylePanel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,7 @@ public void updateSeries(SeriesGroup seriesGroup, List<AcquireImageInfo> imageIn
setSelected(selected);
}
} else {
// Create series list
btnMap.put(seriesGroup, imageInfos);

SeriesButton btn = new SeriesButton(seriesGroup, this);
btnGrp.add(btn);
seriesList.addButton(btn);

if (selected == null) {
btnGrp.setSelected(btn.getModel(), true);
setSelected(btn);
}
createSeriesList(seriesGroup, imageInfos);
}
}

Expand All @@ -101,17 +91,20 @@ public void addSeriesElement(SeriesGroup seriesGroup, List<AcquireImageInfo> ima
setSelected(selected);
}
} else {
// Create series list
btnMap.put(seriesGroup, imageInfos);
createSeriesList(seriesGroup, imageInfos);
}
}

SeriesButton btn = new SeriesButton(seriesGroup, this);
btnGrp.add(btn);
seriesList.addButton(btn);
private void createSeriesList(SeriesGroup seriesGroup, List<AcquireImageInfo> imageInfos) {
btnMap.put(seriesGroup, imageInfos);

if (selected == null) {
btnGrp.setSelected(btn.getModel(), true);
setSelected(btn);
}
SeriesButton btn = new SeriesButton(seriesGroup, this);
btnGrp.add(btn);
seriesList.addButton(btn);

if (selected == null) {
btnGrp.setSelected(btn.getModel(), true);
setSelected(btn);
}
}

Expand Down
Loading

0 comments on commit 443505e

Please sign in to comment.