[sword-svn] r103 - in trunk: . app/src/org/crosswire/flashcards micro micro/classes micro/classes/org micro/classes/org/crosswire micro/classes/org/crosswire/flashcards micro/classes/org/crosswire/flashcards/lessons micro/doc micro/doc/org micro/doc/org/crosswire micro/doc/org/crosswire/flashcards micro/doc/org/crosswire/flashcards/mobile micro/src micro/src/org micro/src/org/crosswire micro/src/org/crosswire/flashcards micro/src/org/crosswire/flashcards/mobile src/org/crosswire/flashcards

Apache apache at www.crosswire.org
Sat Dec 9 06:51:24 MST 2006


Author: 
Date: 2006-12-09 06:51:24 -0700 (Sat, 09 Dec 2006)
New Revision: 103

Added:
   trunk/micro/
   trunk/micro/FlashcardsMobile.jpx
   trunk/micro/classes/
   trunk/micro/classes/org/
   trunk/micro/classes/org/crosswire/
   trunk/micro/classes/org/crosswire/flashcards/
   trunk/micro/classes/org/crosswire/flashcards/lessons/
   trunk/micro/classes/org/crosswire/flashcards/lessons/lesson0.flash
   trunk/micro/classes/org/crosswire/flashcards/lessons/lesson1.flash
   trunk/micro/doc/
   trunk/micro/doc/org/
   trunk/micro/doc/org/crosswire/
   trunk/micro/doc/org/crosswire/flashcards/
   trunk/micro/doc/org/crosswire/flashcards/mobile/
   trunk/micro/doc/org/crosswire/flashcards/mobile/FlashCards.html
   trunk/micro/src/
   trunk/micro/src/org/
   trunk/micro/src/org/crosswire/
   trunk/micro/src/org/crosswire/flashcards/
   trunk/micro/src/org/crosswire/flashcards/MicroLesson.java
   trunk/micro/src/org/crosswire/flashcards/MicroLessonSet.java
   trunk/micro/src/org/crosswire/flashcards/Properties.java
   trunk/micro/src/org/crosswire/flashcards/mobile/
   trunk/micro/src/org/crosswire/flashcards/mobile/FlashCards.java
   trunk/micro/src/org/crosswire/flashcards/mobile/FlashCards.jbx
   trunk/micro/src/org/crosswire/flashcards/mobile/LessonGroups.java
   trunk/micro/src/org/crosswire/flashcards/mobile/Lessons.java
   trunk/micro/src/org/crosswire/flashcards/mobile/Quiz.java
   trunk/src/org/crosswire/flashcards/Quizer.java
Modified:
   trunk/app/src/org/crosswire/flashcards/ComplexLesson.java
   trunk/app/src/org/crosswire/flashcards/ComplexLessonSet.java
   trunk/app/src/org/crosswire/flashcards/LessonPane.java
   trunk/src/org/crosswire/flashcards/FlashCard.java
   trunk/src/org/crosswire/flashcards/Lesson.java
Log:
First cut of sortof working micro edition
Still need to support prerendered images
Still need to make desktop app use Quizer
Still need to figure out how to do multiple lesson sets



Modified: trunk/app/src/org/crosswire/flashcards/ComplexLesson.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/ComplexLesson.java	2006-12-09 00:53:32 UTC (rev 102)
+++ trunk/app/src/org/crosswire/flashcards/ComplexLesson.java	2006-12-09 13:51:24 UTC (rev 103)
@@ -44,11 +44,11 @@
  */
 public class ComplexLesson extends Lesson {
 
-     public ComplexLesson(String url) {
+     public ComplexLesson(String url) throws Exception {
           super(url);
      }
 
-     public ComplexLesson(String url, String description) {
+     public ComplexLesson(String url, String description) throws Exception {
           super(url, description);
      }
 

Modified: trunk/app/src/org/crosswire/flashcards/ComplexLessonSet.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/ComplexLessonSet.java	2006-12-09 00:53:32 UTC (rev 102)
+++ trunk/app/src/org/crosswire/flashcards/ComplexLessonSet.java	2006-12-09 13:51:24 UTC (rev 103)
@@ -96,7 +96,10 @@
                String lessonPath = jarEntry.getName();
                if (lessonPath.startsWith(dirName) && !jarEntry.isDirectory() &&
                    lessonPath.toUpperCase(Locale.ENGLISH).endsWith(".FLASH")) {
-                    add(new ComplexLesson("jar:" + jarConnection.getJarFileURL() + "!/" + lessonPath));
+                    try {
+                         add(new ComplexLesson("jar:" + jarConnection.getJarFileURL() + "!/" + lessonPath));
+                    }
+                    catch (Exception e) {}
                }
           }
      }
@@ -108,20 +111,18 @@
       * @param lessonSet
       */
      private void loadDirectoryLessonSet(File directory) {
-          try {
                File[] files = directory.listFiles(new FlashFileFilter());
                if (files == null) {
                     return;
                }
                Arrays.sort(files);
                for (int i = 0; i < files.length; i++) {
-                    add(new ComplexLesson(files[i].getCanonicalFile().toURL().toString()));
+                    try {
+                         add(new ComplexLesson(files[i].getCanonicalFile().toURL().toString()));
+                    }
+                    catch (Exception e) {}
                }
           }
-          catch (IOException e) {
-               // that's fine.  We just failed to load local files.
-          }
-     }
 
 
      public String getNextLessonFilename() {

Modified: trunk/app/src/org/crosswire/flashcards/LessonPane.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/LessonPane.java	2006-12-09 00:53:32 UTC (rev 102)
+++ trunk/app/src/org/crosswire/flashcards/LessonPane.java	2006-12-09 13:51:24 UTC (rev 103)
@@ -128,7 +128,11 @@
 
     public void createLesson(String description)
     {
-        Lesson lesson = new ComplexLesson(lessonSet.getNextLessonFilename(), description);
+	    Lesson lesson = null;
+         try {
+              lesson = new ComplexLesson(lessonSet.getNextLessonFilename(), description);
+         }
+         catch (Exception e) {}
         DefaultListModel model = (DefaultListModel) lessonList.getModel();
         if (!model.contains(lesson))
         {

Added: trunk/micro/FlashcardsMobile.jpx
===================================================================
--- trunk/micro/FlashcardsMobile.jpx	                        (rev 0)
+++ trunk/micro/FlashcardsMobile.jpx	2006-12-09 13:51:24 UTC (rev 103)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--JBuilder XML Project-->
+<project>
+<property category="generalFormatting2" name="overrideBasicFormatting" value="1"/>
+<property category="javaFormatting" name="packagePrefixGroups" value="java;javax;BLANK_LINE;java.awt;javax.swing;BLANK_LINE;org;(*)"/>
+<property category="javadoc" name="custom.tags.1" value="todo;a;To Do:"/>
+<property category="micro.ftpupload" name="file_list.1" value="file:////space/home/scribe/src/flashcards/mobile/FlashcardsMobile.jar"/>
+<property category="micro.ftpupload" name="file_list.2" value="file:////space/home/scribe/src/flashcards/mobile/FlashcardsMobile.jad"/>
+<property category="runtime" name="DefaultConfiguration" value="-1"/>
+<property category="runtime.0" name="ConfigurationName" value="FlashCards"/>
+<property category="runtime.0" name="RunnableType" value="com.borland.jbuilder.runtime.micro.MidletRunner"/>
+<property category="runtime.0" name="midlet.class" value="org.crosswire.flashcards.mobile.FlashCards"/>
+<property category="serverservices" name="disabled.services" value="jdatastore"/>
+<property category="serverservices" name="single.server.name" value=""/>
+<property category="sys" name="AuthorLabel" value="@author"/>
+<property category="sys" name="BackupPath" value="bak"/>
+<property category="sys" name="CheckStable" value="1"/>
+<property category="sys" name="Company" value=""/>
+<property category="sys" name="CompanyLabel" value="Company:"/>
+<property category="sys" name="Copyright" value="Copyright (c) 2006"/>
+<property category="sys" name="CopyrightLabel" value="Copyright:"/>
+<property category="sys" name="DefaultPath" value="src"/>
+<property category="sys" name="Description" value=""/>
+<property category="sys" name="DescriptionLabel" value="Description:"/>
+<property category="sys" name="DocPath" value="doc"/>
+<property category="sys" name="ExcludeClassEnabled" value="0"/>
+<property category="sys" name="IncludeTestPath" value="1"/>
+<property category="sys" name="InstanceVisibility" value="2"/>
+<property category="sys" name="JDK" value="J2ME Wireless Toolkit 2.2"/>
+<property category="sys" name="LastTag" value="0"/>
+<property category="sys" name="Libraries" value=""/>
+<property category="sys" name="MakeStable" value="0"/>
+<property category="sys" name="OutPath" value="classes"/>
+<property category="sys" name="SourcePath" value="src;test;../src"/>
+<property category="sys" name="SourceVersion" value="1.5"/>
+<property category="sys" name="TestPath" value="test"/>
+<property category="sys" name="Title" value=""/>
+<property category="sys" name="TitleLabel" value="Title:"/>
+<property category="sys" name="Version" value="1.0"/>
+<property category="sys" name="VersionLabel" value="@version"/>
+<property category="sys" name="WorkingDirectory" value="."/>
+<node name="FlashcardsMobile" type="MicroArchive">
+<property category="archiving" name="archiverClass" value="com.borland.jbuilder.wizard.micro.archive.MidletArchiver"/>
+<property category="archiving" name="contentRules.1" value="I:**/*.*"/>
+<property category="archiving" name="ignoreClasses.1" value="org.crosswire.flashcards.mobile.FlashCards"/>
+<property category="archiving" name="miscTargetPath.1" value="FlashcardsMobile.jad"/>
+<property category="archiving" name="obfuscator" value="RetroGuard for J2ME"/>
+<property category="archiving" name="targetCompressed" value="1"/>
+<property category="archiving" name="targetPath" value="FlashcardsMobile.jar"/>
+<property category="archiving" name="usingRules" value="1"/>
+<property category="archiving.micro" name="microEditionConfiguration" value="CLDC-1.1"/>
+<property category="archiving.micro" name="microEditionProfile" value="MIDP-2.0"/>
+<property category="archiving.micro" name="midlet-n-IconPath.1" value=""/>
+<property category="archiving.micro" name="midlet-n-MainClass.1" value="org.crosswire.flashcards.mobile.FlashCards"/>
+<property category="archiving.micro" name="midlet-n-Name.1" value="FlashCards"/>
+<property category="archiving.micro" name="midletIgnoreClasses.1" value="org.crosswire.flashcards.mobile.FlashCards"/>
+<property category="archiving.micro" name="midletName" value="FlashcardsMobile"/>
+<property category="archiving.micro" name="midletObfuscator" value="RetroGuard for J2ME"/>
+<property category="archiving.micro" name="midletVendor" value="CrossWire Bible Society"/>
+<property category="archiving.micro" name="midletVersion" value="1.0"/>
+</node>
+</project>

Added: trunk/micro/classes/org/crosswire/flashcards/lessons/lesson0.flash
===================================================================
--- trunk/micro/classes/org/crosswire/flashcards/lessons/lesson0.flash	                        (rev 0)
+++ trunk/micro/classes/org/crosswire/flashcards/lessons/lesson0.flash	2006-12-09 13:51:24 UTC (rev 103)
@@ -0,0 +1,77 @@
+word0=\u03BF\u0314
+freq0=2281
+answers0=that (11); which (10); He that (7); he that (6); he (4); him (3); to them (2); whosoever (1); who (1); which were (1); when (1); things (1); they that (1); they (1); them which (1); them (1); the (1); that are (1); some (1); my (1); his (1); him that (1); he, which (1); She (1); He tha (1); He (1); 
+word1=\u03BA\u03B1\u03B9\u0301
+freq1=864
+answers1=and (644); And (128); also (42); both (8); but (4); so (3); even (2); also. (2); also, (2); yet (1); yea, (1); when (1); to do with (1); nor (1); have (1); for (1); and, (1); and yet (1); and also (1); Yet (1); Even (1); But (1); 
+word2=\u03B1\u03C5\u0313\u03C4\u03BF\u0301\u03C2
+freq2=785
+answers2=him (220); his (119); unto him (78); them (58); unto them (48); he (24); unto them, (22); him, (22); unto him, (21); it (16); her (16); unto her (13); their (11); himself (10); them, (9); to him (6); they (6); him. (6); unto her, (4); thereof (4); of him (4); it, (4); His (4); to them (3); them. (3); unto his (2); to his (2); them: (2); on him (2); of them (2); his own (2); yourselves (1); with him. (1); with him (1); with her (1); whose (1); unto them; (1); unto them: (1); unto her. (1); to as (1); this (1); themselves. (1); themselves (1); them; (1); their sakes (1); the same (1); that he was (1); than his (1); shall I (1); sake (1); ourselves (1); of those (1); of them. (1); of it (1); of his (1); itself (1); it? (1); it up (1); him? (1); him: (1); he himself (1); for them (1); Jesus (1); He (1); 
+word3=\u03BF\u03C5\u0313
+freq3=290
+answers3=not (215); no (27); cannot (8); never (6); nothing (3); not. (3); neither (2); none (1); in no wise (1); Not (1); No. (1); No (1); Neither (1); Nay (1); 
+word4=\u03BB\u03B5\u0301\u03B3\u03C9
+freq4=269
+answers4=saith (75); said (36); I say (30); saying (18); he saith (15); sayest (7); He saith (7); say (5); he said (4); called (4); which is called (3); tell (3); saying, (3); saith, (3); saith he (3); said they (3); he spake (3); They say (3); Say (3); ye say (2); they said (2); that is called (2); spake (2); They said (2); She saith (2); which saith, (1); to say (1); they say (1); that saith (1); that (1); telleth (1); speakest (1); speak (1); sayest thou (1); said, (1); said unto (1); said that (1); of (1); is to say, (1); is to say (1); is called (1); he saith, (1); he had spoken (1); he had said (1); had said (1); and saith (1); Sayest (1); Peter saith (1); I tell (1); I speak (1); Henceforth I call (1); He spake (1); He saith, (1); He said (1); 
+word5=\u03BF\u0314\u0301\u03C4\u03B9
+freq5=268
+answers5=that (127); because (51); for (30); For (4); Because (4); how (3); That (3); because that (2); to the intent (1); seeing that (1); for that (1); 
+word6=\u0399\u0313\u03B7\u03C3\u03BF\u03C5\u0303\u03C2
+freq6=254
+answers6=Jesus (223); Jesus, (9); of Jesus (6); When Jesus (3); of Jesus, (2); Jesus. (2); upon Jesus (1); unto Jesus, (1); to Jesus, (1); that Jesus (1); of Jesus: (1); of Jesus. (1); for Jesus (1); Jesus' (1); JESUS (1); 
+word7=\u03B4\u03B5\u0301
+freq7=236
+answers7=And (64); but (43); But (37); Now (21); and (18); When (4); Then (3); Howbeit (3); for (2); also (2); So (2); yet (1); then (1); that (1); so (1); now (1); else (1); The (1); But when (1); And when (1); 
+word8=test word (said)
+freq8=223
+answers8=said (107); he said (15); I said (11); said, (8); said they (6); spake (4); They said (4); told (3); said he (3); had spoken (3); I have told (3); when she had (2); when he had said (2); they said (2); tell (2); spake he (2); he spake, (2); he spake (2); had (2); and said (2); I should say (2); He said (2); when he had spoken (1); when he (1); they said, (1); that which said (1); tell it (1); spoken, (1); spoken (1); spake he, (1); shall I say (1); saying, (1); saying (1); say (1); saith (1); said. (1); said unto (1); said I, (1); he said, (1); he had spoken (1); he had said (1); he called (1); hath said (1); had said (1); as he had said (1); When he had (1); Thou hast (1); Said I (1); I would have told (1); I told (1); I tell (1); I spake (1); I said, (1); I have said (1); He told (1); Hath (1); 
+word9=\u03B5\u0313\u03BD
+freq9=223
+answers9=in (164); at (14); on (7); among (7); In (7); with (4); through (4); into (2); At (2); wherein (1); when (1); one (1); herein (1); by (1); Herein (1); By (1); 
+word10=\u03BF\u03C5\u0313\u0342\u03BD
+freq10=203
+answers10=Then (92); therefore (50); then (19); Therefore (8); So (7); therefore, (5); and (2); When (2); Now (2); then, (1); that (1); is it then (1); but (1); Then when (1); The people (1); So when (1); Now when (1); But (1); 
+word11=\u03B5\u03B9\u0313\u03C2
+freq11=190
+answers11=into (64); on (34); unto (22); to (20); in (19); for (7); among (2); whither (1); up to (1); toward (1); one (1); of against (1); forth (1); back (1); at (1); against (1); To (1); For (1); 
+word12=\u03B5\u0313\u0301\u03C1\u03C7\u03BF\u03BC\u03B1\u03B9
+freq12=169
+answers12=come (28); cometh (23); came (23); am come (5); was (4); coming (4); cometh, (4); they came (3); is come, (3); is come (3); came I (3); were come (2); went (2); was coming (2); was come (2); there came (2); that cometh (2); shall come (2); is coming (2); he that cometh (2); cometh he (2); I will come (2); I come, (2); I came (2); He came (2); Come (2); will (1); which should come (1); which came (1); when he was come (1); when (1); we will come (1); to come. (1); thou art (1); that should come (1); should come (1); shall come, (1); shall (1); resorted (1); let him come (1); it cometh (1); is come; (1); is come: (1); is (1); him that cometh (1); he will (1); he was come (1); he that came (1); go (1); come, (1); come I (1); came. (1); came there (1); came in (1); am coming (1); am (1); They came (1); There cometh (1); I had (1); I come (1); I am (1); He that cometh (1); 
+word13=\u03B5\u0313\u03C3\u03C4\u03B9\u0301
+freq13=168
+answers13=is (96); it is (10); are (10); it was (8); he is (8); there is (5); Is (4); It is (3); He is (3); is he (2); There is (2); ye have (1); was (1); to be (1); they are (1); there are (1); should (1); it be (1); is it (1); he were (1); he was (1); he hath been (1); he be (1); he (1); am (1); There are (1); Is it (1); 
+word14=\u03B5\u0313\u03BA
+freq14=162
+answers14=of (90); from (37); out of (16); with (2); out (2); among (2); by (1); at (1); again (1); Since (1); Of (1); From (1); And from (1); 
+word15=\u03BF\u0314\u0301\u03C2
+freq15=161
+answers15=which (49); that (31); whom (24); whose (5); what (5); the which (3); he whom (3); who (2); wherewith (2); whatsoever (2); what things (2); to whom (2); of whom (2); him whom (2); What (2); whosoever (1); while (1); whereinto (1); was (1); thou (1); those whom (1); those that (1); they (1); them which (1); the things which (1); the same (1); that whereon (1); not (1); him, whom (1); he of whom (1); he (1); Which (1); Whatsoever (1); That (1); 
+word16=\u03B9\u0314\u0301\u03BD\u03B1
+freq16=147
+answers16=that (108); to (22); That (8); lest (4); for (2); 
+word17=\u03B5\u03B9\u0313\u0301\u03B4\u03C9
+freq17=145
+answers17=know (18); I know (13); knew (11); see (9); saw (9); we know (8); Behold (7); ye know (5); knowing (4); knoweth (4); knowest (4); behold (4); they know (3); tell (3); he saw (3); when they saw (2); Ye (2); I saw (2); ye should have known (1); ye see (1); ye saw (1); ye had known (1); wist (1); when they had seen (1); we may see (1); we do know (1); we (1); thou shalt see (1); thou knowest (1); thou knewest (1); they should (1); they might see (1); they knew (1); seen, (1); seeing (1); look (1); lo (1); knowest thou (1); he saw, (1); he knew (1); have (1); canst (1); behold, (1); are we sure (1); and saw that (1); When (1); We know (1); Lo, (1); I shall see (1); I knew (1); Did (1); Behold, (1); 
+word18=\u03B5\u0313\u03B3\u03C9\u0301
+freq18=142
+answers18=I (142); 
+word19=\u03C0\u03B1\u03C4\u03B7\u0301\u03C1
+freq19=140
+answers19=the Father (53); Father (35); father (9); Father, (7); Father's (6); the Father, (5); of the Father (4); fathers (4); the Father. (3); the father (2); the Father's (2); the fathers (1); the Father? (1); the (1); of (1); my Father (1); The Father (1); O Father, (1); Father; (1); Father: (1); Father. (1); 
+word20=\u03BC\u03B7\u0301
+freq20=117
+answers20=not (53); but (3); Except (3); nothing (2); except (2); not; (1); not, (1); never (1); lest (1); also (1); Shall (1); Not (1); 
+word21=\u03C0\u03B9\u03C3\u03C4\u03B5\u03C5\u0301\u03C9
+freq21=114
+answers21=believe (22); believed (14); believeth (8); ye believe (7); He that believeth (5); he that believeth (3); did (3); ye might believe (2); ye may believe (2); ye believed (2); we believe (2); shall ye believe (2); might believe. (2); Believest thou (2); yet they believed (1); ye would have believed (1); ye will (1); will believe (1); which shall believe (1); which believed (1); thou wouldest believe (1); thou hast believed: (1); those (1); they that believe (1); they may believe (1); they have believed (1); they believed (1); they believe (1); that believed (1); that believe (1); may believe (1); he hath (1); have believed. (1); have believed (1); hath believed (1); do (1); commit (1); believing (1); believest thou (1); believed. (1); believe? (1); believe. (1); I will (1); I might believe (1); I believe (1); He (1); Have (1); Dost (1); Do ye (1); Believe (1); 
+word22=\u03C0\u03BF\u03B9\u03B5\u0301\u03C9
+freq22=111
+answers22=do (22); did (8); doeth (7); made (5); make (3); had done (3); I do (3); ye do (2); will they do (2); thou doest (2); shall he do (2); makest (2); he made (2); he did (2); doest (2); did, (2); I have done (2); I did (2); ye would do (1); will he do (1); will do (1); will I do (1); who had made (1); which had made (1); when he had made (1); to execute (1); though (1); thou do (1); they that have done (1); they made (1); they had done (1); should do (1); shewest (1); shall we do (1); making (1); maketh (1); keepeth (1); he that doeth (1); he had done (1); he doeth (1); have done (1); have caused (1); hath done (1); hast thou done? (1); done (1); doeth: (1); do. (1); do we (1); did. (1); did he (1); committeth (1); They shall put (1); Make (1); I have made (1); I had (1); He that made (1); 
+word23=\u03BC\u03BF\u03C5
+freq23=110
+answers23=my (90); me (10); mine (4); My (3); than I (1); mine own (1); me. (1); 
+word24=\u03B7\u0313\u0342\u03BD
+freq24=110
+answers24=was (47); were (11); it was (10); he was (10); there was (9); ye were (2); thou hadst been (2); they were (2); there were (2); It was (2); He was (2); was, (1); thou wast (1); they were, (1); that was (1); it were (1); he had been (1); There were (1); There was (1); 
+wordCount=25
+lessonTitle=Set 1 freq(2281-110)


Property changes on: trunk/micro/classes/org/crosswire/flashcards/lessons/lesson0.flash
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/micro/classes/org/crosswire/flashcards/lessons/lesson1.flash
===================================================================
--- trunk/micro/classes/org/crosswire/flashcards/lessons/lesson1.flash	                        (rev 0)
+++ trunk/micro/classes/org/crosswire/flashcards/lessons/lesson1.flash	2006-12-09 13:51:24 UTC (rev 103)
@@ -0,0 +1,77 @@
+word0=\u03C5\u0314\u03BC\u03B9\u0342\u03BD
+freq0=103
+answers0=unto you (40); you (27); unto you, (10); unto you. (7); you. (4); you, (4); to you (3); for you (3); ye (1); with you (1); unto you: (1); unto (1); to you, (1); 
+word1=\u03B1\u0313\u03BB\u03BB\u03B1\u0301
+freq1=103
+answers1=but (85); But (13); yea, (1); nevertheless (1); but, (1); Nevertheless (1); Howbeit (1); 
+word2=\u03C0\u03C1\u03BF\u0301\u03C2
+freq2=101
+answers2=unto (47); to (40); among (5); at (4); with (2); for (1); 
+word3=\u03BC\u03B5
+freq3=101
+answers3=me (79); me, (7); me? (6); me. (4); me: (3); me; (1); I (1); 
+word4=\u03B5\u0313\u0301\u03C7\u03C9
+freq4=91
+answers4=hath (14); ye have (9); have (9); I have (9); thou hast (4); they might have (4); had (4); ye might have (3); they had (2); having (2); hast (2); ye should have (1); ye shall have (1); which had (1); we have (1); to have (1); thou hast had (1); thou (1); they have (1); shall have (1); save (1); old (1); may have (1); is of (1); he had been (1); he had (1); he began (1); have ye (1); hast thou (1); We have (1); Thou hast (1); Thou couldest have (1); Thou art (1); They have (1); I had (1); He that hath (1); He is (1); He hath (1); 
+word5=\u03B8\u03B5\u03BF\u0301\u03C2
+freq5=85
+answers5=God (43); of God (29); God. (5); gods (2); God, (2); with God (1); of the (1); of God; (1); of God. (1); 
+word6=\u03BC\u03B1\u03B8\u03B7\u03C4\u03B7\u0301\u03C2
+freq6=83
+answers6=disciples (43); the disciples (9); disciple (5); disciples. (4); disciple, (4); the disciple (3); disciples, (3); to the disciples (2); disciples? (2); to the disciple, (1); to (1); that disciple (1); of the disciples (1); of (1); his disciples (1); disciple: (1); a disciple (1); 
+word7=\u03BA\u03BF\u0301\u03C3\u03BC\u03BF\u03C2
+freq7=82
+answers7=the world (34); the world, (14); world (10); the world. (5); of the world (5); of (3); unto the world (2); the world: (2); world: (1); world, (1); to the world; (1); to the world (1); of the world. (1); even the world (1); The world (1); 
+word8=\u03C4\u03B9\u0301\u03C2
+freq8=81
+answers8=what (18); What (17); who (12); why (5); Who (5); whom (4); Why (4); Whom (2); whose (1); which (1); wherefore (1); what things (1); to whom (1); thing (1); how (1); for what intent (1); any (1); Why was (1); Which (1); 
+word9=\u03B1\u0313\u03C0\u03BF\u03BA\u03C1\u03B9\u0301\u03BD\u03BF\u03BC\u03B1\u03B9
+freq9=78
+answers9=answered (61); They answered (7); answered, (6); He answered (2); he answered (1); Answerest thou (1); 
+word10=\u03B4\u03B9\u0301\u03B4\u03C9\u03BC\u03B9
+freq10=76
+answers10=thou gavest (7); gave (7); thou hast given (6); giveth (6); give (6); hath given (4); given (4); will give (3); Give (3); shall give (2); he should give (2); he gave (2); have given (2); had given (2); I have given (2); I give (2); we may give (1); was given (1); they smote (1); struck (1); he would have given (1); he will give (1); he shall give (1); he may give it (1); he hath given (1); hath he given (1); hath committed (1); hast given (1); gave he (1); I shall give (1); He gave (1); Did (1); 
+word11=\u03BF\u03C5\u0314\u0342\u03C4\u03BF\u03C2
+freq11=74
+answers11=this (29); This (16); this man (8); he (6); these (4); the same (4); The same (4); they (1); than this, (1); He (1); 
+word12=\u0399\u0313\u03BF\u03C5\u03B4\u03B1\u03B9\u0342\u03BF\u03C2
+freq12=71
+answers12=the Jews (33); of the Jews (9); The Jews (8); the Jews' (2); of the Jews? (2); of the Jews, (2); unto the Jews, (1); unto the Jews (1); to the Jews: (1); to the Jews, (1); the Jews, (1); of the Jews; (1); of the Jews: (1); of the Jews. (1); of the Jews' (1); of the Jews! (1); of Judaea (1); a Jew? (1); a Jew (1); OF THE JEWS. (1); Jews (1); 
+word13=\u03B5\u0313\u03BA\u03B5\u03B9\u0342\u03BD\u03BF\u03C2
+freq13=70
+answers13=he (17); that (15); He (11); the same (7); they (5); him (3); that same (2); his (2); those (1); them (1); she (1); of that (1); he, (1); She, (1); 
+word14=\u03C0\u03B5\u03C1\u03B9\u0301
+freq14=69
+answers14=of (45); for (12); concerning (4); Of (3); at (2); to (1); about (1); For (1); 
+word15=\u03C5\u0314\u03BC\u03B5\u03B9\u0342\u03C2
+freq15=68
+answers15=ye (56); Ye (10); ye, (1); Ye have (1); 
+word16=\u03C0\u03B1\u0342\u03C2
+freq16=65
+answers16=all (26); all things (12); whosoever (6); every (4); Whosoever (2); Every (2); All things (2); they all (1); them all (1); many as (1); every one (1); all things; (1); all things, (1); all the things (1); Every one (1); Every man (1); All that (1); All (1); 
+word17=\u03B3\u03B1\u0301\u03C1
+freq17=65
+answers17=for (29); For (27); (for (3); because (2); Why (1); And (1); 
+word18=\u03BB\u03B1\u03BB\u03B5\u0301\u03C9
+freq18=64
+answers18=spake (11); speak (7); have I spoken (4); I speak (4); I have spoken (4); speaketh (3); spoken (2); he speaketh (2); I have said (2); to say (1); that talketh (1); that speak (1); talkest thou (1); talk (1); speakest thou (1); speak unto (1); shall speak (1); shall he speak: (1); he talked (1); he spake (1); he shall (1); he saith. (1); have I told (1); have I said (1); have (1); hath told (1); We speak (1); Speakest thou (1); I will (1); I should speak (1); I shall (1); I said (1); He that speaketh (1); As (1); 
+word19=\u03B1\u0313\u03BA\u03BF\u03C5\u0301\u03C9
+freq19=64
+answers19=heard (15); hear (8); heareth (5); I have heard (3); when they heard (2); thou hearest (2); shall hear (2); did (2); ye hear (1); ye (1); when they had heard (1); we have heard (1); was it (1); voice (1); thou hast heard (1); they which heard (1); they that hear (1); they shall hear (1); they heard that (1); that hath heard (1); she heard (1); it hear (1); heard me, (1); hear ye (1); he shall hear, (1); he heareth (1); he had heard (1); have heard (1); had heard (1); Ye have heard (1); Ye have (1); When (1); I hear (1); 
+word20=\u03B4\u03B9\u03B1\u0301
+freq20=64
+answers20=for (14); by (10); therefore (8); because (8); through (6); Therefore (5); cause (2); Why (2); why (1); thereby (1); that by reason of (1); sakes (1); sake (1); because of (1); For (1); 
+word21=\u03B3\u03B9\u03BD\u03C9\u0301\u03C3\u03BA\u03C9
+freq21=64
+answers21=knew (10); know (6); known (4); knoweth (3); have known (3); ye may know (2); ye know (2); understood (2); may know (2); knowest (2); yet hast thou (1); ye should have known (1); ye shall know (1); ye have (1); ye had known (1); who knoweth (1); we know (1); understand (1); thou shalt know (1); they might know (1); they have known (1); they have (1); shall ye know (1); shall know (1); shall (1); perceived (1); knowest thou (1); know I (1); he shall know (1); hath (1); do ye (1); are sure (1); am known (1); They understood (1); Know ye (1); I know (1); 
+word22=\u03C4\u03B1\u03C5\u0342\u03C4\u03B1
+freq22=62
+answers22=these things (23); These things (13); thus (5); these words (3); these (3); These (3); this (2); they (2); those things (1); these words, (1); these things: (1); such things (1); so (1); These words (1); 
+word23=\u03C3\u03C5\u0301
+freq23=62
+answers23=thou (54); Thou (5); thou? (2); thou, (1); 
+word24=\u03B5\u0313\u03B1\u0301\u03BD
+freq24=61
+answers24=if (24); If (21); except (4); Except (3); whomsoever (1); 
+wordCount=25
+lessonTitle=Set 2 freq(103-61)


Property changes on: trunk/micro/classes/org/crosswire/flashcards/lessons/lesson1.flash
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/micro/doc/org/crosswire/flashcards/mobile/FlashCards.html
===================================================================
--- trunk/micro/doc/org/crosswire/flashcards/mobile/FlashCards.html	                        (rev 0)
+++ trunk/micro/doc/org/crosswire/flashcards/mobile/FlashCards.html	2006-12-09 13:51:24 UTC (rev 103)
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<HTML><!--JBuilder QuickDoc-->
+<HEAD>
+<TITLE>Class org.crosswire.flashcards.mobile.FlashCards</TITLE><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
+</HEAD>
+<BODY>
+
+<H2>
+<FONT SIZE="-1">org.crosswire.flashcards.mobile</FONT>
+<BR>Class FlashCards</H2>
+<DL>
+<DT>public class <B>FlashCards</B><DT>extends javax.microedition.midlet.MIDlet
+</DL>
+<DL><DD><p>Title: </p> <p>Description: </p> <p>Copyright: Copyright (c) 2006</p> <p>Company: </p><DL><DD></DD></DL></DD>
+</DL>
+<DL><DT><B>Version:</B><DD>1.0</DD>
+<DT><B>Author:</B><DD>not attributable</DD>
+</DL>
+</BODY>
+</HTML>
\ No newline at end of file

Added: trunk/micro/src/org/crosswire/flashcards/MicroLesson.java
===================================================================
--- trunk/micro/src/org/crosswire/flashcards/MicroLesson.java	                        (rev 0)
+++ trunk/micro/src/org/crosswire/flashcards/MicroLesson.java	2006-12-09 13:51:24 UTC (rev 103)
@@ -0,0 +1,76 @@
+/*
+ * Distribution Licence:
+ * FlashCard is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General Public License,
+ * version 2 as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU General Public License for more details.
+ * The License is available on the internet at:
+ *     http://www.gnu.org/copyleft/gpl.html,
+ * or by writing to:
+ *     Free Software Foundation, Inc.
+ *     59 Temple Place - Suite 330
+ *     Boston, MA 02111-1307, USA
+ *
+ *
+ * Copyright: 2006 CrossWire Bible Society
+ */
+
+package org.crosswire.flashcards;
+
+import java.util.Vector;
+
+/**
+ * A Lesson is an ordered list of FlashCards.
+ * The lesson also has a description which is useful for showing to a user.
+ *
+ * @author Troy A. Griffitts [scribe at crosswire dot org]
+ */
+public class MicroLesson
+    extends Lesson {
+
+  public MicroLesson(String url) throws Exception {
+    super(url);
+  }
+
+  public MicroLesson(String url, String description) throws Exception {
+    super(url, description);
+  }
+
+  /**
+   * Load this lesson from persistent store named by the lesson's <code>filename</code>.
+   */
+  public void load() throws Exception {
+    Properties lesson = new Properties();
+    lesson.load(getURL());
+    int wordCount = Integer.parseInt(lesson.getProperty("wordCount"));
+    setDescription(lesson.getProperty("lessonTitle",
+                                      getURL().substring(getURL().
+        lastIndexOf('/') + 1)));
+
+    int baseOffset = getURL().lastIndexOf('/');
+    if (baseOffset < 0) {
+      baseOffset = getURL().lastIndexOf( ('\\'));
+    }
+    String lname = getURL().substring(baseOffset + 1);
+    lname = lname.substring(0, lname.indexOf(".flash"));
+    String audioPath = getURL().substring(0, baseOffset) + "/audio";
+    String imagePath = getURL().substring(0, baseOffset) + "/images";
+
+    for (int i = 0; i < wordCount; i++) {
+      FlashCard f = new FlashCard(lesson.getProperty("word" + i),
+                                  lesson.getProperty("answers" + i));
+      String audioURLString = audioPath + "/" + lname + "_" +
+          Integer.toString(i) + ".wav";
+      String imageURLString = imagePath + "/" + lname + "_" +
+          Integer.toString(i) + ".png";
+      f.setAudioURL(audioURLString);
+      f.setImageURL(imageURLString);
+      add(f);
+    }
+    setModified(false);
+  }
+}

Added: trunk/micro/src/org/crosswire/flashcards/MicroLessonSet.java
===================================================================
--- trunk/micro/src/org/crosswire/flashcards/MicroLessonSet.java	                        (rev 0)
+++ trunk/micro/src/org/crosswire/flashcards/MicroLessonSet.java	2006-12-09 13:51:24 UTC (rev 103)
@@ -0,0 +1,52 @@
+/*
+ * Distribution Licence:
+ * FlashCard is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General Public License,
+ * version 2 as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU General Public License for more details.
+ * The License is available on the internet at:
+ *     http://www.gnu.org/copyleft/gpl.html,
+ * or by writing to:
+ *     Free Software Foundation, Inc.
+ *     59 Temple Place - Suite 330
+ *     Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2006 CrossWire Bible Society
+ */
+package org.crosswire.flashcards;
+
+
+/**
+ * A <code>LessonSet</code> is an ordered list of <code>Lesson</code>s.
+ * The lessons are sorted by filename.
+ * The lesson set also has a description which is useful for showing to a user
+ * and a directory name where its Lessons are stored. This directory name is expected to be a relative
+ * path and will be stored either in a jar or in the user's FlashCard directory.
+ *
+ * @author Troy A. Griffitts [scribe at crosswire dot org]
+ */
+public class MicroLessonSet extends LessonSet {
+
+     public MicroLessonSet(String url) {
+          super(url);
+     }
+
+
+     /**
+      * Load this lesson set from persistent store named by the lesson set's <code>dirname</code>.
+      * This is the union of lessons in the Jar and in the user's flashcard home directory.
+      */
+     protected void load() {
+		for (int i = 0; true; i++) {
+			String path = getURL() + "/" + "lesson" + Integer.toString(i) + ".flash";
+			try {
+				add(new MicroLesson(path));
+			}
+			catch (Exception e) { break; }
+		}
+     }
+}

Added: trunk/micro/src/org/crosswire/flashcards/Properties.java
===================================================================
--- trunk/micro/src/org/crosswire/flashcards/Properties.java	                        (rev 0)
+++ trunk/micro/src/org/crosswire/flashcards/Properties.java	2006-12-09 13:51:24 UTC (rev 103)
@@ -0,0 +1,122 @@
+package org.crosswire.flashcards;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Hashtable;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2006</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class Properties {
+
+  private Hashtable values = new Hashtable();
+
+  public Properties() {
+  }
+
+  public void load(String filename) throws Exception {
+    InputStream is = null;
+    Class c = this.getClass();
+    is = c.getResourceAsStream(filename);
+    if (is == null) {
+      throw new Exception("File Does Not Exist");
+    }
+    load(is);
+  }
+
+  public void load(InputStream is) {
+    String content = getInputStreamContents(is);
+    int[] pos = new int[1];
+    pos[0] = 0;
+    for (String line = getLine(content, pos); pos[0] > -1;
+         line = getLine(content, pos)) {
+
+      // skip comments
+      if (line.startsWith("#")) {
+        continue;
+      }
+
+      int divider = line.indexOf('=');
+
+      // skip invalid lines
+      if (divider < 0) {
+        continue;
+      }
+
+      String key = line.substring(0, divider);
+      String value = line.substring(divider + 1);
+      setProperty(key, value);
+    }
+
+  }
+
+  public void setProperty(String key, String value) {
+    values.put(key, value);
+  }
+
+  public String getProperty(String key) {
+    return getProperty(key, null);
+  }
+
+  public String getProperty(String key, String defaultValue) {
+    String ret = (String) values.get(key);
+    return (ret != null) ? ret : defaultValue;
+  }
+
+  private String getLine(String content, int[] pos) {
+    int start = pos[0];
+    int end = content.indexOf('\r', start);
+    if (end < 0) {
+      end = content.indexOf('\n', start);
+    }
+    pos[0] = (end > -1) ? end + 1 : end;
+    String line = (end > -1) ? content.substring(start, end) :
+        content.substring(start);
+    return processUnicode(line.trim());
+  }
+
+  private String processUnicode(String in) {
+    int offset = 0;
+    while (true) {
+      offset = in.indexOf("\\u");
+      if ((offset < 0) || (offset > in.length() - 5)) {
+        break;
+      }
+      String val = in.substring(offset+2,offset+6);
+      short valueAsShort = Short.parseShort(val.trim(),16);
+      in = in.substring(0,offset) + (char)valueAsShort + in.substring(offset+6);
+    }
+    return in;
+  }
+
+  private String getInputStreamContents(InputStream is) {
+    InputStreamReader isr = null;
+    StringBuffer buffer = null;
+    try {
+      isr = new InputStreamReader(is, "UTF8");
+
+      buffer = new StringBuffer();
+      int ch;
+      while ( (ch = isr.read()) > -1) {
+        buffer.append( (char) ch);
+      }
+      if (isr != null) {
+        isr.close();
+      }
+    }
+    catch (Exception ex) {
+      System.out.println(ex);
+    }
+    return buffer.toString();
+
+  }
+}

Added: trunk/micro/src/org/crosswire/flashcards/mobile/FlashCards.java
===================================================================
--- trunk/micro/src/org/crosswire/flashcards/mobile/FlashCards.java	                        (rev 0)
+++ trunk/micro/src/org/crosswire/flashcards/mobile/FlashCards.java	2006-12-09 13:51:24 UTC (rev 103)
@@ -0,0 +1,46 @@
+package org.crosswire.flashcards.mobile;
+
+import javax.microedition.midlet.*;
+import javax.microedition.lcdui.*;
+
+import org.crosswire.flashcards.*;
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2006</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class FlashCards extends MIDlet {
+  static FlashCards instance;
+  public LessonGroups lessonGroups = new LessonGroups();
+  public Lessons lessons = new Lessons();
+  public Quiz quiz = new Quiz();
+  public LessonSet lessonSet = new MicroLessonSet("lessons");
+  public FlashCards() {
+    instance = this;
+    lessonSet.setDescription("Greek Top Freq");
+  }
+
+  public void startApp() {
+    lessonGroups.show();
+  }
+
+  public void pauseApp() {
+  }
+
+  public void destroyApp(boolean unconditional) {
+  }
+
+  public static void quitApp() {
+    instance.destroyApp(true);
+    instance.notifyDestroyed();
+    instance = null;
+  }
+
+}

Added: trunk/micro/src/org/crosswire/flashcards/mobile/FlashCards.jbx
===================================================================
--- trunk/micro/src/org/crosswire/flashcards/mobile/FlashCards.jbx	                        (rev 0)
+++ trunk/micro/src/org/crosswire/flashcards/mobile/FlashCards.jbx	2006-12-09 13:51:24 UTC (rev 103)
@@ -0,0 +1,8 @@
+[PropertyInfo]
+displayable,org.crosswire.flashcards.mobile.LessonGroups,false,false, , ,false,<default>
+instance,org.crosswire.flashcards.mobile.FlashCards,false,false, , ,false,<default>
+[IconNames]
+
+
+
+

Added: trunk/micro/src/org/crosswire/flashcards/mobile/LessonGroups.java
===================================================================
--- trunk/micro/src/org/crosswire/flashcards/mobile/LessonGroups.java	                        (rev 0)
+++ trunk/micro/src/org/crosswire/flashcards/mobile/LessonGroups.java	2006-12-09 13:51:24 UTC (rev 103)
@@ -0,0 +1,62 @@
+package org.crosswire.flashcards.mobile;
+
+import javax.microedition.lcdui.*;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2006</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class LessonGroups extends Form implements CommandListener {
+  public LessonGroups() {
+    super("Choose a Lesson Group");
+    try {
+      jbInit();
+    }
+    catch(Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  private void jbInit() throws Exception {
+    // Set up this Displayable to listen to command events
+    setCommandListener(this);
+    // add the Exit command
+    addCommand(new Command("Exit", Command.EXIT, 1));
+    addCommand(new Command("Select", Command.SCREEN, 2));
+    lessonGroupChoice.setLabel("Lesson Groups");
+    this.append(lessonGroupChoice);
+  }
+
+  void show() {
+    loadLessonGroups();
+    Display.getDisplay(FlashCards.instance).setCurrent(this);
+  }
+
+  public void commandAction(Command command, Displayable displayable) {
+    /** @todo Add command handling code */
+    if (command.getCommandType() == Command.EXIT) {
+      // stop the MIDlet
+      FlashCards.quitApp();
+    }
+    else if (command.getCommandType() == Command.SCREEN) {
+      if (command.getPriority() == 2) {
+        FlashCards.instance.lessons.show();
+      }
+    }
+  }
+
+  ChoiceGroup lessonGroupChoice = new ChoiceGroup("", ChoiceGroup.EXCLUSIVE);
+
+  public void loadLessonGroups() {
+    lessonGroupChoice.deleteAll();
+    lessonGroupChoice.append(FlashCards.instance.lessonSet.getDescription(), null);
+  }
+}

Added: trunk/micro/src/org/crosswire/flashcards/mobile/Lessons.java
===================================================================
--- trunk/micro/src/org/crosswire/flashcards/mobile/Lessons.java	                        (rev 0)
+++ trunk/micro/src/org/crosswire/flashcards/mobile/Lessons.java	2006-12-09 13:51:24 UTC (rev 103)
@@ -0,0 +1,73 @@
+package org.crosswire.flashcards.mobile;
+
+import javax.microedition.lcdui.*;
+import java.util.Vector;
+import org.crosswire.flashcards.Lesson;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2006</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class Lessons extends Form implements CommandListener {
+
+  ChoiceGroup lessonChoice = new ChoiceGroup("", ChoiceGroup.EXCLUSIVE);
+
+  public Lessons() {
+    super("Choose Lessons");
+    try {
+      jbInit();
+    }
+    catch(Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  private void jbInit() throws Exception {
+    // Set up this Displayable to listen to command events
+    setCommandListener(this);
+    // add the Exit command
+    addCommand(new Command("Back", Command.BACK, 1));
+    addCommand(new Command("Start", Command.SCREEN, 2));
+    lessonChoice.setLabel("Lesson Group Title");
+    this.append(lessonChoice);
+  }
+
+  void show() {
+    loadLessons();
+    Display.getDisplay(FlashCards.instance).setCurrent(this);
+  }
+
+
+  public void commandAction(Command command, Displayable displayable) {
+    /** @todo Add command handling code */
+    if (command.getCommandType() == Command.BACK) {
+      FlashCards.instance.lessonGroups.show();
+    }
+    else if (command.getCommandType() == Command.SCREEN) {
+      if (command.getPriority() == 2) {
+	FlashCards.instance.quiz.show();
+      }
+    }
+  }
+
+  public void loadLessons() {
+    int lessonGroup = FlashCards.instance.lessonGroups.lessonGroupChoice.getSelectedIndex();
+    String lessonGroupName = FlashCards.instance.lessonGroups.lessonGroupChoice.getString(lessonGroup);
+    lessonChoice.setLabel(lessonGroupName);
+    lessonChoice.deleteAll();
+    Vector lessons = FlashCards.instance.lessonSet.getLessons();
+    for (int i = 0; i < lessons.size(); i++) {
+       Lesson l = (Lesson) lessons.elementAt(i);
+      lessonChoice.append(l.getDescription(), null);
+    }
+  }
+
+}

Added: trunk/micro/src/org/crosswire/flashcards/mobile/Quiz.java
===================================================================
--- trunk/micro/src/org/crosswire/flashcards/mobile/Quiz.java	                        (rev 0)
+++ trunk/micro/src/org/crosswire/flashcards/mobile/Quiz.java	2006-12-09 13:51:24 UTC (rev 103)
@@ -0,0 +1,126 @@
+package org.crosswire.flashcards.mobile;
+
+import javax.microedition.lcdui.*;
+import org.crosswire.flashcards.Lesson;
+import org.crosswire.flashcards.Quizer;
+import org.crosswire.flashcards.FlashCard;
+import java.util.Vector;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2006</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class Quiz extends Form implements CommandListener {
+
+  StringItem wordDisplay = new StringItem("", "");
+  ChoiceGroup answersDisplay = new ChoiceGroup("", ChoiceGroup.EXCLUSIVE);
+  StringItem statusBar = new StringItem("", "");
+  Spacer spacer1 = new Spacer(0, 0);
+  Spacer spacer2 = new Spacer(0, 0);
+  Quizer quizer = new Quizer();
+  FlashCard currentWord = null;
+  int wrongThisTime = 0;
+
+  public Quiz() {
+    super("Quiz");
+    try {
+      jbInit();
+    }
+    catch(Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  private void jbInit() throws Exception {
+    // Set up this Displayable to listen to command events
+    setCommandListener(this);
+    addCommand(new Command("End", Command.BACK, 1));
+    addCommand(new Command("Answer", Command.SCREEN, 2));
+    wordDisplay.setLayout(Item.LAYOUT_CENTER | Item.LAYOUT_TOP |
+                          Item.LAYOUT_NEWLINE_BEFORE |
+                          Item.LAYOUT_NEWLINE_AFTER);
+    wordDisplay.setText("Word");
+    this.append(spacer1);
+    this.append(wordDisplay);
+    this.append(spacer2);
+    this.append(answersDisplay);
+    this.append(statusBar);
+    answersDisplay.setLabel("Answers");
+    answersDisplay.setLayout(Item.LAYOUT_CENTER | Item.LAYOUT_VCENTER |
+                             Item.LAYOUT_VEXPAND);
+    statusBar.setLayout(Item.LAYOUT_BOTTOM | Item.LAYOUT_VEXPAND |
+                        Item.LAYOUT_NEWLINE_BEFORE);
+    statusBar.setText("StatusBar");
+//    spacer1.setPreferredSize();
+    spacer1.setMinimumSize(2, 2);
+  }
+
+  void show() {
+    int lessonNum = FlashCards.instance.lessons.lessonChoice.getSelectedIndex();
+    String lessonName = FlashCards.instance.lessons.lessonChoice.getString(lessonNum);
+    Lesson l = FlashCards.instance.lessonSet.getLesson(lessonName);
+    quizer.clear();
+    quizer.loadLesson(l);
+    wordDisplay(-1, "Begin");
+    Display.getDisplay(FlashCards.instance).setCurrent(this);
+  }
+
+  public void commandAction(Command command, Displayable displayable) {
+    if (command.getCommandType() == Command.BACK) {
+	Display.getDisplay(FlashCards.instance).setCurrent(FlashCards.instance.lessons);
+    }
+    else if (command.getCommandType() == Command.SCREEN) {
+      if (command.getPriority() == 2) {
+        // show answer
+        // for now let's use this as our answer picker button
+        int a = answersDisplay.getSelectedIndex();
+        String ans = answersDisplay.getString(a);
+        String right = currentWord.getBack();
+	if (right.length() > 23) {
+	  right = right.substring(0, 21) + "...";
+	}
+        if (ans.equals(right)) {
+          wordDisplay(wrongThisTime, "Correct");
+        }
+        else {
+          setStatus("Wrong. Try again.");
+          wrongThisTime++;
+        }
+      }
+    }
+  }
+
+
+  public void wordDisplay(int wrong, String status) {
+    currentWord = quizer.getRandomWord(wrong);
+    // we do this here cuz we first need to update stats from line above this
+    wrongThisTime = 0;
+    if (status != null) setStatus(status);
+    if (currentWord == null) {
+      setStatus("Great Job!");
+      return;
+    }
+    wordDisplay.setText(currentWord.getFront());
+    Vector answers = quizer.getRandomAnswers(4);
+    answersDisplay.deleteAll();
+    for (int i = 0; i < answers.size(); i++) {
+      String a = (String) answers.elementAt(i);
+      if (a.length() > 23) {
+        a = a.substring(0, 21) + "...";
+      }
+      answersDisplay.append(a, null);
+    }
+  }
+
+  private void setStatus(String text) {
+    statusBar.setText(text + " | " + Integer.toString(quizer.getNotLearnedCount()) + " | " + Integer.toString(quizer.getTotalAsked() - quizer.getTotalWrong()) + "/" + Integer.toString(quizer.getTotalAsked()) + "("+quizer.getPercentage()+"%)");
+  }
+}

Modified: trunk/src/org/crosswire/flashcards/FlashCard.java
===================================================================
--- trunk/src/org/crosswire/flashcards/FlashCard.java	2006-12-09 00:53:32 UTC (rev 102)
+++ trunk/src/org/crosswire/flashcards/FlashCard.java	2006-12-09 13:51:24 UTC (rev 103)
@@ -15,8 +15,7 @@
  *     59 Temple Place - Suite 330
  *     Boston, MA 02111-1307, USA
  *
- * The copyright to this program is held by it's authors
- * Copyright: 2004
+ * Copyright 2006: CrossWire Bible Society
  */
 package org.crosswire.flashcards;
 
@@ -36,6 +35,7 @@
   private final String front = "front";
   private final String back = "back";
   private final String audioURL = "audioURL";
+  private final String imageURL = "imageURL";
 
   /**
    * Create a partial FlashCard.
@@ -105,6 +105,14 @@
     values.put(audioURL, newAudioURL);
   }
 
+  public String getImageURL() {
+    return (String) values.get(imageURL);
+  }
+
+  public void setImageURL(String newImageURL) {
+    values.put(imageURL, newImageURL);
+  }
+
   /**
    * Method reset
    */

Modified: trunk/src/org/crosswire/flashcards/Lesson.java
===================================================================
--- trunk/src/org/crosswire/flashcards/Lesson.java	2006-12-09 00:53:32 UTC (rev 102)
+++ trunk/src/org/crosswire/flashcards/Lesson.java	2006-12-09 13:51:24 UTC (rev 103)
@@ -63,8 +63,8 @@
      /**
       * Construct a new, empty lesson.
       */
-     public Lesson() {
-          this("NewLesson.flash", "New Lesson");
+     public Lesson() throws Exception {
+         this("NewLesson.flash", "New Lesson");
      }
 
 
@@ -72,7 +72,7 @@
       * Construct a lesson from URL.
       * @param url
       */
-     public Lesson(String url) {
+     public Lesson(String url) throws Exception {
           this(url, null);
      }
 
@@ -82,7 +82,7 @@
       * @param url
       * @param description
       */
-     public Lesson(String url, String description) {
+     public Lesson(String url, String description) throws Exception {
           this.url = url;
           load();
 
@@ -95,7 +95,7 @@
      /**
       * Load this lesson from persistent store named by the lesson's <code>filename</code>.
       */
-     protected void load() {
+     protected void load() throws Exception {
      }
 
 

Added: trunk/src/org/crosswire/flashcards/Quizer.java
===================================================================
--- trunk/src/org/crosswire/flashcards/Quizer.java	                        (rev 0)
+++ trunk/src/org/crosswire/flashcards/Quizer.java	2006-12-09 13:51:24 UTC (rev 103)
@@ -0,0 +1,186 @@
+/*
+ * Distribution Licence:
+ * FlashCard is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General Public License,
+ * version 2 as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU General Public License for more details.
+ * The License is available on the internet at:
+ *     http://www.gnu.org/copyleft/gpl.html,
+ * or by writing to:
+ *     Free Software Foundation, Inc.
+ *     59 Temple Place - Suite 330
+ *     Boston, MA 02111-1307, USA
+ *
+ *
+ * Copyright: 2004 CrossWire Bible Society
+ */
+package org.crosswire.flashcards;
+
+import java.util.Vector;
+import java.util.Random;
+
+/**
+ * A panel that quizzes over a selection of lessons.
+ *
+ * @author Troy A. Griffitts [scribe at crosswire dot org]
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public class Quizer {
+  Random rand = new Random();
+  Vector words = new Vector();
+  Vector notLearned = new Vector();
+  WordEntry lastWord = null;
+  int wrong = 0;
+  int totalAsked = 0;
+  int totalWrong = 0;
+
+  static class WordEntry {
+
+    protected FlashCard flashCard;
+    protected int attempts;
+
+    public WordEntry(FlashCard flashCard) {
+      this.flashCard = flashCard;
+    }
+
+    public void incrementFailures(int failures) {
+      attempts += failures;
+    }
+
+    public int getFailures() {
+      return attempts;
+    }
+
+    public FlashCard getFlashCard() {
+      return flashCard;
+    }
+
+  }
+
+  //Construct the frame
+  public Quizer() {
+    clear();
+  }
+
+  public void clear() {
+    words = new Vector();
+    reset();
+  }
+
+  public void loadLesson(Lesson lesson) {
+    Vector cards = lesson.getFlashcards();
+    for (int i = 0; i < cards.size(); i++) {
+      words.addElement(new WordEntry( (FlashCard) cards.elementAt(i)));
+    }
+    // let's combine duplicate words
+    for (int i = 0; i < words.size() - 1; i++) {
+      WordEntry w = (WordEntry) words.elementAt(i);
+      for (int j = i + 1; j < words.size(); j++) {
+        WordEntry xx = (WordEntry) words.elementAt(j);
+        if (w.flashCard.getFront().equals(xx.flashCard.getFront())) {
+          w.flashCard.setBack(w.flashCard.getBack() + " or " +
+                              xx.flashCard.getBack());
+          words.removeElementAt(j);
+          j--;
+        }
+      }
+    }
+    reset();
+  }
+
+  void reset() {
+    totalAsked = 0;
+    totalWrong = 0;
+    words.trimToSize();
+    notLearned = new Vector();
+    for (int i = 0; i < words.size(); i++) {
+      notLearned.addElement(new WordEntry( ( (WordEntry) words.elementAt(i)).
+                                          getFlashCard()));
+    }
+  }
+
+  // wrongCount: 0 = correct; > 0 = # wrong choices; < 0 = ignore
+  public FlashCard getRandomWord(int wrongCount) {
+    if ( (lastWord != null) && (wrongCount > -1)) {
+      totalAsked++;
+      if (wrongCount > 0) {
+        totalWrong += wrongCount;
+        lastWord.incrementFailures(wrongCount);
+      }
+      else {
+        lastWord.incrementFailures(-1);
+        // if we're the last word, don't ask again
+        if ((notLearned.size() == 1) || (lastWord.getFailures() < 0)) {
+          notLearned.removeElement(lastWord);
+	  notLearned.trimToSize();
+        }
+      }
+    }
+
+    int numToLearn = notLearned.size();
+    if (numToLearn == 0) {
+      return null;
+    }
+    WordEntry currentWord = lastWord;
+    if ( (wrongCount < 0) && (currentWord != null)) {
+      int next = notLearned.indexOf(lastWord) + 1;
+      if (next >= notLearned.size()) {
+        next = 0;
+      }
+      currentWord = (WordEntry) notLearned.elementAt(next);
+    }
+    while (currentWord == lastWord) {
+      int wordNum = rand.nextInt(notLearned.size());
+      currentWord = (WordEntry) notLearned.elementAt(wordNum);
+    }
+    lastWord = currentWord;
+    return currentWord.getFlashCard();
+  }
+
+  public int getPercentage() {
+    int percent = 100;
+    if (totalAsked > 0) {
+      percent = (int) ( ( ( (float) (totalAsked - totalWrong)) /
+                         (float) totalAsked) * 100);
+    }
+    return percent;
+  }
+
+  public Vector getRandomAnswers(int count) {
+    Vector ret = new Vector();
+    if (count > words.size()) {
+      count = words.size();
+    }
+
+    while (count > 0) {
+      int wordNum = rand.nextInt(words.size());
+      String b = ( (WordEntry) words.elementAt(wordNum)).flashCard.getBack();
+      if (ret.indexOf(b) < 0) {
+        ret.addElement(b);
+        count--;
+      }
+    }
+    // be sure the right answer is in there
+    if (ret.indexOf(lastWord.flashCard.getBack()) < 0) {
+      int wordNum = rand.nextInt(ret.size());
+      ret.setElementAt(lastWord.flashCard.getBack(), wordNum);
+    }
+    return ret;
+  }
+
+  public int getTotalAsked() {
+    return totalAsked;
+  }
+
+  public int getTotalWrong() {
+    return totalWrong;
+  }
+
+  public int getNotLearnedCount() {
+    return notLearned.size();
+  }
+}




More information about the sword-cvs mailing list