JAL-2009 added programmatic custom feature setting to show insertion position for...
[jalview.git] / src / jalview / io / PDBFeatureSettings.java
diff --git a/src/jalview/io/PDBFeatureSettings.java b/src/jalview/io/PDBFeatureSettings.java
new file mode 100644 (file)
index 0000000..a422a00
--- /dev/null
@@ -0,0 +1,63 @@
+package jalview.io;
+
+import jalview.api.FeatureColourI;
+import jalview.schemes.FeatureColourAdapter;
+import jalview.schemes.FeatureSettingsAdapter;
+import jalview.ws.dbsources.Pdb;
+
+import java.awt.Color;
+
+public class PDBFeatureSettings extends FeatureSettingsAdapter
+{
+
+  @Override
+  public boolean isFeatureDisplayed(String type)
+  {
+    return type.equalsIgnoreCase(Pdb.FEATURE_INSERTION)
+            || type.equalsIgnoreCase(Pdb.FEATURE_RES_NUM);
+  }
+
+  @Override
+  public FeatureColourI getFeatureColour(String type)
+  {
+    if (type.equalsIgnoreCase(Pdb.FEATURE_INSERTION))
+    {
+      return new FeatureColourAdapter()
+      {
+
+        @Override
+        public Color getColour()
+        {
+          return Color.RED;
+        }
+      };
+    }
+    return null;
+  }
+
+  /**
+   * Order to render insertion after ResNum
+   */
+  @Override
+  public int compare(String feature1, String feature2)
+  {
+    if (feature1.equalsIgnoreCase(Pdb.FEATURE_INSERTION))
+    {
+      return +1;
+    }
+    if (feature2.equalsIgnoreCase(Pdb.FEATURE_INSERTION))
+    {
+      return -1;
+    }
+    if (feature1.equalsIgnoreCase(Pdb.FEATURE_RES_NUM))
+    {
+      return +1;
+    }
+    if (feature2.equalsIgnoreCase(Pdb.FEATURE_RES_NUM))
+    {
+      return -1;
+    }
+    return 0;
+  }
+}
+