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
,Closeable
,AutoCloseable
Concrete implementation of
GraphicalTerminalImplementation
that 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
FieldsModifier and TypeFieldDescriptionprivate final JComponent
private final SwingTerminalFontConfiguration
-
Constructor Summary
ConstructorsConstructorDescriptionSwingTerminalImplementation
(JComponent component, SwingTerminalFontConfiguration fontConfiguration, TerminalSize initialTerminalSize, TerminalEmulatorDeviceConfiguration deviceConfiguration, TerminalEmulatorColorConfiguration colorConfiguration, TerminalScrollController scrollController) Creates a newSwingTerminalImplementation
-
Method Summary
Modifier and TypeMethodDescriptionReturns the current font configuration.protected Font
getFontForCharacter
(TextCharacter character) Returning the AWT font to use for the specific character.protected int
Used to find out the font height, in pixelsprotected int
Used to find out the font width, in pixelsprotected int
Used when requiring the total height of the terminal component, in pixelsprotected int
getWidth()
Used when requiring the total width of the terminal component, in pixelsprotected boolean
Returnstrue
if anti-aliasing is enabled,false
otherwiseReturns the nextKey
off the input queue or blocks until one is available.protected void
repaint()
Called by theGraphicalTerminalImplementation
when it would like the OS to schedule a repaint of the windowMethods 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 Details
-
component
-
fontConfiguration
-
-
Constructor Details
-
SwingTerminalImplementation
SwingTerminalImplementation(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 Details
-
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:GraphicalTerminalImplementation
Used to find out the font height, in pixels- Specified by:
getFontHeight
in classGraphicalTerminalImplementation
- Returns:
- Terminal font height in pixels
-
getFontWidth
protected int getFontWidth()Description copied from class:GraphicalTerminalImplementation
Used to find out the font width, in pixels- Specified by:
getFontWidth
in classGraphicalTerminalImplementation
- Returns:
- Terminal font width in pixels
-
getHeight
protected int getHeight()Description copied from class:GraphicalTerminalImplementation
Used when requiring the total height of the terminal component, in pixels- Specified by:
getHeight
in classGraphicalTerminalImplementation
- Returns:
- Height of the terminal component, in pixels
-
getWidth
protected int getWidth()Description copied from class:GraphicalTerminalImplementation
Used when requiring the total width of the terminal component, in pixels- Specified by:
getWidth
in classGraphicalTerminalImplementation
- Returns:
- Width of the terminal component, in pixels
-
getFontForCharacter
Description copied from class:GraphicalTerminalImplementation
Returning 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:
getFontForCharacter
in 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:GraphicalTerminalImplementation
Returnstrue
if anti-aliasing is enabled,false
otherwise- Specified by:
isTextAntiAliased
in classGraphicalTerminalImplementation
- Returns:
true
if anti-aliasing is enabled,false
otherwise
-
repaint
protected void repaint()Description copied from class:GraphicalTerminalImplementation
Called by theGraphicalTerminalImplementation
when it would like the OS to schedule a repaint of the window- Specified by:
repaint
in classGraphicalTerminalImplementation
-
readInput
Description copied from interface:InputProvider
Returns the nextKey
off 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:
readInput
in interfaceInputProvider
- Specified by:
readInput
in interfaceIOSafeTerminal
- Overrides:
readInput
in classGraphicalTerminalImplementation
- Returns:
- Key object which represents a keystroke coming in through the input stream
-