public class SwingGuiDriver extends AbstractGuiDriver<java.awt.Font>
Modifier and Type | Class and Description |
---|---|
private static class |
SwingGuiDriver.BrowserHelper
Parses the provided command line and returns the executable and its options.
|
AbstractGuiDriver.TextMetrics
Modifier and Type | Field and Description |
---|---|
private java.awt.KeyboardFocusManager |
keyboardFocusManager
The driver's level keyboard focus manager.
|
private SwingKeyboardReader |
keyReader
The key reader.
|
config, control, ews, LOG, translatedOrigin
direct, factory
Constructor and Description |
---|
SwingGuiDriver(BootstrapConfig config)
Create a new GUI screen driver.
|
Modifier and Type | Method and Description |
---|---|
void |
beep()
Provide an audible feedback to user by generating a beep signal.
|
private java.net.URI |
buildOpenResourcePage(java.lang.String mimeType,
java.lang.String url)
Builds the html document that embeds the target resource given by its url path and its mime
type.
|
java.lang.String |
clipboardContents()
Get the current contents from the OS clipboard.
|
void |
copyToClipboard(java.lang.String txt)
Copy the given text to the system clipboard.
|
FontDetails<java.awt.Font> |
createFont(FontDetails<java.awt.Font> specs)
Create a font with the given details and register it with the driver.
|
MousePtrWrapper |
createMousePointer(java.io.InputStream data,
java.lang.String ptrName)
Load mouse pointer from the InputStream
|
void |
deliverDocumentOutput(java.util.function.Consumer<java.io.OutputStream> consumer,
java.lang.Runnable finalizer,
MediaType format)
The method delivers document output to the client.
|
void |
deregisterWidget(int wid)
Deregister the specified widget for mouse events.
|
void |
deriveFont(FontDetails<java.awt.Font> fd)
Scale the given font to match the screen resolution.
|
NativePoint |
getMousePosition()
Returns current mouse cursor display position relative to the display origin.
|
private java.io.File |
getPrintOutputDir()
Returns the directory for print output.
|
int |
getScreenResolution()
Reports the screen resolution in dots per inch (DPI).
|
boolean |
isFontInstalled(java.lang.String fontName,
boolean boldFont)
Tests if the target font is known to JRE.
|
boolean |
isWindowDecorationSupported()
Returns true if a window can be decorated in this graphics environment, otherwise false.
|
void |
moveToBottom(int windowId)
Move the specified window to the bottom of the z-order, at the OS level.
|
void |
moveToTop(int windowId,
boolean focus)
Move the specified window to the top of the z-order, at the OS level.
|
EmulatedWindowState |
newChildWindowEmulator(int windowId,
EmulatedWindowState owner,
java.lang.String windowTitle,
boolean resizable,
boolean isShareActivationWithOwner,
boolean modal)
Create a new child window emulator.
|
EmulatedWindowState |
newEmulator(int windowId,
boolean showInTaskbar)
Create a new window emulator.
|
private void |
openDocument(java.net.URI uri)
Open the target document given by its URI.
|
void |
openMimeResource(java.lang.String mimeType,
java.lang.String urlString,
boolean embedded)
Opens the specified resource in a browser's window.
|
int |
readKey()
Read single keystroke from keyboard.
|
void |
registerHoverableWidget(MouseHoverAction action)
Register this widget as being editable, so that the mouse cursor will adjust properly when
the widget is entered.
|
void |
registerMoveableWidget(int wid)
Register the specified widget as a moveable widget, via mouse.
|
void |
registerResizeableWidget(int wid)
Register the specified widget as a resizeable widget, via mouse.
|
void |
restackWindows(int[] windowIds)
Force the list of all GUI windows to be stacked as in the specified order.
|
void |
setAlwaysOnTop(int windowId,
boolean topOnly,
boolean alwaysOnTop)
Makes the supplied window to be on top of other windows.
|
void |
setCurrentSelection(java.lang.String txt)
Sets the current selection.
|
void |
setCursor(java.awt.Cursor c)
Set the mouse cursor to the given one.
|
void |
setCursor(CursorType type)
Set the mouse cursor to the given type.
|
void |
setCursor(MousePtrWrapper ptr)
Set the mouse cursor
|
void |
setResizeableWindow(boolean resize,
int minWidth,
int minHeight,
int maxWidth,
int maxHeight)
Set the window details for resize; this includes the minimum and maximun dimensions, and
also the window's resizeable state.
|
cacheTextMetrics, captureMouseEvents, clear, createGreyImage, createIcon, createImage, createOutputManager, deiconifyWindow, deregisterTooltipWorkers, deregisterWindow, draw, draw, draw3DRect, drawCursor, drawEllipse, drawFromOrigin, drawHighlight, drawImage, drawLine, drawParagraph, drawRect, drawRoundRect, drawSelection, drawString, drawStringCentered, drawStringCentered, drawStringScaled, drawStringWithMnemonic, drawTextSelection, enableEvents, endBatch, fill3DRect, fillEllipse, fillPolygon, fillRect, fillRectAroundText, fillRoundRect, getBgColor, getBgStdColor, getChildProcessFactory, getDisplayBounds, getDisplayWorkArea, getFgColor, getFgStdColor, getFontHeight, getFontMaxWidth, getFontWidth, getFontWidths, getParagraphHeight, getPrintOutputFile, getSubImage, getSysColor, getTextHeight, getTextMetrics, getTextWidth, getTextWidths, getTextWidths, getWindowDimension, getWindowLocation, handleMouseEvent, hasWindowEmulator, iconifyWindow, isActualTextMetricsCached, isEmptyText, isWindowVisible, listenAnyMouseEvent, makeImage, needsExplicitTextMetricsCaching, registerChildWindow, registerDirectManipulation, registerMouseWidgets, registerPendingTooltipWorkers, registerTooltipWorker, registerWidgetPopup, registerWindow, releaseWindow, resetComposite, resetMode, resizeWindow, resolveTextMetrics, restoreDrawingState, resume, resume, saveDrawingState, scaleFont, selectWindow, setColor, setColor, setControl, setCursorStatus, setDesktopBgColor, setDisableRedraw, setDrawingArea, setDrawingAreas, setFontStyle, setGuiFont, setIcon, setLineStroke, setLineStroke, setTextMetrics, setTitle, setWindowBounds, setWindowEnabled, setWindowLocation, setWindowVisible, setXORComposite, setXORMode, shutdown, stackWindows, startBatch, suspend, suspend, translatePop, translatePush
getFactory, getPrimitives, getWindowSystem, inBackgroundMode, inBatchMode, init, isChui, setBackgroundMode, setBatchMode, setTerminalType, terminalType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initDragAndDrop, notifyWait, parseEditorContent, propagateWaitState, resetSelection, setUploadFileSizeLimits, withSelectedWindow
clientReady, getFactory, getPrimitives, getWindowSystem, inBackgroundMode, inBatchMode, init, isChui, lockMousePointer, propagate, setTerminalType, terminalType
private final SwingKeyboardReader keyReader
private final java.awt.KeyboardFocusManager keyboardFocusManager
public SwingGuiDriver(BootstrapConfig config)
config
- The BootstrapConfig
configuration.public void beep()
public void registerMoveableWidget(int wid)
wid
- The widget ID.public void registerHoverableWidget(MouseHoverAction action)
action
- The widget mouse action.public void registerResizeableWidget(int wid)
wid
- The widget ID.public void setResizeableWindow(boolean resize, int minWidth, int minHeight, int maxWidth, int maxHeight)
This is a no-op for Swing.
resize
- Flag indicating if the window can be resized or not.minWidth
- The window's minimum width.minHeight
- The window's minimum height.maxWidth
- The window's maximum width.maxHeight
- The window's maximum height.public void deregisterWidget(int wid)
deregisterWidget
in interface GuiDriver<java.awt.Font,java.awt.image.BufferedImage>
deregisterWidget
in class AbstractGuiDriver<java.awt.Font>
wid
- The widget ID.public int getScreenResolution()
public int readKey()
public EmulatedWindowState newEmulator(int windowId, boolean showInTaskbar)
newEmulator
in class AbstractGuiDriver<java.awt.Font>
windowId
- The window ID.showInTaskbar
- This flag is not supported by swing driver.public EmulatedWindowState newChildWindowEmulator(int windowId, EmulatedWindowState owner, java.lang.String windowTitle, boolean resizable, boolean isShareActivationWithOwner, boolean modal)
newChildWindowEmulator
in class AbstractGuiDriver<java.awt.Font>
windowId
- The window ID.owner
- The owning window.windowTitle
- Title of the window emulator.resizable
- true
if the window is resizable.isShareActivationWithOwner
- Indicates whether the window shares activation state with its owner.modal
- true
if this is a modal window.public FontDetails<java.awt.Font> createFont(FontDetails<java.awt.Font> specs)
specs
- The font specifications.public void deriveFont(FontDetails<java.awt.Font> fd)
deriveFont
in class AbstractGuiDriver<java.awt.Font>
fd
- Font to scale. This instance's contained font will be modified.public void copyToClipboard(java.lang.String txt)
txt
- The text to be copied.public java.lang.String clipboardContents()
public void restackWindows(int[] windowIds)
This is a no-op. Swing handle this automatically.
restackWindows
in class AbstractGuiDriver<java.awt.Font>
windowIds
- The stack order to be enforced.public void moveToTop(int windowId, boolean focus)
This is a no-op. Swing handle this automatically.
moveToTop
in interface GuiDriver<java.awt.Font,java.awt.image.BufferedImage>
moveToTop
in class AbstractGuiDriver<java.awt.Font>
windowId
- The window to be moved.focus
- If true
, the window will become the focused window
and its state changed to active.public void moveToBottom(int windowId)
This is a no-op. Swing handle this automatically.
moveToBottom
in interface GuiDriver<java.awt.Font,java.awt.image.BufferedImage>
moveToBottom
in class AbstractGuiDriver<java.awt.Font>
windowId
- The window to be moved.public void setCurrentSelection(java.lang.String txt)
txt
- The current selection.public MousePtrWrapper createMousePointer(java.io.InputStream data, java.lang.String ptrName)
data
- cursor dataptrName
- pointer namenull
public void setCursor(MousePtrWrapper ptr)
ptr
- mouse cursorpublic void setCursor(CursorType type)
type
- The cursor type.public void setCursor(java.awt.Cursor c)
c
- The custom cursor.public boolean isFontInstalled(java.lang.String fontName, boolean boldFont)
fontName
- The target font name.boldFont
- Indicates that the bold font is queried.public boolean isWindowDecorationSupported()
public NativePoint getMousePosition()
null
public void deliverDocumentOutput(java.util.function.Consumer<java.io.OutputStream> consumer, java.lang.Runnable finalizer, MediaType format)
This implementation outputs the document data to a file. The output directory is given by
getPrintOutputDir()
and file name by AbstractGuiDriver.getPrintOutputFile(MediaType format)
.
consumer
- Output consumer, must not be null. See above.finalizer
- Finalizer callback, may be null. See above.format
- Report output format.public void openMimeResource(java.lang.String mimeType, java.lang.String urlString, boolean embedded) throws java.net.MalformedURLException
mimeType
- The resource mime type.urlString
- The string presentation of the target resource url.embedded
- The document is embedded in the template document.java.net.MalformedURLException
- If the string presentation of the target resource url is malformed.public void setAlwaysOnTop(int windowId, boolean topOnly, boolean alwaysOnTop)
AbstractGuiDriver.stackWindows(int[])
is not fully supported by the driver.windowId
- The window to be changed.topOnly
- Corresponds to the WINDOW:TOP-ONLY attribute.alwaysOnTop
- Corresponds to the WINDOW:ALWAYS-ON-TOP attribute.private java.io.File getPrintOutputDir()
File
object representing the output directory.private java.net.URI buildOpenResourcePage(java.lang.String mimeType, java.lang.String url) throws java.io.IOException
mimeType
- The resource mime type.url
- The url of the target resource.java.io.IOException
- Iff the target IO operation is failed.private void openDocument(java.net.URI uri) throws java.io.IOException
uri
- The document URIjava.io.IOException
- Iff the target IO operation is failed