Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Math formula display and Java

Started by nerd_boy Feb 15, 2007 at 3:10 PM 1 replies 750+ views
Original Post
nerd_boy
nerd_boy
I've googled this to death, but still haven't found an answer. I need to show fractions and exponents 'properly', like the would in a math book. i.e., n^m needs to be displayed where m is superscripted to n, and fractions need to actually display the numerator on top, not to the left like in 3/4. To cause even more trouble, not only will the formulas be generated on the fly(to a degree), but they will probably not be so simple as 3/4, but more along the lines of ((n+3)^2)/(n*m), etc. So my question is if Java has anything in its API that will actually do this, or if anyone who has dealt with this before, in Java or another language, could offer any pointers on an implementation of doing it. Thanks! [Edited by - nerd_boy on February 15, 2007 4:40:05 PM]
jcseijop
jcseijop
This may come in handy:

http://embedded.eecs.berkeley.edu/Respep/Research/dds/java/jmath/status.html

FatalFun.com - Mobile games and applicationsFatalFun.com - Aplicaciones y juegos para móviles
sphen_lee
sphen_lee
I was trying to do the same thing, but couldn't find anything. I gave up and tried doing it myself using Swing's Graphics classes. I got a simple renderer to render an equation represented by a tree of objects, but never started the parser to generate that tree from an equation.

The trick is to represent the equation in a tree. There are leaf nodes like 'Variable' and 'Number', and branch nodes like 'Fraction' and 'Sequence'. Each leaf node draws itself at the current pen location and scale, whereas the branches move and scale the pen and then draw their children nodes.

Hope that helps.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.