[jsword-svn] r1555 - in trunk: common/src/main/java/org/crosswire/common/util common-swing/src/main/java/org/crosswire/common/config/swing common-swing/src/main/java/org/crosswire/common/swing jsword/src/main/java/org/crosswire/jsword/passage jsword-limbo/src/main/java/org/crosswire/common/swing
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Wed Jul 25 19:08:24 MST 2007
Author: dmsmith
Date: 2007-07-25 19:08:23 -0700 (Wed, 25 Jul 2007)
New Revision: 1555
Added:
trunk/jsword-limbo/src/main/java/org/crosswire/common/swing/FieldLayout.java
Removed:
trunk/common-swing/src/main/java/org/crosswire/common/swing/FieldLayout.java
Modified:
trunk/common-swing/src/main/java/org/crosswire/common/config/swing/FileField_fa.properties
trunk/common-swing/src/main/java/org/crosswire/common/config/swing/NumberField.java
trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java
trunk/common/src/main/java/org/crosswire/common/util/Convert.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java
Log:
More number shaping.
Modified: trunk/common/src/main/java/org/crosswire/common/util/Convert.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/Convert.java 2007-07-25 23:55:57 UTC (rev 1554)
+++ trunk/common/src/main/java/org/crosswire/common/util/Convert.java 2007-07-26 02:08:23 UTC (rev 1555)
@@ -25,6 +25,8 @@
import java.util.Iterator;
import java.util.Map;
+import org.crosswire.common.icu.NumberShaper;
+
/**
* Conversions between various types and Strings.
*
@@ -95,7 +97,7 @@
{
try
{
- return Integer.parseInt(data);
+ return Integer.parseInt(new NumberShaper().unshape(data));
}
catch (NumberFormatException ex)
{
@@ -110,7 +112,7 @@
*/
public static String int2String(int data)
{
- return Integer.toString(data);
+ return new NumberShaper().shape(Integer.toString(data));
}
/**
Modified: trunk/common-swing/src/main/java/org/crosswire/common/config/swing/FileField_fa.properties
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/config/swing/FileField_fa.properties 2007-07-25 23:55:57 UTC (rev 1554)
+++ trunk/common-swing/src/main/java/org/crosswire/common/config/swing/FileField_fa.properties 2007-07-26 02:08:23 UTC (rev 1555)
@@ -1,4 +1,3 @@
-
Browse.Enabled=true
Browse.Name=\u0627\u0646\u062A\u062E\u0627\u0628
Browse.ShortDescription=\u0641\u0627\u06CC\u0644\u0631\u0627 \u0627\u0646\u062A\u062E\u0627\u0628 \u06A9\u0646\u06CC\u062F
Modified: trunk/common-swing/src/main/java/org/crosswire/common/config/swing/NumberField.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/config/swing/NumberField.java 2007-07-25 23:55:57 UTC (rev 1554)
+++ trunk/common-swing/src/main/java/org/crosswire/common/config/swing/NumberField.java 2007-07-26 02:08:23 UTC (rev 1555)
@@ -28,6 +28,7 @@
import javax.swing.JTextField;
import org.crosswire.common.config.Choice;
+import org.crosswire.common.icu.NumberShaper;
import org.crosswire.common.swing.NumericDocument;
/**
@@ -45,6 +46,8 @@
*/
public NumberField()
{
+ shaper = new NumberShaper();
+ text = new JTextField();
text.setDocument(new NumericDocument());
text.setColumns(10);
@@ -68,7 +71,7 @@
*/
public String getValue()
{
- return text.getText();
+ return shaper.unshape(text.getText());
}
/**
@@ -77,7 +80,7 @@
*/
public void setValue(String value)
{
- text.setText(value);
+ text.setText(shaper.shape(value));
}
/**
@@ -95,6 +98,11 @@
private JTextField text = new JTextField();
/**
+ * The internationalizer for numbers.
+ */
+ private NumberShaper shaper;
+
+ /**
* Serialization ID
*/
private static final long serialVersionUID = 3256443594867750451L;
Deleted: trunk/common-swing/src/main/java/org/crosswire/common/swing/FieldLayout.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/FieldLayout.java 2007-07-25 23:55:57 UTC (rev 1554)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/FieldLayout.java 2007-07-26 02:08:23 UTC (rev 1555)
@@ -1,196 +0,0 @@
-/**
- * Distribution License:
- * JSword is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License, version 2.1 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 Lesser General Public License for more details.
- *
- * The License is available on the internet at:
- * http://www.gnu.org/copyleft/lgpl.html
- * or by writing to:
- * Free Software Foundation, Inc.
- * 59 Temple Place - Suite 330
- * Boston, MA 02111-1307, USA
- *
- * Copyright: 2005
- * The copyright to this program is held by it's authors.
- *
- * ID: $Id$
- */
-package org.crosswire.common.swing;
-
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Insets;
-
-/**
- * Layout Components along with labels that describe them.
- * We ought to consider the Form layout idea that I dreamt
- * up earlier when considering updates to this.
- *
- * @see gnu.lgpl.License for license details.
- * The copyright to this program is held by it's authors.
- * @author Joe Walker [joe at eireneh dot com]
- * @author Ideas from JDJ article by Claude Duguay
- */
-public class FieldLayout extends AbstractLayout
-{
- /**
- * A default FieldLayout with intercomponent
- * spacing of 0.
- */
- public FieldLayout()
- {
- }
-
- /**
- * FieldLayout with specified intercomponent
- * spacings.
- * @param hgap The horizontal gaps
- * @param vgap The vertical gaps
- */
- public FieldLayout(int hgap, int vgap)
- {
- super(hgap, vgap);
- }
-
- /**
- * The minimum layout size for a given container
- */
- public Dimension minimumLayoutSize(Container target)
- {
- int left = 0;
- int right = 0;
- int height = 0;
- Insets insets = target.getInsets();
- int ncomponents = target.getComponentCount();
-
- for (int i = 0; i < ncomponents; i += 2)
- {
- Component label = target.getComponent(i);
- int w1 = label.getMinimumSize().width;
- int h1 = label.getMinimumSize().height;
- if (w1 > left)
- {
- left = w1;
- }
-
- if (i + 1 < ncomponents)
- {
- Component field = target.getComponent(i + 1);
- int w2 = field.getMinimumSize().width;
- int h2 = field.getMinimumSize().height;
- if (w2 > right)
- {
- right = w2;
- }
-
- height += Math.max(h1, h2) + hgap;
- }
- else
- {
- height += h1;
- }
- }
-
- return new Dimension(insets.left + insets.right + left + right + vgap, insets.top + insets.bottom + height - hgap);
- }
-
- /**
- * The preferred layout size for a given container
- */
- public Dimension preferredLayoutSize(Container target)
- {
- int left = 0;
- int right = 0;
- int height = 0;
- Insets insets = target.getInsets();
- int ncomponents = target.getComponentCount();
-
- for (int i = 0; i < ncomponents; i += 2)
- {
- Component label = target.getComponent(i);
- int w1 = label.getPreferredSize().width;
- int h1 = label.getPreferredSize().height;
- if (w1 > left)
- {
- left = w1;
- }
-
- if (i + 1 < ncomponents)
- {
- Component field = target.getComponent(i + 1);
- int w2 = field.getPreferredSize().width;
- int h2 = field.getPreferredSize().height;
- if (w2 > right)
- {
- right = w2;
- }
-
- height += Math.max(h1, h2) + hgap;
- }
- else
- {
- height += h1;
- }
- }
-
- return new Dimension(insets.left + insets.right + left + right + vgap, insets.top + insets.bottom + height - hgap);
- }
-
- /**
- * layout the specified container
- */
- public void layoutContainer(Container target)
- {
- int left = 0;
- Insets insets = target.getInsets();
- int ncomponents = target.getComponentCount();
-
- // Pre-calculate left position
- for (int i = 0; i < ncomponents; i += 2)
- {
- Component label = target.getComponent(i);
- int w = label.getPreferredSize().width;
- if (w > left)
- {
- left = w;
- }
- }
-
- int right = target.getSize().width - left - insets.left - insets.right - hgap;
- int vpos = insets.top;
-
- for (int i = 0; i < ncomponents; i += 2)
- {
- Component label = target.getComponent(i);
- int h1 = label.getPreferredSize().height;
- int h2 = 0;
- Component field = null;
-
- if (i + 1 < ncomponents)
- {
- field = target.getComponent(i + 1);
- h2 = field.getPreferredSize().height;
- }
-
- // In order to top align the label setBounds using height of h1 not h
- int h = Math.max(h1, h2);
- label.setBounds(insets.left, vpos, left, h);
- if (field != null)
- {
- field.setBounds(insets.left + left + hgap, vpos, right, h);
- }
-
- vpos += h + hgap;
- }
- }
-
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3617576015757719097L;
-}
Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java 2007-07-25 23:55:57 UTC (rev 1554)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java 2007-07-26 02:08:23 UTC (rev 1555)
@@ -75,6 +75,7 @@
name.setSelectedItem(font.deriveFont(Font.PLAIN, RENDERED_FONT_SIZE));
name.addItemListener(changer);
+ size.setRenderer(new NumberCellRenderer());
for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
{
size.addItem(new Integer(i));
@@ -202,7 +203,7 @@
}
/**
- * When something chenages we must inform out listeners.
+ * When something changes we must inform out listeners.
*/
protected void fireStateChange()
{
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java 2007-07-25 23:55:57 UTC (rev 1554)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java 2007-07-26 02:08:23 UTC (rev 1555)
@@ -23,6 +23,7 @@
import java.io.Serializable;
+import org.crosswire.common.icu.NumberShaper;
import org.crosswire.jsword.versification.BibleInfo;
/**
@@ -596,7 +597,7 @@
{
try
{
- return Integer.parseInt(text);
+ return Integer.parseInt(new NumberShaper().unshape(text));
}
catch (NumberFormatException ex)
{
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java 2007-07-25 23:55:57 UTC (rev 1554)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java 2007-07-26 02:08:23 UTC (rev 1555)
@@ -69,7 +69,6 @@
*/
public Verse()
{
- shaper = new NumberShaper();
originalName = null;
book = DEFAULT.book;
@@ -89,7 +88,6 @@
*/
/*package*/ Verse(String original, int book, int chapter, int verse) throws NoSuchVerseException
{
- shaper = new NumberShaper();
originalName = original;
set(book, chapter, verse);
}
@@ -122,7 +120,6 @@
*/
public Verse(int book, int chapter, int verse, boolean patch_up)
{
- shaper = new NumberShaper();
if (!patch_up)
{
throw new IllegalArgumentException(Msg.ERROR_PATCH.toString());
@@ -143,7 +140,6 @@
*/
public Verse(int ordinal) throws NoSuchVerseException
{
- shaper = new NumberShaper();
originalName = null;
set(ordinal);
}
@@ -257,7 +253,6 @@
copy.verse = verse;
//copy.ord = ord;
copy.originalName = originalName;
- shaper = new NumberShaper();
}
catch (CloneNotSupportedException e)
{
@@ -723,7 +718,7 @@
{
try
{
- return Integer.parseInt(text);
+ return Integer.parseInt(shaper.unshape(text));
}
catch (NumberFormatException ex)
{
@@ -1009,7 +1004,7 @@
/**
* Allow the conversion to and from other number representations.
*/
- private transient NumberShaper shaper;
+ private static NumberShaper shaper = new NumberShaper();
/**
* The parent key. See the key interface for more information.
Copied: trunk/jsword-limbo/src/main/java/org/crosswire/common/swing/FieldLayout.java (from rev 1544, trunk/common-swing/src/main/java/org/crosswire/common/swing/FieldLayout.java)
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/common/swing/FieldLayout.java (rev 0)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/common/swing/FieldLayout.java 2007-07-26 02:08:23 UTC (rev 1555)
@@ -0,0 +1,196 @@
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 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 Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ * http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ * Free Software Foundation, Inc.
+ * 59 Temple Place - Suite 330
+ * Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2005
+ * The copyright to this program is held by it's authors.
+ *
+ * ID: $Id$
+ */
+package org.crosswire.common.swing;
+
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Insets;
+
+/**
+ * Layout Components along with labels that describe them.
+ * We ought to consider the Form layout idea that I dreamt
+ * up earlier when considering updates to this.
+ *
+ * @see gnu.lgpl.License for license details.
+ * The copyright to this program is held by it's authors.
+ * @author Joe Walker [joe at eireneh dot com]
+ * @author Ideas from JDJ article by Claude Duguay
+ */
+public class FieldLayout extends AbstractLayout
+{
+ /**
+ * A default FieldLayout with intercomponent
+ * spacing of 0.
+ */
+ public FieldLayout()
+ {
+ }
+
+ /**
+ * FieldLayout with specified intercomponent
+ * spacings.
+ * @param hgap The horizontal gaps
+ * @param vgap The vertical gaps
+ */
+ public FieldLayout(int hgap, int vgap)
+ {
+ super(hgap, vgap);
+ }
+
+ /**
+ * The minimum layout size for a given container
+ */
+ public Dimension minimumLayoutSize(Container target)
+ {
+ int left = 0;
+ int right = 0;
+ int height = 0;
+ Insets insets = target.getInsets();
+ int ncomponents = target.getComponentCount();
+
+ for (int i = 0; i < ncomponents; i += 2)
+ {
+ Component label = target.getComponent(i);
+ int w1 = label.getMinimumSize().width;
+ int h1 = label.getMinimumSize().height;
+ if (w1 > left)
+ {
+ left = w1;
+ }
+
+ if (i + 1 < ncomponents)
+ {
+ Component field = target.getComponent(i + 1);
+ int w2 = field.getMinimumSize().width;
+ int h2 = field.getMinimumSize().height;
+ if (w2 > right)
+ {
+ right = w2;
+ }
+
+ height += Math.max(h1, h2) + hgap;
+ }
+ else
+ {
+ height += h1;
+ }
+ }
+
+ return new Dimension(insets.left + insets.right + left + right + vgap, insets.top + insets.bottom + height - hgap);
+ }
+
+ /**
+ * The preferred layout size for a given container
+ */
+ public Dimension preferredLayoutSize(Container target)
+ {
+ int left = 0;
+ int right = 0;
+ int height = 0;
+ Insets insets = target.getInsets();
+ int ncomponents = target.getComponentCount();
+
+ for (int i = 0; i < ncomponents; i += 2)
+ {
+ Component label = target.getComponent(i);
+ int w1 = label.getPreferredSize().width;
+ int h1 = label.getPreferredSize().height;
+ if (w1 > left)
+ {
+ left = w1;
+ }
+
+ if (i + 1 < ncomponents)
+ {
+ Component field = target.getComponent(i + 1);
+ int w2 = field.getPreferredSize().width;
+ int h2 = field.getPreferredSize().height;
+ if (w2 > right)
+ {
+ right = w2;
+ }
+
+ height += Math.max(h1, h2) + hgap;
+ }
+ else
+ {
+ height += h1;
+ }
+ }
+
+ return new Dimension(insets.left + insets.right + left + right + vgap, insets.top + insets.bottom + height - hgap);
+ }
+
+ /**
+ * layout the specified container
+ */
+ public void layoutContainer(Container target)
+ {
+ int left = 0;
+ Insets insets = target.getInsets();
+ int ncomponents = target.getComponentCount();
+
+ // Pre-calculate left position
+ for (int i = 0; i < ncomponents; i += 2)
+ {
+ Component label = target.getComponent(i);
+ int w = label.getPreferredSize().width;
+ if (w > left)
+ {
+ left = w;
+ }
+ }
+
+ int right = target.getSize().width - left - insets.left - insets.right - hgap;
+ int vpos = insets.top;
+
+ for (int i = 0; i < ncomponents; i += 2)
+ {
+ Component label = target.getComponent(i);
+ int h1 = label.getPreferredSize().height;
+ int h2 = 0;
+ Component field = null;
+
+ if (i + 1 < ncomponents)
+ {
+ field = target.getComponent(i + 1);
+ h2 = field.getPreferredSize().height;
+ }
+
+ // In order to top align the label setBounds using height of h1 not h
+ int h = Math.max(h1, h2);
+ label.setBounds(insets.left, vpos, left, h);
+ if (field != null)
+ {
+ field.setBounds(insets.left + left + hgap, vpos, right, h);
+ }
+
+ vpos += h + hgap;
+ }
+ }
+
+ /**
+ * Serialization ID
+ */
+ private static final long serialVersionUID = 3617576015757719097L;
+}
More information about the jsword-svn
mailing list