Sunday, April 22, 2007

Controlling Threads by Example

Recently I saw this article where you can understand the importance of threads in the applications GUI.

ONJava.com -- Controlling Threads by Example

Monday, April 16, 2007

Context Handling

I want to point to this link GL Context Handling because I have a really headache sharing context among canvases.

Here is the raw explanation:

Assuming there is no sharing of display lists between multiple contexts in your application, when your GLEventListener.init() method is called, you need to re-create them. That is the callback sent when a new OpenGL context is created. Depending on how the JDK implements full-screen support you may or may not have to reinitialize these objects. Fundamentally you should just structure your application to watch for calls to init() and perform your display list initialization there.

Note that if you have sharing of display lists in place then the rules change. OpenGL specifies a reference counting mechanism for these server-side objects. If you have a second persistent context sharing with the first, then the when the first is destroyed and re-created the lists will still be alive since the second one kept them alive.

As it happens the GL object is also supposed to be discarded when init() is called. Internally to the library a new one is created for the GLContext each time it is re-initialized. You can either pass the GL object down your call chain or call GLU.getCurrentGL() each time you need access to it. The GLContext object is persistent and is a container for the real OpenGL context which may or may not be created at the current time, depending on whether the window is visible.

Wednesday, April 11, 2007

Sorting and paging - Interaction between EJB3 and JSF

Remember my previous post (Looking for EJB3 and JSF integration with Sun webui-jsf) about interacting with the business layer (EJB3) from JSF (with NetBeans VisualWebPack).

Ok, here is a set of posts that shows the steps for a possible solution:
Sorting and Paging with EJB Alternatives
Paging and Sorting in ejb3 Analysis
Sorting and paging with EJB3.
Basically you need to create a web module class that implements the DataProvider interface and this class call the beans of your EJB3 module.

Be happy.

Monday, April 09, 2007

Ubuntu Edgy, ATI driver and Java2D rendering pipeline, the new headache

I think the title is pretty expressive. Finally, I updated my system from Dapper to Edgy. After that, I updated my ATI drivers to the last version following the method 2 of:

How to install Graphics Driver (ATI)
and
Method 2: Install the 8.35.5 Driver Manually

Once finallized all seems ok.


> fglrxinfo
display: :0.0 screen: 0
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: ATI MOBILITY RADEON 9600/9700 Series
OpenGL version string: 2.0.6400 (8.35.5)


The problems comes with Java. To not duplicate my job (and spend more time) I put here a link to the post at JavaGaming.org (http://www.javagaming.org/forums/index.php?topic=16421.0) and also a copy of the test:

I spend the last day looking for some answer but I only found a similar problem in another post (http://www.mail-archive.com/java2d-interest@capra.eng.sun.com/msg03962.html).

Recently I updated my system from Ubuntu Dapper to Edgy and from ATI 8.26.x driver version to 8.35.5.

> fglrxinfo
display: :0.0 screen: 0
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: ATI MOBILITY RADEON 9600/9700 Series
OpenGL version string: 2.0.6400 (8.35.5)

Also I have JDK6 and the last release of JOGL (jogl-1.1.0-pre-20070404-linux-i586).
The fgl_glxgears program runs ok

Until now, using JDK6, the old 8.26.x drivers for ATI and JOGL 1.0.0 all was ok in my little application. Now I use JDK6, ATI 8.35.5 and JOGL 1.1.0 (last night build).

I have two problems:

First)
In some part of my code I try to create a PBuffer, first checking with "canCreateGLPbuffer" and then using "GLPbuffer pbuffer = GLDrawableFactory.getFactory().createGLPbuffer(capabilities, null, 1,1, null);"

Until now it works fine but now I recive this:

javax.media.opengl.GLException: pbuffer creation error: glXCreatePbuffer() failed
at com.sun.opengl.impl.x11.X11PbufferGLDrawable.createPbuffer(X11PbufferGLDrawable.java:162)
at com.sun.opengl.impl.x11.X11PbufferGLDrawable.(X11PbufferGLDrawable.java:73)
at com.sun.opengl.impl.x11.X11GLDrawableFactory$3.run(X11GLDrawableFactory.java:320)
at com.sun.opengl.impl.x11.X11GLDrawableFactory.maybeDoSingleThreadedWorkaround(X11GLDrawableFactory.java:670)
at com.sun.opengl.impl.x11.X11GLDrawableFactory.createGLPbuffer(X11GLDrawableFactory.java:327)


Second)
Also (and this I didn't test it in the previous configuration) when I try to execute any JOGL app enabling the opengl pipeline I receive another error.
When I execute demo.gears I get:

> java Gears
INIT GL IS: com.sun.opengl.impl.GLImpl
Chosen GLCapabilities: GLCapabilities [DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 0, Red: 8, Green: 8, Blue: 8, Alpha: 8, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: false ]
GL_VENDOR: ATI Technologies Inc.
GL_RENDERER: ATI MOBILITY RADEON 9600/9700 Series
GL_VERSION: 2.0.6400 (8.35.5)


That's ok, my vendor is ATI, but when I execute demo.jgears I get:

> java JGears
java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(ImageIO.java:1322)
at JGears.(JGears.java:42)
at JGears.main(JGears.java:109)
INIT GL IS: com.sun.opengl.impl.GLImpl
Chosen GLCapabilities: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 0, Red: 8, Green: 8, Blue: 8, Alpha: 8, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: false ]
GL_VENDOR: Mesa project: www.mesa3d.org
GL_RENDERER: Mesa GLX Indirect
GL_VERSION: 1.2 (1.5 Mesa 6.5.1)


It runs slowly but runs.
What is the problem here?? My vendor is not Mesa.

And finally it I execute with:

> java -Dsun.java2d.opengl=true JGears

or

> java -Dsun.java2d.opengl=true -Dsun.java2d.opengl.fbobject=false JGears


the result is:

exception in QueueFlusher:
javax.media.opengl.GLException: context creation error: couldn't find a suitable frame buffer configuration
at com.sun.opengl.impl.x11.X11ExternalGLDrawable$Context.create(X11ExternalGLDrawable.java:180)
at com.sun.opengl.impl.x11.X11ExternalGLDrawable$Context.makeCurrentImpl(X11ExternalGLDrawable.java:123)
at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:134)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
at javax.media.opengl.GLJPanel$2.run(GLJPanel.java:629)
at sun.java2d.opengl.OGLRenderQueue$QueueFlusher.run(OGLRenderQueue.java:203)


Only one more detail. I execute my NetBeans with the options -Dsun.java2d.opengl=true in the netbeans.conf file. Until now it words nice but now the slicers and other components are not well rendered.

If anybody falls here and read this post (and has something about it) please, write a comment.

Tuesday, April 03, 2007

Looking for EJB3 and JSF integration with Sun webui-jsf

Ok, after a good job you good model business and model layer, that is, you have a set of amazing entities (using JPA) and a set of business objects (EJB session beans).
Now you want to make a beautiful presentation tier. You can immolate or make a precise job using servlets, JSP or by your hand JSF pages.

But no, you are pretty lazy and also you are saw some videos using the new NetBeans VisualWebPack and you want to try its visual component and its easy to use.

What?... you can bind components (tables, labels, text fiels, droplist, ...) to tables or SELECTions, but what about my business layer? what can I do with all my previous job?

I was looking for "binding ejb to jsf" and here are some interesting links which points to some blueprints solutions:
JSF + Session Facade + Entity Bean (EJB3)
JSF combined with EJB, how??

but finally I found (not that I want but at least):
Creator/Vsual Web Pack sources are available in Netbeans repository

It seems in NB 5.5 it is not possible bind an EJB3 to a JSF visual component, but it will be possible in NB6.

Visual Web Development in NetBeans
Visual Web Consumer of Enterprise Java Beans from Services Tab

Finally, I want to point to Project Woodstock: ...an Open Source library of JSF components that provide modern presentations, including the use of AJAX. And borrowed from here: Woodstock is a new Java.net open source project that provides an extensive set of JavaServer Faces (JSF) components for web application developers to build enterprise level applications, and can be fully drag-and-drop enabled within NetBeans 5.5 and its Visual Web Pack.

Monday, April 02, 2007

The NimROD Look And Feel

Hi people,
I don't write since a long time, but now there is a great thing to write about it: the NimROD Look And Feel.
Recently I downloaded and configured my NetBeans to work with it. I think it is a beautiful and smooth theme.

If you don't like the default brown theme you can create your own theme with the editor:
java -jar nimrodlf.jar