JAL-1667 make transferSettings an API method
[jalview.git] / src / jalview / viewmodel / seqfeatures / FeatureRendererModel.java
index 674f3d1..28eda82 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview 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 General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.viewmodel.seqfeatures;
 
 import jalview.api.AlignViewportI;
@@ -43,6 +63,7 @@ public abstract class FeatureRendererModel implements
 
   protected AlignmentViewport av;
 
+  @Override
   public AlignViewportI getViewport()
   {
     return av;
@@ -62,12 +83,7 @@ public abstract class FeatureRendererModel implements
     this.featureOrder = fr.featureOrder;
   }
 
-  /**
-   * update from another feature renderer
-   * 
-   * @param fr
-   *          settings to copy
-   */
+  @Override
   public void transferSettings(jalview.api.FeatureRenderer _fr)
   {
     FeatureRenderer fr = (FeatureRenderer) _fr;
@@ -119,8 +135,7 @@ public abstract class FeatureRendererModel implements
     }
     if (!fdi.isRegistered(featureType))
     {
-      pushFeatureType(Arrays.asList(new String[]
-      { featureType }));
+      pushFeatureType(Arrays.asList(new String[] { featureType }));
     }
     fdi.setVisible(featureType);
   }
@@ -163,7 +178,7 @@ public abstract class FeatureRendererModel implements
     types.toArray(neworder);
     if (renderOrder != null)
     {
-      System.arraycopy(neworder,0,neworder,renderOrder.length,ts);
+      System.arraycopy(neworder, 0, neworder, renderOrder.length, ts);
       System.arraycopy(renderOrder, 0, neworder, 0, renderOrder.length);
     }
     renderOrder = neworder;
@@ -186,8 +201,7 @@ public abstract class FeatureRendererModel implements
   protected final byte[] normaliseScore(SequenceFeature sequenceFeature)
   {
     float[] mm = ((float[][]) minmax.get(sequenceFeature.type))[0];
-    final byte[] r = new byte[]
-    { 0, (byte) 255 };
+    final byte[] r = new byte[] { 0, (byte) 255 };
     if (mm != null)
     {
       if (r[0] != 0 || mm[0] < 0.0)
@@ -369,20 +383,19 @@ public abstract class FeatureRendererModel implements
         {
           allfeatures.add(features[index].getType());
         }
-        if (features[index].score != Float.NaN)
+        if (!Float.isNaN(features[index].score))
         {
           int nonpos = features[index].getBegin() >= 1 ? 0 : 1;
           float[][] mm = (float[][]) minmax.get(features[index].getType());
           if (mm == null)
           {
-            mm = new float[][]
-            { null, null };
+            mm = new float[][] { null, null };
             minmax.put(features[index].getType(), mm);
           }
           if (mm[nonpos] == null)
           {
-            mm[nonpos] = new float[]
-            { features[index].score, features[index].score };
+            mm[nonpos] = new float[] { features[index].score,
+                features[index].score };
 
           }
           else
@@ -433,8 +446,7 @@ public abstract class FeatureRendererModel implements
         {
           if (initOrders)
           {
-            setOrder(oldRender[j], (1 - (1 + (float) j)
-                    / oldRender.length));
+            setOrder(oldRender[j], (1 - (1 + (float) j) / oldRender.length));
           }
           if (allfeatures.contains(oldRender[j]))
           {
@@ -521,6 +533,7 @@ public abstract class FeatureRendererModel implements
    * @param featureType
    * @return java.awt.Color or GraduatedColor
    */
+  @Override
   public Object getFeatureStyle(String featureType)
   {
     Object fc = featureColours.get(featureType);
@@ -601,6 +614,7 @@ public abstract class FeatureRendererModel implements
     return av.getFeaturesDisplayed().isVisible(type);
   }
 
+  @Override
   public void setColour(String featureType, Object col)
   {
     // overwrite
@@ -667,7 +681,7 @@ public abstract class FeatureRendererModel implements
   @Override
   public Map<String, Object> getFeatureColours()
   {
-    return new ConcurrentHashMap<String, Object>(featureColours);
+    return featureColours;
   }
 
   /**
@@ -770,8 +784,7 @@ public abstract class FeatureRendererModel implements
   {
     if (renderOrder == null)
     {
-      return Arrays.asList(new String[]
-      {});
+      return Arrays.asList(new String[] {});
     }
     return Arrays.asList(renderOrder);
   }