Skip to content

Commit

Permalink
Instantiate Log Service
Browse files Browse the repository at this point in the history
  • Loading branch information
AvocadoMoon committed Apr 23, 2024
1 parent f7dd10e commit 1b69322
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 32 deletions.
7 changes: 7 additions & 0 deletions view-simulation-results/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@
<artifactId>jsoup</artifactId>
<version>1.16.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.scijava/scijava-log-slf4j -->
<dependency>
<groupId>org.scijava</groupId>
<artifactId>scijava-log-slf4j</artifactId>
<version>1.0.6</version>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,44 +1,22 @@
package org.vcell.N5;


import org.scijava.service.Service;
import org.scijava.log.slf4j.SLF4JLogService;
import org.vcell.N5.UI.N5ExportTable;
import org.vcell.N5.UI.N5ViewerGUI;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.AnonymousAWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.AmazonS3URI;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import ij.ImagePlus;
import ij.plugin.Duplicator;
import net.imglib2.cache.img.CachedCellImg;
import net.imglib2.img.display.imagej.ImageJFunctions;
import net.imglib2.type.numeric.integer.*;
import net.imglib2.type.numeric.real.DoubleType;
import net.imglib2.type.numeric.real.FloatType;
import org.janelia.saalfeldlab.n5.imglib2.N5Utils;
import org.janelia.saalfeldlab.n5.s3.N5AmazonS3Reader;
import org.scijava.command.Command;
import org.scijava.log.LogService;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
import org.janelia.saalfeldlab.n5.*;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Type;
import java.net.URI;
import java.util.*;


/*
Expand Down Expand Up @@ -120,6 +98,10 @@ public void enableCriticalButtons(boolean enable) {
logService.error("Test Error");
}

static {

}

@Override
public void run() {
// this.vGui = new N5ViewerGUI(this);
Expand All @@ -130,6 +112,9 @@ public void run() {
// this.vGui.remoteFileSelection.submitS3Info.addActionListener(this);
// this.vGui.mostRecentExport.addActionListener(this);
N5ExportTable exportTable = new N5ExportTable(this);
if(N5ImageHandler.logService == null){
N5ImageHandler.logService = new SLF4JLogService();
}
N5ImageHandler.logService.setLevel(LogService.DEBUG);
exportTable.displayExportTable();
}
Expand All @@ -144,6 +129,13 @@ public void displayN5Dataset(ImagePlus imagePlus) throws IOException {
}
}

public static LogService getLogger(){
if (logService == null){
logService = new SLF4JLogService();
}
return logService;
}

public static void main(String[] args) {
N5ImageHandler n5ImageHandler = new N5ImageHandler();
n5ImageHandler.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.AmazonS3URI;
import ij.ImagePlus;
import loci.common.DebugTools;
import net.imglib2.cache.img.CachedCellImg;
import net.imglib2.img.display.imagej.ImageJFunctions;
import net.imglib2.type.numeric.real.DoubleType;
Expand All @@ -17,7 +16,6 @@
import org.janelia.saalfeldlab.n5.imglib2.N5Utils;
import org.janelia.saalfeldlab.n5.s3.N5AmazonS3Reader;
import org.scijava.log.LogService;
import org.scijava.plugin.Parameter;

import java.io.File;
import java.io.IOException;
Expand All @@ -28,8 +26,6 @@
import java.util.Arrays;
import java.util.HashMap;

import static org.vcell.N5.N5ImageHandler.logService;

public class SimResultsLoader {
private File selectedLocalFile;
private AmazonS3 s3Client;
Expand All @@ -39,6 +35,8 @@ public class SimResultsLoader {
private String dataSetChosen;
private String userSetFileName;

private final LogService logService = N5ImageHandler.getLogger();

public SimResultsLoader(){

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import ij.ImagePlus;
import ij.plugin.Duplicator;
import org.scijava.log.LogService;
import org.scijava.plugin.Parameter;
import org.vcell.N5.ExportDataRepresentation;
import org.vcell.N5.N5ImageHandler;
import org.vcell.N5.SimResultsLoader;
Expand Down Expand Up @@ -54,6 +53,8 @@ public class N5ExportTable implements ActionListener, ListSelectionListener {
private RemoteFileSelection remoteFileSelection;
private final int paneWidth = 800;

private final LogService logService = N5ImageHandler.getLogger();

public N5ExportTable(N5ImageHandler n5ImageHandler){
remoteFileSelection = new RemoteFileSelection();
}
Expand Down Expand Up @@ -244,14 +245,14 @@ public void openN5FileDataset(ArrayList<SimResultsLoader> filesToOpen, boolean o
enableCriticalButtons(false);
try{
for(SimResultsLoader simResultsLoader: filesToOpen){
N5ImageHandler.logService.debug("Creating S3 Client from Table");
logService.debug("Creating S3 Client from Table");
simResultsLoader.createS3Client();
ImagePlus imagePlus = simResultsLoader.getImgPlusFromN5File();
N5ImageHandler.logService.debug("Got ImagePlus in Table");
logService.debug("Got ImagePlus in Table");
if(openInMemory){
N5ImageHandler.logService.debug("Loading Image Into Memory");
logService.debug("Loading Image Into Memory");
imagePlus = new Duplicator().run(imagePlus);
N5ImageHandler.logService.debug("Loaded Image Into Memory");
logService.debug("Loaded Image Into Memory");
}
imagePlus.show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ private File getTestResourceFiles(String filePath){
}
}

@Before
public void run(){
N5ImageHandler.getLogger();
}

@Test
public void testN5DatasetList() throws IOException {
SimResultsLoader simResultsLoader = new SimResultsLoader();
Expand Down

0 comments on commit 1b69322

Please sign in to comment.