@WebSocket public class GuiWebSocket extends WebClientProtocol
IMPORTANT: Do not use logging anywhere inside this class. When an authentication plugin is running during session establishment with the P2J server using logging no messages are written into the log and the application is blocked.
Modifier and Type | Class and Description |
---|---|
private class |
GuiWebSocket.BinaryMessage
Auxiliary class for creating messages
|
private static class |
GuiWebSocket.ClipboardRequest
Defines the possible ways that the clipboard contents can be requested.
|
private class |
GuiWebSocket.DrawCacheExpiryListener
A listener for notification when draw cache entries expire.
|
private class |
GuiWebSocket.DrawRecording
Internal class containing details about an intermediate recording of the drawing operations.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
clipboardContents
The most recently read contents of the clipboard from the web client.
|
private java.lang.Object |
clipboardLock
Lock for clipboard operations.
|
private java.util.List<byte[]> |
drawingNoCacheOps
Pending drawing operations (will be cleared and sent as a batch); this includes all
operations, unaltered.
|
private java.util.List<byte[]> |
drawingOps
Pending drawing operations (will be cleared and sent as a batch).
|
private java.util.Map<java.lang.Integer,ExpiryCache<java.lang.String,byte[]>> |
fullWindowCache
The drawing cache, for an entire window state.
|
private boolean |
graphicsCached
The true value indicates that batches of drawing commands are cached.
|
private static int |
HASH_LENGTH
The length of the MD5 hash.
|
private byte[] |
lastHash
The MD5 of the last drawing message sent to the JS side.
|
private static byte[] |
MAGIC
The magic hash sum indicates that the batch of drawing operations mustn't be cached.
|
private static int |
MAX_DRAW_CACHE_SIZE
The maximum cache size.
|
private java.security.MessageDigest |
MD5
The provider for MD5 hashes.
|
private int |
nextMessageId
The next message ID, used to track message request which require an immediate response
from the JS side.
|
private GuiWebSocket.ClipboardRequest |
pending
Describes the currently pending clipboard request.
|
private int |
pendingBytes
Accumulator to track the total number of pending bytes on the drawing ops list.
|
private int |
pendingNoCacheBytes
Accumulator to track the total number of pending bytes on the drawing ops list, including
the operations which were replaced with a hash code (as the resulted image is already
cached).
|
private ExpiryCache<java.lang.String,byte[]> |
perWidgetCache
Drawing cache for intermediate widget states.
|
private java.util.Deque<GuiWebSocket.DrawRecording> |
recordings
This stack will contain the drawing operation recordings.
|
private int |
resizeOps
Pending resize operations counter
|
callbacks, isVT100, lock
CAPTURE_MOUSE, ENABLE_OS_EVENTS, MSG_BEEP, MSG_CLEAR, MSG_CLIENT_READY, MSG_CLIPBOARD_CONTENTS, MSG_CLIPBOARD_PREPARE, MSG_CREATE_CHILD_WINDOW, MSG_CREATE_FONT, MSG_CREATE_WINDOW, MSG_CURRENT_SELECTION, MSG_CURSOR_POS, MSG_CURSOR_STATUS, MSG_DEREGISTER_WIDGET, MSG_DERIVE_FONT, MSG_DESTROY_WINDOW, MSG_DONE_CREATE_FONT, MSG_DONE_DERIVE_FONT, MSG_DRAW, MSG_DRAW_HASH_REMOVED, MSG_GET_DESKTOP_DIMENSION, MSG_GET_FONT_HEIGHT, MSG_GET_FONT_WIDTHS, MSG_GET_PAR_HEIGHT, MSG_GET_TEXT_HEIGHT, MSG_GET_TEXT_WIDTH, MSG_GET_TEXT_WIDTHS, MSG_GET_TEXT_WIDTHS_BATCH, MSG_INVALIDATE_SELECTION, MSG_IS_FONT_INSTALLED, MSG_KEY, MSG_KEY_VT100, MSG_LOCK_MOUSE_PTR, MSG_MOUSE_EVENT, MSG_MOVE_TO_BOTTOM, MSG_MOVE_TO_TOP, MSG_OPEN_URL, MSG_P2J_CREATE_RESOURCE, MSG_P2J_DELETE_HANDLE, MSG_P2J_INVOKE, MSG_P2J_PUBLISH, MSG_P2J_SUBSCRIBE, MSG_P2J_UNSUBSCRIBE, MSG_PAGE_LOADED, MSG_PARSE_EDITOR_CONTENT, MSG_PARTIAL, MSG_PASTE, MSG_PING_PONG, MSG_QUIT, MSG_READ_CLIPBOARD, MSG_REGISTER_HOVERABLE_WIDGET, MSG_REMOTE_CALL, MSG_REMOVE_EXPIRED_HASH, MSG_RESTACK_WINDOWS, MSG_SENT_DESKTOP_DIMENSION, MSG_SENT_FONT_HEIGHT, MSG_SENT_FONT_WIDTHS, MSG_SENT_PAR_HEIGHT, MSG_SENT_TEXT_HEIGHT, MSG_SENT_TEXT_WIDTH, MSG_SENT_TEXT_WIDTHS, MSG_SENT_TEXT_WIDTHS_BATCH, MSG_SET_CURSOR_STYLE, MSG_SET_MOUSE_PTR, MSG_SET_WAIT_STATE, MSG_SET_WINDOW_LOC, MSG_VT100, MSG_WINDOW_ACTIVATED, MSG_WINDOW_ICONIFY, MSG_WINDOW_RESIZED, MSG_WINDOW_SENSITIVITY, MSG_WINDOW_VISIBILITY, MSG_WRITE_CLIPBOARD, PROCESS_MOUSE_WIDGETS, SET_ICONIFICATION_STATE, SET_RESIZEABLE_WINDOW
Constructor and Description |
---|
GuiWebSocket(java.lang.Object lock,
ClientProtocolHooks callbacks,
long timeout,
long wdtimeout,
boolean graphicsCached)
Create a new GUI web socket instance.
|
Modifier and Type | Method and Description |
---|---|
private void |
addDrawingOp(byte[] message)
Add a prepared drawing to the pending operations list.
|
void |
allocateAndSend(PaintPrimitives type)
Allocate and send message, with no subsequent data
|
void |
allocateAndSend(PaintPrimitives type,
int one)
Allocate and send message with 1 integer.
|
void |
allocateAndSend(PaintPrimitives type,
int one,
int two)
Allocate and send message with 2 integers.
|
void |
allocateAndSend(PaintPrimitives type,
int one,
int two,
int three)
Allocate and send message with 3 integers.
|
void |
allocateAndSend(PaintPrimitives type,
int one,
int two,
int three,
int four)
Allocate and send message with 4 integers.
|
void |
allocateAndSend(PaintPrimitives type,
int one,
int two,
int three,
int four,
boolean flag)
Allocate and send message with 4 integers and a boolean.
|
void |
allocateAndSend(PaintPrimitives type,
int one,
int two,
int three,
int four,
int five)
Allocate and send message with 5 integers.
|
private byte[] |
allocateDrawingOp(PaintPrimitives type,
int len)
Allocate a new byte array of the proper size, add it to the pending operations list and
set the message byte.
|
private byte[] |
buildDrawingMessage(int windowId,
java.util.List<byte[]> ops,
int length)
Build a byte array with all the drawing operations from the given list.
|
void |
captureMouseEvents(boolean state)
Enable or disable capture of mouse events.
|
(package private) void |
clientReady()
Notify the driver that the client is ready (useful for embedded mode, to notify the embedded
app the client can handle messages).
|
void |
clip(java.util.Set<NativeRectangle> clip)
Add the given rectangles to the current clipping region.
|
void |
createChildWindow(int id,
int owner,
java.lang.String title,
boolean resizable,
boolean isShareActivationWithOwner,
boolean modal)
Create a new child window (which will be backed by a canvas instance in the client).
|
int |
createFont(int font,
java.lang.String fontName,
int pointSize,
int fontStyle,
byte[] fontDefinition)
Create a font with the given details and register it with the driver.
|
void |
createWindow(int id)
Create a new top-level window (which will be backed by a canvas instance in the client).
|
void |
deregisterWidget(int wid,
int id)
Deregister widget.
|
void |
deriveFont(int font)
Scale the given font by the specified X and Y factors.
|
void |
destroyWindow(int id,
java.lang.Integer[] cachedImages)
Destroy the specified window at the client side.
|
void |
draw3DRect(int x,
int y,
int width,
int height,
boolean raised)
Draw a 3D rectangle in the current color/stroke.
|
void |
drawImage(int x,
int y,
int width,
int height,
ImageEncoding encoding,
int imageHash,
byte[] encodedImage)
Draw a given image on the virtual screen and prepare it to transfer.
|
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draw a line in the current color/stroke from the given starting and ending points.
|
void |
drawParagraph(java.lang.String text,
int font,
int x,
int y,
int width)
Draws a multiline text (paragraph) at the supplied position and with the specified font.
|
void |
drawRect(int x,
int y,
int width,
int height)
Draw a rectangle in the current color/stroke.
|
void |
drawRoundRect(int x,
int y,
int width,
int height,
int diameter)
Draw a rounded stroked rectangle in the current color/stroke.
|
void |
drawSelection(int x,
int y,
int width,
int height,
boolean clear)
Draw a selection box rectangular area with current color.
|
void |
drawString(java.lang.String text,
boolean centered,
int x,
int y)
Draw a string at the specified location.
|
void |
drawStringScaled(java.lang.String text,
boolean centered,
int x,
int y,
int width,
int height)
Draw a string using the current font, which will be scaled so that the final string will
have the specified legacy width and height.
|
void |
enableOsEvents(int[] windowIds,
boolean state)
Enable or disable processing of OS events.
|
void |
fill3DRect(int x,
int y,
int width,
int height,
boolean raised)
Draw a 3D filled rectangle in the current color/stroke.
|
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int num)
Draw a filled, closed polygon in the current color/stroke.
|
void |
fillRect(int x,
int y,
int width,
int height)
Draw a rectangle with the area filled by the current color.
|
void |
fillRoundRect(int x,
int y,
int width,
int height,
int diameter)
Draw a rounded filled rectangle in the current color/stroke.
|
NativeDimension |
getDesktopDimension()
Get the desktop's dimension.
|
int |
getFontHeight(int font)
Get the height of the specified font.
|
int |
getParagraphHeight(java.lang.String text,
int font,
int maxWidth)
The method performs a layout operation on the supplied text and * returns the resulting
paragraph height while maintaining the supplied maximum width.
|
int |
getTextHeight(java.lang.String text,
int font)
Get the height of the specified text, using the given font.
|
int |
getTextWidth(java.lang.String text,
int font)
Get the width of the specified text, using the given font.
|
int[][] |
getTextWidths(java.lang.String[] texts,
int font)
Get the widths of the specified texts, using the given font.
|
int[] |
getTextWidths(java.lang.String text,
int font)
Get the widths of the specified text, using the given font.
|
boolean |
isFontInstalled(java.lang.String fontName)
Requests the client if the target font is installed.
|
void |
lockMousePointer(int widgetId,
MousePtrWrapper ptr)
Lock/unlock mouse pointer.
|
private byte[] |
md5Hash(byte[] message)
Compute an MD5 hash for the given message.
|
void |
moveToBottom(int windowId)
Move the specified window to the bottom of the z-order, at the OS level.
|
void |
moveToTop(int windowId)
Move the specified window to the top of the z-order, at the OS level.
|
private int |
nextMessageId()
Get the next message ID.
|
(package private) int[][] |
parseEditorContent(int widgetId,
int windowId,
int maxWidth,
java.lang.String text,
int delta,
int font)
Split the text for a editor widget, so that it fits the specified maximum width.
|
void |
paste(byte[] message,
int offset,
int length)
Process the incoming PASTE message from the client.
|
boolean |
processBinaryMessage(byte[] message,
int offset,
int length)
This is the worker method which is called when a binary message is received.
|
(package private) void |
processMouseWidgets(java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>>> allWidgets,
java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>>> newWidgets,
java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,NativeRectangle>> newWidgetsBounds,
java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>>> deadWidgets,
java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>> newAnyWidgets,
java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>> deadAnyWidgets)
Process the details for the specified widgets and send them to the JS side.
|
void |
propagateWaitState(boolean isWaitState)
Propagate wait state
|
void |
publish(long subId,
java.lang.String event,
java.lang.String[] param)
Send a PUBLISH notification to a remote application.
|
java.lang.String |
readClipboard()
Send a request to the web client to read the current contents of the clipboard and send
that back as text.
|
void |
registerHoverableWidget(int wid,
int id,
int pid,
NativeRectangle bound,
MousePtrWrapper ptr,
MousePtrWrapper defaultPtr,
boolean enforceDefault)
Register hoverable widget.
|
UnformattedPayload |
remoteCall(UnformattedPayload request)
This is a special API which is used to delegate a call from converted 4GL code
(via _P2J_REMOTE_CALL_ functions) to the remote side.
|
void |
resetComposite()
Reset composite mode and return to normal drawing mode.
|
void |
resetSelection()
Reset selection boxes painting mode and return to normal drawing mode.
|
void |
resizeWindow(int width,
int height)
Resize the window.
|
int[] |
resolveWidths(int font)
Report the advance widths of the first 256 characters in the font.
|
void |
restackWindows(int[] windowIds)
Force the list of all GUI windows to be stacked as in the specified order.
|
void |
sendPendingDrawingOps(int windowId)
Send all pending drawing operations to the javascript side and clear the list of pending
operations.
|
private static int |
serializedSize(MousePtrWrapper ptr)
Calculate the serialized size of the mouse pointer
|
void |
setColor(int red,
int green,
int blue)
Set the given color as the current color for graphics operations.
|
void |
setCursorStyle(int cursorStyle,
int wid)
Sends MSG_SET_CURSOR_STYLE that the cursor style must be changed on the client side.
|
void |
setDesktopBgColor(int red,
int green,
int blue)
Set the desktop background color.
|
void |
setFont(int font)
Set current font used on draw operations.
|
void |
setFontStyle(int fontStyle)
Set the style of the current font used on draw operations.
|
void |
setIconificationState(int windowId,
boolean state)
Set the specified window's iconification state.
|
void |
setIconImage(int width,
int height,
ImageEncoding encoding,
int imageHash,
byte[] encodedImage)
Sets the window icon.
|
void |
setLineStroke(int strokeStyle,
int width)
Sends MSG_SET_STROKE_STYLE to order the current window stroke to be changed
on the client side.
|
void |
setMousePtr(int wid,
int id,
MousePtrWrapper ptr)
Set custom mouse pointer for a widget.
|
void |
setResizeableWindow(int wid,
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.
|
void |
setSelection(java.lang.String text)
Notifies the JS client that the current editors selection is changed.
|
void |
setWindowBounds(int x,
int y,
int width,
int height)
Set the window bounds.
|
void |
setWindowEnabled(int id,
boolean enable)
Set the window's sensitive state, depending on the
enable flag. |
void |
setWindowLocation(int x,
int y)
Set the window location in X and Y coordinates.
|
void |
setWindowTitle(java.lang.String title)
Set the window title at the OS level.
|
void |
setWindowVisible(int id,
boolean visible)
Hide or show the window, depending on the
visible flag. |
void |
setXORComposite()
Set "XOR composite" mode: color of the drawn elements is calculated as XOR (for each RGB
component) of their color with color of underlying pixels.
|
void |
setXORMode(int red,
int green,
int blue)
Set XOR mode painting allowing to invert the destination color with current drawing
primitive color.
|
(package private) void |
startRecording(int x,
int y,
int width,
int height)
Mark the start of recording the drawing operations.
|
(package private) void |
stopRecording()
Mark the stop of the drawing operations recording.
|
void |
translate(boolean push,
int x,
int y)
Translate the graphics context by the given values.
|
void |
unclip()
Remove the most recently added rectangle from the current clipping region.
|
void |
writeClipboard(java.lang.String text)
Copies the given text to the application clipboard and notifies the JS client
about the current clipboards content.
|
beep, getMessagesCollector, injectKey, onClose, onConnect, onError, onMessage, onMessage, quit, readKey, readMessageInt16, readMessageInt32, readMessageInt64, readMessageText, receiveResult, sendBinaryMessage, sendBinaryMessage, sendBinaryMessage, sendBinaryMessage, sendBinaryMessage, sendBinaryMessage, sendSwitchMode, sendTextMessage, swapKeyboardMode, waitForResult, writeMessageInt16, writeMessageInt32, writeMessageText
private static final int HASH_LENGTH
private static final int MAX_DRAW_CACHE_SIZE
private static byte[] MAGIC
private java.security.MessageDigest MD5
private GuiWebSocket.ClipboardRequest pending
private java.lang.Object clipboardLock
private volatile java.lang.String clipboardContents
private java.util.List<byte[]> drawingOps
PaintPrimitives.DRAW_CACHED
operation, to let the Web driver draw from cache.private int pendingBytes
private int resizeOps
private int pendingNoCacheBytes
private java.util.List<byte[]> drawingNoCacheOps
private int nextMessageId
private byte[] lastHash
private java.util.Map<java.lang.Integer,ExpiryCache<java.lang.String,byte[]>> fullWindowCache
private ExpiryCache<java.lang.String,byte[]> perWidgetCache
private java.util.Deque<GuiWebSocket.DrawRecording> recordings
private boolean graphicsCached
public GuiWebSocket(java.lang.Object lock, ClientProtocolHooks callbacks, long timeout, long wdtimeout, boolean graphicsCached)
lock
- Object to use for locking. By passing this in, the caller can share the
locking instance with this code. Use null
if an internal
lock object should be created.callbacks
- An instance with hooks to call at specific events.timeout
- Web socket timeout.wdtimeout
- Watchdog thread timeout.graphicsCached
- True if the drawing batches are cached, otherwise false.public UnformattedPayload remoteCall(UnformattedPayload request)
This API is expected to block waiting for a response.
request
- The request data incoming from 4GL.public void publish(long subId, java.lang.String event, java.lang.String[] param)
subId
- The subscriber's ID, known by the remote application.event
- The published event name.param
- The parameters for this event.public void createWindow(int id)
id
- The window id to associate with the newly created window.public void createChildWindow(int id, int owner, java.lang.String title, boolean resizable, boolean isShareActivationWithOwner, boolean modal)
id
- The window id to associate with the newly created window.owner
- The window id to associate with the owning window.title
- Taskbar title for the child window.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 void setWindowVisible(int id, boolean visible)
visible
flag.id
- The window to modify.visible
- The window visibility state.public void setWindowEnabled(int id, boolean enable)
enable
flag.id
- The window to modify.enable
- The window sensitive state.public void destroyWindow(int id, java.lang.Integer[] cachedImages)
id
- The window id to destroy.cachedImages
- The array of client cached images to remove.public void drawLine(int x1, int y1, int x2, int y2)
x1
- The starting X coordinate in pixels.y1
- The starting Y coordinate in pixels.x2
- The ending X coordinate in pixels.y2
- The ending Y coordinate in pixels.public void drawRect(int x, int y, int width, int height)
x
- The top left X coordinate in pixels.y
- The top left Y coordinate in pixels.width
- The rectangle width in pixels.height
- The rectangle height in pixels.public void fillRect(int x, int y, int width, int height)
x
- The top left X coordinate in pixels.y
- The top left Y coordinate in pixels.width
- The rectangle width in pixels.height
- The rectangle height in pixels.public void drawRoundRect(int x, int y, int width, int height, int diameter)
x
- The top left X coordinate in pixels.y
- The top left Y coordinate in pixels.width
- The rectangle width in pixels.height
- The rectangle height in pixels.diameter
- Diameter of the arc that defines the rounded corner.public void fillRoundRect(int x, int y, int width, int height, int diameter)
x
- The top left X coordinate in pixels.y
- The top left Y coordinate in pixels.width
- The rectangle width in pixels.height
- The rectangle height in pixels.diameter
- Diameter of the arc that defines the rounded corner.public void draw3DRect(int x, int y, int width, int height, boolean raised)
x
- The top left X coordinate in pixels.y
- The top left Y coordinate in pixels.width
- The rectangle width in pixels.height
- The rectangle height in pixels.raised
- true
if the rendering should appear raised.public void fill3DRect(int x, int y, int width, int height, boolean raised)
x
- The top left X coordinate in pixels.y
- The top left Y coordinate in pixels.width
- The rectangle width in pixels.height
- The rectangle height in pixels.raised
- true
if the rendering should appear raised.public void drawSelection(int x, int y, int width, int height, boolean clear)
x
- The top left X coordinate in pixels.y
- The top left Y coordinate in pixels.width
- The rectangle width in pixels.height
- The rectangle height in pixels.clear
- TRUE
means clean up area instead of drawing selections.public void resetSelection()
public void drawImage(int x, int y, int width, int height, ImageEncoding encoding, int imageHash, byte[] encodedImage)
x
- The x-coordinate of the image position.y
- The y-coordinate of the image position.width
- The width of the image.height
- The height of the image.encoding
- The encoding id.imageHash
- The image hash code, its own id.encodedImage
- The encoded image represented by bytes.public void fillPolygon(int[] xPoints, int[] yPoints, int num)
xPoints
- Array of X coordinates.yPoints
- Array of Y coordinates.num
- The number of points defining vertices.public void translate(boolean push, int x, int y)
push
- true
for a PUSH operation, false
for POP.x
- Change in X coordinate.y
- Change in Y coordinate.public void clip(java.util.Set<NativeRectangle> clip)
clip
- The clipping rectangles.public void unclip()
public void setColor(int red, int green, int blue)
red
- Red value.green
- Green value.blue
- Blue value.public void setDesktopBgColor(int red, int green, int blue)
red
- Red value.green
- Green value.blue
- Blue value.public void setXORComposite()
public void resetComposite()
public void setXORMode(int red, int green, int blue)
red
- Red XOR alternation color value.green
- Green XOR alternation color value.blue
- Blue XOR alternation color value.public void resizeWindow(int width, int height)
width
- The window width in pixels.height
- The window height in pixels.public void setWindowLocation(int x, int y)
x
- The X coordinate in pixels.y
- The Y coordinate in pixels.public void setWindowBounds(int x, int y, int width, int height)
x
- The X coordinate in pixels.y
- The Y coordinate in pixels.width
- The window width in pixels.height
- The window height in pixels.public void setResizeableWindow(int wid, boolean resize, int minWidth, int minHeight, int maxWidth, int maxHeight)
wid
- The window ID.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 restackWindows(int[] windowIds)
windowIds
- The stack order to be enforced.public void moveToTop(int windowId)
windowId
- The window to be moved.public void moveToBottom(int windowId)
windowId
- The window to be moved.public void captureMouseEvents(boolean state)
state
- true
to capture mouse events, false
to ignore them.public void enableOsEvents(int[] windowIds, boolean state)
windowIds
- The window IDs.state
- true
to process OS events, false
to ignore them.public void setIconificationState(int windowId, boolean state)
windowId
- The window ID.state
- true
to iconify the window, false
to de-iconify it.public void allocateAndSend(PaintPrimitives type)
type
- Message type.public void allocateAndSend(PaintPrimitives type, int one)
type
- Message type.one
- Only integer to send.public void allocateAndSend(PaintPrimitives type, int one, int two)
type
- Message type.one
- First integer to send.two
- Second integer to send.public void allocateAndSend(PaintPrimitives type, int one, int two, int three)
type
- Message type.one
- First integer to send.two
- Second integer to send.three
- Third integer to send.public void allocateAndSend(PaintPrimitives type, int one, int two, int three, int four)
type
- Message type.one
- First integer to send.two
- Second integer to send.three
- Third integer to send.four
- Fourth integer to send.public void allocateAndSend(PaintPrimitives type, int one, int two, int three, int four, int five)
type
- Message type.one
- First integer to send.two
- Second integer to send.three
- Third integer to send.four
- Fourth integer to send.five
- Fifth integer to send.public void allocateAndSend(PaintPrimitives type, int one, int two, int three, int four, boolean flag)
type
- Message type.one
- First integer to send.two
- Second integer to send.three
- Third integer to send.four
- Fourth integer to send.flag
- Boolean value to send.public void setWindowTitle(java.lang.String title)
title
- The window's title.public void setIconImage(int width, int height, ImageEncoding encoding, int imageHash, byte[] encodedImage)
width
- The width of the image.height
- The height of the image.encoding
- The encoding id.imageHash
- The image hash code, its own id.encodedImage
- The encoded image represented by bytes.public void sendPendingDrawingOps(int windowId)
windowId
- The window which is being drawn.public java.lang.String readClipboard()
public void writeClipboard(java.lang.String text)
text
- The current clipboard content.public boolean processBinaryMessage(byte[] message, int offset, int length)
processBinaryMessage
in class WebClientProtocol
message
- Message content as an byte array.offset
- Message offset..length
- Message size.true
if the message has been handled, false
otherwise.public void paste(byte[] message, int offset, int length)
paste
in class WebClientProtocol
message
- Message content as an byte array.offset
- Offset into the message at which the text begins.length
- Location in the message where the text ends.public void setFontStyle(int fontStyle)
fontStyle
- Font style.public void setFont(int font)
font
- Drawing font.public int createFont(int font, java.lang.String fontName, int pointSize, int fontStyle, byte[] fontDefinition)
font
- The font ID to register it on the js-side.fontName
- The font name.pointSize
- The font's size, in points.fontStyle
- The font style as packaged via FontStyle.toInt()
.fontDefinition
- The font definition. May be null
.public void deriveFont(int font)
font
- Font to scale. This instance's contained font will be modified.public NativeDimension getDesktopDimension()
public int getParagraphHeight(java.lang.String text, int font, int maxWidth)
Note that the algorithm for text layout is compatible with drawParagraph(java.lang.String, int, int, int, int)
and so can
be used in conjunction with this method.
text
- The text to measure.font
- The font to use during layout.maxWidth
- The maximum paragraph width.public int getTextHeight(java.lang.String text, int font)
text
- The text.font
- The font used to draw and measure the text.public int getTextWidth(java.lang.String text, int font)
text
- The text.font
- The font used to draw and measure the text.public int[][] getTextWidths(java.lang.String[] texts, int font)
texts
- The texts.font
- The font used to draw and measure the text.public int[] getTextWidths(java.lang.String text, int font)
text
- The text.font
- The font used to draw and measure the text.public boolean isFontInstalled(java.lang.String fontName)
fontName
- The target font name.public int getFontHeight(int font)
font
- The font.public int[] resolveWidths(int font)
public void setCursorStyle(int cursorStyle, int wid)
cursorStyle
- Denotes the cursor style id.wid
- The window id.public void setLineStroke(int strokeStyle, int width)
strokeStyle
- The known stroke style id.width
- The stroke line width.public void drawString(java.lang.String text, boolean centered, int x, int y)
text
- text string to draw.centered
- Flag indicating if the text is centered vertically.x
- left position.y
- top position.public void drawStringScaled(java.lang.String text, boolean centered, int x, int y, int width, int height)
The string will be drawn at the specified location.
text
- text string to draw.centered
- Flag indicating if the text is centered vertically.width
- The legacy width, which needs to be matched when drawing.height
- The legacy width, which needs to be matched when drawing.x
- left position.y
- top position.public void drawParagraph(java.lang.String text, int font, int x, int y, int width)
Note that the algorithm for text layout is compatible with getParagraphHeight(java.lang.String, int, int)
and
so can be used in conjunction with this method.
text
- The text to draw.font
- The drawing font.x
- The x position.y
- The y position.width
- The maximum paragraph width.void processMouseWidgets(java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>>> allWidgets, java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>>> newWidgets, java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,NativeRectangle>> newWidgetsBounds, java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>>> deadWidgets, java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>> newAnyWidgets, java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>> deadAnyWidgets)
All newWidgets
will be registered with their JS window.
The deadWidgets
will be removed.
Each map has a key a window ID and as value a map with the window's widgets: for each widget, its supported mouse events are specified.
allWidgets
- The entire widget tree, in z-order. This will always be sent to the Web side, if
there are changes in the new/dead widgets.newWidgets
- Details about the new widgets.newWidgetsBounds
- Maps a window to its widgets bounds: screen locations and physical dimensions.deadWidgets
- Details about the widgets which no longer process mouse events (i.e. they were
hidden/disabled/etc).newAnyWidgets
- Details about "any mouse" widgets that process all mouse events.deadAnyWidgets
- Details about the "any mouse" widgets which no longer process mouse events
(i.e. they were hidden/disabled/etc).public void setSelection(java.lang.String text)
text
- The current editors selection.public void registerHoverableWidget(int wid, int id, int pid, NativeRectangle bound, MousePtrWrapper ptr, MousePtrWrapper defaultPtr, boolean enforceDefault)
wid
- The windows id.id
- The widget id.pid
- The parent widget id.bound
- The widget boundariesptr
- The widget custom mouse pointer.defaultPtr
- The widget default mouse pointer.enforceDefault
- true
id default pointer should be always used.public void deregisterWidget(int wid, int id)
wid
- The windows id.id
- The widget id.public void lockMousePointer(int widgetId, MousePtrWrapper ptr)
ptr
- The custom mouse pointer or null
for unlock.public void setMousePtr(int wid, int id, MousePtrWrapper ptr)
wid
- The windows id.id
- The widget id.ptr
- The widget custom mouse pointer.public void propagateWaitState(boolean isWaitState)
isWaitState
- wait statevoid clientReady()
int[][] parseEditorContent(int widgetId, int windowId, int maxWidth, java.lang.String text, int delta, int font)
delta
parameter represents the start position of this text, in the editor's
content; when the full content is parsed, this will be zero.widgetId
- The editor's ID.windowId
- The editor's window ID.maxWidth
- The width for the content to fit (the editor's editable area).text
- The text to split into lines.delta
- The start position of this text in the editor's full content.font
- The editor's font.private static int serializedSize(MousePtrWrapper ptr)
ptr
- the mouse pointervoid startRecording(int x, int y, int width, int height)
x
- The X origin at the time recording was started.y
- The Y origin at the time recording was started.width
- The width of the resulted image, which will be captured and cached.height
- The height of the resulted image, which will be captured and cached.void stopRecording()
pristine drawing operation list
. If there is already a cached
image, it will replace the drawing operations with a PaintPrimitives.DRAW_CACHED
operation, which will tell the Web driver to draw the cached image.private byte[] allocateDrawingOp(PaintPrimitives type, int len)
type
- The drawing operation type.len
- The message size.private int nextMessageId()
private void addDrawingOp(byte[] message)
message
- The prepared drawing to transfer.private byte[] md5Hash(byte[] message)
message
- The message with the drawing ops.null
.private byte[] buildDrawingMessage(int windowId, java.util.List<byte[]> ops, int length)
windowId
- The window ID targeted by the drawing ops.ops
- The drawing ops.length
- The length (in bytes) of all drawing ops.