<div>
<div>Hello all,</div>
<div> </div>
<div>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.
</div>
<div> </div>
<div>I think this example is already out there on the internet somewhere. Sorry if this is a duplication.</div>
<div> </div>
<div>Best Regards,</div>
<div>Todd</div>
<div> </div></div>
<div> </div>
<div>
<p>package examples;<br>import vtk.vtkActor;<br>import vtk.vtkConeSource;<br>import vtk.vtkPanel;<br>import vtk.vtkPolyDataMapper;</p>
<p>import javax.swing.*;<br>import java.awt.*;<br>import java.awt.event.WindowAdapter;<br>import java.awt.event.WindowEvent;</p>
<p>/**<br> * A very basic application that simple displays a cone using vtkPanel.<br> * Close the window to exit aplication.<br> */<br>public class SimpleCone extends JPanel {</p>
<p> /**<br> *<br> */<br> private static final long serialVersionUID = 1L;</p>
<p><br>public SimpleCone() {<br> // Setup VTK rendering panel<br> vtkPanel renWin = new vtkPanel();</p>
<p> // Setup cone rendering pipeline<br> vtkConeSource cone = new vtkConeSource();<br> cone.SetResolution(8);</p>
<p> vtkPolyDataMapper coneMapper = new vtkPolyDataMapper();<br> coneMapper.SetInput(cone.GetOutput());</p>
<p> vtkActor coneActor = new vtkActor();<br> coneActor.SetMapper(coneMapper);</p>
<p> renWin.GetRenderer().AddActor(coneActor);<br> renWin.setSize(300, 300);</p>
<p> // Place renWin in the center of this panel<br> setLayout(new BorderLayout());<br> add(renWin, BorderLayout.CENTER);<br> }</p>
<p><br> public static void main(String s[]) {<br> SimpleCone panel = new SimpleCone();</p>
<p> JFrame frame = new JFrame("SimpleCone");<br> frame.addWindowListener(new WindowAdapter() {<br> public void windowClosing(WindowEvent e) {<br> System.exit(0);<br> }<br> });<br> frame.getContentPane
().add("Center", panel);<br> frame.pack();<br> frame.setVisible(true);<br> }<br>}</p>
<p> </p></div>