[FOray-commit] SF.net SVN: foray:[11806] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2021-01-17 00:33:08
|
Revision: 11806
http://sourceforge.net/p/foray/code/11806
Author: victormote
Date: 2021-01-17 00:33:06 +0000 (Sun, 17 Jan 2021)
Log Message:
-----------
Clean up internal data for CharSet4a.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Symbol.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/ZapfDingbats.jbso
trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/CharSet4a.java
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Symbol.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/ZapfDingbats.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/CharSet4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/CharSet4a.java 2021-01-17 00:00:51 UTC (rev 11805)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/CharSet4a.java 2021-01-17 00:33:06 UTC (rev 11806)
@@ -28,6 +28,9 @@
package org.foray.ps.encode;
+import org.foray.common.sequence.CharArray;
+import org.foray.common.sequence.IntArray;
+
import org.axsl.common.sequence.IntSequenceMutable;
import org.axsl.ps.CharSet;
@@ -35,7 +38,6 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -59,20 +61,18 @@
private transient String name;
/** The 16-bit Unicode codepoints. */
- private transient char[] characterSet16;
+ private transient CharArray characterSet16;
/** The 32-bit Unicode codepoints. These are conceptually appended to the
* end of {@link #characterSet16} as if they were all in one array. */
- private transient int[] characterSet32;
+ private transient IntArray characterSet32;
/**
* Constructor.
* @param name The name of this character set.
- * @param mutable The array containing the code points in this character set.
+ * @param characterSet The array containing the code points in this character set.
*/
- public CharSet4a(final String name, final IntSequenceMutable mutable) {
- final int[] characterSet = mutable.toArray();
-
+ public CharSet4a(final String name, final IntSequenceMutable characterSet) {
this.name = name;
if (characterSet == null) {
return;
@@ -79,41 +79,24 @@
}
/* Make sure the input array is sorted. */
- Arrays.sort(characterSet);
+ characterSet.sort();
- /* Find the index to the first code point > 0xFFFF. */
- int first32bitIndex = Integer.MAX_VALUE;
- for (int i = characterSet.length - 1; i > -1 && first32bitIndex < 0;
- i--) {
- if (characterSet[i] <= Character.MAX_VALUE) {
- /* We are down to the 16-bit items, so we are done. */
+ /* Count the values needing 32 bits. */
+ int count32 = 0;
+ for (int i = characterSet.length() - 1; i > -1; i--) {
+ if (characterSet.intAt(i) > Character.MAX_VALUE) {
+ count32 ++;
+ } else {
break;
}
- /* We are still in the 32-bit items, so this one is now the first
- * known 32-bit item. */
- first32bitIndex = i;
}
- /* Split the input array into 2 arrays, one for 16-bit items, one for
- * 32-bit items. */
- if (first32bitIndex == Integer.MAX_VALUE) {
- /* There are no 32-bit values. */
- this.characterSet32 = null;
- this.characterSet16 = new char[characterSet.length];
- for (int i = 0; i < characterSet.length; i++) {
- this.characterSet16[i] = (char) characterSet[i];
- }
+ if (count32 == 0) {
+ this.characterSet16 = new CharArray(characterSet);
+ this.characterSet32 = IntArray.EMPTY;
} else {
- final int num16bits = first32bitIndex;
- final int num32bits = characterSet.length - num16bits;
- this.characterSet16 = new char[num16bits];
- for (int i = 0; i < first32bitIndex; i++) {
- this.characterSet16[i] = (char) characterSet[i];
- }
- this.characterSet32 = new int[num32bits];
- for (int i = first32bitIndex; i < characterSet.length; i++) {
- this.characterSet32[i - first32bitIndex] = characterSet[i];
- }
+ this.characterSet16 = new CharArray(characterSet.subSequence(0, count32));
+ this.characterSet32 = new IntArray(characterSet.subSequence(count32, characterSet.length()));
}
}
@@ -127,24 +110,13 @@
@Override
public int getIndex(final int codePoint) {
- int index = -1;
- if (this.characterSet16 != null) {
- index = Arrays.binarySearch(this.characterSet16, (char) codePoint);
+ if (codePoint > Character.MAX_VALUE) {
+ final int index = this.characterSet32.binarySearch(codePoint);
+ return index < 0 ? -1 : index + this.characterSet16.length();
+ } else {
+ final int index = this.characterSet16.binarySearch((char) codePoint);
+ return index < 0 ? -1 : index;
}
- if (index > -1) {
- return index;
- }
- if (this.characterSet32 != null) {
- index = Arrays.binarySearch(this.characterSet32, codePoint);
- if (index > -1
- && this.characterSet16 != null) {
- index += this.characterSet16.length;
- }
- }
- if (index < 0) {
- index = -1;
- }
- return index;
}
/**
@@ -197,14 +169,7 @@
* @return The size of this character set.
*/
public int size() {
- int size = 0;
- if (this.characterSet16 != null) {
- size += this.characterSet16.length;
- }
- if (this.characterSet32 != null) {
- size += this.characterSet32.length;
- }
- return size;
+ return this.characterSet16.length() + this.characterSet32.length();
}
/**
@@ -260,8 +225,8 @@
}
stream.defaultReadObject();
this.name = (String) stream.readObject();
- this.characterSet16 = (char[]) stream.readObject();
- this.characterSet32 = (int[]) stream.readObject();
+ this.characterSet16 = (CharArray) stream.readObject();
+ this.characterSet32 = (IntArray) stream.readObject();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|