import jalview.datamodel.SequenceFeature;
import jalview.io.gff.SequenceOntologyFactory;
import jalview.io.gff.SequenceOntologyI;
+import jalview.util.Platform;
import java.util.ArrayList;
import java.util.Arrays;
public Set<String> getFeatureTypesForGroups(boolean positionalFeatures,
String... groups)
{
- Set<String> result = new HashSet<>();
+ // BH 2020.03.21 This set is the one that sets the initial ordering for
+ // feature rendering. We set it to new HashSet<>(16,0.75) to force it to
+ // be backed by a Java hash-ordered HashMap instead of a JavaScript Map.
+ Set<String> result = Platform.getJavaOrderedHashSet();
for (Entry<String, FeatureStore> featureType : featureStore.entrySet())
{
@Override
public Set<String> getFeatureTypes(String... soTerm)
{
- Set<String> types = new HashSet<>();
+ Set<String> types = new HashSet<>(15, 0.75f);
for (Entry<String, FeatureStore> entry : featureStore.entrySet())
{
String type = entry.getKey();
import java.io.Reader;
import java.net.URL;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Properties;
+import java.util.Set;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
return (isJS() ? jsutil.getJSContext("jssingletons") : null);
}
+ /**
+ * By designating initialCapacity and loadFactor, we tell SwingJS to use a
+ * standard (slower) Java HashMap to back this HashSet, thus providing exactly
+ * the same iterator order (until a new Java version changes it!)
+ *
+ * @return a standard Java HashSet
+ */
+ public static Set<String> getJavaOrderedHashSet()
+ {
+ return new HashSet<>(16, 0.75f);
+ }
+
+ /**
+ * Switch the flag in SwingJS to use or not use the JavaScript Map object in
+ * any Hashtable, HashMap, or HashSet. Default is enabled.
+ *
+ * For testing purposes only.
+ *
+ */
+ public static boolean setJavaScriptMapObjectEnabled(boolean enabled)
+ {
+ if (!isJS())
+ {
+ return false;
+ }
+ jsutil.setJavaScriptMapObjectEnabled(enabled);
+ HashSet<String> hs = new HashSet<>();
+ // Java hash table iterator in HashMap will return "one" before "two"
+ // because of its hash code;
+ // JavaScript Map object will return "two" first because it was added first.
+ hs.add("two");
+ hs.add("one");
+ return (hs.iterator().next() == (enabled ? "two" : "one"));
+ }
}
public class FeaturesDisplayed implements FeaturesDisplayedI
{
- private Set<String> featuresDisplayed = new HashSet<String>();
+ private Set<String> featuresDisplayed = new HashSet<>();
- private Set<String> featuresRegistered = new HashSet<String>();
+ private Set<String> featuresRegistered = new HashSet<>();
public FeaturesDisplayed(FeaturesDisplayedI featuresDisplayed2)
{
*/
boolean streamToFile(InputStream is, File outFile);
+ /**
+ * Switch the flag in SwingJS to use or not use the JavaScript Map object in
+ * Hashtable, HashMap, and HashSet. Default is enabled.
+ *
+ */
+
+ void setJavaScriptMapObjectEnabled(boolean enabled);
+
}
-20200319234711
+20200321085805
-20200319234711
+20200321085805