Eclipse Wiki Weblog

All | General | Java | Eclipse | Groovy | Grails | GWT | Google | MathEclipse | Bliki
20080103 Thursday January 03, 2008

Eval API inspired by Google Chart API

The simplified Eval API lets you dynamically generate calculation forms. To see the Eval API in action, open up a browser window and copy the following URL into it:

Press the Enter or Return key and you should see the following calculator form in your browser:
http://www.groovy-news.org/e/resources/axelclk/eval_page.png

For the MathEclipse wiki I created this wiki page which contains some more examples:

The more complex Google Web Toolkit interface is available here:

The following wiki syntax creates the Eval API URLs inside the wiki. The <eval> tag creates a link to an URL which will generate a dynamic calculator input form on the matheclipse.org/eval.jsp page.

<eval ci="x1:X:i:10|y1:Y:i:2" 
      ca="x!:x1!|Fibonacci[x]:Fibonacci[x1]|Binomial[x,y]:Binomial[x1,y1]">
  Combinatoric Numbers
</eval> 

Until now I don't tested the generated calculation forms on a mobile device (PDA or mobile phone with AJAX capable browser, iPhone, ...). So my questions are:

Your feedback would be appreciated.

Posted by axelclk ( Jan 03 2008, 11:42:16 PM CET ) Permalink Comments [5]

20071215 Saturday December 15, 2007

Java Wikipedia API (bliki engine) 3.0.0 Beta released

I made a new release of the Java Wikipedia API (bliki engine) available.

Download:

Javadoc:

The MathEclipse wiki is now also using the latest API:

Example math rendering with jsMath library:

For usage examples please look at the JUnit tests:

Posted by axelclk ( Dec 15 2007, 07:18:48 PM CET ) Permalink Comments [5]

20071111 Sunday November 11, 2007

STIX Fonts Released for Beta Test

From the project description page:

The mission of the Scientific and Technical Information Exchange (STIX) font creation project is the preparation of a comprehensive set of fonts that serve the scientific and engineering community in the process from manuscript creation through final publication, both in electronic and print formats. Toward this purpose, the STIX fonts will be made available, under royalty-free license, to anyone, including publishers, software developers, scientists, students, and the general public.

Posted by axelclk ( Nov 11 2007, 12:32:39 PM CET ) Permalink Comments [3]

20071107 Wednesday November 07, 2007

GMail warning if Firebug is enabled

Seems that GMail now analyzes special browser configurations.

Today I get this warning message in Firefox:
http://www.groovy-news.org/e/resources/axelclk/FirebugGMailWarning.png

After disabling Firebug for the site https://mail.google.com, the GMail user interface seem to be a bit faster.

Posted by axelclk ( Nov 07 2007, 08:02:04 AM CET ) Permalink Comments [4]

20070901 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.

Printing pages with jsMath Hi-Res Fonts

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":

http://www.groovy-news.org/e/resources/axelclk/jamwiki_dialogbox.png

After this step you can print out the math pages in your browser with the formulas rendered with Hi-Res fonts.

Integration into JAMWiki

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.BlikiParser

Posted by axelclk ( Sep 01 2007, 06:51:14 PM CEST ) Permalink Comments [4]

20070716 Monday July 16, 2007

MathEclipse 0.1.1 alpha released

The MathEclipse plugin is downloadable here:

Contents
  1. Installation
  2. Workbench Basics
    1. MathEclipse Project creation
    2. MathEclipse Perspective
    3. Show the MathEclipse Control view

Installation

Workbench Basics

Before you interact with the MathEclipse interpreter, you need to create a MathEclipse project.

MathEclipse Project creation

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.

http://www.groovy-news.org/e/resources/axelclk/meproject_wizard.png

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.

MathEclipse Perspective

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:

http://www.groovy-news.org/e/resources/axelclk/meperspective.png

Show the MathEclipse Control view

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]

20070622 Friday June 22, 2007

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:
http://www.groovy-news.org/e/resources/axelclk/jmathtex.png

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]

20070617 Sunday June 17, 2007

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]

20070319 Monday March 19, 2007

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:

Posted by axelclk ( Mar 19 2007, 10:58:47 PM CET ) Permalink Comments [22]

20070307 Wednesday March 07, 2007

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).

Usage

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.

Disclaimers bugs and problems

Links

Posted by axelclk ( Mar 07 2007, 10:21:56 PM CET ) Permalink Comments [9]

20070209 Friday February 09, 2007

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.

Posted by axelclk ( Feb 09 2007, 10:32:18 PM CET ) Permalink Comments [8]

20070103 Wednesday January 03, 2007

Groovy 1.0 released

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]

20061217 Sunday December 17, 2006

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]

20061215 Friday December 15, 2006

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
  1. An AJAX calculator example
  2. Creating a new Special:Calc page
  3. Integrating the GWT module
  4. Introductory articles

An AJAX calculator example

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);
 ...

Creating a new Special:Calc page

 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>

Integrating the GWT module

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>

Introductory articles

Posted by axelclk ( Dec 15 2006, 11:01:57 PM CET ) Permalink Comments [8]

Calendar

Links

Search

del.icio.us Tag Cloud

RSS Feeds

Navigation

Referers