[vtkusers] New wiki Java examples

Sebastien Jourdain sebastien.jourdain at kitware.com
Sun Nov 14 20:32:15 EST 2010


Hi Jim,

I'm just saying that vtkCanvas/vtkPanel are classes that wrap a
renderwindow/renderer into a Java graphical component class which is
easier to use in the Java graphical world.

You can give a look at
http://dev.artenum.com/projects/cassandra/forum/how-to-use-eclipse-and-vtk

And good luck,

Seb

PS: With the new wrapper we might be able to get some better JavaDoc
at some point... And I agree that will be great.

On Sun, Nov 14, 2010 at 8:06 PM, Jim Peterson <jimcp at cox.net> wrote:
> Sebastien,
> So if I understand what you are saying, you see a "different paradigm" for
> VTK-Java programming than that established for C++, Python and TCL. Where
> those three generally have a renderer, a renderwindow and a renderwindow
> interactor, each created by the user application, the Java pardigm expects a
> vtkPanel to replace the renderer and renderwindow, and vtkCanvas which
> extends the vtkPanel to add the renderwindowInteractor.  So if I want to add
> a  renderer or interactor callback, I should subclass vtkCanvas.
> I still find the implementation confusing. vtkCanvas appears to drive the
> generic render window interactor, so we have the java events captured, but
> we are driving them through the interactor so the user java application can
> use the addObserver callbacks to get the events via the JNI. In my other
> career we call that a "'round robinhood's barn" approach.
>
> I also dislike having to read the virtually uncommented source code as the
> only source of documentation. If we had javadoc or something else similar to
> the doxygen class doc for vtk itself, I would feel a lot more comfortable.
>
> I think I like the idea of using a panel of my java application for the 3D
> display. I will see what happens when I make the ExtrudeTest extend
> vtkCanvas.
>
> wish me luck.
> Jim
>
> Sebastien Jourdain wrote:
>>
>> Hi Jim,
>>
>> I am lazy too and I could have done such kind of documentation, but
>> you've done it and that is GREAT !
>>
>> I did learn VTK some time ago with Java and with the IDE completion...
>> So I know how hard it is.
>>
>> Anyway, I could give some hints here that can be useful and that may
>> have a place in a wiki some time...
>>
>>  - If you create a vtkPanel before using any VTK code, you don't need
>> the System.loadLibrary because the vtkPanel embed them...
>> - The vtkPanel provide you a renderer where you can add actors and
>> Reset the camera.
>> - the vtkPanel can be include in any Swing component, although it's a
>> AWT component so you may need to deal with HeavyWeight component for
>> menu and tooltip that might want to go below the 3d view.
>> - If you need to access the interactor for working with widget, you
>> might want to go to vtkCanvas, but you will have to setup yourself the
>> interaction style if you want a trackball mode.
>> - I've added recently some Enum for CellTypes and Helper for library
>> loading. (Sorry I don't remember what I've called them)
>> - The garbage collection management has been improved to be more
>> flexible to allow multi-threaded VTK management. Although VTK is NOT
>> thread safe. (See some other Java class about garbage collection.)
>> - what else... VTK is fun in Java !!!
>>
>> Enjoy,
>>
>> Seb
>> -
>>
>> On Sun, Nov 14, 2010 at 6:19 PM, Jim Peterson <jimcp at cox.net> wrote:
>>
>>>
>>> Sebastien,
>>> Thanks for having a look.
>>> The short answer is "Jim is a lazy good for nothing slug.".... <grin>
>>> The fact is I built my vtk/Java knowledge on the examples I found in the
>>> distribution, and at the time that was the tutorial steps 1 through 5. I
>>> see
>>> there are three others in infovis that might have been illuminating,
>>> however, I cannot get the TreeView example to display anything. Also, as
>>> far
>>> as I can tell, there is no help or documentation for vtkCanvas, vtkPanel,
>>> or
>>> vtkRenderWindowPanel. they consist of undocumented source code, so even
>>> if I
>>> create javadoc, I get no more information than the IDE provides by
>>> listing
>>> the available methods, parameter types and return types, so unless you
>>> think
>>> the
>>>
>>> I started with something that worked and stayed with it, and that was the
>>> very basic tutorial style code. While composing this I found the
>>> SimpleVTK
>>> example. It claims to have JRadioButtons to control the display, but
>>> actually only has one large friendly Exit button. The first time I ran it
>>> I
>>> did not recognize the cone because of the camera position, I now know
>>> enough
>>> to use the R interaction to reset the camera position. I may see if I can
>>> adapt that one to some of my existing projects.
>>>
>>> Feel free to post updates or interpretations of these or any of the other
>>> java examples to use the intended Java interfaces.
>>> thanks,
>>> Jim
>>>
>>> Sebastien Jourdain wrote:
>>>
>>>>
>>>> Thanks Jim for your contribution !
>>>>
>>>> Just a quick question. Why you didn't use the vtkPanel for the
>>>> renderer and render window ?
>>>>
>>>> Anyway, thanks again
>>>>
>>>> Seb
>>>>
>>>> On Sun, Nov 14, 2010 at 4:12 PM, Jim Peterson <jimcp at cox.net> wrote:
>>>>
>>>>
>>>>>
>>>>> Dear list, I have demonstrated several interaction concepts in Java on
>>>>> the
>>>>> Examples Wiki here :
>>>>>
>>>>>
>>>>>
>>>>> http://www.vtk.org/Wiki/VTK/Examples/Java/ImplicitFunctions/ImplicitSphere
>>>>> Illustrates the shere source, and use of the tubefilter to create tubes
>>>>> around likes.
>>>>> http://www.vtk.org/Wiki/VTK/Examples/Java/Interaction/ExtrudeTest
>>>>> Illustrates the linear extrusion filter, the rotational extrusion
>>>>> filter,
>>>>> uses a CharEvent callback on the renderwindow interactor to toggle
>>>>> between
>>>>>  the trackballActor and trackballCamera style interactions. This
>>>>> example
>>>>> also demonstrates the end plane artifacts when the extrusion profile
>>>>> has
>>>>> concave characteristics.
>>>>> Please feel free to give feedback/comment/modify/add to them.
>>>>>
>>>>> Thanks,
>>>>>
>>>>>
>>>
>>>
>>
>>
>
>



More information about the vtkusers mailing list