Class RemoteControl
- java.lang.Object
-
- org.faceless.pdf2.viewer2.ViewerFeature
-
- org.faceless.pdf2.viewer2.feature.RemoteControl
-
public class RemoteControl extends ViewerFeature
The RemoteControl feature provides remote control of the PDFViewer. The exact mechanism is not defined; it's set by configuring the provider by callingsetProvider(java.lang.String)
. By default there is no provider, and this class adds no functionality to the viewer.- Since:
- 2.26
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RemoteControl.RemoteControlProvider
An interface which should be implemented by the Provider for the RemoteControl class.
-
Constructor Summary
Constructors Constructor Description RemoteControl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
debug(String s)
PDFViewer
getViewer()
void
initialize(PDFViewer viewer)
Called when the feature is first added to a viewervoid
receive(String action, String data, byte[] binaryData)
Receive a message and act on it.void
send(String action, String data, byte[] binaryData)
Send a message to current the RemoteControlProvider.void
setDebug(boolean debug)
void
setPreferences(Preferences prefs)
boolean
setProvider(String providerClass)
Set the Provider for this class.void
setProvider(RemoteControl.RemoteControlProvider p)
Set the Provider for this class.-
Methods inherited from class org.faceless.pdf2.viewer2.ViewerFeature
getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getFeatureURLProperty, getName, isEnabledByDefault, setFeatureName, teardown, toString
-
-
-
-
Method Detail
-
getViewer
public PDFViewer getViewer()
-
setDebug
public void setDebug(boolean debug)
-
setProvider
public boolean setProvider(String providerClass)
Set the Provider for this class.- Parameters:
providerClass
- the fully qualfied classname of an instance of RemoteControlProvider with a public constructor- Returns:
- true if the provider could be instantiated and set, false otherwise
-
setProvider
public void setProvider(RemoteControl.RemoteControlProvider p)
Set the Provider for this class.- Parameters:
p
- the provider, or null to remove the current provider.
-
initialize
public void initialize(PDFViewer viewer)
Description copied from class:ViewerFeature
Called when the feature is first added to a viewer- Overrides:
initialize
in classViewerFeature
-
setPreferences
public void setPreferences(Preferences prefs)
-
debug
protected void debug(String s)
-
send
public void send(String action, String data, byte[] binaryData)
Send a message to current the RemoteControlProvider. If none is set, this is a no-op- Parameters:
action
- the action to senddata
- the data to sendbinaryData
- the binary data to send
-
receive
public void receive(String action, String data, byte[] binaryData)
Receive a message and act on it. Called by the RemoteControlProvider- Parameters:
action
- the action to perform. If null, the action will be retrieved from the JSON field "action"data
- the text data, which will be parsed as JSON.binaryData
- the binary data, which will be parsed as JSON/CBOR only if "data" is null.
-
-