TextGUI
, WindowBasedTextGUI
public class MultiWindowTextGUI extends AbstractTextGUI implements WindowBasedTextGUI
TextGUI.Listener
Constructor | Description |
---|---|
MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory,
Screen screen) |
Creates a new
MultiWindowTextGUI that uses the specified Screen as the backend for all drawing
operations. |
MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory,
Screen screen,
WindowManager windowManager) |
Creates a new
MultiWindowTextGUI that uses the specified Screen as the backend for all drawing
operations and a custom WindowManager . |
MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory,
Screen screen,
WindowManager windowManager,
WindowPostRenderer postRenderer,
Component background) |
Creates a new
MultiWindowTextGUI that uses the specified Screen as the backend for all drawing
operations. |
MultiWindowTextGUI(Screen screen) |
Creates a new
MultiWindowTextGUI that uses the specified Screen as the backend for all drawing
operations. |
MultiWindowTextGUI(Screen screen,
WindowManager windowManager,
Component background) |
Creates a new
MultiWindowTextGUI that uses the specified Screen as the backend for all drawing
operations. |
MultiWindowTextGUI(Screen screen,
WindowManager windowManager,
WindowPostRenderer postRenderer,
Component background) |
Creates a new
MultiWindowTextGUI that uses the specified Screen as the backend for all drawing
operations. |
MultiWindowTextGUI(Screen screen,
TextColor backgroundColor) |
Deprecated.
It's preferred to use a custom background component if you want to customize the background color,
or change the theme
|
Modifier and Type | Method | Description |
---|---|---|
WindowBasedTextGUI |
addWindow(Window window) |
Adds a window to the TextGUI system, depending on the window manager this window may or may not be immediately
visible.
|
WindowBasedTextGUI |
addWindowAndWait(Window window) |
Adds a window to the TextGUI system, depending on the window manager this window may or may not be immediately
visible.
|
WindowBasedTextGUI |
cycleActiveWindow(boolean reverse) |
Switches the active window by cyclically shuffling the window list.
|
protected void |
drawGUI(TextGUIGraphics graphics) |
Draws the entire GUI using a
TextGUIGraphics object |
Window |
getActiveWindow() |
Returns the window which the TextGUI considers the active one at the time of the method call.
|
BasePane |
getBackgroundPane() |
Returns the container for the background, which works as a single large component that takes up the whole
terminal area and is always behind all windows.
|
TerminalPosition |
getCursorPosition() |
Top-level method for drilling in to the GUI and figuring out, in global coordinates, where to place the text
cursor on the screen at this time.
|
Interactable |
getFocusedInteractable() |
Returns the interactable component currently in focus
|
WindowManager |
getWindowManager() |
Returns the window manager that is currently controlling this TextGUI.
|
WindowPostRenderer |
getWindowPostRenderer() |
Returns the
WindowPostRenderer for this WindowBasedTextGUI |
Collection<Window> |
getWindows() |
Returns a list of all windows currently in the TextGUI.
|
boolean |
handleInput(KeyStroke keyStroke) |
This method should take the user input and feed it to the focused component for handling.
|
boolean |
isEOFWhenNoWindows() |
Returns whether the TextGUI should return EOF when you try to read input while there are no windows in the window
manager.
|
boolean |
isPendingUpdate() |
This method can be used to determine if any component has requested a redraw.
|
WindowBasedTextGUI |
moveToTop(Window window) |
Windows are internally stored as a stack and newer windows are added at the top of the stack.
|
protected KeyStroke |
readKeyStroke() |
Reads one key from the input queue, blocking or non-blocking depending on if blocking I/O has been enabled.
|
WindowBasedTextGUI |
removeWindow(Window window) |
Removes a window from the TextGUI.
|
MultiWindowTextGUI |
setActiveWindow(Window activeWindow) |
Selects a particular window to be considered 'active' and receive all input events
|
void |
setEOFWhenNoWindows(boolean eofWhenNoWindows) |
Sets whether the TextGUI should return EOF when you try to read input while there are no windows in the window
manager.
|
void |
setVirtualScreenEnabled(boolean virtualScreenEnabled) |
This method controls whether or not the virtual screen should be used.
|
void |
updateScreen() |
Updates the screen, to make any changes visible to the user.
|
void |
waitForWindowToClose(Window window) |
Waits for the specified window to be closed
|
addListener, fireUnhandledKeyStroke, getGUIThread, getScreen, getTheme, invalidate, isBlockingIO, pollInput, processInput, removeListener, setBlockingIO, setTheme
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addListener, getGUIThread, getScreen, getTheme, processInput, removeListener, setTheme
public MultiWindowTextGUI(Screen screen)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations. The screen will be automatically wrapped in a VirtualScreen
in order to deal with GUIs
becoming too big to fit the terminal. The background area of the GUI will be solid blue.screen
- Screen to use as the backend for drawing operationspublic MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory, Screen screen)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations. The screen will be automatically wrapped in a VirtualScreen
in order to deal with GUIs
becoming too big to fit the terminal. The background area of the GUI will be solid blueguiThreadFactory
- Factory implementation to use when creating the TextGUIThread
screen
- Screen to use as the backend for drawing operationspublic MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory, Screen screen, WindowManager windowManager)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations and a custom WindowManager
. The screen will be automatically wrapped in a
VirtualScreen
in order to deal with GUIs becoming too big to fit the terminal. The background area of the
GUI will use the default GUIBackdrop
component.guiThreadFactory
- Factory implementation to use when creating the TextGUIThread
screen
- Screen to use as the backend for drawing operationswindowManager
- Custom window manager to use@Deprecated public MultiWindowTextGUI(Screen screen, TextColor backgroundColor)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations. The screen will be automatically wrapped in a VirtualScreen
in order to deal with GUIs
becoming too big to fit the terminal. The background area of the GUI is a solid color as decided by the
backgroundColor
parameter.screen
- Screen to use as the backend for drawing operationsbackgroundColor
- Color to use for the GUI backgroundpublic MultiWindowTextGUI(Screen screen, WindowManager windowManager, Component background)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations. The screen will be automatically wrapped in a VirtualScreen
in order to deal with GUIs
becoming too big to fit the terminal. The background area of the GUI is the component passed in as the
background
parameter, forced to full size.screen
- Screen to use as the backend for drawing operationswindowManager
- Window manager implementation to usebackground
- Component to use as the background of the GUI, behind all the windowspublic MultiWindowTextGUI(Screen screen, WindowManager windowManager, WindowPostRenderer postRenderer, Component background)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations. The screen will be automatically wrapped in a VirtualScreen
in order to deal with GUIs
becoming too big to fit the terminal. The background area of the GUI is the component passed in as the
background
parameter, forced to full size.screen
- Screen to use as the backend for drawing operationswindowManager
- Window manager implementation to usepostRenderer
- WindowPostRenderer
object to invoke after each window has been drawnbackground
- Component to use as the background of the GUI, behind all the windowspublic MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory, Screen screen, WindowManager windowManager, WindowPostRenderer postRenderer, Component background)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations. The screen will be automatically wrapped in a VirtualScreen
in order to deal with GUIs
becoming too big to fit the terminal. The background area of the GUI is the component passed in as the
background
parameter, forced to full size.guiThreadFactory
- Factory implementation to use when creating the TextGUIThread
screen
- Screen to use as the backend for drawing operationswindowManager
- Window manager implementation to usepostRenderer
- WindowPostRenderer
object to invoke after each window has been drawnbackground
- Component to use as the background of the GUI, behind all the windowspublic boolean isPendingUpdate()
TextGUI
true
, you may want to call updateScreen()
.isPendingUpdate
in interface TextGUI
isPendingUpdate
in class AbstractTextGUI
true
if this TextGUI has a change and is waiting for someone to call updateScreen()
public void updateScreen() throws IOException
TextGUI
updateScreen
in interface TextGUI
updateScreen
in class AbstractTextGUI
IOException
- In case there was an underlying I/O errorprotected KeyStroke readKeyStroke() throws IOException
AbstractTextGUI
setBlockingIO(true)
.readKeyStroke
in class AbstractTextGUI
KeyStroke
or null
if blocking I/O is disabled and there was
no input waitingIOException
- In case of an I/O error while reading inputprotected void drawGUI(TextGUIGraphics graphics)
AbstractTextGUI
TextGUIGraphics
objectdrawGUI
in class AbstractTextGUI
graphics
- Graphics object to draw usingpublic TerminalPosition getCursorPosition()
AbstractTextGUI
getCursorPosition
in class AbstractTextGUI
null
if the cursor should be hiddenpublic void setEOFWhenNoWindows(boolean eofWhenNoWindows)
eofWhenNoWindows
- Should the GUI return EOF when there are no windows leftpublic boolean isEOFWhenNoWindows()
public void setVirtualScreenEnabled(boolean virtualScreenEnabled)
false
, the virtual screen will be bypassed and any content outside of the screen will be cropped. This
property is true
by default.setVirtualScreenEnabled
in interface TextGUI
virtualScreenEnabled
- If true
, then virtual screen will be used, otherwise it is bypassedpublic Interactable getFocusedInteractable()
TextGUI
getFocusedInteractable
in interface TextGUI
public boolean handleInput(KeyStroke keyStroke)
AbstractTextGUI
handleInput
in class AbstractTextGUI
keyStroke
- KeyStroke
representing the user inputtrue
if the input was recognized and handled by the GUI, indicating that the GUI should be redrawnpublic WindowManager getWindowManager()
WindowBasedTextGUI
getWindowManager
in interface WindowBasedTextGUI
public WindowBasedTextGUI addWindow(Window window)
WindowBasedTextGUI
addWindowAndWait(..)
.
Windows are internally stored as a stack and newer windows are added at the top of the stack. The GUI system will
render windows in a predictable order from bottom to top. You can modify the stack by using
moveToTop(..)
to move a Window from its current position in the stack to the top.addWindow
in interface WindowBasedTextGUI
window
- Window to add to the GUIpublic WindowBasedTextGUI addWindowAndWait(Window window)
WindowBasedTextGUI
addWindow(..)
. This method call is useful for modal dialogs that requires a certain user input
before the application can continue.
Windows are internally stored as a stack and newer windows are added at the top of the stack. The GUI system will
render windows in a predictable order from bottom to top. You can modify the stack by using
moveToTop(..)
to move a Window from its current position in the stack to the top.addWindowAndWait
in interface WindowBasedTextGUI
window
- Window to add to the GUIpublic WindowBasedTextGUI removeWindow(Window window)
WindowBasedTextGUI
removeWindow
in interface WindowBasedTextGUI
window
- Window to closepublic void waitForWindowToClose(Window window)
WindowBasedTextGUI
waitForWindowToClose
in interface WindowBasedTextGUI
window
- Window to wait forpublic Collection<Window> getWindows()
WindowBasedTextGUI
getWindows
in interface WindowBasedTextGUI
public MultiWindowTextGUI setActiveWindow(Window activeWindow)
WindowBasedTextGUI
setActiveWindow
in interface WindowBasedTextGUI
activeWindow
- Window to become active and receive input eventspublic Window getActiveWindow()
WindowBasedTextGUI
getActiveWindow
in interface WindowBasedTextGUI
null
public BasePane getBackgroundPane()
WindowBasedTextGUI
getBackgroundPane
in interface WindowBasedTextGUI
BasePane
used by this WindowBasedTextGUI
public WindowPostRenderer getWindowPostRenderer()
WindowBasedTextGUI
WindowPostRenderer
for this WindowBasedTextGUI
getWindowPostRenderer
in interface WindowBasedTextGUI
WindowPostRenderer
for this WindowBasedTextGUI
public WindowBasedTextGUI moveToTop(Window window)
WindowBasedTextGUI
moveToTop
in interface WindowBasedTextGUI
window
- Window in the stack to move to the top positionpublic WindowBasedTextGUI cycleActiveWindow(boolean reverse)
reverse
parameter is false
then the current top window is placed at the bottom of the stack and the window immediately behind it is the new
top. If reverse
is set to true
then the window at the bottom of the stack is moved up to the
front and the previous top window will be immediately below itcycleActiveWindow
in interface WindowBasedTextGUI
reverse
- Direction to cycle through the windowsCopyright © 2020. All rights reserved.