Skip to content

Commit

Permalink
Merge pull request #70 from nafisahis/GUI-fitting-large-image
Browse files Browse the repository at this point in the history
This adds a scroll bar to fit large images in the GUI window.  This closes #32.
  • Loading branch information
etadobson committed Jul 18, 2018
2 parents 70bb4b4 + 1dde8e6 commit f229583
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/main/java/sc/fiji/coloc/Coloc_2.java
Expand Up @@ -556,6 +556,7 @@ else if (roi != null) {
}
// if we have ROIs/masks, add them to results
if (displayImages) {
swDisplay.displayOriginalImages = true;
RandomAccessibleInterval<T> channel1, channel2;
if (mask != null || roi != null) {
final long[] offset = container.getMaskBBOffset();
Expand Down
23 changes: 16 additions & 7 deletions src/main/java/sc/fiji/coloc/results/SingleWindowDisplay.java
Expand Up @@ -88,7 +88,7 @@ public class SingleWindowDisplay<T extends RealType<T>> extends JFrame
protected static final int WIN_HEIGHT = 600;

// indicates if original images should be displayed or not
protected boolean displayOriginalImages = false;
public boolean displayOriginalImages = false;

// this is the image currently selected by the drop down menu
protected RandomAccessibleInterval<? extends RealType<?>> currentlyDisplayedImageResult;
Expand Down Expand Up @@ -150,7 +150,7 @@ public void setup() {

imagePanel = new JImagePanel(ij.IJ.createImage("dummy", "8-bit", 10, 10, 1));
imagePanel.addMouseMotionListener(this);

// Create something to display it in
final JEditorPane editor = new JEditorPane();
editor.setEditable(false); // we're browsing not editing
Expand Down Expand Up @@ -223,7 +223,8 @@ public void actionPerformed(ActionEvent arg0) {
xAxisLabel.setHorizontalAlignment(SwingConstants.CENTER);
xAxisLabel.setBorder(new EmptyBorder(0, 0, 15, 0));
imageAndLabelPanel.add(xAxisLabel, BorderLayout.SOUTH);
pane.add(imageAndLabelPanel, c);
JScrollPane scrollImagePane = new JScrollPane(imageAndLabelPanel);
pane.add(scrollImagePane, c);
c.gridy++;
c.weighty = 1;
pane.add(scrollPane, c);
Expand All @@ -241,14 +242,21 @@ private String labelName(int ch, String s) {

@Override
public void process() {
int imageWidth = 0;
int imageHeight = 0;

// if wanted, display source images
if (displayOriginalImages) {
RandomAccessibleInterval<? extends RealType<?>> img1 = dataContainer.getSourceImage1();
RandomAccessibleInterval<? extends RealType<?>> img2 = dataContainer.getSourceImage2();

listOfImages.add(new NamedContainer<RandomAccessibleInterval<? extends RealType<?>>>(
dataContainer.getSourceImage1(), dataContainer.getSourceImage1Name()));
img1, dataContainer.getSourceImage1Name()));
listOfImages.add(new NamedContainer<RandomAccessibleInterval<? extends RealType<?>>>(
dataContainer.getSourceImage2(), dataContainer.getSourceImage2Name()));
img2, dataContainer.getSourceImage2Name()));
imageWidth = (int)img1.dimension(0);
imageHeight = (int)img1.dimension(1);
}

// set up the GUI, which runs makeHtmlText() for the value results
// formatting.
setup();
Expand All @@ -257,7 +265,8 @@ public void process() {
adjustDisplayedImage(listOfImages.get(0).object);
}
// show the GUI
setSize(600,600);
setSize((600+imageWidth), (600+imageHeight));

this.setVisible(true);
}

Expand Down

0 comments on commit f229583

Please sign in to comment.