Saturday September 01, 2007 jsMath - new version 3.4d installed in MathEclipse wiki
JsMath v3.4d has been released. JsMath is a JavaScript program that allows you to incorporate mathematical notation into your HTML web pages. The input language is LaTeX, so many mathematicians already know how to enter equations using jsMath.
The new release is now installed in the MathEclipse wiki, which is based on JAMWiki (JAMWiki is written in Java and understands the Wikipedia markup syntax).
Here are some demo pages, which are copied from Wikipedia:
Although the resulting pages look impressive, there are still some incompatibles between the jsMath and Wikipedia syntax dialects.
For printing out the math formulas, it's necessary to install the "Hi-Res Fonts for Printing" provided by jsMath.
Therefore you have to click on the small jsMath box in the lower right corner of a wiki page and in the appearing dialog box choose "Hi-Res Fonts for Printing":
After this step you can print out the math pages in your browser with the formulas rendered with Hi-Res fonts.
Here is the jsMath related coding which is inserted in JAMWiki's top.jsp page (updated 2008/01/05):
...
<SCRIPT> jsMath = {Controls: {cookie: {scale: 200}}} </SCRIPT>
<SCRIPT src="../static/jsMath/jsMath.js"></SCRIPT>
<SCRIPT>jsMath.Extension.Require("AMSmath");jsMath.Macro('sgn','\\mathop{\\rm sgn}');jsMath.Macro('R','\\mathop{\\bf R}');</SCRIPT>
<style type="text/css">#jsMath_Warning {display: none} </style>
</head>
...
Here is the jsMath related coding which is inserted in JAMWiki's close-document.jsp page:
... ... <SCRIPT> jsMath.Process() </SCRIPT> </body> </html>
Here is the jsMath related coding which is inserted in JAMWiki's printable.jsp page:
...
</head>
<SCRIPT> jsMath = {Controls: {cookie: {scale: 133}}} </SCRIPT>
<SCRIPT src="../static/jsMath/jsMath.js"></SCRIPT>
<SCRIPT>jsMath.Extension.Require("AMSmath");jsMath.Macro('sgn','\\mathop{\\rm sgn}');jsMath.Macro('R','\\mathop{\\bf R}');</SCRIPT>
<style type="text/css">#jsMath_Warning {display: none} </style>
<body style="background:none">
...
...
<SCRIPT> jsMath.Process() </SCRIPT>
</body>
</html>
To render the <math>-tags I've changed the info.bliki parser. Homepage:
You can find the sources in the SVN repository:
To activate the parser I've modified the /WEB-INF/classes/jamwiki.properties file:
parser=org.jamwiki.parser.bliki.BlikiParserPosted by axelclk ( Sep 01 2007, 06:51:14 PM CEST ) Permalink Comments [4]
MathEclipse 0.1.1 alpha released
The MathEclipse plugin is downloadable here:
| Contents |
|---|
-clean option.
Before you interact with the MathEclipse interpreter, you need to create a MathEclipse project.
Select the Eclipse menu File->New->Project. It will bring up the New Project dialog box. Select the wizard MathEclipse Project under the category MathEclipse and click on the Next button.
It will bring up the Project Wizard for MathEclipse.
Type the project name in the Projcet names textbox and click on the Finish button.
On successful completion of above steps, you will see that a project has been created in your workspace. Also, you will notice that the perspective has changed from Java to MathEclipse.
Before we describe the MathEclipse perspective, lets have a look at the project created in the last section. The navigator view on the left shows the project. It consists of a new folder Interpreter and a default interpreter default.mi created under folder Interpreter. If the navigator view's filter does not block resource files starting with a dot ("."), then you will also be able, to see the .project file created for the MathEclipse project.
The central area of the window shows the default.mi interpreter. This is where most of the user interaction happens. Here you will type in commands and look at the response:
The area at the bottom of the MathEclipse perspective shows the standard Eclipse Console and the MathEclipse Control view.
Enter an expression like
2^32
into the upper text area and press one of the buttons
to get a result in the lower text area.
Posted by axelclk ( Jul 16 2007, 11:26:17 AM CEST ) Permalink Comments [1]Java API for MediaWiki query API
I released a start for a Java API to use the MediaWiki query API:
You can find the download here:
The library uses the Jakarta Commons HTTPClient library to simplify the HTTP functionality:
At the moment the API isn't complete, and I'd like to here other opinions about the design and usability of the library.
This is a simple test class:
package info.bliki.api;
import java.util.List;
public class APITest {
public APITest() {
super();
}
public static void testQueryContent001() {
String[] listOfTitleStrings = { "Main Page", "API" };
User user = new User("", "", "http://meta.wikimedia.org/w/api.php");
user.login();
List listOfPages = user.queryContent(listOfTitleStrings);
for (int i = 0; i < listOfPages.size(); i++) {
Page page = (Page) listOfPages.get(i);
// print page information
System.out.println(page.getCurrentContent());
}
}
public static void testQueryLinks001() {
String[] listOfTitleStrings = { "Main Page", "API" };
User user = new User("", "", "http://meta.wikimedia.org/w/api.php");
user.login();
List listOfPages = user.queryLinks(listOfTitleStrings);
for (int i = 0; i < listOfPages.size(); i++) {
Page page = (Page) listOfPages.get(i);
// print page information
System.out.println(page.toString());
for (int j = 0; j < page.sizeOfLinksList(); j++) {
Link link = page.getLink(j);
// print every link in this page
System.out.println(link.toString());
}
}
}
public static void testQueryCategories001() {
String[] listOfTitleStrings = { "Main Page", "API" };
User user = new User("", "", "http://meta.wikimedia.org/w/api.php");
user.login();
List listOfPages = user.queryCategories(listOfTitleStrings);
for (int i = 0; i < listOfPages.size(); i++) {
Page page = (Page) listOfPages.get(i);
// print page information
System.out.println(page.toString());
for (int j = 0; j < page.sizeOfCategoryList(); j++) {
Category cat = page.getCategory(j);
// print every category in this page
System.out.println(cat.toString());
}
}
}
public static void main(String[] args) {
testQueryContent001();
testQueryLinks001();
testQueryCategories001();
}
}
Posted by axelclk
( Jun 22 2007, 06:53:43 PM CEST )
Permalink
Comments [7]
JMathTeX example - render TeX formula to PNG image
Kris Coolsaet, project admin of the JMathTeX SourceForge project, send me this example to create a PNG image from a TeX formula:
package be.ugent.caagt.jmathtex.test;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.JLabel;
import be.ugent.caagt.jmathtex.TeXConstants;
import be.ugent.caagt.jmathtex.TeXFormula;
public class TestPNG {
public static void main(String[] args) {
TeXFormula formula = new TeXFormula("\\int_{t=0}^{2\\pi}\\frac{\\sqrt{t}}{1 + \\mathrm{cos}^2 t}\\nbsp dt");
Icon icon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 25);
BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = image.createGraphics();
icon.paintIcon(new JLabel(), g2, 0, 0); // component can't be null
// fill a file path below
File file = new File("c:\\temp\\jmathtex.png");
try {
ImageIO.write(image, "png", file.getAbsoluteFile());
} catch (IOException ex) {
//
}
}
}
The created PNG image looks like this:
JMathTeX could be useful for integrating <math>...</math> Tag support into the JAMWiki project.
JMathTeX home:
JAMWiki home:
Addendum:
The HotEqn applet seems to be released under GPL now:
Update 2008/01/05:
This math plugin integrates HotEqn into JSPWiki:
In my opinion the completest solution for generating Math formulas on the server would be a LaTeX to MathML converter written in Java. The generated MathML could when be rendered directly by Gecko based browsers or images could be created for non-MathML capable browsers with the JEuclid project:
Posted by axelclk ( Jun 22 2007, 04:24:10 PM CEST ) Permalink Comments [10]MathEclipse - "symbolic mathematics" plugin preview released
I created a preview of the MathEclipse "symbolic mathematics" plugin:
Developers with eclipse knowledge are invited to help improving this plugin.
See also:
Posted by axelclk ( Jun 17 2007, 08:51:39 PM CEST ) Permalink Comments [5]Experiments with the JSR-223 compatible Quercus PHP engine
There's a lot of hype for all sorts of Java scripting engines at the moment. For myself I've made some experiments with groovy/grails. Today I've found the PHP Quercus engine from Caucho.com, which is licensed under GPL and I also tried to use it as a JSR-223 scripting engine. As the goal of the test, I want to generate some text from a PHP file, which prints out some PHP variables ($x, $y) in a PHP double quoted string.
Therefore I opened the downloadable *.war file from the Quercus 3.1 snapshot (alpha) with my ZIP tool and extracted:
in the /lib classpath of a newly created quercus.script.test Eclipse project.
Additionally I added a servlet-api.jar from a tomcat 6.x installation to the project's classpath.
The Quercus standard JSR-223 script engine is implemented in the package com.caucho.quercus.script.
Note: if you're not using JDK 1.6, but only JDK 1.5, you'll also need the javax.scripting.* JSR 223 (see link at the end of the blog entry). I also didn't install necessary additional *.jar libraries for Quercus MailModule and UnicodeModule classes.
The Test.java file below now creates the following output
hello world Hello - World Hasta la vista Baby
Test.java file (updated: it now reflects the comments from baennaeck)
package info.bliki.quercus.script.test;
import java.io.FileReader;
import java.io.StringWriter;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public class Test {
public static void main(String[] args) {
ScriptEngineManager scriptManager = new ScriptEngineManager();
Object php2javaResult = null;
ScriptEngine phpEngine = scriptManager.getEngineByExtension("php");
ScriptContext context = phpEngine.getContext();
try {
context.setWriter(new StringWriter());
php2javaResult = phpEngine.eval("<?php echo \"hello world\"; ?>",
context);
StringWriter writer = (StringWriter) context.getWriter();
// show output from PHP script in console:
System.out.println(writer.toString());
} catch (Exception ex) {
ex.printStackTrace();
}
try {
context.setWriter(new StringWriter());
phpEngine.put("x", "Hello");
phpEngine.put("y", "World");
php2javaResult = phpEngine.eval("<?php echo \"$x - $y\"; ?>", context);
StringWriter writer = (StringWriter) context.getWriter();
System.out.println(writer.toString());
} catch (Exception ex) {
ex.printStackTrace();
}
try {// file test
context.setWriter(new StringWriter());
//redefine variable in ENGINE_SCOPE x,y:
phpEngine.put("x", "Hasta la vista");
phpEngine.put("y", "Baby");
// the following file contains the line: <?php echo "$x $y"; ?>
php2javaResult = phpEngine
.eval(new FileReader(
"C:\\temp\\echo_test.php"), context);
StringWriter writer = (StringWriter) context.getWriter();
System.out.println(writer.toString());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
BTW: the Quercus phpinfo() implementation gives the following output:
<h1>Quercus</h1><pre>PHP Version => 5.2.0 System => Windows XP 5.1 x86 Build Date => 20061220T1222 Configure Command => n/a Server API => CGI Virtual Directory Support => disabled Configuration File (php.ini) Path => WEB-INF/php.ini PHP API => 20031224 PHP Extension => 20041030 Debug Build => no Thread Safety => enabled Registered PHP Streams => php, file, http, https </pre>
Related links:
Eclipse Grails plugin (very early alpha)
I created a Grails plugin for the Eclipse Java IDE.
You can download it here (source code included):
Install the *.jar file in your eclipse/plugins directory and restart Eclipse with the -clean option. Set the GRAILS_HOME classpath variable in your Java->Build Path->Classpath Variables preferences menu.
I simply wrapped the calls to the Grails Ant targets with some Eclipse external tool calls (see the org.eclipse.ui.externaltools plugin for more information).
Do a "right mouse click" on a Grails project node in the Eclipse Package Explorer and choose the menu Grails and the appropriate target you would like to run. The script should show its output in the Eclipse console.
Wikipedia Java API - parser now based on htmlcleaner project's API
I just committed some sources to SVN for my Wikipedia Java API project. In the first version of this API, I've rendered the wiki text directly into a java.lang.StringBuffer. In the new version I'm using the org.htmlcleaner DOM API as a base to parse the text into an internal HTML tree node structure. This HTML tree is then rendered into a HTML string.
In the future it should be easier to convert the internal HTML tree into other formats like plain text, PDF or even TeX.
One promising new project I've found for converting texts into PDF, is Ulrich Fuchs JTypeSet library. Ulrich has used this library as a base for PDF creation in his german Wikipedia clone: Wikiweise
Description of the JTypeSet project from the sourceforge.net summary page:
Type setting engine in Java. Uses an algorithm similar to Tex to layout text and images on a page and create a pdf output, supports multiple columns and images, which can be placed at arbitrary positions, spawm columns etc.
Guillaume Laforge announced the Groovy 1.0 release on his blog:
Groovy 1.0 can be downloaded here:
Posted by axelclk ( Jan 03 2007, 07:48:49 AM CET ) Permalink Comments [4]How to integrate jsMath into JAMWiki
A mini guide for integrating jsMath into JAMWiki.
In the following I assume that your JAMWiki Application-URI is /wiki
Store the jsMath files and fonts in the directory:
wiki/static/jsMath
Modify the file:
wiki/WEB-INF/jsp/top.jsp
...
<script src="../static/jsMath/jsMath.js"></script>
<style type="text/css">#jsMath_Warning {display: none} </style>
</head>
<body>
Modify the file:
wiki/WEB-INF/jsp/close-document.jsp
... <SCRIPT> jsMath.Process() </SCRIPT> </body> </html>
Note: the wiki syntax renderer in JAMWiki has to be enabled so that the math wikitag
<math>sin(x)</math>
will be transformed to the following html:
<DIV CLASS="math">sin(x)</DIV>
All DIV formulas that have the class math are now rendered by jsMath.
See also:
Posted by axelclk ( Dec 17 2006, 02:47:30 PM CET ) Permalink Comments [4]How to integrate a GWT module in a new JAMWiki Special: page
Note: this document is work in progress and not complete at the moment
| Contents |
|---|
My example GWT module is the MathEclipse AJAX calculator called org.matheclipse.gwt.Calc which is separately developed in the GWT hosted mode and should now be included into a new JAMWiki Special:Calc page.
In the main GWT EntryPoint in the method org.matheclipse.gwt.client.Calc#onModuleLoad() we can distinguish between non-hosted mode and hosted mode with the GWT.isScript() method. In the onModuleLoad() method we also create the main calculator GUI panel and insert it into a prepared "slot1" in calc.jsp (see below).
public void onModuleLoad() {
CALC_SERVICE = (CalcServiceAsync) GWT.create(CalcService.class);
ServiceDefTarget target = (ServiceDefTarget) CALC_SERVICE;
if (GWT.isScript()) {
String url = GWT.getModuleBaseURL();
url += "calc";
target.setServiceEntryPoint(url);
} else {
target.setServiceEntryPoint("/calc");
}
...
// Create a panel for the GUI and insert it into a prepared "slot1" in cals.jsp
RootPanel slot1 = RootPanel.get("slot1");
slot1.add(panel);
...
protected ModelAndView handleJAMWikiRequest(HttpServletRequest request, HttpServletResponse response, ModelAndView next, WikiPageInfo pageInfo) throws Exception {
pageInfo.setPageTitle(new WikiMessage("calc.title"));
pageInfo.setAction(WikiPageInfo.ACTION_CALC);
pageInfo.setSpecial(true);
return next;
}
calc.title=AJAX online calculator
...
public static final int ACTION_CALC = 999;
...
public boolean getActionCalc() {
return (this.action == ACTION_CALC);
}
<c:when test="${pageInfo.actionCalc}">
<jsp:include page="calc.jsp" flush="true" />
</c:when>
Note:In the following I assume that your JAMWiki Application-URI is /wiki
In a separated GWT project I compiled all GWT files with the GWTCompiler from Java to JavaScript into the \www\org.matheclipse.gwt.Calc directory. These files must now been copied into a JAMWiki subdirectory.
For a better organization all compiled (static) GWT files in this example go into subdirectory:
/wiki/static
and the main gwt.js is stored in
/wiki/static/gwt.js
/www/org.matheclipse.gwt.Calc
directory into the directory
/wiki/static/org.matheclipse.gwt.Calc
<meta name='gwt:module' content='/wiki/static/org.matheclipse.gwt.Calc=org.matheclipse.gwt.Calc'>
<%@ page errorPage="/WEB-INF/jsp/error.jsp"
contentType="text/html; charset=utf-8"
%>
<%@ include file="page-init.jsp" %>
<-- <GWT CSS styles follow in this section -->
<style type="text/css">
...
</style>
<script language='javascript' src='/wiki/static/gwt.js'></script>
<iframe id='__gwt_historyFrame' style='width:0;height:0;border:0'></iframe>
<div id="loadingWait">Loading...</div>
<table align="left" verticalalign="top">
<tr><td id="slot1"></td></tr>
</table>
...
<servlet>
<servlet-name>calculator</servlet-name>
<servlet-class>org.matheclipse.gwt.server.CalcServiceImpl</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
...
<servlet-mapping>
<servlet-name>calculator</servlet-name>
<url-pattern>/static/org.matheclipse.gwt.Calc/calc</url-pattern>
</servlet-mapping>
Eclipse Wikipedia Editor plugin 2.0.6 released
I released the Eclipse Wikipedia Editor plugin version 2.0.6.
You can download it here:
Usage:
Changes:
*.wp in the package explorer, the browser views the rendered HTML output from the corresponding file in the /wpbin subdirectory.
MathEclipse Parser API 0.0.4 released
The Math Parser API is used in the Math Eclipse Plugin for parsing math expressions. The expression parser is driven by an operator table as described in this Wikipedia article:
Download
The latest API is available as meparser.jar in this source code download:
Usage
This is a wiki page describing the Math Parser API
Related Links
Google MathEclipse news and discussion group:
MathEclipse homepage:
Example
This is a JUnit example for parsing a math string expression into an abstract syntax tree node (ASTNode):
public void testParser1() {
try {
Parser p = new Parser();
ASTNode obj = p.parseExpression("Integrate[Sin[x]^2+3*x^4, x]");
assertEquals(obj.toString(),
"Integrate[Plus[Power[Sin[x], 2], Times[3, Power[x, 4]]], x]");
} catch (Exception e) {
e.printStackTrace();
}
}
Posted by axelclk
( Oct 08 2006, 01:48:45 PM CEST )
Permalink
Comments [3]
Bliki Wikipedia Syntax rendering engine 2.0.5 released
The Bliki engine API supports the rendering of a Wikipedia article into HTML.
Download:
Description of the API usage:
The download contains the following parts
info.bliki.wiki/bliki.jar is a precompiled binary for the API
BlikiParser.java and JAMWikiModel.java parser files for JAMWiki.org (see the demo page at: http://www.bliki.info.jamwiki )
A simple wiki to html fragment looks like this:
public static void main(String[] args)
{
WikiModel wikiModel =
new WikiModel("${image}", "${title}");
String htmlStr = wikiModel.render(" [[Hello World]] wiki tag");
System.out.print(htmlStr);
}
Posted by axelclk
( Oct 08 2006, 12:18:03 PM CEST )
Permalink
Comments [5]
Eclipse Wikipedia Editor plugin version 2.0.5 released
I released version 2.0.5 of the Eclipse Wikipedia Editor plugin.
You can download the plugin here:
You can view the installation description here:
The Wikipedia Plugin contains a Wikipedia Syntax Editor with the following features: