Tuesday December 29, 2009 MathEclipse 0.0.8 is a Java computer algebra system with integrated JSR 223 math scripting engine.
You can download the new console application version 0.0.8 here:
Release Notes:
Getting started:
Project Homepage:
Discussion Forum:
Posted by axelclk ( Dec 29 2009, 10:38:52 PM CET ) Permalink Comments [1]MathEclipse core moved to Google code project page
In a first step the MathEclipse core moved to this Google Code project page:
Posted by axelclk ( Sep 02 2009, 10:14:14 PM CEST ) Permalink Comments [2]Java Wikipedia API 3.0.11 released
The main purpose of the Java Wikipedia API (Bliki engine) is the rendering of the Wikipedia (aka Mediawiki) syntax into HTML:
There is a Bliki Engine Forum for help and discussion of the Wikipedia Engine API:
Download:
Changes in this release
Started support for Cream in MathEclipse
Thanks to Filippo Carone it's now possible to add new functions to MathEclipse through the Eclipse plugin mechanism.
To test the plugin mechanism, I added a simple example plugin to CVS which uses the CREAM library:
A function call like:
Cream[{x>=0,y>=0,x+y==7,2*x+4*y==20},{x,y}] should give:
{x->4,y->3}
An external Eclipse plugin must add a dependency on org.matheclipse.eval and
then add this extension point in the plugin.xml
<extension
point="org.matheclipse.eval.namespace">
<stringNamespace
package="org.matheclipse.cream.functions"></stringNamespace>
</extension>
where the Java package (org.matheclipse.cream.functions) is the place where new MathEclipse functions must be implemented:
package org.matheclipse.cream.functions;
...
public class Cream implements IFunctionEvaluator {
public Cream() {
}
public IExpr evaluate(final IAST function) {
...
}
public IExpr numericEval(final IAST function) {
// called in numeric mode
return evaluate(function);
}
public void setUp(final ISymbol symbol) {
}
}
It' also important to export the package in the /org.matheclipse.cream/META-INF/MANIFEST.MF:
... Export-Package: org.matheclipse.cream.functions
See the CVS here:
Posted by axelclk ( Oct 23 2008, 08:51:27 PM CEST ) Permalink Comments [1]Bliki in a Jar is a small Wiki written in Java with focus on supporting the Wikipedia syntax. It is intended to run on an USB stick as a replacement for a paper notebook as a Personal Information Manager (PIM).
You can download the latest release here:
Unzip the BlikiInAJar ZIP file onto you harddisk or USB stick. Run one of the files
The webpage http://localhost:3003/wiki will be opened in your default webbrowser and you are ready to create and edit your own personal wiki pages. All wiki pages (with the exception of downloaded Wikipedia template pages, which are stored in a Derby database) are stored as *.wiki files in the directory:
bliki.in.a.jar/public/docs/wiki
In the start.cmd (Windows) or start.sh (Linux) files you can set the default language for the wiki, by changing the -Duser.language=XX command line option.
For example for german namespaces it should be changed to
-Duser.language=de
At the moment Bliki in a Jar supports the following language (locales) for Wikipedia namespaces:
See: http://matheclipse.org/en/Bliki_in_a_JAR
Posted by axelclk ( Sep 23 2008, 11:43:26 PM CEST ) Permalink Comments [1]Extended Euclidean algorithm in Java
Jeremy Watts joined the MathEclipse developer team and provided the following implementation for the Extended Euclidean algorithm in Java.
The example program calculates the ExtendedGCD[12,60,256,282] and prints the result [2, [1470, 0, -70, 1]] to the console.
This means that the greatest common divisor 2 could be calculated as 1470*12 + 0*60 + (-70)*256 + 1*282.
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
public class ExtendedGCD {
public ExtendedGCD() {
}
public static void main(String[] args) {
// calculate ExtendedGCD(12,60,256,282)
List<BigInteger> argumentsList = new ArrayList<BigInteger>();
argumentsList.add(BigInteger.valueOf(12));
argumentsList.add(BigInteger.valueOf(60));
argumentsList.add(BigInteger.valueOf(256));
argumentsList.add(BigInteger.valueOf(282));
try {
Object[] results;
BigInteger gcd = argumentsList.get(0);
BigInteger factor = BigInteger.ONE;
BigInteger[] subBezouts = new BigInteger[argumentsList.size()];
results = extendedGCD(argumentsList.get(1), gcd);
gcd = (BigInteger) results[0];
subBezouts[0] = ((BigInteger[]) results[1])[0];
subBezouts[1] = ((BigInteger[]) results[1])[1];
for (int i = 2; i < argumentsList.size(); i++) {
results = extendedGCD(argumentsList.get(i), gcd);
gcd = (BigInteger) results[0];
factor = ((BigInteger[]) results[1])[0];
for (int j = 0; j < i; j++) {
subBezouts[j] = subBezouts[j].multiply(factor);
}
subBezouts[i] = ((BigInteger[]) results[1])[1];
}
List list = new ArrayList();
list.add(gcd);
List<BigInteger> subList = new ArrayList<BigInteger>();
for (int i = 0; i < subBezouts.length; i++) {
subList.add(subBezouts[i]);
}
list.add(subList);
// prints: [2, [1470, 0, -70, 1]]
System.out.println(list);
} catch (ArithmeticException ae) {
ae.printStackTrace();
}
}
/**
* Returns the gcd of two positive numbers plus the Bezout relation
*/
public static Object[] extendedGCD(BigInteger numberOne, BigInteger numberTwo) {
Object[] results = new Object[2];
BigInteger[] divisionResult = new BigInteger[2];
BigInteger dividend;
BigInteger divisor;
BigInteger quotient;
BigInteger remainder;
BigInteger xValue;
BigInteger yValue;
BigInteger tempValue;
BigInteger lastxValue;
BigInteger lastyValue;
BigInteger gcd = BigInteger.ONE;
BigInteger mValue = BigInteger.ONE;
BigInteger nValue = BigInteger.ONE;
boolean exchange;
remainder = BigInteger.ONE;
xValue = BigInteger.ZERO;
lastxValue = BigInteger.ONE;
yValue = BigInteger.ONE;
lastyValue = BigInteger.ZERO;
if ((!((numberOne.compareTo(BigInteger.ZERO) == 0) || (numberTwo.compareTo(BigInteger.ZERO) == 0)))
&& (((numberOne.compareTo(BigInteger.ZERO) == 1) && (numberTwo.compareTo(BigInteger.ZERO) == 1)))) {
if (numberOne.compareTo(numberTwo) == 1) {
exchange = false;
dividend = numberOne;
divisor = numberTwo;
} else {
exchange = true;
dividend = numberTwo;
divisor = numberOne;
}
while (remainder.compareTo(BigInteger.ZERO) != 0) {
divisionResult = dividend.divideAndRemainder(divisor);
quotient = divisionResult[0];
remainder = divisionResult[1];
dividend = divisor;
divisor = remainder;
tempValue = xValue;
xValue = lastxValue.subtract(quotient.multiply(xValue));
lastxValue = tempValue;
tempValue = yValue;
yValue = lastyValue.subtract(quotient.multiply(yValue));
lastyValue = tempValue;
}
gcd = dividend;
if (exchange == false) {
mValue = lastxValue;
nValue = lastyValue;
} else {
mValue = lastyValue;
nValue = lastxValue;
}
} else {
throw new ArithmeticException("ExtendedGCD has wrong arguments");
}
results[0] = gcd;
BigInteger[] values = new BigInteger[2];
values[0] = nValue;
values[1] = mValue;
results[1] = values;
return results;
}
}
The algorithm is integrated in MathEclipse as class:
Posted by axelclk ( Sep 11 2008, 09:38:29 PM CEST ) Permalink Comments [0]Using the GWT Requestbuilder and the JSON-LIB server side library
The process for working with the GWT Requestbuilder could be divided into a server part for creating the JSON data and a client part to use the JSON data. In this example a GWT Listbox show some "category" entries.
| Contents |
|---|
I installed these 3 JARs in my GWT project:
/tomcat/webapps/ROOT/WEB-INF/lib/json-lib-2.2.2-jdk15.jar /tomcat/webapps/ROOT/WEB-INF/lib/commons-lang-2.3.jar /tomcat/webapps/ROOT/WEB-INF/lib/ezmorph-1.0.4.jar
And added them to the .classpath file:
<?xml version="1.0" encoding="UTF-8"?> <classpath> ... <classpathentry kind="lib" path="tomcat/webapps/ROOT/WEB-INF/lib/json-lib-2.2.2-jdk15.jar"/> <classpathentry kind="lib" path="tomcat/webapps/ROOT/WEB-INF/lib/commons-lang-2.3.jar"/> <classpathentry kind="lib" path="tomcat/webapps/ROOT/WEB-INF/lib/ezmorph-1.0.4.jar"/> <classpathentry kind="output" path="bin"/> </classpath>
and also in the gwt-project.launch file.
Create the JSON data on the server side with the help of the Json-lib:
package org.matheclipse.ajax.server;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
public class JSONCategories extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doPost(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
JSONArray jsonArray = createCategories();
PrintWriter out = resp.getWriter();
out.println(jsonArray);
}
public static JSONArray createCategories() {
List<String> list = new ArrayList<String>();
list.add("Algebra");
list.add("Calculus");
list.add("Geometry");
list.add("Finance");
return JSONArray.fromObject(list);
}
}
Because the "/categories" url-pattern should be used to get the JSON data from the server, I added the following additional servlet configuration in Tomcat's tomcat/webapps/ROOT/WEB-INF/web.xml configuration file:
<?xml version="1.0" encoding="UTF-8"?> <web-app> <servlet> <servlet-name>json</servlet-name> <servlet-class>org.matheclipse.ajax.server.JSONCategories</servlet-class> </servlet> <servlet-mapping> <servlet-name>json</servlet-name> <url-pattern>/categories</url-pattern> </servlet-mapping> ... ... </web-app>
Include the JSON module in your module definition like this:
<module> <-- <Inherit the core Web Toolkit stuff. --> <inherits name="com.google.gwt.core.Core"/> <inherits name='com.google.gwt.user.User'/> <inherits name='com.google.gwt.json.JSON'/> ... ... </module>
Extend Listbox like this to show the categories which you request from the JSONCategories servlet.
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.ListBox;
public class CategoriesListbox extends ListBox {
public CategoriesListbox(boolean isMultipleSelect) {
super(isMultipleSelect);
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "/categories");
try {
builder.setCallback(new RequestCallback() {
public void onError(Request request, Throwable exception) {
Window.alert(request.toString());
}
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() == 200) {
JSONArray items = JSONParser.parse(response.getText()).isArray();
for (int i = 0; i < items.size(); i++) {
addItem(((JSONString) items.get(i)).stringValue());
}
setVisibleItemCount(items.size());
} else {
Window.alert(response.getStatusText());
}
}
});
builder.send();
} catch (Exception e) {
Window.alert(e.getMessage());
}
}
}
Posted by axelclk
( Aug 07 2008, 12:04:59 AM CEST )
Permalink
Comments [3]
For testing my MathEclipse Eval API I've found the http://www.testiphone.com iPhone simulator.
Try these examples:
Note from the TestiPhone.com About section: "This tool has been so far tested and working using Internet Explorer 7, FireFox 2 and Safari 3 in Windows, but you need Safari to get the real experience."
Posted by axelclk ( Aug 03 2008, 01:33:01 PM CEST ) Permalink Comments [0]Java Wikipedia API 3.0.7 released
The main purpose of the Java Wikipedia API (Bliki engine) is the rendering of the Wikipedia (aka Mediawiki) syntax into HTML:
For an overview of the complete API please look at the Bliki Javadocs:
There is a Bliki Engine Forum for help and discussion of the Wikipedia Engine API:
Download:
Changes in this release:
TEMPLATE_FUNCTION_MAP.put("#expr", Expr.CONST); for example
An advanced example can now be found in the HTMLCreatorTest.java file. If you run this example the first time, the Tom Hanks wiki source from Wikipedia is downloaded through the Wikipedia API. The downloaded wiki texts and templates are stored in an Apache Derby database, and associated images are downloaded in an already existing image directory c:/temp/WikiImages. After the first run there's a new Derby database created in the directory C:\temp\WikiDB. Every subsequent run of this code snippet will only download the Tom Hanks wiki source again. The associated templates and images are already cached in the Derby database and in the images directory:
public static void testCreator001() {
String[] listOfTitleStrings = { "Tom Hanks" };
User user = new User("", "", "http://en.wikipedia.org/w/api.php");
user.login();
String mainDirectory = "c:/temp/";
// the following subdirectory should not exist if you would like to create a
// new database
String databaseSubdirectory = "WikiDB";
// the following directory must exist for image downloads
String imageDirectory = "c:/temp/WikiImages";
WikiDB db = null;
try {
db = new WikiDB(mainDirectory, databaseSubdirectory);
APIWikiModel wikiModel = new APIWikiModel(user, db, "${image}", "${title}", imageDirectory);
DocumentCreator creator = new DocumentCreator(wikiModel, user, listOfTitleStrings);
creator.setHeader(HTMLConstants.HTML_HEADER1 + HTMLConstants.CSS_STYLE + HTMLConstants.HTML_HEADER2);
creator.setFooter(HTMLConstants.HTML_FOOTER);
creator.renderToFile(mainDirectory + "TomHanks.html");
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
} finally {
if (db != null) {
try {
db.tearDown();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Similar to the HTML creation example there's partial support for converting a Wikipedia text into a PDF document.
See for example the PDFCreatorTest.java file:
public static void testPDF001() {
String[] listOfTitleStrings = { "Tom Hanks" };
User user = new User("", "", "http://en.wikipedia.org/w/api.php");
user.login();
WikiDB db = null;
String mainDirectory = "c:/temp/";
// the following subdirectory should not exist if you would like to create a
// new database
String databaseSubdirectory = "WikiDB";
// the following directory must exist for image downloads
String imageDirectory = "c:/temp/WikiImages";
try {
db = new WikiDB(mainDirectory, databaseSubdirectory);
APIWikiModel myWikiModel = new APIWikiModel(user, db, "${image}", "file:///c:/temp/${title}", imageDirectory);
DocumentCreator creator = new DocumentCreator(myWikiModel, user, listOfTitleStrings);
creator.renderPDFToFile(mainDirectory, "Tom_Hanks.pdf", HTMLConstants.CSS_STYLE);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null) {
try {
db.tearDown();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
The PDF Generation is based on the Flying Saucer All-Java XHTML Renderer project. See these webpages for more information:
MathEclipse 0.0.6 - JSR 223 compatible symbolic math scripting engine
MathEclipse 0.0.6 is a JSR 223 compatible symbolic math scripting engine.
| Contents |
|---|
You can download version 0.0.6 from Sourceforge.net:
Project Homepage:
Discussion Forum:
To create a MathEclipse ScriptEngine we start with the following snippet:
import java.io.FileReader;
import java.util.ArrayList;
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();
String stringResult = null;
ScriptEngine meEngine = scriptManager.getEngineByExtension("m");
This evaluates the derivative of Sin[x]*Cos[x]:
try {
stringResult = (String) meEngine.eval("D[Sin[x]*Cos[x],x]");
System.out.println(stringResult);
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
The following snippet expands an expression and after that factorizes it again:
try {
stringResult = (String) meEngine.eval("Expand[(x+5)^3]");
System.out.println(stringResult);
stringResult = (String) meEngine.eval("Factor["+stringResult+"]");
System.out.println(stringResult);
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
This snippet shows how to assign values to variables:
try {
meEngine.put("$x", new Boolean(true));
meEngine.put("$y", new Boolean(true));
stringResult = (String) meEngine.eval("$x && $y");
System.out.println(stringResult);
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
Assuming that the c:\temp\test.m script file contains this code:
$m={$x, $y, {13, 7, 8}}; $m.$m
we can now define values for the variables $x and $y (which contain the first and second row of the matrix $m) and multiply the matrix $m by itself:
try {
ArrayList<Object> row = new ArrayList<Object>();
row.add("List"); // head of the expression
row.add(Integer.valueOf(1));
row.add(Integer.valueOf(2));
row.add(Integer.valueOf(3));
int[] intArr = { 3, 4, 11 };
meEngine.put("$x", row);
meEngine.put("$y", intArr);
// the test.m file contains this script for matrix multiplication:
// $m={$x, $y, {13, 7, 8}}; $m.$m
ScriptContext context = meEngine.getContext();
context.setAttribute(MathScriptEngine.RETURN_OBJECT, Boolean.TRUE, ScriptContext.ENGINE_SCOPE);
Object objectResult = meEngine.eval(new FileReader("C:\\temp\\test.m"));
// print the result for matrix multiplication: {{1,2,3}, {3, 4, 11}, {13, 7, 8}}.{{1,2,3}, {3, 4, 11}, {13, 7, 8}}
System.out.println(objectResult.toString());
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
You can run the following command from the console.bat file under windows:
java -classpath commons-discovery.jar;commons-math.jar;google-collect-snapshot.jar;xercesImpl.jar;matheclipse-script-0.0.6.jar org.matheclipse.core.eval.Console
You can run the calculator console with the following command:
java -classpath commons-discovery.jar;commons-math.jar;google-collect-snapshot.jar;xercesImpl.jar;matheclipse-script-0.0.6.jar org.matheclipse.parser.util.ConsolePosted by axelclk ( May 04 2008, 10:04:15 AM CEST ) Permalink Comments [1]
Developing JAMWiki with Eclipse
A tutorial to get started with the JAMWiki software in an Eclipse development environment. JAMWiki offers many of the features of the MediaWiki (aka Wikipedia) wikis.
| Contents |
|---|
Install Subclipse, the Maven Eclipse and the Tomcat Launcher plugins.
Once installed, select the "SVN Repository" Eclipse perspective and add
as a repository URL.
You should now be able to click on this repository and open the SVN tree:
Right click on the trunk node, select the "Find/Check out as..." menu option. In the following dialog box you can Check out the source code:
Now change back to the Java perspective.
In the package explorer view do a right mouse click on the pom.xml file and select the menu Run As → Maven build....
In the appearing dialog box select the Select... button in the Main tab and choose the package goal:
I needed to run this twice and increase the default java heap for eclipse to -Xmx1024m, because in the first run I get an OutOfMemoryError exception:
[INFO] Compiling 2 source files to C:\IDE\workspace\jamwiki_svn\javadiff\target\classes org.apache.maven.plugin.CompilationFailureException: Compilation failure Failure executing javac, but could not parse the error: The system is out of resources. Consult the following stack trace for details. java.lang.OutOfMemoryError: Java heap space at java.util.zip.ZipEntry.initFields(Native Method) at java.util.zip.ZipEntry.<init>(ZipEntry.java:96) at java.util.zip.ZipFile$2.nextElement(ZipFile.java:329) at java.util.zip.ZipFile$2.nextElement(ZipFile.java:299) at com.sun.tools.javac.util.DefaultFileManager$ZipArchive.<init>(DefaultFileManager.java:405) at com.sun.tools.javac.util.DefaultFileManager$SymbolArchive.<init>(DefaultFileManager.java:460) at com.sun.tools.javac.util.DefaultFileManager.openArchive(DefaultFileManager.java:544) ... ...
The Maven package build has now generated some additional files and directories.
Copy these generated jflex files:
from
C:\IDE\workspace\jamwiki_svn\jamwiki-core\target\generated-sources\jflex\org\jamwiki\parser\jflex
to
C:\IDE\workspace\jamwiki_svn\jamwiki-core\src\main\java\org\jamwiki\parser\jflex
Delete these files from the
C:\IDE\workspace\jamwiki_svn\jamwiki-war\target\jamwiki-war-0.6.6-SNAPSHOT\WEB-INF\lib
directory:
and delete this file
C:\IDE\workspace\jamwiki_svn\jamwiki-war\target\jamwiki-war-0.6.6-SNAPSHOT.war
Select the Eclipse Window → Preferences... menu. In the dialog select the node Java → Build Path → Classpath Variables and:
JAMWIKI_WEBAPP which points toC:/IDE/workspace/jamwiki_svn/jamwiki-war/target/jamwiki-war-0.6.6-SNAPSHOT
TOMCAT_HOME which points to your Tomcat home directory. In my case it points to:
C:/server/tomcat-6.0.13
After that, select the Tomcat node and define your Tomcat settings. Be sure that the directory C:\server\tomcat-6.0.13\conf\Catalina\localhost exists:
Edit the .project file, so that the project is a Java, Maven2 and Tomcat plugin related project:
<?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>jamwiki_svn</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> <name>org.maven.ide.eclipse.maven2Builder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.maven.ide.eclipse.maven2Nature</nature> <nature>com.sysdeo.eclipse.tomcat.tomcatnature</nature> </natures> </projectDescription>
Create a new source folder named mysrc.
Change the .classpath file in the following way:
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="my-src"/> <classpathentry kind="src" path="addon-src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry combineaccessrules="false" kind="src" path="/info.bliki.wiki.svn"/> <classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/core-renderer.jar"/> <classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/itext-paulo-155.jar"/> <classpathentry kind="lib" path="lib/junit.jar"/> <classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/commons-codec-1.3.jar"/> <classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/commons-logging.jar"/> <classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/commons-validator-1.3.1.jar"/> <classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/jakarta-oro.jar"/> <classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/commons-fileupload-1.2.jar"/> <classpathentry kind="var" path="TOMCAT_HOME/lib/servlet-api.jar"/> <classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/commons-httpclient-3.1.jar"/> <classpathentry kind="lib" path="lib/mysql-connector-java-3.1.10-bin.jar"/> <classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/commons-lang-2.4.jar"/> <classpathentry kind="output" path="bin"/> </classpath>
Do a right mouse click on your project and select menu Properties. In the dialog box select the Tomcat node. In the dialog box define the Application-URI as jam066 and the sub-directory for the webapps root as /jamwiki-war/target/jamwiki-war-0.6.6-SNAPSHOT:
In the Java perspective's toolbar, where are three buttons to
Press the Start Tomcat button and you should see the Tomcat logging in the Eclipse Console view. (If the Console view isn't open, you can open it in the menu Window → Show View → Console)
Now open a browser and run JAMWiki with the following URL:
JAMWiki should automatically switch to the installation setup page:
Create a directory for your JAMWiki cache, search, database and upload files:
c:\temp\jamwiki
and configure it in the setup page. I've used the following path settings in the setup process:
... file-dir-full-path=C\:\\IDE\\workspace\\jamwiki_svn\\jamwiki-war\\target\\jamwiki-war-0.6.6-SNAPSHOT\\upload file-dir-relative-path=/jam066/upload/ ... homeDir=C\:\\temp\\jamwiki
Stop Tomcat now and do a refresh (right mouse click in the Package Explorer view and select menu Refresh F5) of your JAMWiki Eclipse project.
The JAMWiki installation created a new properties file:
/jamwiki_svn/jamwiki-war/target/jamwiki-war-0.6.6-SNAPSHOT/WEB-INF/classes/jamwiki.properties
Copy this jamwiki.properties file directly under your mysrc folder.
In the jamwiki.properties file you can now directly edit the configuration and restart Tomcat afterwards. For example I configured my Bliki engine as the default Wikipedia syntax parser:
parser=org.jamwiki.parser.bliki.BlikiParserPosted by axelclk ( Apr 29 2008, 08:52:02 PM CEST ) Permalink Comments [0]
Math expression parser API 0.0.5 released
Today I released the MathEclipse expression parser API version 0.0.5.
Now there are two engines for double and Complex number type calculations included. See:
Posted by axelclk ( Mar 25 2008, 10:48:01 PM CET ) Permalink Comments [1]MathEclipse Nested Lists API released
The MathEclipse Nested Lists API version 0.0.4 is a generic Java library which simplifies functional programming for nested lists (i.e. the nested lists build a tree of the form [[...],...]).
For more information, see:
I've released a first 0.0.4 version here:
Posted by axelclk ( Mar 15 2008, 04:56:29 PM CET ) Permalink Comments [2]Get LaTeX formula from Mathtran.org as PNG image file
Here's a quick and dirty snippet in Java, how to create a local *.png image file from a LaTeX formula.
The image name in the given directory is generated with URLEncoder.encode().
Remember to include these libraries on the Java classpath:
Some questions remain:
Reference:
Last updated 3/01/08 for font size:
package info.bliki.wiki.addon.test.util;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;
/**
* Download LaTeX formula from www.mathtran.org as PNG image.
*
*/
public class MathtranUtil {
private final String fMathtranUrl;
private final String fDirectoryName;
public static void main(String[] args) {
String texFormula = "\\sin^2\\theta + \\cos^2\\theta = 1";
if (args.length > 0) {
texFormula = args[0];
}
MathtranUtil util = new MathtranUtil("http://www.mathtran.org/cgi-bin/mathtran?", "c:/temp/");
util.downloadImageFile(texFormula, 5);
}
/**
* Create this utility instance from a given mathtran url and a
* <code>diretoryName</code>, where the image file should be saved with the
* filename in <code>URLEncoder.encode()</code> format.
*
* @param mathtranUrl
* @param directoryName
*/
public MathtranUtil(String mathtranUrl, String directoryName) {
super();
fMathtranUrl = mathtranUrl;
fDirectoryName = directoryName;
}
/**
* Download the <code>texFormula</code> from www.mathtran.org as a PNG
* image.
*
* @param texFormula
* the pure LaTeX formula
* @param fontSize
* a number in the range from 1 to 10
*/
public void downloadImageFile(String texFormula, int fontSize) {
FileOutputStream fos = null;
try {
HttpClient client = new HttpClient();
client.setConnectionTimeout(30000);
String formualEncoded = URLEncoder.encode(texFormula, "UTF-8");
String fileName = fDirectoryName + formualEncoded + ".png";
GetMethod method = new GetMethod(fMathtranUrl + "D=" + fontSize + "&tex=" + formualEncoded);
method.setRequestHeader("accept", "image/png");
// method.setFollowRedirects(true);
// Execute the GET method
int statusCode = client.executeMethod(method);
if (statusCode != -1) {
System.out.println("Reading image url: " + fMathtranUrl + " filename: " + fileName);
byte[] b = method.getResponseBody();
method.releaseConnection();
fos = new FileOutputStream(fileName);
fos.write(b);
}
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
Posted by axelclk
( Feb 28 2008, 09:00:47 PM CET )
Permalink
Comments [3]
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:
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 [0]