I am trying to integrate jzy3d into my swing application. Basically I
want to have a JInternalFrame that shows graphs with jzy3d.
An example of code could be the following:
public class JZY3DFrame extends JInternalFrame implements Observer
{
public JZY3DFrame (Chart chart, Rectangle bounds, String title)
{
this (chart, title);
setBounds (bounds);
}
public JZY3DFrame (Chart chart, String title)
{
_chart = chart;
addInternalFrameListener(new JZY3DFrameInternalFrameAdapter
());
setDefaultCloseOperation (EXIT_ON_CLOSE);
getContentPane().setLayout(new BorderLayout());
getContentPane().add((Component)_chart.getCanvas());
setTitle (title);
}
public void update(Observable o, Object arg) {
throw new UnsupportedOperationException("Not supported yet.");
}
private Chart _chart;
private class JZY3DFrameInternalFrameAdapter extends
InternalFrameAdapter
{
@Override
public void internalFrameClosing (InternalFrameEvent e)
{
remove ((Component) _chart.getCanvas());
_chart.dispose();
_chart = null;
dispose();
}
}
public static Chart getTestChart() {
// Define a function to plot
Mapper mapper = new Mapper() {
public double f(double x, double y) {
return 10 * Math.sin(x / 10) * Math.cos(y / 20) * x;
}
};
// Define range and precision for the function to plot
Range range = new Range(-150, 150);
int steps = 50;
surface = (Shape)Builder.buildOrthonormal(new OrthonormalGrid
(range, steps, range, steps), mapper);
surface.setColorMapper(new ColorMapper(new ColorMapRainbow(),
surface.getBounds().getZmin(), surface.getBounds().getZmax(), new Color
(1,1,1,.5f)));
surface.setFaceDisplayed(true);
surface.setWireframeDisplayed(true);
surface.setWireframeColor(Color.BLACK);
surface.setFace(new ColorbarFace(surface));
surface.setFace2dDisplayed(true); // opens a colorbar on the
right part of the display
Chart c = new Chart() {
@Override
public void setScale(Scale scale) {
super.setScale(scale);
ColorMapper cm = surface.getColorMapper();
cm.setScale(scale);
surface.setColorMapper(cm);
//surface.setFaceDisplayed(true);
}
};
c.getScene().getGraph().add (surface);
return c;
}
static Shape surface;
}
With Windows everything is working fine (http://dl.dropbox.com/u/
234787/Stuff/windows.png) but with Mac OS (Leopard, Java 1.6, 64bit)
the canvas where the graph is rendered is always on top of everything,
no matter if the JInternalFrame is the one with focus or not (http://
dl.dropbox.com/u/234787/Stuff/osx.png).
Just a note: Since I had troubles recompiling JOGL for 64bit myself I
am using the one distributed together with worldwind.
Hope somebody has a clue about what's going on.
Thanks,
Max
Windows: http://dl.dropbox.com/u/234787/Stuff/windows.png
Mac OSx: http://dl.dropbox.com/u/234787/Stuff/osx.png
I will try this as soon as I can and let you know!
On Jan 23, 6:58 am, Martin Pernollet <martin.pernol...@gmail.com>
wrote:
> Hi Massimiliano
> That's weird it worked on windows, because I fear you are actually using the
> heavywight CanvasAWT component in Swing.
> The Chart object relies on a Canvas, either CanvasAWT or CanvasSwing. Its
> default behaviour is to use a CanvasAWT but you may force a Swing one this
> way:
>
> Chart c = new Chart(){
> @Override
> public Canvas initializeCanvas(Scene scene, Quality quality){
> return new CanvasSwing(scene, quality);
> }
>
> }
>
> as CanvasSwing is just an extention of the JOGL GLJPanel (http://savior.awardspace.com/javax/media/opengl/GLJPanel.html) you should
> have something that doesn't mess up when having other swing components on
> top. I however have no clue on why the colorbar doesn't render properly in
> your Swing case.
>
> Regards
> Martin
>
> 2010/1/22 Massimiliano <emaildel...@gmail.com>
I have also seen the other post where you say you added the parameter
swing/awt in the constructor, thanks, I will checkout the latest code
from SVN and test it out.
Unfortunately the color bar on the right still doesn't render
properly.
Never mind, my final objective is essentially the following: I need to
draw points in a 3d canvas, I don't need any graph (at least for now)
I want to be able to show essentially spheres, each sphere represents
a point and I want to be able to control the radius of the sphere, the
color and maybe the opacity and of course the coordinates of the
center. It'd be great if I could also click on such spheres and show
related information somewhere, a separate window would be fine.
Is this doable with jzy3d?
Before reading the documentation I wanted to make sure I could easily
integrate it into my project, and now that I was able to make it work
I need to see if I can do what I need. There aren't many libraries
that enable 3d visualization in java, so I hope I can do what I need
with this one.
Thanks,
Massimiliano
On Jan 23, 6:58 am, Martin Pernollet <martin.pernol...@gmail.com>
wrote:
> Hi Massimiliano
> That's weird it worked on windows, because I fear you are actually using the
> heavywight CanvasAWT component in Swing.
> The Chart object relies on a Canvas, either CanvasAWT or CanvasSwing. Its
> default behaviour is to use a CanvasAWT but you may force a Swing one this
> way:
>
> Chart c = new Chart(){
> @Override
> public Canvas initializeCanvas(Scene scene, Quality quality){
> return new CanvasSwing(scene, quality);
> }
>
> }
>
> as CanvasSwing is just an extention of the JOGL GLJPanel (http://savior.awardspace.com/javax/media/opengl/GLJPanel.html) you should
> have something that doesn't mess up when having other swing components on
> top. I however have no clue on why the colorbar doesn't render properly in
> your Swing case.
>
> Regards
> Martin
>
> 2010/1/22 Massimiliano <emaildel...@gmail.com>
Ok, that worked :)
I have also seen the other post where you say you added the parameter
swing/awt in the constructor, thanks, I will checkout the latest code
from SVN and test it out.
Unfortunately the color bar on the right still doesn't render
properly.
Never mind, my final objective is essentially the following: I need to
draw points in a 3d canvas, I don't need any graph (at least for now)
I want to be able to show essentially spheres, each sphere represents
a point and I want to be able to control the radius of the sphere, the
color and maybe the opacity and of course the coordinates of the
center.
It'd be great if I could also click on such spheres and show
related information somewhere, a separate window would be fine.
Is this doable with jzy3d?
Before reading the documentation I wanted to make sure I could easily
integrate it into my project, and now that I was able to make it work
I need to see if I can do what I need. There aren't many libraries
that enable 3d visualization in java, so I hope I can do what I need
with this one.
On Jan 26, 5:39 pm, Martin Pernollet <martin.pernol...@gmail.com>
wrote:
> Hi,
> Selecting objects seems to be easy to do with Gleem (http://alumni.media.mit.edu/~kbrussel/gleem/). Although the lib home page is
> old, it seems to have been integrated to JOGL.
> I let you check :)
> Martin
>
> 2010/1/26 Martin Pernollet <martin.pernol...@gmail.com>
>
>
>
>
>
> > 2010/1/26 Martin Pernollet <martin.pernol...@gmail.com>
>
> >> 2010/1/25 Massimiliano <emaildel...@gmail.com>
> > *jMonkeyEngine <http://www.jmonkeyengine.com/>, lwjgl <http://lwjgl.org/>,
> > Xith3D <http://xith.org/>, Aviatrix3D <http://aviatrix3d.j3d.org/>*
What I am trying to do now is having the ability of customize the axis
labels and scale. For instance, I would like to do the following:
let's say I want to visually plot a netflow-like dataset, e.g. source-
ip, dest-ip, port, number-of-packets.
What I will do is assigning a numeric value for each of the fields,
i.e. the IPs will be 0 to 100, port will stay as it is (and these are
x, y and z) and number-of-packets will be the alpha value, normalized
between 0 and 1. This I have already done.
Now I would like to have the possibility to label the x-axes as source-
IP the y as dest-IP and the z port (BTW, Z never shows up in the
graph). Moreover, I'd like to have rather than numbers on the axes
(0-100 for instance) the corresponding IPs (using a look-up-table for
instance). I started to look into this, at least at the axes labels,
however there is some problem with jzy's source code:
- The only way I found would be extending AxeBox and reimplementing
drawTicks. Unfortunately AxeBox has a number of private fields which I
cannot use in my subclass. So I just created my own class, copy
pasting basically all the AxeBox + adding methods and variables to set
the labels. BUT:
- My plan was to extend View as well, and set my own axebox in the
constructor. However the attribute in View for the axebox is of type
AxeBox and not Axe (the interface) as I expected. I could cast of
course, but before writing messy code I'd like to know if there are
other ways to do what I am trying to do.
Thanks for your help with this,
Massimiliano
On Jan 26, 11:26 am, Martin Pernollet <martin.pernol...@gmail.com>
wrote:
> 2010/1/26 Martin Pernollet <martin.pernol...@gmail.com>
>
>
>
>
>
>
>
> > 2010/1/25 Massimiliano <emaildel...@gmail.com>
>
> *jMonkeyEngine <http://www.jmonkeyengine.com/>, lwjgl <http://lwjgl.org/>,
> Xith3D <http://xith.org/>, Aviatrix3D <http://aviatrix3d.j3d.org/>*
>
>
>
>
>