wme mathedit (status report)

34
4 2 5 1 0011 0010 1010 1101 0001 0100 1011 WME MathEdit (Status Report) by K. Cem Karadeniz Kent State University Computer Science March 15 th , 2006

Upload: rene

Post on 24-Jan-2016

39 views

Category:

Documents


0 download

DESCRIPTION

WME MathEdit (Status Report). by K. Cem Karadeniz Kent State University Computer Science March 15 th , 2006. Overview. New implementation platform: JAVA Why Applet? Advantages & Disadvantages Security, Applet Signature, Policy The Box Model and Animation - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: WME MathEdit (Status Report)

42510011 0010 1010 1101 0001 0100 1011

WME MathEdit(Status Report)

by

K. Cem Karadeniz

Kent State University

Computer Science

March 15th, 2006

Page 2: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 2

Overview

• New implementation platform: JAVA– Why Applet?– Advantages & Disadvantages– Security, Applet Signature, Policy– The Box Model and Animation– Current Package and Class Hierarchy– Serializer, Parser and SAX

Page 3: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 3

Overview (cont.)

• Interface Design– Old Interface vs. New Interface

• Application Programming Interface (API)– Interaction with Other WME Components

• Enabling Web Pages for MathML (brief)– Use XHML template package (cancelled)

• Demo of the Current Tool

Page 4: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 4

Refreshing the RequirementsThe WME MathEdit tool,

• requires animation and very intensive input control (keyboard, mouse)

• has to work online on client side • has to be able to communicate two ways within

the web page • should have access to clients’ local hard drives

to read/write files (for also debugging)

• may store formulas as image files

Page 5: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 5

Communication Scenario• Considering those requirements, we have the following

communication scenario diagram:

W ME MathEditin brow s er w indow

W ME page

A P Ie di t ins e r t

que s t io ninc ludingfo rm ula

ans we rinc ludingfo rm ula

W MEComponent

A P I

Page 6: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 6

Why JAVA?

• All the requirements can be implemented by using JAVA and its Applet technology.

• Applets are full JAVA programs and they,– allow to create the highly needed symbol

animation,– are capable to work online,– can interact with web page,– may access the client hard drive (!)

Page 7: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 7

JAVA Applet: ProsCons

• Applets provide ways to fulfill all five requirements that I just mentioned; they are full

featured programs! x5

• Object-oriented code has tremendous advantages (i.e. plug n play parsers, code reuse and easy

maintenance)

• Platform independent coding & execution on platform dependent JVM

Page 8: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 8

JAVA Applet: ProsCons

• Applet comes with following constraints as far as the WME is concerned:– Extra action needed for security (next)

– Requires a heavy weight plug-in (JRE) ~16MB!• Like every other tool to implement MathEdit!

– Relatively slow initialization due to Java nature (interpreted language) and large bytecode size

• Researching open-source optimizers and tools to convert to native code (!) – if larger than 300k I will try

• 1.5.0 (or 5.0) is beyond other older versions

Page 9: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 9

Applet Security

• Applets used to have a bad fame about security• First choice of malicious hackers to hack MS

Windows remotely• JDK’s goal is to enable browsers to run

untrusted applets in a trusted environment1. Local policy files (suitable for development)2. Signed applets (WME will possibly use this)

Page 10: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 10

Applet Security: Local Policy• Plain text files on client machines• Default: .java.policy in the user home directory• Not very practical for WME (why?)• You can use policytool program in SDK• For now WME MathEdit needs the following permissions:

grant codeBase "file:/e:/javaworld/-" { permission java.io.FilePermission "<<ALL FILES>>",

"read, write"; permission java.util.PropertyPermission "user.dir",

"read"; permission java.lang.RuntimePermission "modifyThread";

};

It is also possible to grant all permissions:

grant codeBase "file:/e:/javaworld/-" {

permission java.security.AllPermission;

};

Page 11: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 11

Applet Security: Signed Classes

• This does not require any file on client • Program has to be in a JAR package• Only the main class must still be present

together with the signed JAR file• Tools to use in J2SE SDK:

– jar– keytool– jarsigner

Page 12: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 12

Applet Security: Signed Classes (cont.)

1. # jar cvf mathedit_unsigned.jar mathedit2. # keytool –genkey \

-alias mymathedit \-keypass keymathedit \-keystore matheditkey.bin \ (can have multiple keys -alias)

-storepass pubmathedit3. Answer questions (next slide)4. # jarsigner -keystore matheditkey.bin

-signedjar mathedit_signed.jar mathedit_unsigned.jar mymathedit

5. Answer questions (next-next slide)

• Signing an applet is almost like writing a small program! It needs some effort . My five-step minimal process below:

Page 13: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 13

Applet Security: Signed Classes (cont.)• You have to answer seven questions when you issue the keytool

command on previous slide. User will grant access depending on them.• Answers should be explanatory otherwise people will deny access

What is your first and last name? [Unknown]: The WME Research TeamWhat is the name of your organizational unit? [Unknown]: Web-based Mathematics EducationWhat is the name of your organization? [Unknown]: Kent State University Computer ScienceWhat is the name of your City or Locality? [Unknown]: KentWhat is the name of your State or Province? [Unknown]: OHWhat is the two-letter country code for this unit? [Unknown]: USIs CN=The WME Research Team, OU=Web-based Mathematics Education, O=Kent

State University Computer Science, L=Kent, ST=OH, C=US correct?[no]: yes

Page 14: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 14

Applet Security: Signed Classes (cont.)• You have to answer two more questions when you issue the jarsigner command (step 4)

• Answers are from the keytool command (from step 2)

# jarsigner -keystore matheditkey.bin

-signedjar mathedit_signed.jar mathedit_unsigned.jar mymathedit

Enter Passphrase for keystore: pubmatheditEnter key password for mymathedit: keymathedit

Page 15: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 15

• If you successfully complete the process you will get the following message:

Warning: The signer certificate will expire within six months.

• You can always buy a permanent certificate that will allow your applet to run automatically without any warning message (next)

• From VeriSign or some similar company…

Applet Security: Signed Classes (cont.)

Page 16: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 16

Running the Applet

• If you are a developer you will use a policy file like I showed together with the appletviewer tool

• You don’t need to sign your applet until you publish it• To run the applet on your local machine:

# appletviewer

-J-Djava.security.policy=myappletpolicy deploy.html

Page 17: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 17

Page 18: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 18

Page 19: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 19

Applet Security: Signed Classes (cont.)

Page 20: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 20

JAVA and the Box Model• Currently I implemented square root and fraction using what I

refer as “box model”• Box is from javax.swing.Box• private Component ra =

Box.createRigidArea(new Dimension(myD+5,0));

• Creates an invisible Component

3.141

Fake cursor (care t)us ing thread.s leep E dit box w ith

rea l cursor A n im ation

Page 21: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 21

Fraction Model Box• Same idea but now starts with two rigid areas at the same time• private Component ra = Box.createRigidArea(new

Dimension(myDim1+5,0));• private Component dxra = Box.createRigidArea(new

Dimension(0,myDim2));

12.34 12.34

Youm ust use arrowkeys or m ouseto m ove cursor here

Page 22: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 22

Package & Class Hierarchy

• I have currently 10 (img and mmlex are different) packages and 28 classes & interfaces

• Main package is mathedit.cem.appmain– MyEditorApp.html– MyEditorApp.java– MyEditorPanel.java– MyEditorRenderer.java

Page 23: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 23

Parser and SAX• I have a 750 lines MathML parser class, I wrote it

converting from a C++ parser, not easy even to convert!

• As I mentioned before plug & play, can allow to change the parser since each parser is a class obeying some rules (OOP interface concept)

• public interface Parser { // . . . }• public class MMLParser implements Parser { // . . . }

Page 24: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 24

• Simple API for XML• Comes as part of JAVA core:

import org.xml.sax.InputSource;

public MyBox parse(InputSource source) throws Exception {DocumentBuilderFactory f =

DocumentBuilderFactory.newInstance();f.setValidating(true);f.setNamespaceAware(true);f.setIgnoringElementContentWhitespace(true);DocumentBuilder builder = f.newDocumentBuilder();return parseDom(builder.parse(source)); // XML +

MathML Parse}

• Visit http://www.saxproject.org/ for more information

Parser and SAX

Page 25: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 25

MathML Serializers (MMLSerializer.java)

• In Java a Serializer converts a Java object to an XML representation using a specific XML processing mechanism

• In WME MathEdit: convert what is visually on the swing panel (on the tool’s typing area) to XML

• XML is MathML in this case• I have two serializers for now (one for square root

and one for fraction)• Each added feature will require a new serializer

Page 26: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 26

private String serializeFraction(FracMyBox box) {String result = "";if (attrs.length()>0) {

result += ind()+"<"+tag("mstyle")+attrs+">";indcnt++;

}result += ind()+"<"+tag("mfrac");if (box.getLineThickness()!=1)

result += " linethickness=\""+box.getLineThickness()+"\"";

result += ">";indcnt++;result += serializeBox(box.getNumerator()) +

serializeBox(box.getDenominator());indcnt--;result += ind()+"</"+tag("mfrac")+">";if (attrs.length()>0) {

indcnt--;result += ind()+"</"+tag("mstyle")+">";

}return result;

}

Page 27: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 27

private String serializeSqrt(SqrtMyBox box) {String result = "";String attrs = checkForStyle(box);if (attrs.length()>0) {

result += ind()+"<"+tag("mstyle")+attrs+">";indcnt++;

}result += ind()+"<"+tag("msqrt")+">";indcnt++;if ( box.getChilds().size()==1 &&

(box.getBase().getType()==MyBox.rowBBox) )result += serializeBox(box.getBase());

else {result += ind()+"<"+tag("mrow")+">";indcnt++;for (int i=0; i<box.getChilds().size(); i++)

result += serializeBox((MyBox)box.getChilds().elementAt(i));

indcnt--;result += ind()+"</"+tag("mrow")+">";

}indcnt--;result += ind()+"</"+tag("msqrt")+">";if (attrs.length()>0) {

indcnt--;result += ind()+"</"+tag("mstyle")+">";

}return result;

}

Page 28: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 28

API for WME Components• Other WME components like DMAD, Glossary

Service, Bulletin Board need output of my program, which brings a need for API

• API is also needed for ordinary WME pages• I don’t have any JavaScript API yet because the

program is not even half way implemented• Two APIs are available through <param … />• Output is simply a string containing full of

MathML tags, attributes, and user input(see the demo)

Page 29: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 29

How to Embed the Tool

<applet code="mathedit/cem/appmain/MyEditorApp.class“archive="mathedit/mathedit_signed.jar"type="application/x-java-applet;version=1.5.0"width="430"height="300">

<param name="type" value="application/x-java-applet" />

(next slide covers HERE, the param API)

</applet>

• Two files under mathedit directory which is in the root directory of the web page/site

• File 1: mathedit_signed.jar• File 2: MyEditorApp.class

Page 30: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 30

Two Applet Parameters

<param name="openMMLfile" value="ex02.mml" />

<param name="openMMLstr" value="<math><mrow><mfrac><mrow><mn>1</mn></mrow>…” />

• But there is a problem in the second param (why?)

<param name="openMMLstr" value="&lt;math&gt;&lt;mrow&gt;&lt;mfrac&gt;&lt

;mrow&gt;&lt;mn&gt;…” />

• JavaScript API should handle the problem

Page 31: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 31

Interface Design

Page 32: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 32

Interface Design (cont.)

Page 33: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 33

Demo

Page 34: WME MathEdit (Status Report)

4251

0011 0010 1010 1101 0001 0100 1011

03/15/2006 34

Thank you

• Questions?

• Comments?

• Suggestions?