Skip to content

Commit

Permalink
Refactor Job(Single|All)ImageFileScan to use same simplified base code
Browse files Browse the repository at this point in the history
Note that this might have led to a changed behaviour of
"Check for Barcodes in Image File"
and has even more potential to be simplified.
  • Loading branch information
GenieTim committed Nov 29, 2019
1 parent 2221ab0 commit bc76218
Show file tree
Hide file tree
Showing 21 changed files with 811 additions and 1,292 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public CandidateImageFile(File aFile) throws UnreadableFileException {
if (!template.getTemplateId().equals(PositionTemplate.TEMPLATE_NO_COMPONENT_PARTS)) {
try {
if (getTaxonLabelQRText(template) == null) {
getLabelOCRText(template);
getTaxonLabelOCRText(template);
}
} catch (OCRReadException e) {
log.error("Unable to OCR file: " + candidateFile.getName() + " " + e.getMessage());
Expand Down Expand Up @@ -801,7 +801,7 @@ public void setFile(File aFile, PositionTemplate aTemplate) throws UnreadableFil
if (!aTemplate.getTemplateId().equals(PositionTemplate.TEMPLATE_NO_COMPONENT_PARTS)) {
try {
if (getTaxonLabelQRText(aTemplate) == null) {
getLabelOCRText(aTemplate);
getTaxonLabelOCRText(aTemplate);
}
} catch (OCRReadException e) {
log.error("Unable to OCR file: " + candidateFile.getName() + " " + e.getMessage());
Expand Down Expand Up @@ -1014,7 +1014,7 @@ public UnitTrayLabel getTaxonLabelQRText(PositionTemplate positionTemplate) {
* @return a string
* @throws OCRReadException
*/
public String getLabelOCRText(PositionTemplate aTemplate) throws OCRReadException {
public String getTaxonLabelOCRText(PositionTemplate aTemplate) throws OCRReadException {
// Actual read attempt is only invoked once,
// subsequent calls return cached value.
log.debug("in CandidateImageFile.getLabelOCRText() 1 labelText is " + labelText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import edu.harvard.mcz.imagecapture.ui.dialog.PositionTemplateBoxDialog;
import edu.harvard.mcz.imagecapture.ui.frame.ImagePanelForDrawing;
import edu.harvard.mcz.imagecapture.ui.tablemodel.PositionTemplateTableModel;
import edu.harvard.mcz.imagecapture.utility.FileUtility;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
Expand Down Expand Up @@ -622,18 +622,11 @@ private JMenuItem getJMenuItemLoadImage() {
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
jLabelFeedback.setText("");
final JFileChooser fileChooser = new JFileChooser();
if (Singleton.getSingletonInstance().getProperties().getProperties().getProperty(ImageCaptureProperties.KEY_LASTPATH) != null) {
fileChooser.setCurrentDirectory(new File(Singleton.getSingletonInstance().getProperties().getProperties().getProperty(ImageCaptureProperties.KEY_LASTPATH)));
}
//FileNameExtensionFilter filter = new FileNameExtensionFilter("TIFF Images", "tif", "tiff");
FileNameExtensionFilter filter = new FileNameExtensionFilter("Image files", "tif", "tiff", "jpg", "jpeg", "png");
fileChooser.setFileFilter(filter);
int returnValue = fileChooser.showOpenDialog(Singleton.getSingletonInstance().getMainFrame());
if (returnValue == JFileChooser.APPROVE_OPTION) {
File imageFile = FileUtility.askForImageFile(new File(Singleton.getSingletonInstance().getProperties().getProperties().getProperty(ImageCaptureProperties.KEY_LASTPATH)));
if (imageFile != null) {
jLabelFeedback.setText("Loading...");
try {
setImageFile(fileChooser.getSelectedFile());
setImageFile(imageFile);
jLabelFeedback.setText("");
drawLayers();
} catch (IOException e1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1088,16 +1088,16 @@ public boolean isStateDone() {

public String getLoadFlags() {
String result = "Unexpected State";
if (flagInBulkloader == false && flagInMCZbase == false && flagAncilaryAlsoInMCZbase == false) {
if (!flagInBulkloader && !flagInMCZbase && !flagAncilaryAlsoInMCZbase) {
result = "In DataShot";
}
if (flagInBulkloader == true && flagInMCZbase == false && flagAncilaryAlsoInMCZbase == false) {
if (flagInBulkloader && !flagInMCZbase && !flagAncilaryAlsoInMCZbase) {
result = "In Bulkloader";
}
if (flagInBulkloader == true && flagInMCZbase == true && flagAncilaryAlsoInMCZbase == false) {
if (flagInBulkloader && flagInMCZbase && !flagAncilaryAlsoInMCZbase) {
result = "Adding Image and Ids.";
}
if (flagInBulkloader == true && flagInMCZbase == true && flagAncilaryAlsoInMCZbase == true) {
if (flagInBulkloader && flagInMCZbase && flagAncilaryAlsoInMCZbase) {
result = WorkFlowStatus.STAGE_DONE;
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* <p>
*/
package edu.harvard.mcz.imagecapture.struct;
package edu.harvard.mcz.imagecapture.entity.fixed;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* <p>
*/
package edu.harvard.mcz.imagecapture.struct;
package edu.harvard.mcz.imagecapture.entity.fixed;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* <p>
*/
package edu.harvard.mcz.imagecapture.struct;
package edu.harvard.mcz.imagecapture.entity.fixed;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down
Loading

0 comments on commit bc76218

Please sign in to comment.