comments and version wget ping timeout fix for when www connection is unavailable...
[jalview.git] / src / jalview / gui / FeatureRenderer.java
index 04324ac..b643efb 100755 (executable)
@@ -49,7 +49,7 @@ public class FeatureRenderer
 
   // A higher level for grouping features of a
   // particular type
-  Hashtable featureGroups = null;
+  Hashtable featureGroups = new Hashtable();
 
   // This is actually an Integer held in the hashtable,
   // Retrieved using the key feature type
@@ -72,7 +72,44 @@ public class FeatureRenderer
     this.av = ap.av;
   }
 
-
+  public class FeatureRendererSettings implements Cloneable {
+    String[] renderOrder;
+    Hashtable featureGroups;
+    Hashtable featureColours;
+    float transparency;
+    Hashtable featureOrder;
+    public FeatureRendererSettings(String[] renderOrder,
+            Hashtable featureGroups, Hashtable featureColours,
+            float transparency, Hashtable featureOrder)
+    {
+      super();
+      this.renderOrder = renderOrder;
+      this.featureGroups = featureGroups;
+      this.featureColours = featureColours;
+      this.transparency = transparency;
+      this.featureOrder = featureOrder;
+    }
+    public FeatureRendererSettings(FeatureRenderer fr)
+    {
+      this.renderOrder = fr.renderOrder;
+      this.featureGroups = fr.featureGroups;
+      this.featureColours = fr.featureColours;
+      this.transparency = fr.transparency;
+      this.featureOrder = fr.featureOrder;
+    }
+  }
+  public FeatureRendererSettings getSettings()
+  {
+    return new FeatureRendererSettings(this);
+  }
+  public void transferSettings(FeatureRendererSettings fr)
+  {
+    this.renderOrder = fr.renderOrder;
+    this.featureGroups = fr.featureGroups;
+    this.featureColours = fr.featureColours;
+    this.transparency = fr.transparency;
+    this.featureOrder = fr.featureOrder;
+  }
   public void transferSettings(FeatureRenderer fr)
   {
     this.renderOrder = fr.renderOrder;
@@ -119,7 +156,7 @@ public class FeatureRenderer
       }
     }
 
-    if (sequenceFeatures == null)
+    if (sequenceFeatures == null || sfSize==0)
     {
       return initialCol;
     }
@@ -196,9 +233,10 @@ public class FeatureRenderer
   SequenceFeature[] sequenceFeatures;
   int sfSize, sfindex, spos, epos;
 
-  public void drawSequence(Graphics g, SequenceI seq,
+  synchronized public void drawSequence(Graphics g, SequenceI seq,
                            int start, int end, int y1)
   {
+
     if (seq.getDatasetSequence().getSequenceFeatures() == null
         || seq.getDatasetSequence().getSequenceFeatures().length == 0)
     {
@@ -221,7 +259,6 @@ public class FeatureRenderer
       }
 
       sequenceFeatures = seq.getDatasetSequence().getSequenceFeatures();
-      sfSize = sequenceFeatures.length;
     }
 
     if (lastSeq == null || seq != lastSeq
@@ -229,7 +266,6 @@ public class FeatureRenderer
     {
       lastSeq = seq;
       sequenceFeatures = seq.getDatasetSequence().getSequenceFeatures();
-      sfSize = sequenceFeatures.length;
     }
 
     if (transparency != 1 && g != null)
@@ -246,6 +282,7 @@ public class FeatureRenderer
       epos = lastSeq.findPosition(end);
     }
 
+    sfSize = sequenceFeatures.length;
     String type;
     for (int renderIndex = 0; renderIndex < renderOrder.length; renderIndex++)
     {
@@ -260,10 +297,6 @@ public class FeatureRenderer
       // current feature to render
       for (sfindex = 0; sfindex < sfSize; sfindex++)
       {
-        if (sequenceFeatures.length <= sfindex)
-        {
-          continue;
-        }
         if (!sequenceFeatures[sfindex].type.equals(type))
         {
           continue;
@@ -401,13 +434,16 @@ public class FeatureRenderer
    * them. Then fires a PropertyChangeEvent on the changeSupport object.
    *
    */
-  synchronized void findAllFeatures()
+  void findAllFeatures()
   {
-    findAllFeatures(true); // add all new features as visible
-    if (!firing) {
-      firing=true;
-      changeSupport.firePropertyChange("changeSupport",null,null);
-      firing=false;
+    synchronized (firing)
+    {
+        if (firing.equals(Boolean.FALSE)) {
+          firing=Boolean.TRUE;
+          findAllFeatures(true); // add all new features as visible
+          changeSupport.firePropertyChange("changeSupport",null,null);
+          firing=Boolean.FALSE;
+      }
     }
   }
   /**
@@ -459,6 +495,7 @@ public class FeatureRenderer
       {
         if (!av.featuresDisplayed.containsKey(features[index].getType()))
         {
+
           if(featureGroups.containsKey(features[index].getType()))
           {
             boolean visible = ( (Boolean) featureGroups.get(
@@ -466,8 +503,6 @@ public class FeatureRenderer
 
             if(!visible)
             {
-              System.out.println(features[index].featureGroup
-                                 +" not visible");
               index++;
               continue;
             }
@@ -499,7 +534,7 @@ public class FeatureRenderer
     updateRenderOrder(allfeatures);
     findingFeatures = false;
   }
-  protected boolean firing=false;
+  protected Boolean firing=Boolean.FALSE;
   /**
    * replaces the current renderOrder with the unordered features in allfeatures.
    * The ordering of any types in both renderOrder and allfeatures is preserved,