Java Examples

Click here for a tutorial on setting up your Java environment.

It would be appreciated if there are any Java VTK experts who could convert any of the c++ examples to Java!

Info

This table shows the VTK classes covered by the examples.

Info

This table shows VTK classes that do not have an example. Please add examples in your area of expertise!

Hello World

Example Name Classes Demonstrated Description Image
A hello world example vtkPolyDataMapper vtkActor vtkRenderer vtkRenderWindow vtkRenderWindowInteractor Cylinder example from the VTK Textbook and source code. A hello world example.

Input and Output

Graph Formats

3D File Formats

Example Name Classes Demonstrated Description Image
ConvertFile Convert a file from one type to another

Standard Formats

Input
Example Name Classes Demonstrated Description Image
DEMReader vtkDEMReader Read DEM (elevation map) files
ParticleReader vtkParticleReader This example reads ASCII files where each line consists of points with its position (x,y,z) and (optionally) one scalar or binary files in RAW 3d file format.
ReadCML vtkCMLMoleculeReader Read Chemistry Markup Language files.
ReadOBJ vtkOBJReader Read an OBJ (.obj) file.
ReadPLOT3D vtkPLOT3DReader Read PLOT3D data files.
ReadPLY vtkPLYReader Read PLY (.ply) files
ReadSLC vtkSLCReader Read an SLC volume file.
ReadSTL vtkSTLReader Read stereo lithography STL (.stl) files.
SimplePointsReader vtkSimplePointsReader Read a simple "xyz" file of points.
Importers
Example Name Classes Demonstrated Description Image
ThreeDSImporter vtk3DSImporter Import a 3D Studio scene that includes multiple actors.
VRMLImporter vtkVRMLImporter Import a VRML 2.0 (WRL) file.
Output
Example Name Classes Demonstrated Description Image
SimplePointsWriter vtkSimplePointsWriter Write a simple ".xyz" file
WritePLY vtkPLYWriter Write PLY (.ply) files.
WriteSTL vtkSTLWriter Write stereo lithography STL (.stl) files.

VTK Formats

Input
Example Name Classes Demonstrated Description Image
ReadPolyData vtkXMLPolyDataReader Read VTK XML PolyData files.
ReadRectilinearGrid vtkXMLRectilinearGridReader Read VTK XML RectilinearGrid files.
ReadStructuredGrid vtkXMLStructuredGridReader Read VTK XML StructuredGrid files.
ReadVTP vtkXMLPolyDataReader Read a VTK XML PolyData file.
Output
Example Name Classes Demonstrated Description Image
WriteVTP vtkXMLPolyDataWriter Write a VTK XML PolyData file.
WriteVTU vtkXMLUnstructuredGridWriter Write a .vtu file. VTU is an "Unstructured Grid". This format allows for 3D data to be stored.
XMLPImageDataWriter vtkXMLPImageDataWriter Write a .pvti file with 4 .vti pieces.
XMLPUnstructuredGridWriter vtkXMLPUnstructuredGridWriter Write a .pvtu with 4 .vtu pieces.
XMLStructuredGridWriter vtkXMLStructuredGridWriter Write a .vts file from a vtkStructuredGrid.
Legacy VTK Formats
Example Name Classes Demonstrated Description Image
StructuredPointsReader vtkStructuredPointsReader Read a structured points (.vtk) file.

Image Format

Input

Example Name Classes Demonstrated Description Image
ReadBMP vtkBMPReader Read Windows BMP files.
ReadDICOM vtkDICOMImageReader Read DICOM images.
JPEGReader vtkJPEGReader Read a JPEG image.
ReadPNM vtkPNMReader Read PNM (.pnm) files.
ReadTIFF vtkTIFFReader Read TIFF (.tif) files.

Output

Example Name Classes Demonstrated Description Image
JPEGWriter vtkJPEGWriter Write a JPEG file.
PNGReader vtkPNGReader Read a PNG image.
WritePNM vtkPNMWriter Write a PNM (.pnm) file.
WriteTIFF vtkTIFFWriter Write a TIFF (.tif) file.

Annotation

Example Name Classes Demonstrated Description Image
TextOrigin vtkTextOrigin TextOrigin
MultiLineText vtkMultiLineText MultiLineText

CompositeData

Example Name Classes Demonstrated Description Image
CompositePolyDataMapper vtkCompositePolyDataMapper CompositePolyDataMapper

Filtering

Example Name Classes Demonstrated Description Image
Delaunay2D vtkDelaunay2D An example to generate set of points and to triangulate using Delaunay2D
Glyph2D vtkGlyph2D Example to copy a polydata to everypoint in the input set.
Glyph3D vtkGlyph3D This example applies an object at every point using vtkGlyph3D
PerlinNoise vtkPerlinNoise An implicit function that implements Perlin noise.
TransformPolyData vtkTransformPolyDataFilter Transforms points, associated normals and vectors for polygonal dataset
VertexGlyphFilter vtkVertexGlyphFilter Creates a set of points and adds a vertex at each point.
WarpTo vtkWarpTo Deform geometry by warping towards a point

GeometricObjects

Example Name Classes Demonstrated Description Image
Arrow vtkArrow Arrow Visualization
Circle vtkCircle Circle Visualization
Cone vtkCone Cone Visualization
EllipticalCylinder vtkEllipticalCylinder EllipticalCylinder
ConvexPointSet vtkConvexPointSet ConvexPointSet Visualization
Frustum vtkFrustum Frustum Visualization
Disk vtkDiskSource Disk Visualization
Line vtkLineSource Line Visualization
LongLine vtkLine A visualization of a long line
OrientedCylinder vtkOrientedCylinder Oriented Cylinder visualization
OrientedArrow vtkOrientedArrow Oriented Arrow visualization.
Polygon vtkPolygon Polygon Visualization
PlanesIntersection vtkPlanesIntersection PlanesIntersection
RegularPolygonSource vtkRegularPolygonSource RegularPolygon Visualization
ParametricObjects vtkParametricObjects ParametricObjects Visualization
Pyramid vtkPyramid Pyramid Visualization
Quad vtkQuad Quad Visualization
ShrinkCube vtkCubeSource vtkShrinkFilter Applying shrink filter to an object.
Vertex vtkVertex Vertex Visualization
TextActor vtkTextActor TextActor Demonstration
Triangle vtkTriangle Triangle Visualization
TriangleStrip vtkTriangleStrip Triangle Strip Visualization

HyperTreeGrid

Example Name Classes Demonstrated Description Image
HyperTreeGridSource vtkHyperTreeGridSource Demonstration of a hyper-tree grid source.

Geographic Visualization (Geovis)

Example Name Classes Demonstrated Description Image
EarthSource vtkEarthSource Earth Source Visualization
CompassWidget vtkCompassWidget CompassWidget Visualization
GeoAssignCoordinates vtkGeoAssignCoordinates Convert latitude and longitude coordinates to world coordinates.

Graphs

Example Name Classes Demonstrated Description Image
VisualizeGraph vtkMutableUndirectedGraph An example to construct a graph and visualize it.
GraphPoints vtkGraph Manually set the coordinates of vertices in a graph.
RandomGraphSource vtkRandomGraphSource A graph with random edges.

Working with Images

Example Name Classes Demonstrated Description Image
Actor2D vtkActor2D A actor that draws 2D data
Cast vtkImageCast Image Data type Casting Filter.
ImageSinusoidSource vtkImageSinusoidSource Creates an image with sinusoidal pixel values.
StaticImage vtkImageViewer2 Displays a 2D image
RTAnalyticSource vtkRTAnalyticSource Creates an image for regression testing

Image Processing

Example Name Classes Demonstrated Description Image
Flip vtkImageFlip Flips an image.
ImageFFT vtkImageFFT Compute the Fast Fourier Transform of an image.
ImageTest vtkImageReader2Factory Use Java file dialog to select an image file to display.
ShotNoise vtkImageCanvasSource2D vtkPNGWriter Create an image using vtkImageCanvasSource2D and write it to a file.

Implicit Functions and Iso-surfaces

Example Name Classes Demonstrated Description Image
IceCream vtkImplicitBoolean vtkSampleFunction How to use boolean combinations of implicit functions to create a model of an ice cream cone.
ImplicitDataSet Implicit functions, implicit data set.
ImplicitSphere vtkSphere vtkAppendPolyData vtkTubeFilter ImplicitFunctions, Append poly data, tube filter, sphere
SampleFunction vtkSampleFunction Sample an implicit function over a structured point set.

User Interaction

Example Name Classes Demonstrated Description Image
Assembly vtkAssembly Combine/group actors into an assembly.
InteractorStyleTerrain vtkInteractorStyleTerrain Manipulate camera in scene with natural view up.
RubberBandPick vtkInteractorStyleRubberBandPick Pick props underneath a rubber band selection rectangle.
RubberBandZoom vtkInteractorStyleRubberBandZoom Zoom in by amount indicated by rubber band box.
TrackballActor vtkInteractorStyleTrackballActor Trackball actor mode.
TrackballCamera vtkInteractorStyleTrackballCamera Trackball camera mode.
PickableOff vtkActor Disallow interaction with a specific actor.
StyleSwitch vtkInteractorStyleSwitch Choose between multiple interaction modes.

Working with Meshes

Example Name Classes Demonstrated Description Image
AddCell vtkPolyData Add a cell to an existing mesh.
BoundaryEdges vtkFeatureEdges Find the edges that are used by only one face.
DelaunayMesh vtkDelaunay2D vtkMinimalStandardRandomSequence vtkExtractEdges vtkGlyph3D vtkTubeFilter Two-dimensional Delaunay triangulation of a random set of points. Points and edges are shown highlighted with sphere glyphs and tubes.

Working with 3D Data

Example Name Classes Demonstrated Description Image
Bottle vtkRotationalExtrusionFilter Sweeps polygonal data creating "skirt" from free edges and lines, and lines from vertices
CellCenters vtkCellCenters Compute points at the center of every cell.
CenterOfMass vtkCenterOfMass Compute the center of mass of the points.
ProjectSphere vtkProjectSphereFilter Unroll a sphere or spherical-like model.
Spring vtkRotationalExtrusionFilter Rotation in combination with linear displacement and radius variation.

Working with Structured 3D Data

This section includes vtkImageData vtkStructuredGrid and vtkRectilinearGrid.

"ImageData" is not the traditional "flat, 2D image" you are used to. It is a special VTK data structure in the collection of 3D data structures provided by VTK. Here is an overview of these data structures. Image data can represent at typical 2D image, but also, a 3D volume.

vtkImageData

Example Name Classes Demonstrated Description Image
ImageNormalize vtkImageNormalize Normalizes the scalar components for each point.
ImageWeightedSum vtkImageWeightedSum Add two or more images.

vtkStructuredPoints

Example Name Classes Demonstrated Description Image
StructuredPointsToUnstructuredGrid vtkStructuredPoints vtkUnstructuredGrid Convert a vtkStructuredPoints to a vtkUnstructuredGrid.
Vol vtkStructuredPoints vtkContourFilter Creating a image data dataset. Scalar data is generated from the equation for a sphere. Volume dimensions are 26 x 26 x 26.

vtkStructuredGrid

Example Name Classes Demonstrated Description Image
BlankPoint vtkStructuredGrid Blank a point of a vtkStructuredGrid.
StructuredGridOutline vtkStructuredGridOutlineFilter Creates a wireframe outline for structured grid.

This section includes vtkImageData, vtkStructuredGrid and vtkRectilinearGrid.

"ImageData" is not the traditional "flat, 2D image" you are used to. It is a special VTK data structure in the collection of 3D data structures provided by VTK. Here is an overview of these data structures. Image data can represent at typical 2D image, but also, a 3D volume.

vtkRectilinearGrid

Example Name Classes Demonstrated Description Image
RectilinearGrid vtkRectilinearGrid A dataset that is topologically regular with variable spacing in the three coordinate directions
RectilinearGridToTetrahedra vtkRectilinearGridToTetrahedra Convert a vtkRectilinearGrid to a vtkUnstructuredGrid mesh.
VisualizeRectilinearGrid vtkRectilinearGrid vtkShrinkFilter Visualize the cells of a rectilinear grid.

Point Cloud Operations

Example Name Classes Demonstrated Description Image
FitImplicitFunction vtkFitImplicitFunction Extract points within a distance to an implicit function.

Data Structures

KD-Tree

Example Name Classes Demonstrated Description Image
VisualizeKDTree vtkKdTreePointLocator Show the levels of a KD Tree.

Octree

Example Name Classes Demonstrated Description Image
BuildOctree vtkOctreePointLocator Create an octree.

Rendering

Example Name Classes Demonstrated Description Image
AmbientSpheres vtkProperty Demonstrates the effect of ambient lighting on spheres.
ColoredSphere vtkSphereSource vtkElevationFilter A simple sphere.
Cone6 vtkBoxWidget vtkInteractorStyleTrackballCamera This example introduces 3D widgets. 3D widgets take advantage of the event/observer design pattern. Corresponds to the missing Step 6 Java example from VTK/Examples/Tutorial.
Mace An example of multiple inputs and outputs.
SpecularSpheres vtkProperty Demonstrates the effect of specular lighting on spheres.

Lighting

Example Name Classes Demonstrated Description Image
SpotLight vtkSpotLight vtkSpotLight Demonstration
LightActor vtkLightActor vtkLightActor Demonstration

Math Operations

Example Name Classes Demonstrated Description Image
MatrixInverse vtkMatrix3x3 Represents and manipulates 3x3 transformation matrices.
MatrixTranspose vtkMatrix3x3 The transpose of a matrix is a new matrix whose rows are the columns of the original.
NormalizeVector vtkMath Normalize a vector.

Parallel

Example Name Classes Demonstrated Description Image
ExodusIIWriter vtkExodusIIWriter Example Program to demonstrates how to use vtkExodusIIWriter

PolyData

Example Name Classes Demonstrated Description Image
Stripper vtkStripper Stripper
KochanekSpline vtkKochanekSpline KochanekSpline
ColorDisconnectedRegions vtkColorDisconnectedRegions ColorDisconnectedRegions
ColoredPoints vtkUnsignedCharArray Example to visualize Colored Points.
Outline vtkOutline Outline
RibbonFilter vtkRibbonFilter RibbonFilter
ColorCells vtkColorCells ColorCells
TubeFilter vtkTubeFilter TubeFilter
ConvexHullShrinkWrap vtkConvexHullShrinkWrap ConvexHullShrinkWrap
MeshQuality vtkMeshQuality MeshQuality
ColorCellsWithRGB vtkColorCellsWithRGB ColorCellsWithRGB
Reflection vtkReflection Reflection
RotationAroundLine vtkTransform vtkTransformPolyDataFilter Rotation around a line.
RuledSurfaceFilter vtkRuledSurfaceFilter Create a surface between lines.
ThinPlateSplineTransform vtkThinPlateSplineTransform A nonlinear warp transformation.
TriangleColoredPoints vtkUnsignedCharArray Adding color to each vertex of a triangle
TransformPipeline vtkTransform Combining the transformation, in order to manipulate a group of vtkActor. Shown in the example robot arm motion.
TransformFilter vtkTransformFilter Transforms points, associated normals and vectors
Example Name Classes Demonstrated Description Image
AVI vtkAVIWriter An example to demonstrate how to make an AVI video using vtkAVIWriter
Example Name Classes Demonstrated Description Image
RenderView vtkRenderView An easier way to make objects appear on the screen using RenderView

Texture Mapping

Example Name Classes Demonstrated Description Image
TexturePlane vtkTexture Example of texture mapping.
TexturedSphere vtkTexturedSphereSource Texture a sphere.

Utilities

Example Name Classes Demonstrated Description Image
BrownianPoints vtkBrownianPoints Produce a random vector at each point in a dataset.
DiscretizableColorTransferFunction vtkDiscretizableColorTransferFunction Discretizable Color Transfer Function.
FullScreen vtkRenderWindow Example to Display Actors in a Full Screen Render Window.
FunctionParser vtkFunctionParser String function parser.
GetDataRoot vtkTesting Find the path of VTK_DATA_ROOT.
TimerLog vtkTimerLog Example to Demonstrate Timer support and logging.
ColorLookupTable vtkLookupTable Color Lookup Table.
PassThrough vtkPassThrough Shallow copies the input into the output.
PiecewiseFunction vtkPiecewiseFunction Interpolation using a piecewise function.
ReportRenderWindowCapabilities vtkRenderWindow Report the capabilities of a render window.
Screenshot vtkWindowToImageFilter Use a vtkWindow as input to image pipeline.

Arrays

Example Name Classes Demonstrated Description Image
UnKnownLengthArray vtkFloatArray UnKnown Length Array
KnownLengthArray vtkFloatArray Known Length Array

Video

Example Name Classes Demonstrated Description Image
OggTheora vtkOggTheoraWriter Uses the ogg and theora libraries to write video files.

Visualization

Example Name Classes Demonstrated Description Image
AnimDataCone vtkRenderWindowInteractor Animate a cone by modifying the polydata points - uses Interaction M key (Motion) to toggle animation.
Animation Move a sphere across a scene
BackfaceCulling Turn on/off fast culling of polygons based on orientation of normal with respect to camera.
AnnotatedCubeActor vtkAnnotatedCubeActor A 3D cube with face labels.
BackgroundColor Example program to set the background color of the render window
BackgroundGradient viewport having gradient background using the Background (bottom) and Background2 (top) colors.
BlobbyLogo vtkImplicitModeller Blobby logo from VTK textbook.
Camera vtkCamera A virtual camera for 3D rendering.
CameraActor vtkCameraActor A frustum to represent a camera.
ColorAnActor vtkActor vtkCanvas Switch style interaction adds C and A key actions for selecting Camera or Actor interaction, and T and J key actions for Trackball or Joystick interaction mode. Adds charEvent observer callback to restore the missing E and Q events to quit.
CornerAnnotation vtkCornerAnnotation Write text in the corners of a window.
ColorActorEdges vtkActor Color the edges of an Actor.
ComplexV vtkHedgeHog ComplexV from the VTK Textbook.
CubeAxesActor vtkCubeAxesActor Display three orthogonal axes with labels.
CubeAxesActor2D vtkCubeAxesActor2D This example uses the vtkCubeAxesActor2D to show your scene with axes to indicate the spatial extent of your data.
Cursor2D vtkCursor2D Generates a 2D Cursor Representation.
Cursor3D vtkCursor3D Generates a 3D Cursor Representation
CursorShape Change the shape of the cursor.
Cutter vtkCutter How to use vtkCutter by cutting through a cube.
DrawText vtkTextActor vtkTextProperty Display Text.
DisplayCoordinateAxes vtkOrientationMarkerWidget Display coordinate axes.
DistanceToCamera vtkDistanceToCamera Calculate distance from points to the camera.
Follower vtkFollower Draw text that stays right side up.
SpikeFran vtkGlyph3D Glyphs indicate surface normals on model of human face. Glyph positions are randomly selected.
ImageOrientation vtkInteractorStyleImage Orientation of the view of an image.
Legend vtkLegendBoxActor Draw symbols with text.
LegendScaleActor vtkLegendScaleActor Display the scale of a scene.
LoopShrink vtkShrinkFilter A network with a loop.
LineWidth vtkActor vtkProperty Change the width/thickness of lines in an actor.
MoveActor vtkInteractorStyleTrackballActor Moving an Actor.
MoveCamera vtkInteractorStyleTrackballCamera Moving the Camera.
MultipleActors vtkActor Multiple Actors.
MultipleViewports vtkRenderer Multiple Viewports.
Opacity vtkActor Transparency, transparent.
OrientedGlyphs vtkGlyph3D Copies oriented and scaled glyph geometry to every input point
VectorFieldExample vtkXMLUnstructuredGridReader, vtkThresholdPoints, vtkGlyph3D A vector field visualisation.
NoShading vtkActor
ProteinRibbons vtkProteinRibbonFilter Display pdb ribbons.
RandomProbe vtkProbeFilter Demonstrates how to probe a dataset with random points and select points inside the data set.
ScalarBarActor vtkScalarBarActor Display a color bar.
ScalarBarActorColorSeries vtkScalarBarActor vtkColorSeries Display a color bar with a color series lookup table.
ScalarVisibility vtkDataSetMapper Switch between coloring the actor and coloring the data.
SideBySideViewports vtkRenderer Side by side viewports.
VisualizeImageData vtkDataSetMapper vtkImageData Visualize the points of an ImageData.
VisualizeVTP vtkXMLPolyDataReader vtkPolyDataMapper Visualize a VTP File.
WindowSize vtkRenderWindow Change the size of a window.
WireframeSphere vtkSphere A Wireframe Sphere Visualization.

Volume Rendering

Example Name Classes Demonstrated Description Image
SimpleRayCast vtkFixedPointVolumeRayCastMapper Volume rendering of a high potential iron protein.

Graphs

Example Name Classes Demonstrated Description Image
SelectGraphVertices vtkAnnotationLink Select Edges and vertices in a graph

SimpleOperations

Example Name Classes Demonstrated Description Image
DistanceBetweenPoints vtkMath Example Program to find squared distance and the Euclidean distance between two 3D points.
PerspectiveTransform vtkPerspectiveTransform It is used to describe the full range of homogeneous transformations. It was designed in particular to describe a camera-view of a scene
ProjectPointPlane vtkPlane Performs various plane computations.
RandomSequence vtkMinimalStandardRandomSequence Park and Miller Sequence of pseudo random numbers.

Swing Integration

Example Name Classes Demonstrated Description Image
JFrameRender vtkRenderWindowPanel Render a scene in a JFrame using a vtkRenderWindowPanel
SwingHandleMouseEvent vtkRenderWindowPanel Display in a JLabel the point the mouse is hovering over using a mouse listener

Widgets

Example Name Classes Demonstrated Description Image
AngleWidget vtkAngleWidget AngleWidget Demonstration
AngleWidget2D vtkAngleWidget2D AngleWidget2D Demonstration
BalloonWidget vtkBalloonWidget The balloon text describes each object when you hover it.
CaptionWidget vtkCaptionWidget Widget for placing a caption (text plus leader)
DistanceWidget vtkDistanceWidget Measures the distance between two points.
ImagePlaneWidget vtkImagePlaneWidget 3D widget for reslicing image data.
ImageTracerWidgetNonPlanar vtkImageTracerWidget 3D widget for tracing on planar props.
LogoWidget vtkLogoWidget 2D widget for placing and manipulating a logo
OrientationMarkerWidget vtkOrientationMarkerWidget Display a polydata as an orientation icon.
PlaneWidget vtkPlaneWidget A finite (bounded) plane that can be interactively placed in a scene.
SeedWidget vtkSeedWidget Places multiple seed points, where a user moves the cursor to and clicks it.
SplineWidget vtkSplineWidget SplineWidget Demonstration
TextWidget vtkTextWidget Widget for placing text on overlay plane.