Skip to content

Commit

Permalink
Merge branch 'master' into multi_channel
Browse files Browse the repository at this point in the history
# Conflicts:
#	render-app/src/main/java/org/janelia/alignment/Render.java
#	render-app/src/main/java/org/janelia/alignment/util/ImageProcessorCache.java
#	render-app/src/main/java/org/janelia/alignment/util/LabelImageProcessorCache.java
#	render-app/src/test/java/org/janelia/alignment/RenderRawTileTest.java
#	render-ws-spark-client/src/main/java/org/janelia/render/client/spark/ScapeClient.java
  • Loading branch information
trautmane committed Jun 12, 2017
2 parents 9cc3b2a + 78cef36 commit ce40772
Show file tree
Hide file tree
Showing 12 changed files with 498 additions and 124 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package org.janelia.alignment.spec;

import java.beans.Transient;
import java.io.Serializable;
import java.util.Comparator;

import org.janelia.alignment.json.JsonUtils;

/**
* Maps a section identifier to its z value.
Expand Down Expand Up @@ -68,4 +72,35 @@ public Double getMinX() {
public Double getMinY() {
return minY;
}

@Transient
public int getWidth() {
return (int) (maxX - minX + 0.5);
}

@Transient
public int getHeight() {
return (int) (maxY - minY + 0.5);
}

public String toJson() {
return JSON_HELPER.toJson(this);
}

@Override
public String toString() {
return this.toJson();
}

public static final Comparator<SectionData> Z_COMPARATOR = new Comparator<SectionData>() {
@Override
public int compare(final SectionData o1,
final SectionData o2) {
return o1.z.compareTo(o2.z);
}
};

private static final JsonUtils.Helper<SectionData> JSON_HELPER =
new JsonUtils.Helper<>(SectionData.class);

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.janelia.alignment.spec.stack;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;

import org.janelia.alignment.util.CollectionNameUtil;
Expand Down Expand Up @@ -74,14 +76,17 @@ public int compareTo(final StackId that) {
return v;
}

@JsonIgnore
public String getSectionCollectionName() {
return getCollectionName(SECTION_COLLECTION_SUFFIX);
}

@JsonIgnore
public String getTileCollectionName() {
return getCollectionName(TILE_COLLECTION_SUFFIX);
}

@JsonIgnore
public String getTransformCollectionName() {
return getCollectionName(TRANSFORM_COLLECTION_SUFFIX);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public boolean isLoading() {
return LOADING.equals(state);
}

public boolean isOffline() {
return OFFLINE.equals(state);
}

public boolean isReadOnly() {
return READ_ONLY.equals(state);
}
Expand Down Expand Up @@ -280,6 +284,15 @@ public static StackMetaData fromJson(final String json) {
return JSON_HELPER.fromJson(json);
}

public static StackMetaData buildDerivedMetaData(final StackId stackId,
final StackMetaData fromStackMetaData) {
final StackMetaData derivedMetaData = new StackMetaData(stackId, fromStackMetaData.getCurrentVersion());
derivedMetaData.state = fromStackMetaData.state;
derivedMetaData.currentVersionNumber = fromStackMetaData.currentVersionNumber;
derivedMetaData.stats = fromStackMetaData.stats;
return derivedMetaData;
}

private static final JsonUtils.Helper<StackMetaData> JSON_HELPER =
new JsonUtils.Helper<>(StackMetaData.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public String getUri() {
}
public boolean isConvertTo16Bit(){
return convertTo16Bit;
}
}
public int getDownSampleLevels() {
return downSampleLevels;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected ImageProcessor loadImageProcessor(final String url,
ImageProcessor imageProcessor;

if (isMask) {
imageProcessor = super.loadImageProcessor(url, downSampleLevels, true, false);
imageProcessor = super.loadImageProcessor(url, downSampleLevels, true, convertTo16Bit);
} else {

final Color labelColor = getColorForUrl(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -44,6 +45,7 @@
*
* @author Eric Trautman
*/
@Ignore
public class TransformMeshTest {

// increase this to 10 (or more) to see average times
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
Expand Down Expand Up @@ -90,6 +91,25 @@ public static void saveJsonFile(final String path,
LOG.info("saveJsonFile: exit, wrote data to {}", toPath);
}

public static void ensureWritableDirectory(final File directory) {
// try twice to work around concurrent access issues
if (! directory.exists()) {
if (! directory.mkdirs()) {
if (! directory.exists()) {
// last try
if (! directory.mkdirs()) {
if (! directory.exists()) {
throw new IllegalArgumentException("failed to create " + directory);
}
}
}
}
}
if (! directory.canWrite()) {
throw new IllegalArgumentException("not allowed to write to " + directory);
}
}

private static final Logger LOG = LoggerFactory.getLogger(FileUtil.class);

private static final int DEFAULT_BUFFER_SIZE = 65536;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public RenderSectionClient(final Parameters clientParameters) {
sectionsAtScaleName).toAbsolutePath();

this.sectionDirectory = sectionPath.toFile();
ensureWritableDirectory(this.sectionDirectory);
FileUtil.ensureWritableDirectory(this.sectionDirectory);

// set cache size to 50MB so that masks get cached but most of RAM is left for target image
final int maxCachedPixels = 50 * 1000000;
Expand Down Expand Up @@ -155,29 +155,11 @@ private File getSectionFile(final Double z) {
final int hundreds = (z.intValue() % 1000) / 100;
final File hundredsDir = new File(thousandsDir, String.valueOf(hundreds));

ensureWritableDirectory(hundredsDir);
FileUtil.ensureWritableDirectory(hundredsDir);

return new File(hundredsDir, z + "." + clientParameters.format.toLowerCase());
}

private void ensureWritableDirectory(final File directory) {
// try twice to work around concurrent access issues
if (! directory.exists()) {
if (! directory.mkdirs()) {
if (! directory.exists()) {
// last try
if (! directory.mkdirs()) {
if (! directory.exists()) {
throw new IllegalArgumentException("failed to create " + directory);
}
}
}
}
}
if (! directory.canWrite()) {
throw new IllegalArgumentException("not allowed to write to " + directory);
}
}

private String getNumericDirectoryName(final int value) {
String pad = "00";
Expand Down
Loading

0 comments on commit ce40772

Please sign in to comment.