Interface Luwrain
-
- All Superinterfaces:
HookContainer
,PropertiesBase
public interface Luwrain extends PropertiesBase, HookContainer
The main bridge for applications and extensions purposed for communication with LUWRAIN core. This class is a central object to be used by applications and extensions to call system routines. Applications and extensions never have the access with the level deeper than this class. The packages likeorg.luwrain.controls
ororg.luwrain.popups
always wrap the instance ofLuwrain
class (meaning, are unable to give more access to system core than provided with given instance ofLuwrain
class).The core creates new instance of this class for each newly launched application or loaded extension. Therefore, the environment is always aware which application oor extension has issued the particular request. Applications get the object associated with them through
onLaunch()
method. Extensions get the corresponding instance through the argument for the methods they override (it is always the same instance provided this way just for convenience). Everybody is encouraged to keep provided instance in secret.It could be slightly confusing that the extension and the applications launched by this extension get different instances of
Luwrain
class, but it's necessary to distinguish multiple instances of the particular application (while an extension can be loaded only once).Various instance of
Luwrain
class may provide different level of access. It is necessary to make extensions using more accurate and transparent.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Luwrain.AreaAttr
static class
Luwrain.AreaTextType
static class
Luwrain.JobFlags
static class
Luwrain.MessageType
static class
Luwrain.SpeakableTextType
-
Nested classes/interfaces inherited from interface org.luwrain.core.HookContainer
HookContainer.Hook, HookContainer.HookResult, HookContainer.HookRunner
-
-
Field Summary
Fields Modifier and Type Field Description static String
PROP_DIR_DATA
static String
PROP_DIR_JS
static String
PROP_DIR_SOUNDS
static String
PROP_DIR_USERHOME
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
announceActiveArea()
void
announcement(String text, String announcementClass, String announcementSubclass)
Object
callUiSafely(Callable callable)
void
closeApp()
void
crash(Throwable e)
void
crash(App app)
void
executeBkg(Runnable runnable)
String
getActiveAreaAttr(Luwrain.AreaAttr attr)
String
getActiveAreaText(Luwrain.AreaTextType type, boolean issueErrorMessage)
String[]
getAllShortcutNames()
Path
getAppDataDir(String appName)
Returns a path to the directory where the application may safely store its auxiliary data.int
getAreaVisibleHeight(Area area)
int
getAreaVisibleWidth(Area area)
Clipboard
getClipboard()
CmdLine
getCmdLine()
MediaResourcePlayer[]
getMediaResourcePlayers()
Player
getPlayer()
Registry
getRegistry()
int
getScreenHeight()
int
getScreenWidth()
ScriptFile[]
getScriptFilesList(String componentName)
String
getSpeakableText(String text, Luwrain.SpeakableTextType type)
UniRefInfo
getUniRefInfo(String uniRef)
I18n
i18n()
void
launchApp(String shortcutName)
void
launchApp(String shortcutName, String[] args)
Channel
loadSpeechChannel(String engineName, String params)
void
message(String text)
void
message(String text, Luwrain.MessageType messageType)
void
message(String text, Sounds sound)
Job.Instance
newJob(String name, String[] args, String dir, Set<Luwrain.JobFlags> flags, Job.Listener listener)
void
onAreaNewBackgroundSound(Area area)
void
onAreaNewContent(Area area)
Notifies the environment that the area gets new content.void
onAreaNewHotPoint(Area area)
Notifies the environment that the area gets new position of the hot point.void
onAreaNewName(Area area)
Notifies the environment that the area gets new name.void
onNewAreaLayout()
void
openFile(String fileName)
void
openFiles(String[] fileNames)
boolean
openHelp(String sectName)
boolean
openUniRef(String uniRef)
boolean
openUniRef(UniRefInfo uniRefInfo)
boolean
openUrl(String url)
void
playSound(File file)
void
playSound(Sounds sound)
/** Plays one of the system sounds.void
popup(Popup popup)
boolean
registerExtObj(ExtensionObject extObj)
Registers new extension object.boolean
runCommand(String command)
Object
runLaterSync(Callable callable)
void
runUiSafely(Runnable runnable)
boolean
runWorker(String workerName)
void
sendBroadcastEvent(SystemEvent event)
void
sendInputEvent(InputEvent event)
void
setActiveArea(Area area)
Sets the new active area of the application.void
setEventResponse(EventResponse eventResponse)
void
showGraphical(Interaction.GraphicalMode graphicalMode)
void
silence()
void
speak(String text)
void
speak(String text, int pitch)
void
speak(String text, int pitch, int rate)
void
speak(String text, Sounds sound)
void
speakLetter(char letter)
void
speakLetter(char letter, int pitch)
void
speakLetter(char letter, int pitch, int rate)
String
staticStr(LangStatic id)
String
suggestContentType(File file, ContentTypes.ExpectedType expectedType)
String
suggestContentType(URL url, ContentTypes.ExpectedType expectedType)
boolean
unloadDynamicExtension(String extId)
String[]
xGetLoadedSpeechFactories()
int
xGetSpeechPitch()
int
xGetSpeechRate()
boolean
xQuit()
void
xSetSpeechPitch(int value)
void
xSetSpeechRate(int value)
-
Methods inherited from interface org.luwrain.core.HookContainer
runHooks
-
Methods inherited from interface org.luwrain.core.PropertiesBase
getFileProperty, getProperty
-
-
-
-
Field Detail
-
PROP_DIR_DATA
static final String PROP_DIR_DATA
- See Also:
- Constant Field Values
-
PROP_DIR_JS
static final String PROP_DIR_JS
- See Also:
- Constant Field Values
-
PROP_DIR_USERHOME
static final String PROP_DIR_USERHOME
- See Also:
- Constant Field Values
-
PROP_DIR_SOUNDS
static final String PROP_DIR_SOUNDS
- See Also:
- Constant Field Values
-
-
Method Detail
-
announceActiveArea
void announceActiveArea()
-
closeApp
void closeApp()
-
crash
void crash(App app)
-
crash
void crash(Throwable e)
-
getActiveAreaAttr
String getActiveAreaAttr(Luwrain.AreaAttr attr)
-
getActiveAreaText
String getActiveAreaText(Luwrain.AreaTextType type, boolean issueErrorMessage)
-
getAllShortcutNames
String[] getAllShortcutNames()
-
getAppDataDir
Path getAppDataDir(String appName)
Returns a path to the directory where the application may safely store its auxiliary data. The returned directory, if it it isn'tnull
, always exists and always belongs to the current user. Meaning, different users get different directories for the same application. Application must be identified with some short string. We discourage using application names starting with "luwrain.", because such names are usually used by the applications from LUWRAIN standard distribution.- Parameters:
appName
- A short string for application identification, the same application name will result in the same directory- Returns:
- The application data directory or
null
if the directory cannot be created
-
getAreaVisibleHeight
int getAreaVisibleHeight(Area area)
-
getAreaVisibleWidth
int getAreaVisibleWidth(Area area)
-
getClipboard
Clipboard getClipboard()
-
getCmdLine
CmdLine getCmdLine()
-
xGetLoadedSpeechFactories
String[] xGetLoadedSpeechFactories()
-
getMediaResourcePlayers
MediaResourcePlayer[] getMediaResourcePlayers()
-
getPlayer
Player getPlayer()
-
getRegistry
Registry getRegistry()
-
getScreenWidth
int getScreenWidth()
-
getScreenHeight
int getScreenHeight()
-
getUniRefInfo
UniRefInfo getUniRefInfo(String uniRef)
-
executeBkg
void executeBkg(Runnable runnable)
-
i18n
I18n i18n()
-
launchApp
void launchApp(String shortcutName)
-
loadSpeechChannel
Channel loadSpeechChannel(String engineName, String params) throws SpeechException
- Throws:
SpeechException
-
message
void message(String text)
-
message
void message(String text, Luwrain.MessageType messageType)
-
onAreaNewBackgroundSound
void onAreaNewBackgroundSound(Area area)
-
onAreaNewHotPoint
void onAreaNewHotPoint(Area area)
Notifies the environment that the area gets new position of the hot point. This method causes updating of the visual position of the hot point on the screen for low vision users. Please keep in mind that this method doesn't produce any speech announcement of the new position and you should do that on your own, depending on the behaviour of your application.- Parameters:
area
- The area which gets new position of the hot point
-
onAreaNewContent
void onAreaNewContent(Area area)
Notifies the environment that the area gets new content. This method causes updating of the visual representation of the area content on the screen for low vision users. Please keep in mind that this method doesn't produce any speech announcement of the changes and you should do that on your own, depending on the behaviour of your application.- Parameters:
area
- The area which gets new content
-
onAreaNewName
void onAreaNewName(Area area)
Notifies the environment that the area gets new name. This method causes updating of the visual title of the area on the screen for low vision users. Please keep in mind that this method doesn't produce any speech announcement of name changes and you should do that on your own, depending on the behaviour of your application.- Parameters:
area
- The area which gets new name
-
onNewAreaLayout
void onNewAreaLayout()
-
openFile
void openFile(String fileName)
-
openFiles
void openFiles(String[] fileNames)
-
openHelp
boolean openHelp(String sectName)
-
openUniRef
boolean openUniRef(String uniRef)
-
openUniRef
boolean openUniRef(UniRefInfo uniRefInfo)
-
openUrl
boolean openUrl(String url)
-
playSound
void playSound(Sounds sound)
/** Plays one of the system sounds. This method takes an identifier of the system sound, stops any previous playing, if there was any, and plays. The exact sound is selected depending on user's settings. Please node that sounds playing isn't interfering with speech.- Parameters:
sound
- The identifier of the sound to play
-
playSound
void playSound(File file)
-
popup
void popup(Popup popup)
-
registerExtObj
boolean registerExtObj(ExtensionObject extObj)
Registers new extension object. This operation is allowed for highly privileged interfaces only, what, for example, can be useful for custom startup and shutdown procedures. Custom objects may be of any kind, they are registered as they would be a part of the core.- Parameters:
extObj
- The object to register- Returns:
- True if the object was successfully registered, false otherwise
- Throws:
RuntimeException
- on any attempt to do this operation without enough privileged level
-
runCommand
boolean runCommand(String command)
-
newJob
Job.Instance newJob(String name, String[] args, String dir, Set<Luwrain.JobFlags> flags, Job.Listener listener)
-
runUiSafely
void runUiSafely(Runnable runnable)
-
runWorker
boolean runWorker(String workerName)
-
speak
void speak(String text)
-
speakLetter
void speakLetter(char letter)
-
speak
void speak(String text, int pitch)
-
speak
void speak(String text, int pitch, int rate)
-
speakLetter
void speakLetter(char letter, int pitch)
-
sendBroadcastEvent
void sendBroadcastEvent(SystemEvent event)
-
sendInputEvent
void sendInputEvent(InputEvent event)
-
setActiveArea
void setActiveArea(Area area)
Sets the new active area of the application. This method asks the environment to choose another visible area as an active area of the application. This operation is applicable only to regular areas, not for popup areas, for which it is pointless. In contrast toonAreaNewHotPoint()
,onAreaNewName()
andonAreaNewContent()
methods, this one produces proper introduction of the area being activated.- Parameters:
area
- The area to choose as an active
-
setEventResponse
void setEventResponse(EventResponse eventResponse)
-
silence
void silence()
-
speakLetter
void speakLetter(char letter, int pitch, int rate)
-
staticStr
String staticStr(LangStatic id)
-
suggestContentType
String suggestContentType(URL url, ContentTypes.ExpectedType expectedType)
-
getSpeakableText
String getSpeakableText(String text, Luwrain.SpeakableTextType type)
-
suggestContentType
String suggestContentType(File file, ContentTypes.ExpectedType expectedType)
-
unloadDynamicExtension
boolean unloadDynamicExtension(String extId)
-
xQuit
boolean xQuit()
-
xSetSpeechRate
void xSetSpeechRate(int value)
-
xGetSpeechRate
int xGetSpeechRate()
-
xGetSpeechPitch
int xGetSpeechPitch()
-
xSetSpeechPitch
void xSetSpeechPitch(int value)
-
showGraphical
void showGraphical(Interaction.GraphicalMode graphicalMode)
-
getScriptFilesList
ScriptFile[] getScriptFilesList(String componentName)
-
-