Commit 8777df20 authored by lafabregue's avatar lafabregue

small fix

parent 256c8146
......@@ -27,8 +27,10 @@ import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.io.LineNumberReader;
import java.util.List;
......@@ -37,9 +39,11 @@ import java.util.Vector;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
......@@ -65,10 +69,9 @@ import jcl.data.Data;
import jcl.utils.Images.StreamedImageReaderWrapper;
import mustic.gui.ProgressPropertyChangeListener;
import mustic.io.RawImage;
import mustic.utils.image.ImageViewer;
import mustic.utils.image.PyramidImageViewer;
import mustic.utils.filters.CSVFileFilter;
import mustic.utils.image.ZoomBoxPanel;
import mustic.utils.image.Zoomable;
import mustic.utils.io.CSVUtils;
/**
* Dialog window that allows the user to generate a set of constraints
......@@ -76,7 +79,7 @@ import mustic.utils.image.Zoomable;
* @author Baptiste LAFABREGUE
*
*/
public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomable {
public class ConstraintsSelectionDialog extends JInternalFrame implements mustic.utils.image.Zoomable {
private static final long serialVersionUID = 1L;
......@@ -98,9 +101,6 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
/** Image displayed */
private BufferedImage mNew = null;
/** Image viewer that handle image read operations */
private ImageViewer viewer = null;
/** Panel that contains the displayed image */
private JPanel displayPanel = null;
......@@ -504,7 +504,47 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
}
protected void addConstraint(List<String> line, boolean isImageRelated) {
private boolean openFile(File file) {
System.out.println(
"__________________________________________________________________________________________\n"); //$NON-NLS-1$
System.out.println("Opening file : " + file.getPath()); //$NON-NLS-1$
System.out
.println("__________________________________________________________________________________________"); //$NON-NLS-1$
boolean isImageRelated = true;
if (data != null) {
// choose between image or data indexes
String[] possibilities = { Messages.getString("ConstraintsSelectionDialog.521"),
Messages.getString("ConstraintsSelectionDialog.522") };
String s = (String) JOptionPane.showInputDialog(this, Messages.getString("ConstraintsSelectionDialog.524"),
Messages.getString("ConstraintsSelectionDialog.523"), JOptionPane.PLAIN_MESSAGE, null,
possibilities, Messages.getString("ConstraintsSelectionDialog.522"));
// if data is selected
if (s.equals(Messages.getString("ConstraintsSelectionDialog.522"))) {
isImageRelated = false;
}
}
CSVUtils reader = null;
try {
reader = new CSVUtils(file);
clear();
List<String> line;
while ((line = reader.readNext()) != null) {
addConstraint(line, isImageRelated);
}
enableAllComponents();
displayPixels();
updateUI();
} catch (FileNotFoundException e) {
e.printStackTrace();
return false;
}
return true;
}
private void addConstraint(List<String> line, boolean isImageRelated) {
switch (Integer.parseInt(line.get(line.size() - 1))) {
case Constraint.MUST_LINK_TYPE:
try {
......@@ -810,9 +850,6 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
if (img == null) {
return;
}
// this.viewer = new PyramidImageViewer(img.getFilename(), true);
if (this.image != null && !this.image.getPath().equals(img.getPath()))
this.clear();
this.width = img.getWidth();
......@@ -887,7 +924,11 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
}
this.image = img;
doZoomedOp();
// TODO : Solve conflict
// <<
displayPixels();
// doZoomedOp();
//>>
}
protected void addSecondPixel(int x, int y) {
......@@ -1293,13 +1334,25 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
// coordinates in original image
int xo = (int) (x/mZoomRate);
int yo = (int) (y/mZoomRate);
// int widthOrigin = (int) (width/mZoomRate);
// int heightOrigin= (int) (height/mZoomRate);
int widthOrigin = (int) (width/mZoomRate);
int heightOrigin= (int) (height/mZoomRate);
float zoomOrigin = zoom*mZoomRate ;
BufferedImage subImage = viewer.getScreenImage(xo, yo, width, height, zoomOrigin, false);
return subImage;
int widthSubImage=widthOrigin;
int heightSubImage=heightOrigin;
// manage integer precision rounding problem
if(widthSubImage + xo > this.getOriginalImage().getWidth()) {
widthSubImage=this.getOriginalImage().getWidth() - xo;
}
if(heightSubImage + yo > this.getOriginalImage().getHeight()) {
heightSubImage=this.getOriginalImage().getHeight() - yo;
}
BufferedImage subImage = this.getOriginalImage().getSubimage(xo, yo, widthSubImage, heightSubImage);
return subImage.getScaledInstance((int) (widthSubImage * zoomOrigin), (int) (heightSubImage * zoomOrigin ), Image.SCALE_SMOOTH);
}
public BufferedImage getOriginalImage() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment