[vtkusers] Example for SimpleCone
Todd Simons
todd.a.simons at gmail.com
Wed Dec 20 10:29:18 EST 2006
Hello all,
I'm a relatively new VTK developer. I am using Java as the gui for my VTK
applications. I had a hard time getting started and finding examples
written in Java. I have ported a dozen examples to Java to get familiar
with it. I wanted to post my examples so other Java enthusiasts could get
up to speed on VTK a bit more easily. I hope this helps.
I think this example is already out there on the internet somewhere. Sorry
if this is a duplication.
Best Regards,
Todd
package examples;
import vtk.vtkActor;
import vtk.vtkConeSource;
import vtk.vtkPanel;
import vtk.vtkPolyDataMapper;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
* A very basic application that simple displays a cone using vtkPanel.
* Close the window to exit aplication.
*/
public class SimpleCone extends JPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
public SimpleCone() {
// Setup VTK rendering panel
vtkPanel renWin = new vtkPanel();
// Setup cone rendering pipeline
vtkConeSource cone = new vtkConeSource();
cone.SetResolution(8);
vtkPolyDataMapper coneMapper = new vtkPolyDataMapper();
coneMapper.SetInput(cone.GetOutput());
vtkActor coneActor = new vtkActor();
coneActor.SetMapper(coneMapper);
renWin.GetRenderer().AddActor(coneActor);
renWin.setSize(300, 300);
// Place renWin in the center of this panel
setLayout(new BorderLayout());
add(renWin, BorderLayout.CENTER);
}
public static void main(String s[]) {
SimpleCone panel = new SimpleCone();
JFrame frame = new JFrame("SimpleCone");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.getContentPane().add("Center", panel);
frame.pack();
frame.setVisible(true);
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061220/e2119185/attachment.htm>
More information about the vtkusers
mailing list