JAL-2009 added programmatic custom feature setting to show insertion position for...
[jalview.git] / src / jalview / io / PDBFeatureSettings.java
1 package jalview.io;
2
3 import jalview.api.FeatureColourI;
4 import jalview.schemes.FeatureColourAdapter;
5 import jalview.schemes.FeatureSettingsAdapter;
6 import jalview.ws.dbsources.Pdb;
7
8 import java.awt.Color;
9
10 public class PDBFeatureSettings extends FeatureSettingsAdapter
11 {
12
13   @Override
14   public boolean isFeatureDisplayed(String type)
15   {
16     return type.equalsIgnoreCase(Pdb.FEATURE_INSERTION)
17             || type.equalsIgnoreCase(Pdb.FEATURE_RES_NUM);
18   }
19
20   @Override
21   public FeatureColourI getFeatureColour(String type)
22   {
23     if (type.equalsIgnoreCase(Pdb.FEATURE_INSERTION))
24     {
25       return new FeatureColourAdapter()
26       {
27
28         @Override
29         public Color getColour()
30         {
31           return Color.RED;
32         }
33       };
34     }
35     return null;
36   }
37
38   /**
39    * Order to render insertion after ResNum
40    */
41   @Override
42   public int compare(String feature1, String feature2)
43   {
44     if (feature1.equalsIgnoreCase(Pdb.FEATURE_INSERTION))
45     {
46       return +1;
47     }
48     if (feature2.equalsIgnoreCase(Pdb.FEATURE_INSERTION))
49     {
50       return -1;
51     }
52     if (feature1.equalsIgnoreCase(Pdb.FEATURE_RES_NUM))
53     {
54       return +1;
55     }
56     if (feature2.equalsIgnoreCase(Pdb.FEATURE_RES_NUM))
57     {
58       return -1;
59     }
60     return 0;
61   }
62 }
63