Skip to content
Snippets Groups Projects
Commit c6a40852 authored by Stephan Saalfeld's avatar Stephan Saalfeld
Browse files

added flexible URL patterns for other CATMAID tile sources by format string

TODO read the string from XML
parent 795d67ad
Branches
Tags
No related merge requests found
...@@ -380,7 +380,8 @@ public class BigDataViewer ...@@ -380,7 +380,8 @@ public class BigDataViewer
public static void main( final String[] args ) public static void main( final String[] args )
{ {
final String fn = "/Users/pietzsch/desktop/data/catmaid-confocal.xml"; // final String fn = "/Users/pietzsch/desktop/data/catmaid-confocal.xml";
final String fn = "/home/saalfeld/catmaid-confocal.xml";
// final String fn = "/Users/pietzsch/desktop/data/BDV130418A325/BDV130418A325_NoTempReg.xml"; // final String fn = "/Users/pietzsch/desktop/data/BDV130418A325/BDV130418A325_NoTempReg.xml";
// final String fn = "/Users/pietzsch/Desktop/data/valia2/valia.xml"; // final String fn = "/Users/pietzsch/Desktop/data/valia2/valia.xml";
// final String fn = "/Users/pietzsch/workspace/data/fast fly/111010_weber/combined.xml"; // final String fn = "/Users/pietzsch/workspace/data/fast fly/111010_weber/combined.xml";
......
...@@ -84,7 +84,7 @@ public class CatmaidImageLoader implements ViewerImgLoader< ARGBType, VolatileAR ...@@ -84,7 +84,7 @@ public class CatmaidImageLoader implements ViewerImgLoader< ARGBType, VolatileAR
final int[] maxLevels = new int[] { numScales - 1 }; final int[] maxLevels = new int[] { numScales - 1 };
cache = new VolatileGlobalCellCache< VolatileIntArray >( cache = new VolatileGlobalCellCache< VolatileIntArray >(
new CatmaidVolatileIntArrayLoader( baseUrl, tileWidth, tileHeight ), 1, 1, numScales, maxLevels, 10 ); new CatmaidVolatileIntArrayLoader( baseUrl + "%5$d/%8$d_%9$d_%1$d.jpg", tileWidth, tileHeight ), 1, 1, numScales, maxLevels, 10 );
} }
final static public int getNumScales( long width, long height, final long tileWidth, final long tileHeight ) final static public int getNumScales( long width, long height, final long tileWidth, final long tileHeight )
......
...@@ -14,20 +14,50 @@ public class CatmaidVolatileIntArrayLoader implements CacheArrayLoader< Volatile ...@@ -14,20 +14,50 @@ public class CatmaidVolatileIntArrayLoader implements CacheArrayLoader< Volatile
{ {
private VolatileIntArray theEmptyArray; private VolatileIntArray theEmptyArray;
private final String baseUrl; private final String urlFormat;
private final int tileWidth; private final int tileWidth;
private final int tileHeight; private final int tileHeight;
public CatmaidVolatileIntArrayLoader( final String baseUrl, final int tileWidth, final int tileHeight ) /**
* <p>Create a {@link CacheArrayLoader} for a CATMAID source. Tiles are
* addressed, in this order, by their</p>
* <ul>
* <li>scale level,</li>
* <li>scale,</li>
* <li>x,</li>
* <li>y,</li>
* <li>z,</li>
* <li>tile width,</li>
* <li>tile height,</li>
* <li>tile row, and</li>
* <li>tile column.</li>
* </ul>
* <p><code>urlFormat</code> specifies how these parameters are used
* to generate a URL referencing the tile. Examples:</p>
*
* <dl>
* <dt>"http://catmaid.org/my-data/xy/%5$d/%8$d_%9$d_%1$d.jpg"</dt>
* <dd>CATMAID DefaultTileSource (type 1)</dd>
* <dt>"http://catmaid.org/my-data/xy/?x=%3$d&y=%4$d&width=%6d&height=%7$d&row=%8$d&col=%9$d&scale=%2$f&z=%4$d"</dt>
* <dd>CATMAID RequestTileSource (type 2)</dd>
* <dt>"http://catmaid.org/my-data/xy/%1$d/%5$d/%8$d/%9$d.jpg"</dt>
* <dd>CATMAID LargeDataTileSource (type 5)</dd>
* </dl>
*
* @param urlFormat
* @param tileWidth
* @param tileHeight
*/
public CatmaidVolatileIntArrayLoader( final String urlFormat, final int tileWidth, final int tileHeight )
{ {
theEmptyArray = new VolatileIntArray( 256 * 256, false ); theEmptyArray = new VolatileIntArray( tileWidth * tileHeight, false );
this.baseUrl = baseUrl; this.urlFormat = urlFormat;
this.tileWidth = tileWidth; this.tileWidth = tileWidth;
this.tileHeight = tileHeight; this.tileHeight = tileHeight;
} }
@Override @Override
public int getBytesPerElement() public int getBytesPerElement()
{ {
...@@ -35,24 +65,19 @@ public class CatmaidVolatileIntArrayLoader implements CacheArrayLoader< Volatile ...@@ -35,24 +65,19 @@ public class CatmaidVolatileIntArrayLoader implements CacheArrayLoader< Volatile
} }
@Override @Override
public VolatileIntArray loadArray( final int timepoint, final int setup, final int level, final int[] dimensions, final long[] min ) throws InterruptedException public VolatileIntArray loadArray(
final int timepoint,
final int setup,
final int level,
final int[] dimensions,
final long[] min ) throws InterruptedException
{ {
final int c = ( int ) min[ 0 ] / tileWidth; final int c = ( int ) min[ 0 ] / tileWidth;
final int r = ( int ) min[ 1 ] / tileHeight; final int r = ( int ) min[ 1 ] / tileHeight;
final int z = ( int ) min[ 2 ]; final double scale = 1.0 / Math.pow(2.0, level);
final int s = level;
final String urlString = final String urlString = String.format( urlFormat, level, scale, min[ 0 ], min[ 1 ], min[ 2 ], tileWidth, tileHeight, r, c );
new
StringBuffer( baseUrl ).
append( z ).
append( "/" ).
append( r ).
append( "_" ).
append( c ).
append( "_" ).
append( s ).
append( ".jpg" ).
toString();
final int w = dimensions[ 0 ]; final int w = dimensions[ 0 ];
final int h = dimensions[ 1 ]; final int h = dimensions[ 1 ];
final int[] data = new int[ w * h ]; final int[] data = new int[ w * h ];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment