Skip to content
Permalink
Browse files

use same job name in all ResultHandlers

make getJobName method in DataContainer class.
Make sure we always use the same job name in different ResultHandler
implementations by making it easy with the getJobName method in the
DataContainer. To avoid making up different or conflicting names in each
ResultHandler. PDF writer updates jobName if the user writes something
else in the save dialog.
  • Loading branch information...
chalkie666 authored and tomka committed Jul 27, 2015
1 parent 2795dda commit e833597d7d8a7b4d3db747512f6048d67d61d120
@@ -15,10 +15,10 @@
import net.imglib2.type.numeric.RealType;

/**
* The DataContainer keeps all the source data, pre-processing results and
* algorithm results that have been computed. It allows a client to get most of
* its content and makes the source image and channel information available to a
* client.
* The DataContainer keeps all the source data, jobName, pre-processing results
* and algorithm results that have been computed. It allows a client to get most
* of its content and makes the source image and channel information available
* to a client.
*
* @param <T>
*/
@@ -31,6 +31,8 @@
RandomAccessibleInterval<T> sourceImage1, sourceImage2;
// The names of the two source images
String sourceImage1Name, sourceImage2Name;
// The name of the colocalisation run job
public String jobName;
// The mask for the images
RandomAccessibleInterval<BitType> mask;
// Type of the used mask
@@ -65,6 +67,9 @@ public DataContainer(RandomAccessibleInterval<T> src1,
sourceImage2 = src2;
sourceImage1Name = name1;
sourceImage2Name = name2;
// create a jobName so ResultHandler instances can all use the same
// object for the job name.
jobName = "Colocalization_of_" + name1 + "_versus_" + name2;
// create a mask that is true at all pixels.
final long[] dims = new long[src1.numDimensions()];
src1.dimensions(dims);
@@ -110,6 +115,9 @@ public DataContainer(RandomAccessibleInterval<T> src1,
this.ch2 = ch2;
sourceImage1Name = name1;
sourceImage2Name = name2;
// create a jobName so ResultHandler instances can all use the same
// object for the job name.
jobName = "Colocalization_of_" + name1 + "_versus_" + name2;

final int numDims = src1.numDimensions();
maskBBOffset = new long[numDims];
@@ -148,6 +156,9 @@ public DataContainer(RandomAccessibleInterval<T> src1,
sourceImage2 = src2;
sourceImage1Name = name1;
sourceImage1Name = name2;
// create a jobName so ResultHandler instances can all use the same
// object for the job name.
jobName = "Colocalization_of_" + name1 + "_versus_" + name2;

final int numDims = src1.numDimensions();
final long[] dim = new long[numDims];
@@ -248,6 +259,10 @@ public String getSourceImage2Name() {
return sourceImage2Name;
}

public String getJobName() {
return jobName;
}

public RandomAccessibleInterval<BitType> getMask() {
return mask;
}
@@ -176,29 +176,29 @@ public void process() {
String nameCh1 = container.getSourceImage1Name();
String nameCh2 = container.getSourceImage2Name();

////send names of the 2 images to IJ.log for scraping batch results
IJ.log("ImageNames" + ", " + nameCh1 + ", " + nameCh2);
// Use the getJobName() in DataContainer for the job name.
String jobName = container.getJobName();

String name = "coloc_" + nameCh1 + "_" + nameCh2;
/* If a mask is in use, add a counter
* information to the name.
* information to the jobName.
*/
if (container.getMaskType() != MaskType.None) {
name += "_mask_"+ (succeededPrints + 1);
jobName += "_mask_"+ (succeededPrints + 1);
}
// get the path to the file we are about to create
SaveDialog sd = new SaveDialog("Save as PDF", name, ".pdf");
name = sd.getFileName();
SaveDialog sd = new SaveDialog("Save as PDF", jobName, ".pdf");
// update jobName id the user changes it in the save file dialog.
jobName = sd.getFileName();
String directory = sd.getDirectory();
// make sure we got what we need
if ((name == null) || (directory == null)) {
// make sure we have what we need next
if ((jobName == null) || (directory == null)) {
return;
}
String path = directory+name;
String path = directory+jobName;
// create a new iText Document and add date and title
document = new Document(isLetter ? PageSize.LETTER : PageSize.A4);
document.addCreationDate();
document.addTitle(name);
document.addTitle(jobName);
// get a writer object to do the actual output
writer = PdfWriter.getInstance(document, new FileOutputStream(path));
document.open();
@@ -208,7 +208,7 @@ public void process() {
}

//send name of analysis job to IJ.log for scraping batch results
IJ.log("ColocAnalysisJobName" + ", " + name);
IJ.log("ColocAnalysisJobName" + ", " + jobName);

//iterate over all produced text objects
for (Paragraph p : listOfPDFTexts) {
@@ -102,8 +102,8 @@
protected DataContainer<T> dataContainer = null;

public SingleWindowDisplay(DataContainer<T> container, PDFWriter<T> pdfWriter){
super("Colocalisation " + container.getSourceImage1Name() + " vs " +
container.getSourceImage2Name());
// Show job name in title bar
super(container.getJobName());

setPreferredSize(new Dimension(WIN_WIDTH, WIN_HEIGHT));

0 comments on commit e833597

Please sign in to comment.
You can’t perform that action at this time.