Rich Text (HTML) Display

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Rich Text (HTML) Display

Scott Baxter
Has anyone tried to display HTML inside of Pivot?  If so, what route did you take?  Do Swing components behave properly inside of Pivot containers?
Reply | Threaded
Open this post in threaded view
|

Re: Rich Text (HTML) Display

Greg Brown
Administrator
It is not currently supported. You might take a look at the Flying Saucer library. I have not used it myself, but it seems promising. Note that it is LGPL and therefore not compatible with the Apache License:

https://xhtmlrenderer.dev.java.net/

 
On Feb 23, 2010, at 2:12 PM, Scott Baxter wrote:

> Has anyone tried to display HTML inside of Pivot?  If so, what route did you take?  Do Swing components behave properly inside of Pivot containers?

Reply | Threaded
Open this post in threaded view
|

Re: Rich Text (HTML) Display

Scott Baxter
On Tue, Feb 23, 2010 at 2:19 PM, Greg Brown <[hidden email]> wrote:
It is not currently supported. You might take a look at the Flying Saucer library. I have not used it myself, but it seems promising. Note that it is LGPL and therefore not compatible with the Apache License:

https://xhtmlrenderer.dev.java.net/ 

Looks like it might work.  For simple HTML rendering, why do you recommend this over JTextPane?
Reply | Threaded
Open this post in threaded view
|

Re: Rich Text (HTML) Display

Greg Brown
Administrator
Good question. I neglected to mention in my previous post there is currently no way to embed Swing components in a Pivot app. However, you might be able to wrap a JTextPane in a custom Pivot component and delegate paint() calls to it. Alternatively, there may be some lower-level Swing text rendering APIs you could delegate to and bypass JTextPane altogether.


On Feb 23, 2010, at 3:37 PM, Scott Baxter wrote:

On Tue, Feb 23, 2010 at 2:19 PM, Greg Brown <[hidden email]> wrote:
It is not currently supported. You might take a look at the Flying Saucer library. I have not used it myself, but it seems promising. Note that it is LGPL and therefore not compatible with the Apache License:

https://xhtmlrenderer.dev.java.net/ 

Looks like it might work.  For simple HTML rendering, why do you recommend this over JTextPane?

Reply | Threaded
Open this post in threaded view
|

Re: Rich Text (HTML) Display

Scott Baxter
On Tue, Feb 23, 2010 at 3:46 PM, Greg Brown <[hidden email]> wrote:
Good question. I neglected to mention in my previous post there is currently no way to embed Swing components in a Pivot app. However, you might be able to wrap a JTextPane in a custom Pivot component and delegate paint() calls to it. Alternatively, there may be some lower-level Swing text rendering APIs you could delegate to and bypass JTextPane altogether.

OK, one last (probably obvious) question:  Why might flying saucer work better with Pivot?  I assume that it is not based on Swing?  Does it use SWT or something else that plays well with Pivot?  Again, I apologize for the basic questions, I have almost no Java GUI experience.
Reply | Threaded
Open this post in threaded view
|

Re: Rich Text (HTML) Display

Greg Brown
Administrator
On Tue, Feb 23, 2010 at 3:46 PM, Greg Brown <[hidden email]> wrote:
Good question. I neglected to mention in my previous post there is currently no way to embed Swing components in a Pivot app. However, you might be able to wrap a JTextPane in a custom Pivot component and delegate paint() calls to it. Alternatively, there may be some lower-level Swing text rendering APIs you could delegate to and bypass JTextPane altogether.

OK, one last (probably obvious) question:  Why might flying saucer work better with Pivot?  I assume that it is not based on Swing?  Does it use SWT or something else that plays well with Pivot?  Again, I apologize for the basic questions, I have almost no Java GUI experience.

Like Swing, Pivot uses Java2D for rendering. However, Pivot doesn't doesn't depend on or extend Swing, so it's not especially straightforward to drop a Swing component into a Pivot app. I haven't looked into Flying Saucer in any great detail, but I imagine that it renders directly to Java2D, which would make it a lot easier to embed in a Pivot app. We did something similar with JFreeChart:


We can't include JFreeChart in the Pivot distribution for the same reason we can't have a dependency on Flying Saucer. However, it would be possible to write a bridge library to Flying Saucer similar to what we did for JFreeChart...that is definitely worth considering.

G


Reply | Threaded
Open this post in threaded view
|

Re: Rich Text (HTML) Display

Todd Volkert
FYI, I tried to get Swing components able to drop into Pivot apps back in the day via a SwingAdapter component.  It *almost* worked :)

On Tue, Feb 23, 2010 at 4:18 PM, Greg Brown <[hidden email]> wrote:
On Tue, Feb 23, 2010 at 3:46 PM, Greg Brown <[hidden email]> wrote:
Good question. I neglected to mention in my previous post there is currently no way to embed Swing components in a Pivot app. However, you might be able to wrap a JTextPane in a custom Pivot component and delegate paint() calls to it. Alternatively, there may be some lower-level Swing text rendering APIs you could delegate to and bypass JTextPane altogether.

OK, one last (probably obvious) question:  Why might flying saucer work better with Pivot?  I assume that it is not based on Swing?  Does it use SWT or something else that plays well with Pivot?  Again, I apologize for the basic questions, I have almost no Java GUI experience.

Like Swing, Pivot uses Java2D for rendering. However, Pivot doesn't doesn't depend on or extend Swing, so it's not especially straightforward to drop a Swing component into a Pivot app. I haven't looked into Flying Saucer in any great detail, but I imagine that it renders directly to Java2D, which would make it a lot easier to embed in a Pivot app. We did something similar with JFreeChart:


We can't include JFreeChart in the Pivot distribution for the same reason we can't have a dependency on Flying Saucer. However, it would be possible to write a bridge library to Flying Saucer similar to what we did for JFreeChart...that is definitely worth considering.

G



Reply | Threaded
Open this post in threaded view
|

Re: Rich Text (HTML) Display

Greg Brown
Administrator
I think the "HTML provider" model would work better anyways. Less messy, more functional.  :-)

On Feb 23, 2010, at 4:22 PM, Todd Volkert wrote:

FYI, I tried to get Swing components able to drop into Pivot apps back in the day via a SwingAdapter component.  It *almost* worked :)

On Tue, Feb 23, 2010 at 4:18 PM, Greg Brown <[hidden email]> wrote:
On Tue, Feb 23, 2010 at 3:46 PM, Greg Brown <[hidden email]> wrote:
Good question. I neglected to mention in my previous post there is currently no way to embed Swing components in a Pivot app. However, you might be able to wrap a JTextPane in a custom Pivot component and delegate paint() calls to it. Alternatively, there may be some lower-level Swing text rendering APIs you could delegate to and bypass JTextPane altogether.

OK, one last (probably obvious) question:  Why might flying saucer work better with Pivot?  I assume that it is not based on Swing?  Does it use SWT or something else that plays well with Pivot?  Again, I apologize for the basic questions, I have almost no Java GUI experience.

Like Swing, Pivot uses Java2D for rendering. However, Pivot doesn't doesn't depend on or extend Swing, so it's not especially straightforward to drop a Swing component into a Pivot app. I haven't looked into Flying Saucer in any great detail, but I imagine that it renders directly to Java2D, which would make it a lot easier to embed in a Pivot app. We did something similar with JFreeChart:


We can't include JFreeChart in the Pivot distribution for the same reason we can't have a dependency on Flying Saucer. However, it would be possible to write a bridge library to Flying Saucer similar to what we did for JFreeChart...that is definitely worth considering.

G




Reply | Threaded
Open this post in threaded view
|

Re: Rich Text (HTML) Display

Scott Baxter
In reply to this post by Todd Volkert
Todd,

What were the sticking points with the Swing adapter?  It seems like a Swing adapter would add a lot of extensibility to Pivot that may be needed as it grows.  Specifically, there is a commercial Swing component (Ephox LiveEdit) that I'd like to integrate into the content management type app I'm prototyping now in Pivot.  I'm sure other potential Pivot developers have other Swing components they'd like to integrate as well.  At the moment, I'm afraid once I move to the implementation stage, I might have to switch back to a JavaScript framework, which I'd really like to get away from.

Is your SwingAdapter code available for me (or anyone else) to look at as a starting point?  (Not that I'd put much confidence in my ability to get it to work if you haven't had any success.)

Scott
Reply | Threaded
Open this post in threaded view
|

Re: Rich Text (HTML) Display

Todd Volkert
Hi Scott,

As I recall, there was really only one big sticking point, and that was that some Swing components painted directly to the display, which wreaked havoc with Pivot's own paint() calls.  Basically, it caused paint artifacts since the Pivot components weren't notified that they needed to repaint.  For some Swing components, it worked perfectly, so if you have a specific use case in mind, it may suit your needs.

The last that SwingAdapter saw the light of day was in Pivot 1.0.1, so you can see it in the tags folder:

http://svn.apache.org/repos/asf/pivot/tags/v1.0.1/wtk/src/pivot/wtk/SwingAdapter.java
http://svn.apache.org/repos/asf/pivot/tags/v1.0.1/wtk/src/pivot/wtk/SwingAdapterListener.java

Cheers,
-T

On Tue, Feb 23, 2010 at 4:49 PM, Scott Baxter <[hidden email]> wrote:
Todd,

What were the sticking points with the Swing adapter?  It seems like a Swing adapter would add a lot of extensibility to Pivot that may be needed as it grows.  Specifically, there is a commercial Swing component (Ephox LiveEdit) that I'd like to integrate into the content management type app I'm prototyping now in Pivot.  I'm sure other potential Pivot developers have other Swing components they'd like to integrate as well.  At the moment, I'm afraid once I move to the implementation stage, I might have to switch back to a JavaScript framework, which I'd really like to get away from.

Is your SwingAdapter code available for me (or anyone else) to look at as a starting point?  (Not that I'd put much confidence in my ability to get it to work if you haven't had any success.)

Scott