Module com.googlecode.lanterna
Class SwingTerminalImplementation
- java.lang.Object
-
- com.googlecode.lanterna.terminal.swing.GraphicalTerminalImplementation
-
- com.googlecode.lanterna.terminal.swing.SwingTerminalImplementation
-
- All Implemented Interfaces:
InputProvider,IOSafeTerminal,Terminal,java.io.Closeable,java.lang.AutoCloseable
class SwingTerminalImplementation extends GraphicalTerminalImplementation
Concrete implementation ofGraphicalTerminalImplementationthat adapts it to Swing
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.googlecode.lanterna.terminal.swing.GraphicalTerminalImplementation
GraphicalTerminalImplementation.TerminalInputListener, GraphicalTerminalImplementation.TerminalMouseListener
-
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.JComponentcomponentprivate SwingTerminalFontConfigurationfontConfiguration
-
Constructor Summary
Constructors Constructor Description SwingTerminalImplementation(javax.swing.JComponent component, SwingTerminalFontConfiguration fontConfiguration, TerminalSize initialTerminalSize, TerminalEmulatorDeviceConfiguration deviceConfiguration, TerminalEmulatorColorConfiguration colorConfiguration, TerminalScrollController scrollController)Creates a newSwingTerminalImplementation
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SwingTerminalFontConfigurationgetFontConfiguration()Returns the current font configuration.protected java.awt.FontgetFontForCharacter(TextCharacter character)Returning the AWT font to use for the specific character.protected intgetFontHeight()Used to find out the font height, in pixelsprotected intgetFontWidth()Used to find out the font width, in pixelsprotected intgetHeight()Used when requiring the total height of the terminal component, in pixelsprotected intgetWidth()Used when requiring the total width of the terminal component, in pixelsprotected booleanisTextAntiAliased()Returnstrueif anti-aliasing is enabled,falseotherwiseKeyStrokereadInput()Returns the nextKeyoff the input queue or blocks until one is available.protected voidrepaint()Called by theGraphicalTerminalImplementationwhen it would like the OS to schedule a repaint of the window-
Methods inherited from class com.googlecode.lanterna.terminal.swing.GraphicalTerminalImplementation
addInput, addResizeListener, bell, clearScreen, close, disableSGR, enableSGR, enquireTerminal, enterPrivateMode, exitPrivateMode, flush, getColorConfiguration, getCursorPosition, getDeviceConfiguration, getPreferredSize, getTerminalSize, newTextGraphics, onCreated, onDestroyed, paintComponent, pollInput, putCharacter, putString, removeResizeListener, resetColorAndSGR, setBackgroundColor, setCursorPosition, setCursorPosition, setCursorVisible, setForegroundColor, startBlinkTimer, stopBlinkTimer
-
-
-
-
Field Detail
-
component
private final javax.swing.JComponent component
-
fontConfiguration
private final SwingTerminalFontConfiguration fontConfiguration
-
-
Constructor Detail
-
SwingTerminalImplementation
SwingTerminalImplementation(javax.swing.JComponent component, SwingTerminalFontConfiguration fontConfiguration, TerminalSize initialTerminalSize, TerminalEmulatorDeviceConfiguration deviceConfiguration, TerminalEmulatorColorConfiguration colorConfiguration, TerminalScrollController scrollController)Creates a newSwingTerminalImplementation- Parameters:
component- JComponent that is the Swing terminal surfacefontConfiguration- Font configuration to useinitialTerminalSize- Initial size of the terminaldeviceConfiguration- Device configurationcolorConfiguration- Color configurationscrollController- Controller to be used when inspecting scroll status
-
-
Method Detail
-
getFontConfiguration
public SwingTerminalFontConfiguration getFontConfiguration()
Returns the current font configuration. Note that it is immutable and cannot be changed.- Returns:
- This SwingTerminal's current font configuration
-
getFontHeight
protected int getFontHeight()
Description copied from class:GraphicalTerminalImplementationUsed to find out the font height, in pixels- Specified by:
getFontHeightin classGraphicalTerminalImplementation- Returns:
- Terminal font height in pixels
-
getFontWidth
protected int getFontWidth()
Description copied from class:GraphicalTerminalImplementationUsed to find out the font width, in pixels- Specified by:
getFontWidthin classGraphicalTerminalImplementation- Returns:
- Terminal font width in pixels
-
getHeight
protected int getHeight()
Description copied from class:GraphicalTerminalImplementationUsed when requiring the total height of the terminal component, in pixels- Specified by:
getHeightin classGraphicalTerminalImplementation- Returns:
- Height of the terminal component, in pixels
-
getWidth
protected int getWidth()
Description copied from class:GraphicalTerminalImplementationUsed when requiring the total width of the terminal component, in pixels- Specified by:
getWidthin classGraphicalTerminalImplementation- Returns:
- Width of the terminal component, in pixels
-
getFontForCharacter
protected java.awt.Font getFontForCharacter(TextCharacter character)
Description copied from class:GraphicalTerminalImplementationReturning the AWT font to use for the specific character. This might not always be the same, in case a we are trying to draw an unusual character (probably CJK) which isn't contained in the standard terminal font.- Specified by:
getFontForCharacterin classGraphicalTerminalImplementation- Parameters:
character- Character to get the font for- Returns:
- Font to be used for this character
-
isTextAntiAliased
protected boolean isTextAntiAliased()
Description copied from class:GraphicalTerminalImplementationReturnstrueif anti-aliasing is enabled,falseotherwise- Specified by:
isTextAntiAliasedin classGraphicalTerminalImplementation- Returns:
trueif anti-aliasing is enabled,falseotherwise
-
repaint
protected void repaint()
Description copied from class:GraphicalTerminalImplementationCalled by theGraphicalTerminalImplementationwhen it would like the OS to schedule a repaint of the window- Specified by:
repaintin classGraphicalTerminalImplementation
-
readInput
public KeyStroke readInput()
Description copied from interface:InputProviderReturns the nextKeyoff the input queue or blocks until one is available. NOTE: In previous versions of Lanterna, this method was not blocking. From lanterna 3, it is blocking and you can callpollInput()for the non-blocking version.- Specified by:
readInputin interfaceInputProvider- Specified by:
readInputin interfaceIOSafeTerminal- Overrides:
readInputin classGraphicalTerminalImplementation- Returns:
- Key object which represents a keystroke coming in through the input stream
-
-