inheritance
Posted by Tony Shepherd on Aug 08, 2006; 7:44pm
URL: http://imagej.273.s1.nabble.com/inheritance-tp3701842.html
When I create an image I can use one of the existing classes, creating one
of the existing object types, for example
ImagePlus imp = WindowManager.getCurrentImage();
Followed by
ImageProcessor MyImage = imp.getProcessor(); (1)
Then MyImage is an object of type ImageProcessor.
Say I want to write my own methods (like calculating stats from an ROI or
what ever). I dont want to (have to) edit the ImageProcessor class. So I
write methods in a new class, one that EXTENDS ImageProcessor. i.e.
public abstract class MyTypeOfImage extents ImageProcessor{
I can only expect to use my new methods if I create the image in the first
place, as a MyTypeOfImage object, i.e.:
ImagePlus imp = WindowManager.getCurrentImage();
MyTypeOfImage MyImage = imp.getProcessor(); (2)
Now, (1) and (2) above only differ in the type of object being declared/created
I expect the class 'MyTypeOfImage' to inherit all the necessary constructors
from 'ImageProcessor', for creating an image object,
The compiler disagrees, complaining about incompatible types.