custom ImageProcessor sub-class (no-gui) question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

custom ImageProcessor sub-class (no-gui) question

Brian Willkie-2
Hello,

I'm looking into adapting ImageJ code for my own application. Attached  
is an example that attempts to open a tif file (the file I'm using  
opens in ImageJ as 32 bit RGB).

I've built a bare-bones version of ColorProcessor (included in the  
java file) that shouldn't instantiate any java.awt components (it has  
two constructors with empty definitions). Yet when I create an  
instance of my custom ColorProcessor, I get a GUI. If I comment out  
the lines that instantiate my custom ColorProcessor, the program exits  
without creating a GUI.

Can anyone point out what I'm overlooking?

Thanks,
Brian

P.S. To compile and run:
%javac -classpath /path/to/ij.jar -d /path/to/bin/ \
/path/to/src/PseudoProcessorTest.java

%java -classpath /path/to/ij.jar:/path/to/bin/ PseudoProcessorTest \
-p /path/to/image/ -f someImage.tif



PseudoProcessorTest.java (12K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: custom ImageProcessor sub-class (no-gui) question

Brian Willkie-2
Quoting [hidden email]:

Well, to answer my own question, line 68 in ImageProcessor  
instantiates an awt component:

        protected Color drawingColor = Color.black;


Is there anyway to avoid this?

Thanks,
Brian


> Hello,
>
> I'm looking into adapting ImageJ code for my own application. Attached
> is an example that attempts to open a tif file (the file I'm using
> opens in ImageJ as 32 bit RGB).
>
> I've built a bare-bones version of ColorProcessor (included in the
> java file) that shouldn't instantiate any java.awt components (it has
> two constructors with empty definitions). Yet when I create an
> instance of my custom ColorProcessor, I get a GUI. If I comment out
> the lines that instantiate my custom ColorProcessor, the program exits
> without creating a GUI.
>
> Can anyone point out what I'm overlooking?
>
> Thanks,
> Brian
>
> P.S. To compile and run:
> %javac -classpath /path/to/ij.jar -d /path/to/bin/ \
> /path/to/src/PseudoProcessorTest.java
>
> %java -classpath /path/to/ij.jar:/path/to/bin/ PseudoProcessorTest \
> -p /path/to/image/ -f someImage.tif
Reply | Threaded
Open this post in threaded view
|

Re: custom ImageProcessor sub-class (no-gui) question

Albert Cardona
> Well, to answer my own question, line 68 in ImageProcessor
> instantiates an awt component:
>
>     protected Color drawingColor = Color.black;
>
>
> Is there anyway to avoid this?


A hackerous way is to emulate the headless.jar of ImageJA: declare your
own java.awt.Color class, which does not belong to the real java.awt
package. I.e. by adding your own jar in the classpath you can shadow the
internal one.

Albert

--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona