Skip to content
Snippets Groups Projects
Commit a51599b1 authored by Tobias Pietzsch's avatar Tobias Pietzsch
Browse files

add "-t" command line option to set thumbnail directory

parent 0a6c7a03
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,8 @@ import java.util.Map.Entry; ...@@ -40,6 +40,8 @@ import java.util.Map.Entry;
* per line. Each line is formatted as "NAME <TAB> XML". * per line. Each line is formatted as "NAME <TAB> XML".
* -p <PORT> Listening port. (default: 8080) * -p <PORT> Listening port. (default: 8080)
* -s <HOSTNAME> Hostname of the server. * -s <HOSTNAME> Hostname of the server.
* -t <DIRECTORY> Directory to store thumbnails. (new temporary directory
* by default.)
* -m enable statistics and manager context. EXPERIMENTAL! * -m enable statistics and manager context. EXPERIMENTAL!
* </pre> * </pre>
* *
...@@ -65,8 +67,9 @@ public class BigDataServer ...@@ -65,8 +67,9 @@ public class BigDataServer
{ {
hostname = "localhost"; hostname = "localhost";
} }
final String thumbnailDirectory = null;
final boolean enableManagerContext = false; final boolean enableManagerContext = false;
return new Parameters( port, hostname, new HashMap< String, String >(), enableManagerContext ); return new Parameters( port, hostname, new HashMap< String, String >(), thumbnailDirectory, enableManagerContext );
} }
public static void main( final String[] args ) throws Exception public static void main( final String[] args ) throws Exception
...@@ -133,13 +136,16 @@ public class BigDataServer ...@@ -133,13 +136,16 @@ public class BigDataServer
*/ */
private final Map< String, String > datasetNameToXml; private final Map< String, String > datasetNameToXml;
private final String thumbnailDirectory;
private final boolean enableManagerContext; private final boolean enableManagerContext;
Parameters( final int port, final String hostname, final Map< String, String > datasetNameToXml, final boolean enableManagerContext ) Parameters( final int port, final String hostname, final Map< String, String > datasetNameToXml, final String thumbnailDirectory, final boolean enableManagerContext )
{ {
this.port = port; this.port = port;
this.hostname = hostname; this.hostname = hostname;
this.datasetNameToXml = datasetNameToXml; this.datasetNameToXml = datasetNameToXml;
this.thumbnailDirectory = thumbnailDirectory;
this.enableManagerContext = enableManagerContext; this.enableManagerContext = enableManagerContext;
} }
...@@ -155,7 +161,7 @@ public class BigDataServer ...@@ -155,7 +161,7 @@ public class BigDataServer
public String getThumbnailDirectory() public String getThumbnailDirectory()
{ {
return null; return thumbnailDirectory;
} }
/** /**
...@@ -205,6 +211,12 @@ public class BigDataServer ...@@ -205,6 +211,12 @@ public class BigDataServer
.withArgName( "FILE" ) .withArgName( "FILE" )
.create( "d" ) ); .create( "d" ) );
options.addOption( OptionBuilder
.withDescription( "Directory to store thumbnails. (new temporary directory by default.)" )
.hasArg()
.withArgName( "DIRECTORY" )
.create( "t" ) );
if ( Constants.ENABLE_EXPERIMENTAL_FEATURES ) if ( Constants.ENABLE_EXPERIMENTAL_FEATURES )
{ {
options.addOption( OptionBuilder options.addOption( OptionBuilder
...@@ -222,8 +234,10 @@ public class BigDataServer ...@@ -222,8 +234,10 @@ public class BigDataServer
final int port = Integer.parseInt( portString ); final int port = Integer.parseInt( portString );
// Getting server name option // Getting server name option
final String serverString = cmd.getOptionValue( "s", defaultParameters.getHostname() ); final String serverName = cmd.getOptionValue( "s", defaultParameters.getHostname() );
final String serverName = serverString;
// Getting thumbnail directory option
final String thumbnailDirectory = cmd.getOptionValue( "t", defaultParameters.getThumbnailDirectory() );
final HashMap< String, String > datasets = new HashMap< String, String >( defaultParameters.getDatasets() ); final HashMap< String, String > datasets = new HashMap< String, String >( defaultParameters.getDatasets() );
...@@ -280,7 +294,7 @@ public class BigDataServer ...@@ -280,7 +294,7 @@ public class BigDataServer
if ( datasets.isEmpty() ) if ( datasets.isEmpty() )
throw new IllegalArgumentException( "Dataset list is empty." ); throw new IllegalArgumentException( "Dataset list is empty." );
return new Parameters( port, serverName, datasets, enableManagerContext ); return new Parameters( port, serverName, datasets, thumbnailDirectory, enableManagerContext );
} }
catch ( final ParseException | IllegalArgumentException e ) catch ( final ParseException | IllegalArgumentException e )
{ {
......
...@@ -277,8 +277,7 @@ public class CellHandler extends ContextHandler ...@@ -277,8 +277,7 @@ public class CellHandler extends ContextHandler
{ {
final String thumbnailFileName = thumbnailsDirectory + "/" + datasetName + ".png"; final String thumbnailFileName = thumbnailsDirectory + "/" + datasetName + ".png";
final File thumbnailFile = new File( thumbnailFileName ); final File thumbnailFile = new File( thumbnailFileName );
if ( !thumbnailFile.isFile() ) // do not recreate thumbnail if it if ( !thumbnailFile.isFile() ) // do not recreate thumbnail if it already exists
// already exists
{ {
final BufferedImage bi = ThumbnailGenerator.makeThumbnail( spimData, baseFilename, Constants.THUMBNAIL_WIDTH, Constants.THUMBNAIL_HEIGHT ); final BufferedImage bi = ThumbnailGenerator.makeThumbnail( spimData, baseFilename, Constants.THUMBNAIL_WIDTH, Constants.THUMBNAIL_HEIGHT );
try try
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment