4 * Axis actor created in the Java world
8 public class AxesActor extends vtkAssembly {
10 private vtkRenderer ren;
11 private double axisLength = 0.8;
12 private vtkTextActor xactor, yactor, zactor;
14 public AxesActor(vtkRenderer _ren) {
20 public void createAxes() {
21 vtkAxes axes = new vtkAxes();
22 axes.SetOrigin(0, 0, 0);
23 axes.SetScaleFactor(axisLength);
25 xactor = new vtkTextActor();
26 yactor = new vtkTextActor();
27 zactor = new vtkTextActor();
33 xactor.ScaledTextOn();
34 yactor.ScaledTextOn();
35 zactor.ScaledTextOn();
37 xactor.GetPositionCoordinate().SetCoordinateSystemToWorld();
38 yactor.GetPositionCoordinate().SetCoordinateSystemToWorld();
39 zactor.GetPositionCoordinate().SetCoordinateSystemToWorld();
41 xactor.GetPositionCoordinate().SetValue(axisLength, 0.0, 0.0);
42 yactor.GetPositionCoordinate().SetValue(0.0, axisLength, 0.0);
43 zactor.GetPositionCoordinate().SetValue(0.0, 0.0, axisLength);
45 xactor.GetTextProperty().SetColor(1.0, 1.0, 1.0);
46 xactor.GetTextProperty().ShadowOn();
47 xactor.GetTextProperty().ItalicOn();
48 xactor.GetTextProperty().BoldOff();
50 yactor.GetTextProperty().SetColor(1.0, 1.0, 1.0);
51 yactor.GetTextProperty().ShadowOn();
52 yactor.GetTextProperty().ItalicOn();
53 yactor.GetTextProperty().BoldOff();
55 zactor.GetTextProperty().SetColor(1.0, 1.0, 1.0);
56 zactor.GetTextProperty().ShadowOn();
57 zactor.GetTextProperty().ItalicOn();
58 zactor.GetTextProperty().BoldOff();
60 xactor.SetMaximumLineHeight(0.25);
61 yactor.SetMaximumLineHeight(0.25);
62 zactor.SetMaximumLineHeight(0.25);
64 vtkTubeFilter tube = new vtkTubeFilter();
65 tube.SetInput(axes.GetOutput());
67 tube.SetNumberOfSides(8);
69 vtkPolyDataMapper tubeMapper = new vtkPolyDataMapper();
70 tubeMapper.SetInput(tube.GetOutput());
72 vtkActor tubeActor = new vtkActor();
73 tubeActor.SetMapper(tubeMapper);
74 tubeActor.PickableOff();
77 double coneScale = 0.3;
80 vtkConeSource xcone = new vtkConeSource();
81 xcone.SetResolution(coneRes);
82 vtkPolyDataMapper xconeMapper = new vtkPolyDataMapper();
83 xconeMapper.SetInput(xcone.GetOutput());
84 vtkActor xconeActor = new vtkActor();
85 xconeActor.SetMapper(xconeMapper);
86 xconeActor.GetProperty().SetColor(1, 0, 0);
87 xconeActor.SetScale(coneScale, coneScale, coneScale);
88 xconeActor.SetPosition(axisLength, 0.0, 0.0);
91 vtkConeSource ycone = new vtkConeSource();
92 ycone.SetResolution(coneRes);
93 vtkPolyDataMapper yconeMapper = new vtkPolyDataMapper();
94 yconeMapper.SetInput(ycone.GetOutput());
95 vtkActor yconeActor = new vtkActor();
96 yconeActor.SetMapper(yconeMapper);
97 yconeActor.GetProperty().SetColor(1, 1, 0);
98 yconeActor.RotateZ(90);
99 yconeActor.SetScale(coneScale, coneScale, coneScale);
100 yconeActor.SetPosition(0.0, axisLength, 0.0);
103 vtkConeSource zcone = new vtkConeSource();
104 zcone.SetResolution(coneRes);
105 vtkPolyDataMapper zconeMapper = new vtkPolyDataMapper();
106 zconeMapper.SetInput(zcone.GetOutput());
107 vtkActor zconeActor = new vtkActor();
108 zconeActor.SetMapper(zconeMapper);
109 zconeActor.GetProperty().SetColor(0, 1, 0);
110 zconeActor.RotateY(-90);
111 zconeActor.SetScale(coneScale, coneScale, coneScale);
112 zconeActor.SetPosition(0.0, 0.0, axisLength);
114 ren.AddActor2D(xactor);
115 ren.AddActor2D(yactor);
116 ren.AddActor2D(zactor);
118 this.AddPart(tubeActor);
119 this.AddPart(xconeActor);
120 this.AddPart(yconeActor);
121 this.AddPart(zconeActor);
126 public void setAxesVisibility(boolean ison) {
127 this.SetVisibility(ison ? 1 : 0);
128 xactor.SetVisibility(ison ? 1 : 0);
129 yactor.SetVisibility(ison ? 1 : 0);
130 zactor.SetVisibility(ison ? 1 : 0);