I am new to jReality. I would like to use it to visualize the data my java application produces.
To make this embedding possible, I need to address three issues, which I describe below.
In order to embed jReality into my application,
I need to display jReality renderings in JInternalFrame. How can I do it? I have seen in some tutorials, ViewerApp.display() is used, which renders to a JFrame. Instead, can I use
JInternalFrame? How can I do it?
I would like the user to have a lot of interaction with my application. That means the data is updated and re-rendered. This can happen frequently and rapidly. As an important step of this interaction, I need to allow the user interact with the scene by picking and selection. I am assuming this is possible. Am I right?
Finally, I would like to set up multiple visualizations, each rendered into a different JInternalFrame and each rendering done on a different thread. Is this possible in jReality? Are there some examples illustrating this aspect?
I really appreciate any feedback on these issues.
Thanks,
Karuna
Embedding jReality in a Java Application
You can use ViewerApp to get everything set-up and then put the components where you like, but I have never tested JInternalFrames. Just use the constructor ViewerApp(SceneGraphNode n) and give it your SceneGraphComponent. Take a look at the javadoc of ViewerApp for more infos.Instead, can I use JInternalFrame? How can I do it?
Yes, you are ;-) Please see the tutorials in the Wiki for a first introduction...I need to allow the user interact with the scene by picking and selection. I am assuming this is possible. Am I right?
It is no problem to create several ViewerApp instances with different content that is displayed. It is also possible to render different views from the same scene, but interacting with the same scene from different viewers will cause problems. Please give more details about what you want to do.Finally, I would like to set up multiple visualizations, each rendered into a different JInternalFrame and each rendering done on a different thread...
Good luck, Steffen.
-
- Posts: 90
- Joined: Sun 16. Nov 2008, 00:24
Thanks Steffen, for the help, it worked for JFrame and JInternalFrame.
I have also extended the ViewerApp class by adding two constructors that take JFrame and JInternalFrame as arguments and then use the methods already present in ViewerApp.
"...but interacting with the same scene from different viewers will cause problems. Please give more details about what you want to do."
I am working on a Visualization research project that extensively uses surfaces and curves. This is an emerging research project. I will post messages as our work requires new visualizations.
Thanks,
Karuna
I have also extended the ViewerApp class by adding two constructors that take JFrame and JInternalFrame as arguments and then use the methods already present in ViewerApp.
"...but interacting with the same scene from different viewers will cause problems. Please give more details about what you want to do."
I am working on a Visualization research project that extensively uses surfaces and curves. This is an emerging research project. I will post messages as our work requires new visualizations.
Thanks,
Karuna
Re: Embedding jReality in a Java Application
I am also trying to embed a viewer into a JInternalFrame, but have been unsuccessful thus far. Could you share some of the code that you used to add the viewer to the internal frame? Thanks
Re: Embedding jReality in a Java Application
I have been able to add the viewing component to a JPanel "DrawPanel" within a JInternalFrame (see code below), but the ViewerApp is still displayed (see attached picture).
Also the ViewerApp is depreciated. Is there a way to add the viewing component of the JRViewer? Thanks in advance.
Code: Select all
public class DrawPanel extends JPanel {
public DrawPanel(){
//this.setBackground(Color.WHITE);
//SceneGraphComponent sgc = SceneGraphUtility.createFullSceneGraphComponent("world");
//sgc.setGeometry(createSurface(20));
//Appearance ap = sgc.getAppearance();
//ap.setAttribute(CommonAttributes.POLYGON_SHADER+"."+CommonAttributes.DIFFUSE_COLOR, Color.LIGHT_GRAY);
ViewerApp v = new ViewerApp(new SceneGraphComponent());
v.display(null);
v.setCreateMenu(false);
v.setBackgroundColor(Color.GREEN);
v.update();
this.add((Component)v.getContent());
}
}
- Attachments
-
- Untitled.png (80.1 KiB) Viewed 1205 times
Re: Embedding jReality in a Java Application
For others browsing the forum, this is how you can add a viewer to an internal frame.
Code: Select all
/*
* Created on Jan 12, 2010
*
*/
package de.jreality.tutorial.plugin;
import java.awt.GridLayout;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JRootPane;
import de.jreality.plugin.JRViewer;
import de.jreality.plugin.JRViewer.ContentType;
import de.jreality.plugin.basic.Inspector;
import de.jreality.plugin.content.ContentLoader;
import de.jreality.plugin.content.ContentTools;
import de.jtem.jrworkspace.plugin.sidecontainer.template.ShrinkPanelPlugin;
public class InternalFrameTest {
public static void main(String[] args) {
JRViewer v = new JRViewer();
v.addBasicUI();
v.registerPlugin(new ContentLoader());
v.registerPlugin(new ContentTools());
v.getPlugin(Inspector.class).setInitialPosition(ShrinkPanelPlugin.SHRINKER_LEFT);
v.addContentSupport(ContentType.CenteredAndScaled);
v.setShowPanelSlots(true, false, false, false);
// call this to avoid creating a Frame
JRootPane rootPanel = v.startupLocal();
// create your own frame, with a JInternalFrame, and
// put the rootPanel into it.
JFrame f = new JFrame("Internal Frame Test");
JDesktopPane desktop = new JDesktopPane();
JInternalFrame internalFrame1 = new JInternalFrame("Internal Frame");
internalFrame1.setSize(600, 400);
internalFrame1.setLayout(new GridLayout());
internalFrame1.add(rootPanel);
internalFrame1.setResizable(true);
desktop.add(internalFrame1);
internalFrame1.setVisible(true);
f.setLayout(new GridLayout());
f.add(desktop);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(800, 600);
f.setVisible(true);
}
}
Re: Embedding jReality in a Java Application
Thx for this tutorial I've added this to the viewer Tutorials of jReality