1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import java.awt.BorderLayout import javax.swing.JPanel import swing. _ import vtk. _ /** * Create a cone and display it in an application window using Scala's Swing */ object ScalaCone extends SimpleSwingApplication { // Setup VTK rendering panel, this also loads VTK native libraries var renWin : vtkPanel = new vtkPanel // Create wrapper to integrate vtkPanel with Scala's Swing API val scalaPanel = new Component { override lazy val peer = new JPanel( new BorderLayout()) peer.add(renWin) } // Setup cone rendering pipeline var cone = new vtkConeSource cone.SetResolution( 8 ) var coneMapper = new vtkPolyDataMapper coneMapper.SetInputConnection(cone.GetOutputPort) var coneActor = new vtkActor coneActor.SetMapper(coneMapper) renWin.GetRenderer.AddActor(coneActor) renWin.GetRenderer.ResetCamera // Create the main application window def top = new MainFrame { title = "ScaleCone" contents = scalaPanel } } |