views:

114

answers:

5

Hi! I am making an e-book reader for the J2ME and I wonder if I could make it render HTML pages. For the moment, I am using some simplified styling of my own.

So, could anyone point me to a good in-depth tutorial or a specification of an open-source HTML engine? Of course, I have some idea about it all, i.e. the main steps involved, the usage of finite-state machines an so forth, but it's not enough.

But why reinvent the wheel, when it's complicated enough? Do you know of any HTML engine written purely in Java, and light enough to be used as a lib in a J2ME project?

P.S. For the J2ME know-hows:

  • Porting from Java SE to J2ME is not necessarily an issue for me
  • I am not yet concerned about the inability (or at least unsuitability) of using vector fonts

Big thanks!


UPDATE

If you could only point me to a detailed guide about layouting HTML code, I'd be more than grateful! I need to layout some very simple HTML, like text with basic styling, images, divs and tables. That's all.

(I know it's not trivial even though I need simple layouting, that's why I am asking.)

+2  A: 

Webkit comes to mind.

Robert Harvey
Thanks. I found something of interest in the [Technical Articles](http://webkit.org/coding/technical-articles.html) Section.
Albus Dumbledore
A: 

I googled and found Cobra

disown
+2  A: 

I think Firefox uses Gecko Layout engine. Could prove helpful. More here

  1. https://developer.mozilla.org/en/docs/Gecko and
  2. https://wiki.mozilla.org/Gecko:Home_Page and
  3. For some videos http://redivide.com/blog/gecko-reflow-awesome-visualization-of-web-page-layout/
MovieYoda
I guess Gecko doesn't really meet the lightweight requirement :)
dark_charlie
Thanks a lot! The videos are amazing! By the way, there is some info [here](http://www.mozilla.org/newlayout/doc/layout-2006-12-14/master.xhtml) as well.
Albus Dumbledore
MovieYoda
@Albus let us know what you decided to use eventually...
MovieYoda
@Srikar, J2ME is an extremely limited platform. Gecko is certainly impossible (at least for me) to use as: 1. it's *not* written in java; 2. j2me (cldc actually) is a (limited) subset of java se; 3. there is at most 300-400KB free space for the html engine codeThe general info about html layouting, however, *is* quite useful.Thanks!
Albus Dumbledore
+2  A: 

Dear me, I seem to be answering my own question.

The only possibilities that I found are:

Unfortunatelly, neither of these seems to be agile enough so that I could implement it for my own puproses, which are:

  • render on any Graphics object
  • support for bitmap fonts
  • split content to pages
  • TeX hyphenation
  • be able to obtain the word (if any) at a given point on the image.

This all I've done, but the trouble is that it is not rendering html, but custom and limited styling.

Albus Dumbledore
You can accept your own answer, by the way. :)
pinkgothic
Yes, but that would seem damn too selfish on my part, wouldn't it?
Albus Dumbledore
Some info here, too:http://en.wikipedia.org/wiki/Comparison_of_layout_engines_(HTML), http://en.wikipedia.org/wiki/Category:Free_layout_engines
Albus Dumbledore
+1  A: 

Another option would be LWUIT
It has an HTML component in last version.(see http://www.nextgenmoco.com/2010/05/css-support-added-to-htmlcomponent.html)
LWUIT is a swing-insipered set of UI components for J2ME, it's open source and had some sort of SUN support, I don't know if oracle will still support it.

Pablo Grisafi
Wow! I know what _LWUIT_ is, but didn't know they put have an HTML component. Thanks a lot!
Albus Dumbledore
Bad news: It isn't flexible enough and LWUIT is **closed-source** so that I can't even *try* bending it to my use. Thanks for the reply though, it was news to me!
Albus Dumbledore
lwuit is open source. check https://lwuit.dev.java.net/source/browse/lwuit/ In what sense is not flexible enough?
Pablo Grisafi
@Pable, it seems you are right! The site's not working at the moment (gives some error), but no matter, the guy from LWUIT's official blog, said they could help! Thanks! :-)
Albus Dumbledore