public class SwingTerminal extends LogicalScreen implements TerminalReader, java.awt.event.ComponentListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.event.WindowListener
Modifier and Type | Class and Description |
---|---|
static class |
SwingTerminal.CursorStyle
Cursor style to draw.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FONTFILE
The terminus font resource filename.
|
cursorVisible, cursorX, cursorY, height, logical, physical, reallyCleared, width
Constructor and Description |
---|
SwingTerminal(int windowWidth,
int windowHeight,
int fontSize,
java.lang.Object listener)
Public constructor creates a new JFrame to render to.
|
SwingTerminal(javax.swing.JComponent component,
int windowWidth,
int windowHeight,
int fontSize,
java.lang.Object listener)
Public constructor renders to an existing JComponent.
|
Modifier and Type | Method and Description |
---|---|
static java.awt.Color |
attrToBackgroundColor(CellAttributes attr)
Convert a CellAttributes background color to an Swing Color.
|
static java.awt.Color |
attrToForegroundColor(CellAttributes attr)
Convert a CellAttributes foreground color to an Swing Color.
|
void |
closeTerminal()
Restore terminal to normal state.
|
void |
componentHidden(java.awt.event.ComponentEvent event)
Pass component events into the event queue.
|
void |
componentMoved(java.awt.event.ComponentEvent event)
Pass component events into the event queue.
|
void |
componentResized(java.awt.event.ComponentEvent event)
Pass component events into the event queue.
|
void |
componentShown(java.awt.event.ComponentEvent event)
Pass component events into the event queue.
|
void |
flushPhysical()
Push the logical screen to the physical device.
|
long |
getBlinkMillis()
Get the number of millis to wait before switching the blink from
visible to invisible.
|
boolean |
getCursorBlinkVisible()
Get the current status of the blink flag.
|
void |
getEvents(java.util.List<TInputEvent> queue)
Return any events in the IO queue.
|
java.awt.Font |
getFont()
Get the font this screen was last set to.
|
int |
getFontSize()
Get the font size in points.
|
SessionInfo |
getSessionInfo()
Getter for sessionInfo.
|
jexer.backend.SwingComponent |
getSwingComponent()
Getter for the underlying Swing component.
|
int |
getTextAdjustHeight()
Get the height text adjustment.
|
int |
getTextAdjustWidth()
Get the width text adjustment.
|
int |
getTextAdjustX()
Get the X text adjustment.
|
int |
getTextAdjustY()
Get the Y text adjustment.
|
int |
getTextHeight()
Get the height of a character cell in pixels.
|
int |
getTextWidth()
Get the width of a character cell in pixels.
|
boolean |
hasEvents()
Check if there are events in the queue.
|
void |
keyPressed(java.awt.event.KeyEvent key)
Pass Swing keystrokes into the event queue.
|
void |
keyReleased(java.awt.event.KeyEvent key)
Pass Swing keystrokes into the event queue.
|
void |
keyTyped(java.awt.event.KeyEvent key)
Pass Swing keystrokes into the event queue.
|
void |
mouseClicked(java.awt.event.MouseEvent mouse)
Pass mouse events into the event queue.
|
void |
mouseDragged(java.awt.event.MouseEvent mouse)
Pass mouse events into the event queue.
|
void |
mouseEntered(java.awt.event.MouseEvent mouse)
Pass mouse events into the event queue.
|
void |
mouseExited(java.awt.event.MouseEvent mouse)
Pass mouse events into the event queue.
|
void |
mouseMoved(java.awt.event.MouseEvent mouse)
Pass mouse events into the event queue.
|
void |
mousePressed(java.awt.event.MouseEvent mouse)
Pass mouse events into the event queue.
|
void |
mouseReleased(java.awt.event.MouseEvent mouse)
Pass mouse events into the event queue.
|
void |
mouseWheelMoved(java.awt.event.MouseWheelEvent mouse)
Pass mouse events into the event queue.
|
void |
paint(java.awt.Graphics gr)
Paint redraws the whole screen.
|
void |
reloadOptions()
Reload options from System properties.
|
void |
resizeToScreen()
Resize the physical screen to match the logical screen dimensions.
|
void |
setDefaultFont()
Set the font to Terminus, the best all-around font for both CP437 and
ISO8859-1.
|
void |
setFont(java.awt.Font font)
Set to a new font, and resize the screen to match its dimensions.
|
void |
setFontSize(int fontSize)
Set the font size in points.
|
void |
setListener(java.lang.Object listener)
Set listener to a different Object.
|
void |
setTextAdjustHeight(int textAdjustHeight)
Set the height text adjustment.
|
void |
setTextAdjustWidth(int textAdjustWidth)
Set the width text adjustment.
|
void |
setTextAdjustX(int textAdjustX)
Set the X text adjustment.
|
void |
setTextAdjustY(int textAdjustY)
Set the Y text adjustment.
|
void |
setTitle(java.lang.String title)
Set the window title.
|
void |
shutdown()
Restore terminal to normal state.
|
int |
textColumn(int x)
Convert pixel column position to text cell column position.
|
int |
textRow(int y)
Convert pixel row position to text cell row position.
|
void |
windowActivated(java.awt.event.WindowEvent event)
Pass window events into the event queue.
|
void |
windowClosed(java.awt.event.WindowEvent event)
Pass window events into the event queue.
|
void |
windowClosing(java.awt.event.WindowEvent event)
Pass window events into the event queue.
|
void |
windowDeactivated(java.awt.event.WindowEvent event)
Pass window events into the event queue.
|
void |
windowDeiconified(java.awt.event.WindowEvent event)
Pass window events into the event queue.
|
void |
windowIconified(java.awt.event.WindowEvent event)
Pass window events into the event queue.
|
void |
windowOpened(java.awt.event.WindowEvent event)
Pass window events into the event queue.
|
clear, clearPhysical, drawBox, drawBox, drawBoxShadow, getAttrXY, getCharXY, getClipBottom, getClipLeft, getClipRight, getClipTop, getCursorX, getCursorY, getHeight, getWidth, hideCursor, hLineXY, isCursorVisible, isDirty, putAll, putAttrXY, putAttrXY, putCharXY, putCharXY, putCharXY, putCursor, putFullwidthCharXY, putFullwidthCharXY, putFullwidthCharXY, putStringXY, putStringXY, reset, resetClipping, setClipBottom, setClipLeft, setClipRight, setClipTop, setDimensions, setHeight, setOffsetX, setOffsetY, setWidth, unsetImageRow, vLineXY
public static final java.lang.String FONTFILE
public SwingTerminal(int windowWidth, int windowHeight, int fontSize, java.lang.Object listener)
windowWidth
- the number of text columns to start withwindowHeight
- the number of text rows to start withfontSize
- the size in points. Good values to pick are: 16, 20,
22, and 24.listener
- the object this backend needs to wake up when new
input comes inpublic SwingTerminal(javax.swing.JComponent component, int windowWidth, int windowHeight, int fontSize, java.lang.Object listener)
component
- the Swing component to render towindowWidth
- the number of text columns to start withwindowHeight
- the number of text rows to start withfontSize
- the size in points. Good values to pick are: 16, 20,
22, and 24.listener
- the object this backend needs to wake up when new
input comes inpublic void setTitle(java.lang.String title)
setTitle
in interface Screen
setTitle
in class LogicalScreen
title
- the new titlepublic void flushPhysical()
flushPhysical
in interface Screen
flushPhysical
in class LogicalScreen
public boolean hasEvents()
hasEvents
in interface TerminalReader
public void getEvents(java.util.List<TInputEvent> queue)
getEvents
in interface TerminalReader
queue
- list to append new events topublic void closeTerminal()
closeTerminal
in interface TerminalReader
public void setListener(java.lang.Object listener)
setListener
in interface TerminalReader
listener
- the new listening object that run() wakes up on new
inputpublic void reloadOptions()
reloadOptions
in interface TerminalReader
public int getTextWidth()
getTextWidth
in interface Screen
getTextWidth
in class LogicalScreen
public int getTextHeight()
getTextHeight
in interface Screen
getTextHeight
in class LogicalScreen
public long getBlinkMillis()
public boolean getCursorBlinkVisible()
public int getFontSize()
public void setFontSize(int fontSize)
fontSize
- font size in pointspublic void setFont(java.awt.Font font)
font
- the new fontpublic java.awt.Font getFont()
public void setDefaultFont()
public int getTextAdjustX()
public void setTextAdjustX(int textAdjustX)
textAdjustX
- the X text adjustmentpublic int getTextAdjustY()
public void setTextAdjustY(int textAdjustY)
textAdjustY
- the Y text adjustmentpublic int getTextAdjustHeight()
public void setTextAdjustHeight(int textAdjustHeight)
textAdjustHeight
- the height text adjustmentpublic int getTextAdjustWidth()
public void setTextAdjustWidth(int textAdjustWidth)
textAdjustWidth
- the width text adjustmentpublic static java.awt.Color attrToForegroundColor(CellAttributes attr)
attr
- the text attributespublic static java.awt.Color attrToBackgroundColor(CellAttributes attr)
attr
- the text attributespublic void resizeToScreen()
resizeToScreen
in class LogicalScreen
public void paint(java.awt.Graphics gr)
gr
- the Swing Graphics contextpublic void shutdown()
public int textColumn(int x)
x
- pixel column positionpublic int textRow(int y)
y
- pixel row positionpublic SessionInfo getSessionInfo()
public jexer.backend.SwingComponent getSwingComponent()
public void keyReleased(java.awt.event.KeyEvent key)
keyReleased
in interface java.awt.event.KeyListener
key
- keystroke receivedpublic void keyTyped(java.awt.event.KeyEvent key)
keyTyped
in interface java.awt.event.KeyListener
key
- keystroke receivedpublic void keyPressed(java.awt.event.KeyEvent key)
keyPressed
in interface java.awt.event.KeyListener
key
- keystroke receivedpublic void windowActivated(java.awt.event.WindowEvent event)
windowActivated
in interface java.awt.event.WindowListener
event
- window event receivedpublic void windowClosed(java.awt.event.WindowEvent event)
windowClosed
in interface java.awt.event.WindowListener
event
- window event receivedpublic void windowClosing(java.awt.event.WindowEvent event)
windowClosing
in interface java.awt.event.WindowListener
event
- window event receivedpublic void windowDeactivated(java.awt.event.WindowEvent event)
windowDeactivated
in interface java.awt.event.WindowListener
event
- window event receivedpublic void windowDeiconified(java.awt.event.WindowEvent event)
windowDeiconified
in interface java.awt.event.WindowListener
event
- window event receivedpublic void windowIconified(java.awt.event.WindowEvent event)
windowIconified
in interface java.awt.event.WindowListener
event
- window event receivedpublic void windowOpened(java.awt.event.WindowEvent event)
windowOpened
in interface java.awt.event.WindowListener
event
- window event receivedpublic void componentHidden(java.awt.event.ComponentEvent event)
componentHidden
in interface java.awt.event.ComponentListener
event
- component event receivedpublic void componentShown(java.awt.event.ComponentEvent event)
componentShown
in interface java.awt.event.ComponentListener
event
- component event receivedpublic void componentMoved(java.awt.event.ComponentEvent event)
componentMoved
in interface java.awt.event.ComponentListener
event
- component event receivedpublic void componentResized(java.awt.event.ComponentEvent event)
componentResized
in interface java.awt.event.ComponentListener
event
- component event receivedpublic void mouseDragged(java.awt.event.MouseEvent mouse)
mouseDragged
in interface java.awt.event.MouseMotionListener
mouse
- mouse event receivedpublic void mouseMoved(java.awt.event.MouseEvent mouse)
mouseMoved
in interface java.awt.event.MouseMotionListener
mouse
- mouse event receivedpublic void mouseClicked(java.awt.event.MouseEvent mouse)
mouseClicked
in interface java.awt.event.MouseListener
mouse
- mouse event receivedpublic void mouseEntered(java.awt.event.MouseEvent mouse)
mouseEntered
in interface java.awt.event.MouseListener
mouse
- mouse event receivedpublic void mouseExited(java.awt.event.MouseEvent mouse)
mouseExited
in interface java.awt.event.MouseListener
mouse
- mouse event receivedpublic void mousePressed(java.awt.event.MouseEvent mouse)
mousePressed
in interface java.awt.event.MouseListener
mouse
- mouse event receivedpublic void mouseReleased(java.awt.event.MouseEvent mouse)
mouseReleased
in interface java.awt.event.MouseListener
mouse
- mouse event receivedpublic void mouseWheelMoved(java.awt.event.MouseWheelEvent mouse)
mouseWheelMoved
in interface java.awt.event.MouseWheelListener
mouse
- mouse event receivedCopyright © 2019 Kevin Lamonte. Licensed MIT.