diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/XmlIoSplitImgLoader.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/XmlIoSplitImgLoader.java index 81912f84..ae8ab654 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/XmlIoSplitImgLoader.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/XmlIoSplitImgLoader.java @@ -26,6 +26,7 @@ import static mpicbg.spim.data.XmlKeys.IMGLOADER_TAG; import java.io.File; +import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -87,6 +88,43 @@ public Element toXml( final SplitImgLoader imgLoader, final File basePath ) return elem; } + @Override + public SplitImgLoader fromXml( + final Element elem, URI basePath, + final AbstractSequenceDescription sequenceDescription ) + { + final HashMap< Integer, Integer > new2oldSetupId = new HashMap<>(); + final HashMap< Integer, Interval > newSetupId2Interval = new HashMap<>(); + + for ( final Element setup : elem.getChild( XmlIoSplitViewerImgLoader.SETUPIDS_NAME ).getChildren( XmlIoSplitViewerImgLoader.SETUPIDS_TAG ) ) + XmlIoSplitViewerImgLoader.setupFromXML( setup, new2oldSetupId, newSetupId2Interval ); + + try + { + final XmlIoSequenceDescription xmlIoSequenceDescription = new XmlIoSequenceDescription(); + final Element sdElem = elem.getChild( xmlIoSequenceDescription.getTag() ); + if ( sdElem == null ) + throw new SpimDataIOException( "no <" + xmlIoSequenceDescription.getTag() + "> element found." ); + final SequenceDescription oldSD = xmlIoSequenceDescription.fromXml( sdElem, basePath ); + + ImgLoader underlyingImgLoader = null; + + final Element imgLoaderElem = elem.getChild( IMGLOADER_TAG ); + final String format = imgLoaderElem.getAttributeValue( IMGLOADER_FORMAT_ATTRIBUTE_NAME ); + final XmlIoBasicImgLoader< ? > imgLoaderIo = ImgLoaders.createXmlIoForFormat( format ); + underlyingImgLoader = (ImgLoader)imgLoaderIo.fromXml( imgLoaderElem, basePath, oldSD ); + + return new SplitImgLoader( underlyingImgLoader, new2oldSetupId, newSetupId2Interval, oldSD ); + } + catch( Exception e ) + { + IOFunctions.println( "Unable to load underlying Sequence Description & ImgLoader, stopping." ); + e.printStackTrace(); + System.exit( 0 ); + return null; + } + } + @Override public SplitImgLoader fromXml( final Element elem, File basePath, diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/XmlIoSplitMultiResolutionImgLoader.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/XmlIoSplitMultiResolutionImgLoader.java index e717b0cd..8c000fcc 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/XmlIoSplitMultiResolutionImgLoader.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/XmlIoSplitMultiResolutionImgLoader.java @@ -26,6 +26,7 @@ import static mpicbg.spim.data.XmlKeys.IMGLOADER_TAG; import java.io.File; +import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -87,6 +88,43 @@ public Element toXml( final SplitMultiResolutionImgLoader imgLoader, final File return elem; } + @Override + public SplitMultiResolutionImgLoader fromXml( + final Element elem, URI basePath, + final AbstractSequenceDescription sequenceDescription ) + { + final HashMap< Integer, Integer > new2oldSetupId = new HashMap<>(); + final HashMap< Integer, Interval > newSetupId2Interval = new HashMap<>(); + + for ( final Element setup : elem.getChild( XmlIoSplitViewerImgLoader.SETUPIDS_NAME ).getChildren( XmlIoSplitViewerImgLoader.SETUPIDS_TAG ) ) + XmlIoSplitViewerImgLoader.setupFromXML( setup, new2oldSetupId, newSetupId2Interval ); + + try + { + final XmlIoSequenceDescription xmlIoSequenceDescription = new XmlIoSequenceDescription(); + final Element sdElem = elem.getChild( xmlIoSequenceDescription.getTag() ); + if ( sdElem == null ) + throw new SpimDataIOException( "no <" + xmlIoSequenceDescription.getTag() + "> element found." ); + final SequenceDescription oldSD = xmlIoSequenceDescription.fromXml( sdElem, basePath ); + + MultiResolutionImgLoader underlyingImgLoader = null; + + final Element imgLoaderElem = elem.getChild( IMGLOADER_TAG ); + final String format = imgLoaderElem.getAttributeValue( IMGLOADER_FORMAT_ATTRIBUTE_NAME ); + final XmlIoBasicImgLoader< ? > imgLoaderIo = ImgLoaders.createXmlIoForFormat( format ); + underlyingImgLoader = (MultiResolutionImgLoader)imgLoaderIo.fromXml( imgLoaderElem, basePath, oldSD ); + + return new SplitMultiResolutionImgLoader( underlyingImgLoader, new2oldSetupId, newSetupId2Interval, oldSD ); + } + catch( Exception e ) + { + IOFunctions.println( "Unable to load underlying Sequence Description & ImgLoader, stopping." ); + e.printStackTrace(); + System.exit( 0 ); + return null; + } + } + @Override public SplitMultiResolutionImgLoader fromXml( final Element elem, File basePath, diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/XmlIoSplitViewerImgLoader.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/XmlIoSplitViewerImgLoader.java index 026d9b6a..0754fa08 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/XmlIoSplitViewerImgLoader.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/XmlIoSplitViewerImgLoader.java @@ -26,6 +26,7 @@ import static mpicbg.spim.data.XmlKeys.IMGLOADER_TAG; import java.io.File; +import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -139,6 +140,41 @@ protected static < L extends BasicImgLoader > Element createImgLoaderElement( fi return imgLoaderIo.toXml( ( L ) imgLoader, basePath ); } + @Override + public SplitViewerImgLoader fromXml( final Element elem, final URI basePathURI, AbstractSequenceDescription< ?, ?, ? > sequenceDescription ) + { + final HashMap< Integer, Integer > new2oldSetupId = new HashMap<>(); + final HashMap< Integer, Interval > newSetupId2Interval = new HashMap<>(); + + for ( final Element setup : elem.getChild( SETUPIDS_NAME ).getChildren( SETUPIDS_TAG ) ) + setupFromXML( setup, new2oldSetupId, newSetupId2Interval ); + + try + { + final XmlIoSequenceDescription xmlIoSequenceDescription = new XmlIoSequenceDescription(); + final Element sdElem = elem.getChild( xmlIoSequenceDescription.getTag() ); + if ( sdElem == null ) + throw new SpimDataIOException( "no <" + xmlIoSequenceDescription.getTag() + "> element found." ); + final SequenceDescription oldSD = xmlIoSequenceDescription.fromXml( sdElem, basePathURI ); + + ViewerImgLoader underlyingImgLoader = null; + + final Element imgLoaderElem = elem.getChild( IMGLOADER_TAG ); + final String format = imgLoaderElem.getAttributeValue( IMGLOADER_FORMAT_ATTRIBUTE_NAME ); + final XmlIoBasicImgLoader< ? > imgLoaderIo = ImgLoaders.createXmlIoForFormat( format ); + underlyingImgLoader = (ViewerImgLoader)imgLoaderIo.fromXml( imgLoaderElem, basePathURI, oldSD ); + + return new SplitViewerImgLoader( underlyingImgLoader, new2oldSetupId, newSetupId2Interval, oldSD ); + } + catch( Exception e ) + { + IOFunctions.println( "Unable to load underlying Sequence Description & ImgLoader, stopping." ); + e.printStackTrace(); + System.exit( 0 ); + return null; + } + } + @Override public SplitViewerImgLoader fromXml( final Element elem, File basePath,