[vtkusers] Java request = Java sample

Sebastien Jourdain jourdain at artenum.com
Mon Apr 16 03:14:48 EDT 2007


Hello,

some people ask for information about Java and VTK.
I've done a first step with VTK/Java and Eclipse and its available here 
: http://dev.artenum.com/projects/cassandra/forum/how-to-use-eclipse-and-vtk

I've also tried to put it on the Kitware/Wiki, here 
http://www.vtk.org/Wiki/VTK_Online_Tutorials
but my link never shown up. And I always get confused with this Wiki. 
(Where should I put it ? How can I put images ?)

Otherwise for the one who just want a really simple code of a VTK panel 
integration here is a small example.

public class VTKSample {

public static void main(String[] args) { // Build the VTK 3D view // 
(Should be done before using any vtk // object or load the native // 
library first) vtkPanel panel3D = new vtkPanel();

// Build a simple VTK pipeline vtkConeSource coneSource = new 
vtkConeSource(); coneSource.SetRadius(2); coneSource.SetAngle(15); 
coneSource.SetHeight(2); coneSource.SetResolution(10);

vtkPolyDataMapper coneMapper = new vtkPolyDataMapper(); 
coneMapper.SetInput(coneSource.GetOutput());

vtkActor coneActor = new vtkActor(); coneActor.SetMapper(coneMapper);

// Add actor in 3D Panel panel3D.GetRenderer().AddActor(coneActor);

// Build Java Frame and include the VTK view JFrame frame = new 
JFrame("Artenum Demo"); 
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
frame.getContentPane().setLayout(new BorderLayout()); 
frame.getContentPane().add(panel3D, BorderLayout.CENTER); 
frame.setSize(500, 500); frame.setLocationRelativeTo(null); // Center on 
desktop frame.setVisible(true); } }





More information about the vtkusers mailing list