[vtkusers] InteractionProp in Java

Jim Peterson jimcp at cox.net
Sat Nov 13 13:37:38 EST 2010


Ambar,
The set of vtk classes available in Java are not actually java classes, 
they are interfaces with the C++ vtk classes implemented in the vtk 
shared libraries. The Java terminology is the classes are implemented 
via the Java Native Interface (JNI). As such, you cannot extend vtk 
classes in Java to add functionality as you might in C++. The vtk C++ 
logic is unaware of the Java extensions.
You have at least three choices are:
1. Add your modified C++ class to vtk so that it is included in one of 
the vtk shared libraries and wrapped by the Java interface and available 
to your Java program.
2. Use the mouse move or other interaction callbacks in your java code 
to gain control and interact with your vtk model.
3. Use the relatively undocumented vtkRenderWindowPanel class from  Java 
so that you can use Java UI events to interact with the vtk object.

I am not exactly sure what your eventual goal is other that the 
interaction modifications, but some examples of the java addObserver 
callbacks and Swing panel implementation are available from here: 
http://www.vtk.org/Wiki/VTK/Examples/Java

Hope that helps,
Jim

Ambar C wrote:
> Hi Jim,
>
> Could you be more specific? What would I need to do to be able to grab
> the mouse driven value changes in orientation and position in Java? I
> don't understand how I'd be able to replace the interaction prop's
> functionality. Thanks for the help.
>
> Best,
> Ambar
>
> On Tue, Nov 9, 2010 at 4:04 AM, Jim Peterson <jimcp at cox.net> wrote:
>   
>> Ambar C wrote:
>>     
>>> Hello,
>>>
>>> I'm working on modifying an vtkInteractorStyleTrackballActor to have
>>> my own custom class, and am trying to access it's InteractionProp
>>> member but it doesn't seem to be coming through. The equivalent code
>>> works in C++, but something along the lines of
>>>
>>> public modifiedClass extends vtkInteractorStyleTrackballActor
>>> {
>>>     .....
>>>     this.InteractionProp. //Doesn't recognize the member.
>>>
>>> }
>>>
>>>
>>>       
>> Ambar,
>> I think this is not a valid construct for classes that are used for JNI
>> interfaces. Yes, Java compiles it, but no, there is no runtime inheritance
>> to the c++ classes.  The pure java way to modify interaction behavior is to
>> use the interaction observers. If you want to use your C++ code you would
>> need to add it to the vtk source tree and rebuild both vtk and the java
>> wrappers, The new class can be wrapped and accessible to Java in that way.
>>
>> If you need to address this completely in Java, maybe it would be better to
>> identify your desired modification to the interaction rather than the
>> solution first.
>>
>> Hope that helps,
>> Jim
>>
>>     
>
>   




More information about the vtkusers mailing list