Skip to content
Snippets Groups Projects
Commit 4f57ea6f authored by Stéphane  DALLONGEVILLE's avatar Stéphane DALLONGEVILLE
Browse files

Merge branch 'update-plugin' into 'master'

Update POM, remove truly unnecessary boxing/unboxing variables and add some readability

See merge request !3
parents 7ce0670d acc03880
Branches master
Tags v1.0.3
1 merge request!3Update POM, remove truly unnecessary boxing/unboxing variables and add some readability
......@@ -4,3 +4,7 @@
target/
*.class
*.jar
# IntelliJ working directory & files
.idea/
*.iml
\ No newline at end of file
......@@ -6,12 +6,12 @@
<parent>
<groupId>org.bioimageanalysis.icy</groupId>
<artifactId>parent-pom-plugin</artifactId>
<version>1.0.3</version>
<artifactId>pom-icy</artifactId>
<version>2.1.0</version>
</parent>
<artifactId>color-bar</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
<packaging>jar</packaging>
......@@ -20,13 +20,27 @@
Display the colormap over the image using an overlay.
</description>
<organization>
<name>Institut Pasteur</name>
<url>https://www.pasteur.fr/</url>
</organization>
<licenses>
<license>
<name>GNU GPLv3</name>
<url>https://www.gnu.org/licenses/gpl-3.0.en.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<dependencies>
</dependencies>
<repositories>
<repository>
<id>icy</id>
<name>Icy's Nexus</name>
<url>https://icy-nexus.pasteur.fr/repository/Icy/</url>
</repository>
</repositories>
</project>
\ No newline at end of file
</project>
......@@ -93,7 +93,8 @@ public class ColorBarOverlay extends Overlay implements SettingChangeListener
@Override
public void paint(Graphics2D g, Sequence sequence, IcyCanvas canvas)
{
if ((canvas != null) && (g != null) && (canvas instanceof IcyCanvas2D))
// Unnecessary (canvas != null) condition
if ((g != null) && (canvas instanceof IcyCanvas2D))
{
final LUT lut = canvas.getLut();
......@@ -129,7 +130,7 @@ public class ColorBarOverlay extends Overlay implements SettingChangeListener
h *= scale;
x = region.x;
x += (region.width / 2) - (w / 2);
x += (region.width / 2d) - (w / 2);
x += offsetX;
if (position == ColorBarPosition.BOTTOM)
{
......@@ -164,7 +165,7 @@ public class ColorBarOverlay extends Overlay implements SettingChangeListener
}
x += offsetX;
y = region.y;
y += (region.height / 2) - (h / 2);
y += (region.height / 2d) - (h / 2);
y += offsetY;
break;
}
......@@ -197,7 +198,7 @@ public class ColorBarOverlay extends Overlay implements SettingChangeListener
for (int i = 0; i < (int) w; i++)
{
final int colorInd = (int) Math.round(i * ratio);
g2.setColor(colorMap.getColor((int) Math.min(255, Math.max(0, colorInd))));
g2.setColor(colorMap.getColor(Math.min(255, Math.max(0, colorInd))));
g2.fillRect(xi + 1 + i, yi + 1, 1, hi - 1);
}
......@@ -238,7 +239,6 @@ public class ColorBarOverlay extends Overlay implements SettingChangeListener
for (int c = 0; c < numChannel; c++)
{
final IcyColorMap colorMap = lut.getLutChannel(c).getColorMap();
;
// draw white background
g2.setColor(Color.white);
......@@ -248,7 +248,7 @@ public class ColorBarOverlay extends Overlay implements SettingChangeListener
for (int i = 0; i < hi; i++)
{
final int colorInd = (int) Math.round(((hi - 1) - i) * ratio);
g2.setColor(colorMap.getColor((int) Math.min(255, Math.max(0, colorInd))));
g2.setColor(colorMap.getColor(Math.min(255, Math.max(0, colorInd))));
g2.fillRect(xi + 1, yi + 1 + i, wi - 1, 1);
}
......@@ -405,16 +405,24 @@ public class ColorBarOverlay extends Overlay implements SettingChangeListener
final String propertyName = event.getPropertyName();
final Object value = event.getNewValue();
if (propertyName.equals(ColorBarSettingPanel.PROPERTY_DISPLAY_MINMAX))
prefs.putBoolean(ColorBarSettingPanel.PROPERTY_DISPLAY_MINMAX, ((Boolean) value).booleanValue());
else if (propertyName.equals(ColorBarSettingPanel.PROPERTY_OFFSET_X))
prefs.putDouble(ColorBarSettingPanel.PROPERTY_OFFSET_X, ((Double) value).doubleValue());
else if (propertyName.equals(ColorBarSettingPanel.PROPERTY_OFFSET_Y))
prefs.putDouble(ColorBarSettingPanel.PROPERTY_OFFSET_Y, ((Double) value).doubleValue());
else if (propertyName.equals(ColorBarSettingPanel.PROPERTY_POSITION))
prefs.putInt(ColorBarSettingPanel.PROPERTY_POSITION, ((ColorBarPosition) value).ordinal());
else if (propertyName.equals(ColorBarSettingPanel.PROPERTY_SCALE))
prefs.putDouble(ColorBarSettingPanel.PROPERTY_SCALE, ((Double) value).doubleValue());
// More readable than "if-else-if" block
switch (propertyName) {
case ColorBarSettingPanel.PROPERTY_DISPLAY_MINMAX:
prefs.putBoolean(ColorBarSettingPanel.PROPERTY_DISPLAY_MINMAX, ((Boolean) value).booleanValue());
break;
case ColorBarSettingPanel.PROPERTY_OFFSET_X:
prefs.putDouble(ColorBarSettingPanel.PROPERTY_OFFSET_X, ((Double) value).doubleValue());
break;
case ColorBarSettingPanel.PROPERTY_OFFSET_Y:
prefs.putDouble(ColorBarSettingPanel.PROPERTY_OFFSET_Y, ((Double) value).doubleValue());
break;
case ColorBarSettingPanel.PROPERTY_POSITION:
prefs.putInt(ColorBarSettingPanel.PROPERTY_POSITION, ((ColorBarPosition) value).ordinal());
break;
case ColorBarSettingPanel.PROPERTY_SCALE:
prefs.putDouble(ColorBarSettingPanel.PROPERTY_SCALE, ((Double) value).doubleValue());
break;
}
}
// redraw the colorbar
......
......@@ -36,7 +36,7 @@ public class ColorBarSettingPanel extends JPanel implements ActionListener, Chan
public final static String PROPERTY_OFFSET_Y = "offsetY";
public final static String PROPERTY_DISPLAY_MINMAX = "displayMinMax";
protected JComboBox positionComboBox;
protected JComboBox<ColorBarPosition> positionComboBox;
protected JSlider offsetXSlider;
protected JSlider offsetYSlider;
protected JSlider scaleSlider;
......@@ -53,9 +53,9 @@ public class ColorBarSettingPanel extends JPanel implements ActionListener, Chan
initialize();
positionComboBox.setSelectedItem(ColorBarPosition.RIGHT);
offsetXSlider.setValue(Integer.valueOf(0));
offsetYSlider.setValue(Integer.valueOf(0));
scaleSlider.setValue(Integer.valueOf(100));
offsetXSlider.setValue(0);
offsetYSlider.setValue(0);
scaleSlider.setValue(100);
minMaxCheckBox.setSelected(true);
positionComboBox.addActionListener(this);
......@@ -95,9 +95,9 @@ public class ColorBarSettingPanel extends JPanel implements ActionListener, Chan
gbc_lblPosition.gridy = 0;
add(lblPosition, gbc_lblPosition);
positionComboBox = new JComboBox();
positionComboBox = new JComboBox<>();
positionComboBox.setToolTipText("Position of the color bar");
positionComboBox.setModel(new DefaultComboBoxModel(ColorBarPosition.values()));
positionComboBox.setModel(new DefaultComboBoxModel<>(ColorBarPosition.values()));
GridBagConstraints gbc_positionComboBox = new GridBagConstraints();
gbc_positionComboBox.fill = GridBagConstraints.HORIZONTAL;
gbc_positionComboBox.gridwidth = 2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment