Class ConsoleHandler

    • Constructor Detail

      • ConsoleHandler

        public ConsoleHandler()
        Construct a new instance.
      • ConsoleHandler

        public ConsoleHandler​(Formatter formatter)
        Construct a new instance.
        Parameters:
        formatter - the formatter to use
      • ConsoleHandler

        public ConsoleHandler​(ConsoleHandler.Target target)
        Construct a new instance.
        Parameters:
        target - the target to write to, or null to start with an uninitialized target
      • ConsoleHandler

        public ConsoleHandler​(ConsoleHandler.Target target,
                              Formatter formatter)
        Construct a new instance.
        Parameters:
        target - the target to write to, or null to start with an uninitialized target
        formatter - the formatter to use
    • Method Detail

      • setTarget

        public void setTarget​(ConsoleHandler.Target target)
        Set the target for this console handler.
        Parameters:
        target - the target to write to, or null to clear the target
      • writeImagePng

        public boolean writeImagePng​(InputStream imageData,
                                     int columns,
                                     int rows)
                              throws IOException
        Write a PNG image to the console log, if it is supported. The image data stream must be closed by the caller.
        Parameters:
        imageData - the PNG image data stream to write (must not be null)
        columns - the number of text columns to occupy (0 for automatic)
        rows - the number of text rows to occupy (0 for automatic)
        Returns:
        true if the image was written, or false if image support isn't found
        Throws:
        IOException - if the stream failed while writing the image
      • getLocalErrorManager

        public ErrorManager getLocalErrorManager()
        Get the local error manager. This is an error manager that will publish errors to this console handler. The console handler itself should not use this error manager.
        Returns:
        the local error manager
      • setOutputStream

        public void setOutputStream​(OutputStream outputStream)
        Set the output stream to write to. The output stream will then belong to this handler; when the handler is closed or a new writer or output stream is set, this output stream will be closed.
        Overrides:
        setOutputStream in class OutputStreamHandler
        Parameters:
        outputStream - the new output stream or null for none
      • hasConsole

        public static boolean hasConsole()
        Determine whether the console exists. If the console does not exist, then the standard output stream will be used when ConsoleHandler.Target.CONSOLE is selected as the output target.
        Returns:
        true if there is a console, false otherwise
      • isTrueColor

        public static boolean isTrueColor()
        Determine whether the console supports truecolor output. This call may be expensive, so the result should be captured for the lifetime of any formatter making use of this information.
        Returns:
        true if the console exists and supports truecolor output; false otherwise
      • isGraphicsSupportPassivelyDetected

        public static boolean isGraphicsSupportPassivelyDetected()
        Determine whether the console can be passively detected to support graphical output. This call may be expensive, so the result should be captured for the lifetime of any formatter making use of this information.
        Returns:
        true if the console exists and supports graphical output; false otherwise or if graphical support cannot be passively detected