Simple VTK Cone - Java Way
Show a VTK cone using Java's Swing.
import vtk.*;
import javax.swing.*;
/**
* Create a cone and display it in an application window.
*/
final public class JavaCone {
public static void main(String s[]) {
// Setup VTK rendering panel, this also loads VTK native libraries
vtkPanel renWin = new vtkPanel();
// Setup cone rendering pipeline
vtkConeSource cone = new vtkConeSource();
cone.SetResolution(8);
vtkPolyDataMapper coneMapper = new vtkPolyDataMapper();
coneMapper.SetInputConnection(cone.GetOutputPort());
vtkActor coneActor = new vtkActor();
coneActor.SetMapper(coneMapper);
renWin.GetRenderer().AddActor(coneActor);
renWin.GetRenderer().ResetCamera();
// Create the main application window
JFrame frame = new JFrame("JavaCone");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.add(renWin);
frame.pack();
frame.setVisible(true);
}
}