Added checkbox to flip the received image in x and y

Updated Readme
This commit is contained in:
ebner 2013-09-20 14:57:00 +02:00
parent b9f28a3eaa
commit 70fd074d19
3 changed files with 62 additions and 8 deletions

View File

@ -15,3 +15,9 @@ Installation
============
To install the plugin into ImageJ just drop the build jar file into the plugins directory of ImageJ. Afterwards (re)start ImageJ.
Usage
=====
While using the ZeroMQ Viewer Plugin ImageJ need to be configured to have more memory. This can be done in the `run` file located in the ImageJ discribution.
Add/Modify following flag: `-Xmx1024m`

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.psi</groupId>
<artifactId>ch.psi.imagej.zeromq</artifactId>
<version>0.0.7</version>
<version>0.0.8</version>
<dependencies>
<dependency>

View File

@ -6,7 +6,9 @@ package ch.psi.imagej.zeromq;
// Mark Rivers, University of Chicago
import ij.*;
import ij.process.*;
import java.awt.*;
import ij.plugin.*;
import java.io.IOException;
@ -29,13 +31,15 @@ import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
public class ZeroMQViewer implements PlugIn {
private static final Logger logger = Logger.getLogger(ZeroMQViewer.class.getName());
private ImagePlus img;
private boolean flipX = false;
private boolean flipY = false;
private int imageSizeX = 2560;
private int imageSizeY = 2160;
@ -69,6 +73,10 @@ public class ZeroMQViewer implements PlugIn {
private ObjectMapper mapper = new ObjectMapper(new JsonFactory());
private HeaderInfo hinfo = new HeaderInfo();
private JLabel lblFlip;
private JPanel panel;
private JCheckBox chckbxX;
private JCheckBox chckbxY;
public void run(String arg) {
IJ.showStatus("Running ZeroMQ Viewer");
@ -202,7 +210,15 @@ public class ZeroMQViewer implements PlugIn {
// TODO Check whether this is needed
short[] shorts = new short[content.length / 2];
ByteBuffer.wrap(content).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer().get(shorts);
img.getProcessor().setPixels(shorts);
ImageProcessor ip = img.getProcessor();
ip.setPixels(shorts);
if(flipX){
ip.flipHorizontal();
}
if(flipY){
ip.flipVertical();
}
img.updateAndDraw();
numImageUpdates++;
@ -229,9 +245,9 @@ public class ZeroMQViewer implements PlugIn {
frame.getContentPane().add(panel_1, BorderLayout.CENTER);
GridBagLayout gbl_panel_1 = new GridBagLayout();
gbl_panel_1.columnWidths = new int[] { 0, 0, 0 };
gbl_panel_1.rowHeights = new int[] { 0, 0, 0, 0, 0, 0 };
gbl_panel_1.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0 };
gbl_panel_1.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
gbl_panel_1.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
gbl_panel_1.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
panel_1.setLayout(gbl_panel_1);
lblHostname = new JLabel("Hostname");
@ -322,10 +338,42 @@ public class ZeroMQViewer implements PlugIn {
}
}
});
lblFlip = new JLabel("Flip");
GridBagConstraints gbc_lblFlip = new GridBagConstraints();
gbc_lblFlip.insets = new Insets(0, 0, 5, 5);
gbc_lblFlip.gridx = 0;
gbc_lblFlip.gridy = 4;
panel_1.add(lblFlip, gbc_lblFlip);
panel = new JPanel();
GridBagConstraints gbc_panel = new GridBagConstraints();
gbc_panel.insets = new Insets(0, 0, 5, 0);
gbc_panel.fill = GridBagConstraints.BOTH;
gbc_panel.gridx = 1;
gbc_panel.gridy = 4;
panel_1.add(panel, gbc_panel);
chckbxX = new JCheckBox("X");
chckbxX.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flipX = chckbxX.isSelected();
}
});
panel.add(chckbxX);
chckbxY = new JCheckBox("Y");
chckbxY.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flipY = chckbxY.isSelected();
}
});
panel.add(chckbxY);
GridBagConstraints gbc_btnStart = new GridBagConstraints();
gbc_btnStart.anchor = GridBagConstraints.WEST;
gbc_btnStart.gridx = 1;
gbc_btnStart.gridy = 4;
gbc_btnStart.gridy = 5;
panel_1.add(btnStart, gbc_btnStart);
// Display the window.