[ImageJ-devel] [fiji-devel] New methods in CalibratedSpace
Curtis Rueden
ctrueden at wisc.edu
Thu Jul 12 16:22:46 CDT 2012
Hi Steffi & J-Y,
> if ( img instanceOf ImagePlusImg )
I think using instanceof in this way is quite evil, and should be avoided
whenever possible. It is something I very much want to avoid in the core
ImgLib2 and ImageJ2 code, because it prohibits extensibility. Better is to
put the common functionality into an interface method declaration and then
implement it differently in the different subclasses.
That said, how to avoid writing code like this depends on the situation.
We'd have to look over the various places in code that it is currently
happening...
> 1) break it and maybe it is just fine
> 2) make a wrapImgPlus method
> Maybe 1) is the better way to go, I just wanted to bring up potential
implications ....
In this case, given that it would be easy to simply add the wrapImgPlus
methods, that may be a safer way to go. Anyone else have an opinion?
Regards,
Curtis
On Thu, Jul 12, 2012 at 4:19 PM, Stephan Preibisch <preibisch at mpi-cbg.de>wrote:
> We have two options:
>
> 1) break it and maybe it is just fine
> 2) make a second method like
>
> public ImgPlus< T > wrapImgPlus( final ImagePlus imp )
> {
> Img< T > img = wrap( imp );
> ImgPlus< T > imgplus = new ImgPlus( img );
>
> imgplus.setCalibration( imp.getCal ... );
> imgplus.setName( imp.getTitle() );
>
> return imgplus;
> }
>
> Maybe 1) is the better way to go, I just wanted to bring up potential
> implications ....
>
>
>
> On Jul 12, 2012, at 17:14 , Jean-Yves Tinevez wrote:
>
> On 12-Jul-12 23:05, Stephan Preibisch wrote:
>
> In principle, I agree. However it might break some code in a bad way. We
> used several times constructs like
>
> Img< T > img;
>
> if ( img instanceOf ImagePlusImg )
> {
> // get the underlying instance (which is especially true after wrapping)
> ImagePlus imp = ((ImagePlusImg)img).getImagePlus();
> ....
>
> // or do something else where you test instanceof
> }
>
> which would suddenly fail because ImgPlus is an Img, but only HAS for
> example an ImagePlusImg...
>
> What do you think?
>
>
> Bummer.
>
> How do we get the ImagePlusAdapter to return an Img that captures
> calibration as well then?
>
> --
> Please avoid top-posting, and please make sure to reply-to-all!
>
> Mailing list web interface: http://groups.google.com/group/fiji-devel
>
>
> --
> Please avoid top-posting, and please make sure to reply-to-all!
>
> Mailing list web interface: http://groups.google.com/group/fiji-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20120712/83081ff6/attachment.html>
More information about the ImageJ-devel
mailing list