ppt - Web-Based Mathematics Education
Download
Report
Transcript ppt - Web-Based Mathematics Education
WME MathEdit
(Status Report)
0011 0010 1010 1101 0001 0100 1011 by
K. Cem Karadeniz
Kent State University
Computer Science
March 15th, 2006
1
2
4
Overview
0011 0010 1010 1101 0001 0100 1011
• 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
03/15/2006
1
2
4
2
Overview (cont.)
0011 0010 1010 1101 0001 0100 1011
• Interface Design
– Old Interface vs. New Interface
1
2
• Application Programming Interface (API)
– Interaction with Other WME Components
4
• Enabling Web Pages for MathML (brief)
– Use XHML template package (cancelled)
• Demo of the Current Tool
03/15/2006
3
Refreshing the Requirements
0011 0010 1010 1101 0001 0100 1011
The 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
03/15/2006
1
2
4
4
Communication Scenario
0011 0010
1010 1101 0001
0100
1011
• Considering
those
requirements,
we have the following
communication scenario diagram:
WME
Component
API
WME MathEdit
in browser window
question
including
formula
edit
WME page
03/15/2006
insert
2
4
answer
including
formula
API
1
5
Why JAVA?
0011 0010 1010 1101 0001 0100 1011
• All the requirements can be implemented by
using JAVA and its Applet technology.
• Applets are full JAVA programs and they,
1
– allow to create the highly needed symbol
animation,
– are capable to work online,
– can interact with web page,
– may access the client hard drive (!)
03/15/2006
2
4
6
JAVA Applet: Pros[Cons
0011 0010 1010 1101 0001 0100 1011
• Applets provide ways to fulfill all five
requirements that I just mentioned; they are full
featured programs! <x5
1
2
• Object-oriented code has tremendous advantages
(i.e. plug n play parsers, code reuse and easy
maintenance) <
4
• Platform independent coding & execution on
platform dependent JVM
03/15/2006
7
JAVA Applet: Pros[Cons
0011 0010 1010 1101 0001 0100 1011
• 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!
1
2
4
– 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
03/15/2006
8
Applet Security
0011 0010 1010 1101 0001 0100 1011
•
•
•
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 environment
1
03/15/2006
2
4
1. Local policy files (suitable for development)
2. Signed applets (WME will possibly use this)
9
Applet Security: Local Policy
0011 0010
1010text
1101
0001
0100 machines
1011
• Plain
files
on client
•
•
•
•
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:
1
2
grantItcodeBase
"file:/e:/javaworld/-"
{
is also possible
to grant all permissions:
permission java.io.FilePermission "<<ALL FILES>>",
"read,
write";
grant
codeBase "file:/e:/javaworld/-" {
permission java.util.PropertyPermission "user.dir",
"read";
permission
java.security.AllPermission;
permission
java.lang.RuntimePermission
"modifyThread";
};
};
03/15/2006
4
10
Applet Security: Signed Classes
0011 0010 1010 1101 0001 0100 1011
• 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:
1
– jar
– keytool
– jarsigner
03/15/2006
2
4
11
Applet Security: Signed Classes (cont.)
• Signing
an applet
is almost
0011 0010
1010 1101
0001 0100
1011
like writing a small program! It
needs some effort K. My five-step minimal process below:
1.
2.
# jar cvf mathedit_unsigned.jar mathedit
# keytool –genkey \
-alias mymathedit \
-keypass keymathedit \
-keystore matheditkey.bin \ (can have multiple keys -alias)
-storepass pubmathedit
3. Answer questions (next slide)
4. # jarsigner -keystore matheditkey.bin
-signedjar mathedit_signed.jar
mathedit_unsigned.jar mymathedit
5. Answer questions (next-next slide)
03/15/2006
1
2
4
12
Applet Security: Signed Classes (cont.)
0011 •0010
0001seven
0100 questions
1011
You1010
have1101
to answer
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 Team
What is the name of your organizational unit?
[Unknown]: Web-based Mathematics Education
What is the name of your organization?
[Unknown]: Kent State University Computer Science
What is the name of your City or Locality?
[Unknown]: Kent
What is the name of your State or Province?
[Unknown]: OH
What is the two-letter country code for this unit?
[Unknown]: US
Is 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
1
03/15/2006
2
4
13
Applet Security: Signed Classes (cont.)
0011 •0010
1010
1101
0001 0100
1011
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
1
2
4
Enter Passphrase for keystore: pubmathedit
Enter key password for mymathedit: keymathedit
03/15/2006
14
Applet Security: Signed Classes (cont.)
0011 0010 1010 1101 0001 0100 1011
• If you successfully complete the process you will
get the following message:
Warning: The signer certificate will
expire within six months.
1
2
• 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…
03/15/2006
4
15
Running the Applet
0011 0010 1010 1101 0001 0100 1011
• If you are a developer you will use a policy file like I
showed together with the appletviewer tool
2
• You don’t need to sign your applet until you publish it
• To run the applet on your local machine:
1
4
# appletviewer
-J-Djava.security.policy=myappletpolicy
deploy.html
03/15/2006
16
0011 0010 1010 1101 0001 0100 1011
1
03/15/2006
2
4
17
0011 0010 1010 1101 0001 0100 1011
1
03/15/2006
2
4
18
Applet Security: Signed Classes (cont.)
0011 0010 1010 1101 0001 0100 1011
1
03/15/2006
2
4
19
JAVA and the Box Model
0011 0010
1010 1101
0001 0100 square
1011 root and fraction using what I
• Currently
I implemented
refer as “box model”
• Box is from javax.swing.Box
• private Component ra =
Box.createRigidArea(new Dimension(myD+5,0));
• Creates an invisible Component
Fake cursor (caret)
using thread.sleep
03/15/2006
Edit box with
real cursor
1
2
4
Animation
3.141
20
Fraction Model Box
0011 0010
1010idea
1101
0100 with
1011two rigid areas at the same time
• Same
but0001
now starts
• private Component ra = Box.createRigidArea(new
Dimension(myDim1+5,0));
• private Component dxra = Box.createRigidArea(new
Dimension(0,myDim2));
12.34
2
4
You
must use arrow
keys or mouse
to move cursor here
03/15/2006
1
12.34
21
Package & Class Hierarchy
0011 0010 1010 1101 0001 0100 1011
• I have currently 10 (img
and mmlex are different)
packages and 28 classes &
interfaces
• Main package is
mathedit.cem.appmain
–
–
–
–
03/15/2006
MyEditorApp.html
MyEditorApp.java
MyEditorPanel.java
MyEditorRenderer.j
ava
1
2
4
22
Parser and SAX
0011 0010 1010 1101 0001 0100 1011
• 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)
1
03/15/2006
2
4
• public interface Parser { // . . .
• public class MMLParser implements
Parser { // . . . }
}
23
Parser and SAX
• Simple API for XML
• Comes as part of JAVA core:
0011 0010 1010 1101 0001 0100 1011
import org.xml.sax.InputSource;
1
2
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
}
4
• Visit http://www.saxproject.org/ for more information
03/15/2006
24
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
0011 0010 1010 1101 0001 0100 1011
1
03/15/2006
2
4
25
private String serializeFraction(FracMyBox box) {
String result = "";
if (attrs.length()>0) {
result += ind()+"<"+tag("mstyle")+attrs+">";
indcnt++;
} 1101 0001 0100 1011
0011 0010 1010
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;
}
1
03/15/2006
2
4
26
0011
private String serializeSqrt(SqrtMyBox box) {
String result = "";
String attrs = checkForStyle(box);
if (attrs.length()>0) {
result += ind()+"<"+tag("mstyle")+attrs+">";
indcnt++;
} 1101 0001 0100 1011
0010 1010
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;
}
03/15/2006
1
2
4
27
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)
0011 0010 1010 1101 0001 0100 1011
1
03/15/2006
2
4
28
How to Embed the Tool
0011• 0010
1101 0001
0100directory
1011
Two1010
files under
mathedit
which is in the root directory of the
web page/site
• File 1: mathedit_signed.jar
• File 2: MyEditorApp.class
1
2
<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" />
4
(next slide covers HERE, the param API)
</applet>
03/15/2006
29
Two Applet Parameters
0011 0010 1010 1101 0001 0100 1011
<param name="openMMLfile" value="ex02.mml" />
<param name="openMMLstr"
value="<math><mrow><mfrac><mrow><mn>1</mn></mro
w>…” />
1
• But there is a problem in the second param (why?)
2
4
<param name="openMMLstr"
value="<math><mrow><mfrac><
;mrow><mn>…” />
• JavaScript API should handle the problem
03/15/2006
30
Interface Design
0011 0010 1010 1101 0001 0100 1011
1
03/15/2006
2
4
31
Interface Design (cont.)
0011 0010 1010 1101 0001 0100 1011
1
03/15/2006
2
4
32
Demo
0011 0010 1010 1101 0001 0100 1011
1
03/15/2006
2
4
33
Thank you
0011 0010 1010 1101 0001 0100 1011
• Questions?
• Comments?
• Suggestions?
03/15/2006
1
2
4
34