Posted by
ctrueden on
URL: http://imagej.273.s1.nabble.com/controlling-size-and-location-of-Console-window-tp5020161p5020173.html
Hi John & Ken,
SciJava's default ConsoleService implementation overrides the system stdout
and stderr [1].
It creates a MultiOutputStream [2] for each, and adds a mechanism so that
stdout and stderr listeners can be registered.
> IJ is probably just using a TextWindow
Nope, it's a JFrame [3] containing an extension of JPanel [4].
Kenneth Sloan wrote:
> I've become addicted to leaving in extensive tracing/logging output to
> stderr in even the "production" version of the plugin.
Before the creation of the Console window, there were bug reports from
users saying things like "When I perform XYZ action, nothing happens."
Often, an error message or stack trace was being dumped on stderr, which
the user never saw, because they didn't launch ImageJ from the command
line. In order to prevent this situation, and ensure users do not "miss"
important error messages, I added the Console window. Whenever output to
stderr happens, the Console window appears.
Using stderr to report the progress of an operation is not its intended
purpose. But there are good options for reporting progress, including the
Log window (IJ.log) and the status bar (IJ.showStatus or using the SciJava
StatusService).
> Putting it at (0,0) is probably the WORST location for my purposes -
> and I'd just as soon have it display only a few lines (no more than
> the last 10), unless and until someone pulls it up and enlarges it.
I agree. It is at (0, 0) right now because that is the default, and no one
coded anything better. Please feel welcome to file a PR improving matters.
The initial position of the window could be set in LegacyUI [3], and the
default height could be changed at [5]. For the initial position, it might
make sense to align it directly below the main window, for instance.
Regards,
Curtis
[1]
https://github.com/scijava/scijava-common/blob/scijava-common-2.69.0/src/main/java/org/scijava/console/DefaultConsoleService.java#
L148-L156
[2]
https://github.com/scijava/scijava-common/blob/scijava-common-2.69.0/src/main/java/org/scijava/console/
MultiOutputStream.java#L41-L52
[3]
https://github.com/imagej/imagej-legacy/blob/imagej-legacy-0.29.0/src/main/java/net/imagej/legacy/ui/LegacyUI.java#L149-L160
[4]
https://github.com/scijava/scijava-ui-swing/blob/scijava-ui-swing-0.9.5/src/main/java/org/scijava/ui/swing/console/
SwingConsolePane.java#L50-L60
[5]
https://github.com/scijava/scijava-ui-swing/blob/scijava-ui-swing-0.9.5/src/main/java/org/scijava/ui/swing/console/
ConsolePanel.java#L130
--
Curtis Rueden
LOCI software architect -
https://loci.wisc.edu/softwareImageJ2 lead, Fiji maintainer -
https://imagej.net/User:RuedenDid you know ImageJ has a forum?
http://forum.imagej.net/On Tue, Feb 27, 2018 at 9:22 AM, John Hayes <
[hidden email]> wrote:
> Hi Kenneth,
>
> You may want to grep the ImageJ code for where stderr is being piped to
> this console window. Some of the keywords in this example may be helpful:
>
http://www.avajava.com/tutorials/lessons/how-do-i-redirect-> standard-error-to-a-file.html
> When you find it, IJ is probably just using a TextWindow (
>
https://imagej.nih.gov/ij/developer/api/ij/text/TextWindow.html), which
> is kind of a one-shot object. By that I mean, when it’s instantiated I
> think the window is displayed and the reference to it lost to the larger IJ
> code but the stderr could indefinitely be piped to it from the local
> reference.
> Good luck, and I’d be curious what you find.
>
> Best,
> John
>
> > On Feb 26, 2018, at 9:14 PM, Kenneth Sloan <
[hidden email]>
> wrote:
> >
> > Thanks.
> >
> > Now, I just need to make sure that my customers have upgraded to ImageJ2.
> >
> > I confess to not tracking this closely - I just noticed that stderr was
> popping up in the Console window, and could not find any documentation on
> how to control it.
> >
> > I saw some threads on making it invisible - that's NOT what I want to
> do. I want it visible, but I also want it in a corner, out of the way of
> the main content windows. Putting it at (0,0) is probably the WORST
> location for my purposes - and I'd just as soon have it display only a few
> lines (no more than the last 10), unless and until someone pulls it up and
> enlarges it.
> >
> > My plugins seem to always be "under development", and I've become
> addicted to leaving in extensive tracing/logging output to stderr in even
> the "production" version of the plugin. Also, many of my foundational
> tools are used in non-ImageJ contexts, so stderr is a kind of standard
> place to put this stuff.
> >
> > I don't mind the specific gui - but I do wish this kind of documentation
> were easier to find!
> >
> > Again - thank you very much for your prompt reply. Now, I have
> something to keep me occupied this evening.
> >
> > --
> > Kenneth Sloan
> >
[hidden email]
> > Vision is the art of seeing what is invisible to others.
>
>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html