Package provided.owlMaps.cefUtils.impl
Class CefUtils
java.lang.Object
provided.owlMaps.cefUtils.impl.CefUtils
- All Implemented Interfaces:
ICefUtils
public final class CefUtils extends java.lang.Object implements ICefUtils
Implementation of ICefUtils
- Author:
- swong
-
Field Summary
Fields Modifier and Type Field Description private org.cef.browser.CefMessageRouter
callbackMsgRouter
The message router to use for callbacks from the JavaScript side.(package private) org.cef.browser.CefBrowser
cefBrowser
The current CefBrowser instance holding the frame that holds the mapprivate org.cef.CefClient
cefClient
The CEF client object(package private) org.cef.browser.CefFrame
cefFrame
The current CefFrame holding the map in the browser(package private) ICefObject
cefMap
The current map object being held in the browserprivate ICefObjectFactory
cefObjFac
The factory to use to create ICefObjectsprivate java.util.Map<java.util.UUID,java.util.function.Consumer<?>>
consumerCallbackMap
The map of Consumer function ID's to the Consumer itself.private long
devToolsDelay
The current delay to use before creating and displaying the dev tools windowprivate java.lang.String
googleMapsApiKey
The Google Maps API key in useprivate com.google.gson.Gson
gson
GSON JSON converter to use for data transmission to/from the JavaScript side(package private) boolean
isTransparent
If true the browser background is transparentprivate static java.lang.String
JS_CALL_FN_FORMAT
Format string for JavaScript call to run a given window function.private boolean
makeDevTools
If true, create the dev tools window after the current devToolsDelayprivate org.cef.browser.CefMessageRouter
objCreateMsgRouter
The message router to use when creating objects on the JavaScript sideprivate java.util.Map<java.util.UUID,java.util.function.Consumer<?>>
pendingReturnValMap
The map of Consumer function ID's to the Consumer itself where the Consumer is used for processing returned values from the JavaScript side.private org.cef.browser.CefMessageRouter
returnValMsgRouter
The message router to use for return values from JavaScript method calls.private java.util.Map<java.util.UUID,java.lang.Runnable>
runnableCallbackMap
The map of Runnable function ID's to the Runnable itself.private ISystemInfo
sysInfo
Accessors for accessing dynamic system valuesprivate boolean
useOSR
If true, use Off-Screen RenderingFields inherited from interface provided.owlMaps.cefUtils.ICefUtils
DEV_TOOLS_DELAY_DEFAULT, DEV_TOOLS_PORT_DEFAULT, MAKE_DEV_TOOLS_DEFAULT, USE_OFF_SCREEN_RENDERING_DEFAULT
-
Constructor Summary
Constructors Constructor Description CefUtils(java.lang.String googleMapsApiKey, ISystemInfo sysInfo)
Constructor for the class -
Method Summary
Modifier and Type Method Description <T> java.util.concurrent.Future<T>
call(java.lang.String fnName, java.lang.reflect.Type returnType, java.lang.Object... params)
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Call the specified Javascript functuion with the given parameters and return the result as a Futurevoid
callVoid(java.lang.String fnName, java.lang.Object... params)
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
A call to the given Javascript function that is a void return<T> T
convertJsonMap(T x, java.lang.reflect.Type resultType)
Converts the given object into the given result type by converting back to JSON and sending back through the GSON parser.ICefObject
getCefMapObj()
Get the ICefObject that wraps the Javascript map entitydouble
getSysLengthPerMeter()
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Get the conversion factor from the length units currently being used by the system into meters.ICefObject
makeCefObj(java.lang.String jsClassname, java.lang.Object... params)
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Instantiate the given class on the JavaScript side with the given parametersjava.util.UUID
registerConsumerCallback(java.util.function.Consumer<?> callback)
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Register the given Consumer in the system so that it can be used for callbacks.java.util.UUID
registerPendingReturnValCallback(java.util.function.Consumer<?> callback)
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Register the given Consumer in the system so that it can be used for return values of function calls.java.util.UUID
registerRunnableCallback(java.lang.Runnable callback)
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Register the given Runnable in the system so that it can be used for callbacks.void
setDevToolsDelay(long delay)
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Sets the delay to wait before opening the dev tools window.void
setDevToolsPort(int port)
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Set the port used by the dev tools windowvoid
setMakeDevTools(boolean makeDevTools)
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Enables the display of the browser dev console windowvoid
setUseOSR(boolean useOSR)
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Sets whether or not the system uses the Off-Screen Rendering (OSR).javax.swing.JComponent
start(java.lang.String startURL, provided.mixedData.IMixedDataDictionary mapOptionsDict, java.lang.Runnable onMapLoad)
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Start the Map on the Javascript sideMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
JS_CALL_FN_FORMAT
private static final java.lang.String JS_CALL_FN_FORMATFormat string for JavaScript call to run a given window function.- See Also:
- Constant Field Values
-
sysInfo
Accessors for accessing dynamic system values -
googleMapsApiKey
private final java.lang.String googleMapsApiKeyThe Google Maps API key in use -
cefClient
private final org.cef.CefClient cefClientThe CEF client object -
gson
private com.google.gson.Gson gsonGSON JSON converter to use for data transmission to/from the JavaScript side -
isTransparent
boolean isTransparentIf true the browser background is transparent -
makeDevTools
private boolean makeDevToolsIf true, create the dev tools window after the current devToolsDelay -
devToolsDelay
private long devToolsDelayThe current delay to use before creating and displaying the dev tools window -
useOSR
private boolean useOSRIf true, use Off-Screen Rendering -
cefObjFac
The factory to use to create ICefObjects -
callbackMsgRouter
private org.cef.browser.CefMessageRouter callbackMsgRouterThe message router to use for callbacks from the JavaScript side. The callbacks are assumed to be persistent and utilized multiple times. -
objCreateMsgRouter
private org.cef.browser.CefMessageRouter objCreateMsgRouterThe message router to use when creating objects on the JavaScript side -
returnValMsgRouter
private org.cef.browser.CefMessageRouter returnValMsgRouterThe message router to use for return values from JavaScript method calls. The callbacks are assumed to be single use for a particular function call's return value. -
runnableCallbackMap
private java.util.Map<java.util.UUID,java.lang.Runnable> runnableCallbackMapThe map of Runnable function ID's to the Runnable itself. -
consumerCallbackMap
private java.util.Map<java.util.UUID,java.util.function.Consumer<?>> consumerCallbackMapThe map of Consumer function ID's to the Consumer itself. -
pendingReturnValMap
private java.util.Map<java.util.UUID,java.util.function.Consumer<?>> pendingReturnValMapThe map of Consumer function ID's to the Consumer itself where the Consumer is used for processing returned values from the JavaScript side. -
cefBrowser
org.cef.browser.CefBrowser cefBrowserThe current CefBrowser instance holding the frame that holds the map -
cefFrame
org.cef.browser.CefFrame cefFrameThe current CefFrame holding the map in the browser -
cefMap
ICefObject cefMapThe current map object being held in the browser
-
-
Constructor Details
-
CefUtils
Constructor for the class- Parameters:
googleMapsApiKey
- The Google Maps API key to usesysInfo
- ISytemInfo object to provide dynamically set system-wide info such as the unit of length in use.
-
-
Method Details
-
start
public javax.swing.JComponent start(java.lang.String startURL, provided.mixedData.IMixedDataDictionary mapOptionsDict, java.lang.Runnable onMapLoad)Description copied from interface:ICefUtils
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Start the Map on the Javascript side -
setDevToolsDelay
public void setDevToolsDelay(long delay)Description copied from interface:ICefUtils
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Sets the delay to wait before opening the dev tools window. The dev tools window needs to be delayed so that it can show what's happening in the map.- Specified by:
setDevToolsDelay
in interfaceICefUtils
- Parameters:
delay
- The number of milliseconds to delay
-
setUseOSR
public void setUseOSR(boolean useOSR)Description copied from interface:ICefUtils
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Sets whether or not the system uses the Off-Screen Rendering (OSR). -
setDevToolsPort
public void setDevToolsPort(int port)Description copied from interface:ICefUtils
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Set the port used by the dev tools window- Specified by:
setDevToolsPort
in interfaceICefUtils
- Parameters:
port
- A valid port number not being used by any other app.
-
setMakeDevTools
public void setMakeDevTools(boolean makeDevTools)Description copied from interface:ICefUtils
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Enables the display of the browser dev console window- Specified by:
setMakeDevTools
in interfaceICefUtils
- Parameters:
makeDevTools
- If true, show the dev console window
-
getCefMapObj
Description copied from interface:ICefUtils
Get the ICefObject that wraps the Javascript map entity- Specified by:
getCefMapObj
in interfaceICefUtils
- Returns:
- The ICefObject for the map
-
callVoid
public void callVoid(java.lang.String fnName, java.lang.Object... params)Description copied from interface:ICefUtils
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
A call to the given Javascript function that is a void return -
call
public <T> java.util.concurrent.Future<T> call(java.lang.String fnName, java.lang.reflect.Type returnType, java.lang.Object... params)Description copied from interface:ICefUtils
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Call the specified Javascript functuion with the given parameters and return the result as a Future -
registerRunnableCallback
public java.util.UUID registerRunnableCallback(java.lang.Runnable callback)Description copied from interface:ICefUtils
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Register the given Runnable in the system so that it can be used for callbacks.- Specified by:
registerRunnableCallback
in interfaceICefUtils
- Parameters:
callback
- The Runnable to register- Returns:
- A unique ID associated with the given Runnable.
-
registerConsumerCallback
public java.util.UUID registerConsumerCallback(java.util.function.Consumer<?> callback)Description copied from interface:ICefUtils
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Register the given Consumer in the system so that it can be used for callbacks. The callback is assumed to be persistent and used multiple times.- Specified by:
registerConsumerCallback
in interfaceICefUtils
- Parameters:
callback
- The Consumer to register- Returns:
- A unique ID associated with the given Consumer
-
registerPendingReturnValCallback
public java.util.UUID registerPendingReturnValCallback(java.util.function.Consumer<?> callback)Description copied from interface:ICefUtils
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Register the given Consumer in the system so that it can be used for return values of function calls. The callback is assumed to be single use and must be removed from the mapping when executed.- Specified by:
registerPendingReturnValCallback
in interfaceICefUtils
- Parameters:
callback
- The Consumer to register- Returns:
- A unique ID associated with the given Consumer
-
convertJsonMap
public <T> T convertJsonMap(T x, java.lang.reflect.Type resultType)Converts the given object into the given result type by converting back to JSON and sending back through the GSON parser.- Specified by:
convertJsonMap
in interfaceICefUtils
- Type Parameters:
T
- The type of the original object- Parameters:
x
- The original objectresultType
- The desired type of the result- Returns:
- An object of the desired type, not usually the same instance as the given object
-
getSysLengthPerMeter
public double getSysLengthPerMeter()Description copied from interface:ICefUtils
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Get the conversion factor from the length units currently being used by the system into meters.- Specified by:
getSysLengthPerMeter
in interfaceICefUtils
- Returns:
- A length conversion factor of system_units/meter
-
makeCefObj
Description copied from interface:ICefUtils
*** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD DIRECTLY! ***
Instantiate the given class on the JavaScript side with the given parameters- Specified by:
makeCefObj
in interfaceICefUtils
- Parameters:
jsClassname
- The name of the class to instantiateparams
- The class's constructor parameters- Returns:
- An ICefObject representing the instantiated JavaScript object. The object is NOT to be considered viable until it is able to return a valid ID value.
-