public class JRViewer extends Object
ViewerVR
and ViewerApp
.
The simplest way to use the JRViewer is to call the static method
JRViewer.display(SceneGraphNode node);
Any JRViewer is a composition of Plugin
s. There are static add* methods to add bunches of related plugins.
To get a virtual reality JRViewer with a movable avatar you may call the convenient static method
JRViewer v=JRViewer.createJRViewerVR(SceneGraphNode contentNode); v.startup();This is a shortcut for
JRViewer v = new JRViewer(); v.addBasicUI(); v.addVRSupport(); v.addContentSupport(ContentType.TerrainAligned); v.registerPlugin(new ContentAppearance()); v.registerPlugin(new ContentTools()); v.setContent(SceneGraphNode contentNode); v.startup();
SimpleController
. It implements convenient methods to register jReality related plugins
and delegates other methods directly to the controller. The controller may be accessed directly via getController()
.
Plugin
s to read and save properties. These properties
are read from and saved to a file
at startup and shutdown via XStream.
When SimpleController#shutdown()
is called (from the main windows closing method or from a plugin that implements
ShutdownFlavor
) the user gets the chance to decide where the properties are saved.
The decisions are saved
via the java preferences API (see setPropertiesResource(Class, String)
. If nothing
else is specified the SimpleController
tries to read the plugin properties from
System.getProperty("user.home") + "/.jrworkspace/default_simple.xml"and saves the user decisions in the preferences node of the package of the SimpleController.
Besides the name (and path) of the properties file the user may choose
true
), PropertiesFlavor
).It is recommended that applications call
setPropertiesResource(MyClass.class,"propertiesFileName")before calling
startup()
. Then the controller loads the plugin properties from this resource. After deployment this
resource may most likely only be opened for reading, which has the effect that it will only be used
to call setPropertiesInputStream(InputStream)
and the properties file will retain its default
value or whatever it is set to via setPropertiesFile(File)
.
When loading properties the availability of a properties file is checked in the following order
true
true
or both files above can't be opened for writing.
Note to Eclipse developers: if you change the path of the file to save the properties into in the dialog at shutdown to point to the source folder and DISABLE the load from this file check box, then the resource will be accessed to load the properties (and the situation after deployment is always tested) and the source folder file is used to save (which then may be included in version control). Copying of the properties xml file to the bin folder needs to be triggered manually by refreshing the source folder
Modifier and Type | Class and Description |
---|---|
static class |
JRViewer.ContentInjectionPlugin
this plugin is registered in the JRViewer in setConten(Scenegraphnode)
|
static class |
JRViewer.ContentType |
Modifier and Type | Field and Description |
---|---|
static PythonConsole.MyJTextPane |
scriptingTextPane |
Constructor and Description |
---|
JRViewer()
Create a JRViewer with default scene and lights.
|
JRViewer(boolean addLights)
Create a JRViewer with default scene.
|
JRViewer(JrScene s)
create a JRViewer with a custom scene.
|
Modifier and Type | Method and Description |
---|---|
void |
addAudioSupport()
Audio plug-ins.
|
void |
addBasicUI()
Basic UI support: scene graph inspector, bean shell,
menu bar, view menu (with display options and background color),
export menu, camera settings menu, and properties menu.
|
void |
addBeanShellSupport()
Adds a java bean shell to the lower slot
Warning: this plug-in is incompatible with the python console plug-in
|
void |
addContentSupport(JRViewer.ContentType type)
Registers one of the predefined content plug-ins
|
void |
addContentUI()
Registers advanced content tools.
|
void |
addPythonSupport()
Adds a python console to the lower slot
Warning: this plug-in is incompatible with the Shell plug-in
|
void |
addVRSupport()
Virtual reality support.
|
static JRViewer |
createJRViewer(SceneGraphNode node)
Quick display method with encompass
|
static JRViewer |
createJRViewerVR(SceneGraphNode contentNode)
Create a JRViewer that displays the provided
SceneGraphNode in a
virtual reality environment with movable avatar etc. |
static SceneShrinkPanel |
createSceneShrinkPanel(Component c,
String title)
Deprecated.
extend
SceneShrinkPanel or ViewShrinkPanelPlugin |
static Viewer |
display(SceneGraphNode node)
Quick display method with encompass
|
void |
dispose()
Calls the dispose methods on the View and the ToolSystem Plug-ins
to stop running Threads and free the resources.
|
void |
encompassEuclidean()
Call after startup.
|
SimpleController |
getController()
Returns the controller of this JRViewer which is a SimpleController
|
static JRViewer |
getLastJRViewer()
Returns the last created instance of JRViewer
|
<T extends Plugin> |
getPlugin(Class<T> clazz)
Returns a previously registered plug in instance
|
Viewer |
getViewer() |
static void |
main(String[] args)
Starts the default plug-in viewer
|
void |
registerCustomContent(Content contentPlugin)
|
void |
registerPlugin(Plugin p)
Adds a plug-in to this JTViewer's registered plug-ins.
|
void |
registerPlugins(Set<Plugin> pSet)
Registered a set of plug-ins at once
|
static void |
setApplicationIcon(Image icon) |
static void |
setApplicationTitle(String title) |
void |
setContent(SceneGraphNode node)
Sets a content node.
|
void |
setPropertiesFile(File file)
Sets the properties File of the SimpleController.
|
void |
setPropertiesFile(String filename)
Sets the properties File of the SimpleController.
|
void |
setPropertiesInputStream(InputStream in)
Sets the properties InputStream of the SimpleController.
|
void |
setPropertiesResource(Class<?> clazz,
String propertiesFileName)
The provided resource serves 2 purposes:
to set the properties
File and InputStream via setPropertiesFile(File)
(if this resource allows write access) and setPropertiesInputStream(InputStream)
(if this resource allows read access),
to save and read user decisions about the reading and loading of the property file in a package specific node, via
the Java Preferences API. |
void |
setShowMenuBar(boolean show)
Show or hide the menu bar
|
void |
setShowPanelSlots(boolean left,
boolean right,
boolean top,
boolean bottom)
Configures the visibility of the shrink panels slots
|
void |
setShowToolBar(boolean show)
Show or hide the tool bar
|
void |
setSplashScreen(SplashScreen screen)
Sets the splash screen used during startup
|
void |
startup()
Starts this JRViewer's controller and installs all registered
plug-ins.
|
JRootPane |
startupLocal()
Starts this JRViewer's controller and installs all registered
plug-ins.
|
public static PythonConsole.MyJTextPane scriptingTextPane
public JRViewer()
public JRViewer(boolean addLights)
addLights
- if true, standard lights are added.public JRViewer(JrScene s)
s
- the scenepublic static void setApplicationTitle(String title)
public static void setApplicationIcon(Image icon)
public static JRViewer getLastJRViewer()
public void registerPlugin(Plugin p)
p
- public void registerPlugins(Set<Plugin> pSet)
pSet
- a set of plug-inspublic <T extends Plugin> T getPlugin(Class<T> clazz)
T
- clazz
- the class of the plug-inpublic Viewer getViewer()
Viewer
of this JRViewer
(only works
after startup).public void setContent(SceneGraphNode node)
node
- public void setPropertiesResource(Class<?> clazz, String propertiesFileName)
File
and InputStream
via setPropertiesFile(File)
(if this resource allows write access) and setPropertiesInputStream(InputStream)
(if this resource allows read access),clazz
- the class from which the resource may be obtained, the
properties node of the package of this class is used to save the user decisions.propertiesFileName
- name of the resource that contains the plugin properties. This argument may
be null, then only the second purpose is served and the properties File
and
InputStream
are NOT set to null and may be set independently (e.g. to specify a default file, when
the resource gets read only after deployment).public void setPropertiesFile(String filename)
Sets the properties File of the SimpleController.
WARNING: This method does not overwrite a file chosen by the the user. Moreover the user decisions are saved
in the same place for all JRViewer applications, unless you use setPropertiesResource(Class, String)
,
where the class parameter allows to identify an application specific place to save user preferences.
filename
- a file or nullsetPropertiesResource(Class, String)
public void setPropertiesFile(File file)
Sets the properties File of the SimpleController. This does not overwrite a file chosen by the the user and persisted as user properties.
WARNING: This method does not overwrite a file chosen by the the user. Moreover the user decisions are saved
in the same place for all JRViewer applications, unless you use setPropertiesResource(Class, String)
,
where the class parameter allows to identify an application specific place to save user preferences.
file
- a file or nullsetPropertiesResource(Class, String)
public void setPropertiesInputStream(InputStream in)
File
is provided
the InputStream
is used for reading the properties.
WARNING: This method does not overwrite a file chosen by the the user. Moreover the user decisions are saved
in the same place for all JRViewer applications, unless you use setPropertiesResource(Class, String)
,
where the class parameter allows to identify an application specific place to save user preferences.
in
- an InputStream or nullsetPropertiesResource(Class, String)
public SimpleController getController()
public void startup()
public JRootPane startupLocal()
public void dispose()
public void setShowPanelSlots(boolean left, boolean right, boolean top, boolean bottom)
left
- right
- top
- bottom
- public void setShowMenuBar(boolean show)
show
- public void setShowToolBar(boolean show)
show
- public void registerCustomContent(Content contentPlugin)
contentPlugin
- a content plug-inpublic void addContentSupport(JRViewer.ContentType type)
type
- a content enumeration typepublic void addContentUI()
public void addBasicUI()
public void addPythonSupport()
public void addBeanShellSupport()
public void addVRSupport()
public void addAudioSupport()
public void setSplashScreen(SplashScreen screen)
screen
- public static Viewer display(SceneGraphNode node)
node
- public static JRViewer createJRViewer(SceneGraphNode node)
node
- public static JRViewer createJRViewerVR(SceneGraphNode contentNode)
SceneGraphNode
in a
virtual reality environment with movable avatar etc. (#addBasicUISupport()
,
#addVRSUpport()
, terrain aligned content, ContentAppearance
, ContentTools
).
The created viewer is not started yet, so you need to call startup()
on the returned
JRViewer
.contentNode
- the scene graph component to be displayed or null
.public void encompassEuclidean()
public static void main(String[] args)
args
- no arguments are readpublic static SceneShrinkPanel createSceneShrinkPanel(Component c, String title)
SceneShrinkPanel
or ViewShrinkPanelPlugin