Skip to content

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!

VTK Classes Summary

Hello World

Example Name Description Image
A hello world example Cylinder example from the VTK Textbook and source code. A hello world example.

Input and Output

Graph Formats

3D File Formats

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

Standard Formats

Example Name Description Image
DEMReader Read DEM (elevation map) files
ParticleReader 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 Read Chemistry Markup Language files.
ReadOBJ Read an OBJ (.obj) file.
ReadPLOT3D Read PLOT3D data files.
ReadPLY Read PLY (.ply) files
ReadSLC Read an SLC volume file.
ReadSTL Read stereo lithography STL (.stl) files.
SimplePointsReader Read a simple "xyz" file of points.
Example Name Description Image
ThreeDSImporter Import a 3D Studio scene that includes multiple actors.
VRMLImporter Import a VRML 2.0 (WRL) file.
Example Name Description Image
SimplePointsWriter Write a simple ".xyz" file
WritePLY Write PLY (.ply) files.
WriteSTL Write stereo lithography STL (.stl) files.

VTK Formats

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

Image Format


Example Name Description Image
JPEGReader Read a JPEG image.
ReadBMP Read Windows BMP files.
ReadDICOM Read DICOM images.
ReadPNM Read PNM (.pnm) files.
ReadTIFF Read TIFF (.tif) files.


Example Name Description Image
JPEGWriter Write a JPEG file.
PNGReader Read a PNG image.
WritePNM Write a PNM (.pnm) file.
WriteTIFF Write a TIFF (.tif) file.


Example Name Description Image
MultiLineText MultiLineText
TextOrigin TextOrigin


Example Name Description Image
CompositePolyDataMapper CompositePolyDataMapper


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


Example Name Description Image
Arrow Arrow Visualization
Circle Circle Visualization
Cone Cone Visualization
ConvexPointSet ConvexPointSet Visualization
Disk Disk Visualization
EllipticalCylinder EllipticalCylinder
Frustum Frustum Visualization
Line Line Visualization
LongLine A visualization of a long line
OrientedArrow Oriented Arrow visualization.
OrientedCylinder Oriented Cylinder visualization
ParametricObjects ParametricObjects Visualization
PlanesIntersection PlanesIntersection
Polygon Polygon Visualization
Pyramid Pyramid Visualization
Quad Quad Visualization
RegularPolygonSource RegularPolygon Visualization
ShrinkCube Applying shrink filter to an object.
TextActor TextActor Demonstration
Triangle Triangle Visualization
TriangleStrip Triangle Strip Visualization
Vertex Vertex Visualization


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

Geographic Visualization (Geovis)

Example Name Description Image
CompassWidget CompassWidget Visualization
EarthSource Earth Source Visualization
GeoAssignCoordinates Convert latitude and longitude coordinates to world coordinates.


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

Working with Images

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

Image Processing

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

Implicit Functions and Iso-surfaces

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

User Interaction

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

Working with Meshes

Example Name Description Image
AddCell Add a cell to an existing mesh.
BoundaryEdges Find the edges that are used by only one face.
DelaunayMesh 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 Description Image
Bottle Sweeps polygonal data creating "skirt" from free edges and lines, and lines from vertices
CellCenters Compute points at the center of every cell.
CenterOfMass Compute the center of mass of the points.
ProjectSphere Unroll a sphere or spherical-like model.
Spring 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.


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


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


Example Name Description Image
BlankPoint Blank a point of a vtkStructuredGrid.
StructuredGridOutline 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.


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

Point Cloud Operations

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

Data Structures


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


Example Name Description Image
BuildOctree Create an octree.


Example Name Description Image
AmbientSpheres Demonstrates the effect of ambient lighting on spheres.
ColoredSphere A simple sphere.
Cone6 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 Demonstrates the effect of specular lighting on spheres.


Example Name Description Image
LightActor vtkLightActor Demonstration
SpotLight vtkSpotLight Demonstration

Math Operations

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


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


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

Texture Mapping

Example Name Description Image
TexturePlane Example of texture mapping.
TexturedSphere Texture a sphere.


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


Example Name Description Image
KnownLengthArray Known Length Array
UnknownLengthArray UnKnown Length Array


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


Example Name Description Image
AnimDataCone Animate a cone by modifying the polydata points - uses Interaction M key (Motion) to toggle animation.
Animation Move a sphere across a scene
AnnotatedCubeActor A 3D cube with face labels.
BackfaceCulling Turn on/off fast culling of polygons based on orientation of normal with respect to camera.
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 Blobby logo from VTK textbook.
Camera A virtual camera for 3D rendering.
CameraActor A frustum to represent a camera.
ColorActorEdges Color the edges of an Actor.
ColorAnActor 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.
ComplexV ComplexV from the VTK Textbook.
CornerAnnotation Write text in the corners of a window.
CubeAxesActor Display three orthogonal axes with labels.
CubeAxesActor2D This example uses the vtkCubeAxesActor2D to show your scene with axes to indicate the spatial extent of your data.
Cursor2D Generates a 2D Cursor Representation.
Cursor3D Generates a 3D Cursor Representation
CursorShape Change the shape of the cursor.
Cutter How to use vtkCutter by cutting through a cube.
DisplayCoordinateAxes Display coordinate axes.
DistanceToCamera Calculate distance from points to the camera.
DrawText Display Text.
Follower Draw text that stays right side up.
ImageOrientation Orientation of the view of an image.
Legend Draw symbols with text.
LegendScaleActor Display the scale of a scene.
LineWidth Change the width/thickness of lines in an actor.
LoopShrink A network with a loop.
MoveActor Moving an Actor.
MoveCamera Moving the Camera.
MultipleActors Multiple Actors.
MultipleViewports Multiple Viewports.
Opacity Transparency, transparent.
OrientedGlyphs Copies oriented and scaled glyph geometry to every input point
ProteinRibbons Display pdb ribbons.
RandomProbe Demonstrates how to probe a dataset with random points and select points inside the data set.
ScalarBarActor Display a color bar.
ScalarBarActorColorSeries Display a color bar with a color series lookup table.
ScalarVisibility Switch between coloring the actor and coloring the data.
SideBySideViewports Side by side viewports.
SpikeFran Glyphs indicate surface normals on model of human face. Glyph positions are randomly selected.
VectorFieldExample A vector field visualisation.
VisualizeImageData Visualize the points of an ImageData.
VisualizeVTP Visualize a VTP File.
WindowSize Change the size of a window.
WireframeSphere A Wireframe Sphere Visualization.

Volume Rendering

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


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


Example Name Description Image
DistanceBetweenPoints Example Program to find squared distance and the Euclidean distance between two 3D points.
PerspectiveTransform 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 Performs various plane computations.
RandomSequence Park and Miller Sequence of pseudo random numbers.

Swing Integration

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


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