-
- All Known Implementing Classes:
ITerm2Graphics,KittyGraphics,SixelGraphics
public interface TerminalGraphicsCommon interface for terminal graphics protocols.This interface provides a unified API for displaying images in terminals using various graphics protocols such as Sixel, Kitty Graphics Protocol, and iTerm2 Inline Images Protocol.
Different terminals support different graphics protocols:
- Sixel - Supported by xterm, iTerm2, foot, WezTerm, etc.
- Kitty Graphics Protocol - Supported by Kitty, Ghostty, WezTerm
- iTerm2 Inline Images - Supported by iTerm2
The implementation automatically detects which protocols are supported and uses the best available option.
- Since:
- 3.30.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classTerminalGraphics.ImageOptionsImage display options for controlling how images are rendered.static classTerminalGraphics.ProtocolGraphics protocol types supported by terminals.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringconvertImage(java.awt.image.BufferedImage image, TerminalGraphics.ImageOptions options)Converts an image to the protocol-specific format.voiddisplayImage(Terminal terminal, java.awt.image.BufferedImage image)Displays a BufferedImage on the terminal using this graphics protocol.voiddisplayImage(Terminal terminal, java.awt.image.BufferedImage image, TerminalGraphics.ImageOptions options)Displays a BufferedImage on the terminal with custom options.voiddisplayImage(Terminal terminal, java.io.File file)Displays an image file on the terminal.voiddisplayImage(Terminal terminal, java.io.File file, TerminalGraphics.ImageOptions options)Displays an image file on the terminal with custom options.voiddisplayImage(Terminal terminal, java.io.InputStream inputStream)Displays an image from an input stream on the terminal.voiddisplayImage(Terminal terminal, java.io.InputStream inputStream, TerminalGraphics.ImageOptions options)Displays an image from an input stream on the terminal with custom options.intgetPriority()Gets the priority of this protocol for automatic selection.TerminalGraphics.ProtocolgetProtocol()Gets the graphics protocol type supported by this implementation.booleanisSupported(Terminal terminal)Checks if this graphics protocol is supported by the given terminal.
-
-
-
Method Detail
-
getProtocol
TerminalGraphics.Protocol getProtocol()
Gets the graphics protocol type supported by this implementation.- Returns:
- the protocol type
-
isSupported
boolean isSupported(Terminal terminal)
Checks if this graphics protocol is supported by the given terminal.- Parameters:
terminal- the terminal to check- Returns:
- true if the protocol is supported, false otherwise
-
getPriority
int getPriority()
Gets the priority of this protocol for automatic selection. Higher values indicate higher priority.- Returns:
- the priority value (0-100)
-
displayImage
void displayImage(Terminal terminal, java.awt.image.BufferedImage image) throws java.io.IOException
Displays a BufferedImage on the terminal using this graphics protocol.- Parameters:
terminal- the terminal to display the image onimage- the image to display- Throws:
java.io.IOException- if an I/O error occursjava.lang.UnsupportedOperationException- if the protocol is not supported
-
displayImage
void displayImage(Terminal terminal, java.awt.image.BufferedImage image, TerminalGraphics.ImageOptions options) throws java.io.IOException
Displays a BufferedImage on the terminal with custom options.- Parameters:
terminal- the terminal to display the image onimage- the image to displayoptions- display options for the image- Throws:
java.io.IOException- if an I/O error occursjava.lang.UnsupportedOperationException- if the protocol is not supported
-
displayImage
void displayImage(Terminal terminal, java.io.File file) throws java.io.IOException
Displays an image file on the terminal.- Parameters:
terminal- the terminal to display the image onfile- the image file to display- Throws:
java.io.IOException- if an I/O error occursjava.lang.UnsupportedOperationException- if the protocol is not supported
-
displayImage
void displayImage(Terminal terminal, java.io.File file, TerminalGraphics.ImageOptions options) throws java.io.IOException
Displays an image file on the terminal with custom options.- Parameters:
terminal- the terminal to display the image onfile- the image file to displayoptions- display options for the image- Throws:
java.io.IOException- if an I/O error occursjava.lang.UnsupportedOperationException- if the protocol is not supported
-
displayImage
void displayImage(Terminal terminal, java.io.InputStream inputStream) throws java.io.IOException
Displays an image from an input stream on the terminal.- Parameters:
terminal- the terminal to display the image oninputStream- the input stream containing the image data- Throws:
java.io.IOException- if an I/O error occursjava.lang.UnsupportedOperationException- if the protocol is not supported
-
displayImage
void displayImage(Terminal terminal, java.io.InputStream inputStream, TerminalGraphics.ImageOptions options) throws java.io.IOException
Displays an image from an input stream on the terminal with custom options.- Parameters:
terminal- the terminal to display the image oninputStream- the input stream containing the image dataoptions- display options for the image- Throws:
java.io.IOException- if an I/O error occursjava.lang.UnsupportedOperationException- if the protocol is not supported
-
convertImage
java.lang.String convertImage(java.awt.image.BufferedImage image, TerminalGraphics.ImageOptions options) throws java.io.IOExceptionConverts an image to the protocol-specific format. This method is useful for debugging or when you need the raw protocol data.- Parameters:
image- the image to convertoptions- display options for the image- Returns:
- the protocol-specific representation of the image
- Throws:
java.io.IOException- if an I/O error occurs
-
-