[sword-svn] r171 - in trunk: . .settings app app/src/org/crosswire/flashcards
Mon Feb 15 16:32:00 MST 2016
Author:
Date: 2016-02-15 16:32:00 -0700 (Mon, 15 Feb 2016)
New Revision: 171
Added:
trunk/app/start_flashcards.bat
trunk/app/start_flashcards.sh
Modified:
trunk/.classpath
trunk/.settings/org.eclipse.jdt.core.prefs
trunk/.settings/org.eclipse.jdt.ui.prefs
trunk/Makefile
trunk/app/src/org/crosswire/flashcards/LessonManager.java
trunk/app/src/org/crosswire/flashcards/QuizPane.java
trunk/build.xml
Log:
added startup scripts
added new method to determine optimal max font size for word
added new lookup in CWD for lessons/ folder
added eclipse project
Modified: trunk/.classpath
===================================================================
--- trunk/.classpath 2016-02-15 19:01:05 UTC (rev 170)
+++ trunk/.classpath 2016-02-15 23:32:00 UTC (rev 171)
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="app/src"/>
+ <classpathentry kind="src" path="fonts"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
+ <classpathentry kind="output" path="target"/>
</classpath>
Modified: trunk/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/.settings/org.eclipse.jdt.core.prefs 2016-02-15 19:01:05 UTC (rev 170)
+++ trunk/.settings/org.eclipse.jdt.core.prefs 2016-02-15 23:32:00 UTC (rev 171)
@@ -1,4 +1,3 @@
-#Mon Dec 11 21:49:35 EST 2006
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
@@ -15,6 +14,8 @@
org.eclipse.jdt.core.codeComplete.localSuffixes=
org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
Modified: trunk/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- trunk/.settings/org.eclipse.jdt.ui.prefs 2016-02-15 19:01:05 UTC (rev 170)
+++ trunk/.settings/org.eclipse.jdt.ui.prefs 2016-02-15 23:32:00 UTC (rev 171)
@@ -1,6 +1,6 @@
-#Mon Dec 11 21:49:35 EST 2006
eclipse.preferences.version=1
internal.default.compliance=user
org.eclipse.jdt.ui.exception.name=e
org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.keywordthis=false
org.eclipse.jdt.ui.overrideannotation=true
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2016-02-15 19:01:05 UTC (rev 170)
+++ trunk/Makefile 2016-02-15 23:32:00 UTC (rev 171)
@@ -8,6 +8,8 @@
mkdir FlashCards
cp target/install/flashcards.jar FlashCards
cp target/install/lessons.jar FlashCards
+ cp app/start_flashcards.sh FlashCards
+ cp app/start_flashcards.bat FlashCards
cp fonts/* FlashCards
zip FlashCards.zip FlashCards/*
cp -f FlashCards.zip /home/ftp/pub/flashcards
Modified: trunk/app/src/org/crosswire/flashcards/LessonManager.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/LessonManager.java 2016-02-15 19:01:05 UTC (rev 170)
+++ trunk/app/src/org/crosswire/flashcards/LessonManager.java 2016-02-15 23:32:00 UTC (rev 171)
@@ -109,6 +109,9 @@
// see if there are any jars in our CWD with lesson sets
loadLessonSetsFromJarDir("./");
+ // see if there is a CWD/lessons folder with lesson sets
+ loadLessonSetsFromDir(new File("./lessons/"));
+
// see if there are any lesson sets in our home project dir
loadLessonSetsFromDir(homeLessonDir);
Modified: trunk/app/src/org/crosswire/flashcards/QuizPane.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/QuizPane.java 2016-02-15 19:01:05 UTC (rev 170)
+++ trunk/app/src/org/crosswire/flashcards/QuizPane.java 2016-02-15 23:32:00 UTC (rev 171)
@@ -25,6 +25,7 @@
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.Font;
+import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Rectangle;
@@ -482,6 +483,7 @@
notLearned.remove(currentWord);
deleteChildren(choicesPanel);
wordText.setText("-=+* Great! *+=-");
+ setOptimalFontSizes();
statusBar.setText("Nice Job! You've mastered all " + words.size() + " words!");
}
}
@@ -519,6 +521,7 @@
}
else {
wordText.setText("-=+* Great! *+=-");
+ setOptimalFontSizes();
statusBar.setText("Nice Job! You've mastered all " + words.size() + " words!");
}
}
@@ -560,6 +563,51 @@
return biggest;
}
+
+
+
+
+
+
+
+ public static final int MIN_FONT_SIZE=3;
+ public static final int MAX_FONT_SIZE=512;
+
+ protected void adaptLabelFont(JLabel l) {
+ Rectangle r=l.getBounds();
+ int fontSize=MIN_FONT_SIZE;
+ Font f=l.getFont();
+ int lastFontSize = f.getSize();
+
+ Rectangle r1=new Rectangle();
+ Rectangle r2=new Rectangle();
+ while (fontSize<MAX_FONT_SIZE) {
+ r1.setSize(getTextSize(l, f.deriveFont(f.getStyle(), fontSize)));
+ r2.setSize(getTextSize(l, f.deriveFont(f.getStyle(),fontSize+1)));
+ if (r.contains(r1) && ! r.contains(r2)) {
+ break;
+ }
+ fontSize++;
+ }
+
+ l.setFont(f.deriveFont(f.getStyle(),fontSize));
+ }
+
+ private Dimension getTextSize(JLabel l, Font f) {
+ Dimension size=new Dimension();
+ Graphics2D g = (Graphics2D)l.getGraphics();
+ g.setFont(f);
+ FontMetrics fm=g.getFontMetrics(f);
+ size.width=fm.stringWidth(l.getText());
+ size.height=fm.getHeight();
+
+ return size;
+ }
+
+
+
+
+
public float getOptimalFontSize(Rectangle bounds) {
float fontSize = 30;
@@ -587,9 +635,12 @@
}
// Now that bottom layout is adjusted for new font size, computer real
// font size for top
+ adaptLabelFont(wordText);
+/*
optimalFontSize = getOptimalFontSize(bounds);
newFont = loadFont(currentWord.getFontURL()).deriveFont(optimalFontSize);
wordText.setFont(newFont);
+*/
}
Added: trunk/app/start_flashcards.bat
===================================================================
--- trunk/app/start_flashcards.bat (rev 0)
+++ trunk/app/start_flashcards.bat 2016-02-15 23:32:00 UTC (rev 171)
@@ -0,0 +1 @@
+java -jar flashcards.jar
Added: trunk/app/start_flashcards.sh
===================================================================
--- trunk/app/start_flashcards.sh (rev 0)
+++ trunk/app/start_flashcards.sh 2016-02-15 23:32:00 UTC (rev 171)
@@ -0,0 +1 @@
+java -jar flashcards.jar
Property changes on: trunk/app/start_flashcards.sh
___________________________________________________________________
Added: svn:executable
+ *
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2016-02-15 19:01:05 UTC (rev 170)
+++ trunk/build.xml 2016-02-15 23:32:00 UTC (rev 171)
@@ -140,14 +140,16 @@
srcdir="${source.java.common}"
includes="**/*.java"
destdir="${target.classes}"
- source="1.4">
+ includeantruntime="false"
+ source="1.6">
<exclude name="**/migrate/*"/>
</javac>
<javac debug="on"
srcdir="${source.java}"
includes="**/*.java"
destdir="${target.classes}"
- source="1.4">
+ includeantruntime="false"
+ source="1.6">
<exclude name="**/migrate/*"/>
</javac>
<!-- Copy the resources to the proper org/crosswire directory.
More information about the sword-cvs
mailing list