Make ImageMap for features as well as groups
authoramwaterhouse <Andrew Waterhouse>
Tue, 6 Dec 2005 17:14:57 +0000 (17:14 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 6 Dec 2005 17:14:57 +0000 (17:14 +0000)
src/jalview/gui/AlignmentPanel.java

index ed00d33..e3bc620 100755 (executable)
@@ -809,6 +809,11 @@ public class AlignmentPanel extends GAlignmentPanel
     int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30;\r
     int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth);\r
 \r
+    if (idPanel.getWidth() == 0)\r
+    {\r
+      width += calculateIdWidth().getWidth() + 4;\r
+    }\r
+\r
     if (av.getWrapAlignment())\r
     {\r
       height = getWrappedHeight();\r
@@ -897,45 +902,102 @@ public class AlignmentPanel extends GAlignmentPanel
     {\r
       try\r
       {\r
+        int s, sSize = av.alignment.getHeight(),\r
+            res, alwidth = av.alignment.getWidth(), g, gSize, f, fSize, sy;\r
+        StringBuffer text = new StringBuffer();\r
         PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));\r
         out.println(jalview.io.HTMLOutput.getImageMapHTML());\r
         out.println("<img src=\"" + imageName +\r
                     "\" border=\"0\" usemap=\"#Map\" >"\r
                     + "<map name=\"Map\">");\r
 \r
-        for (int s = 0; s < av.alignment.getHeight(); s++)\r
+        for (s = 0; s < sSize; s++)\r
         {\r
+          sy = s * av.charHeight + scaleHeight;\r
+\r
           SequenceI seq = av.alignment.getSequenceAt(s);\r
+          java.util.Vector features = seq.getDatasetSequence().getSequenceFeatures();\r
           SequenceGroup[] groups = av.alignment.findAllGroups(seq);\r
-          for (int i = 0; i < groups.length; i++)\r
+          for(res =0; res<alwidth; res++)\r
           {\r
-            int sy = s * av.charHeight + scaleHeight;\r
-            for (int res = groups[i].getStartRes();\r
-                 res < groups[i].getEndRes() + 1; res++)\r
+            text = new StringBuffer();\r
+            Object obj = ResidueProperties.aa2Triplet.get(\r
+                    seq.getCharAt(res) + "");\r
+            if (obj == null)\r
+                  continue;\r
+\r
+            String triplet = obj.toString();\r
+            int alIndex = seq.findPosition(res);\r
+            gSize = groups.length;\r
+            for (g = 0; g < gSize; g++)\r
             {\r
-              int alIndex = seq.findPosition(res);\r
-              Object obj = ResidueProperties.aa2Triplet.get(\r
-                  seq.getCharAt(res) + "");\r
-              if (obj == null)\r
-                continue;\r
+              if(text.length()<1)\r
+              {\r
+                text.append("<area shape=\"rect\" coords=\""\r
+                  + (idWidth + res * av.charWidth) + ","\r
+                  + sy + ","\r
+                  + (idWidth + (res + 1) * av.charWidth) + ","\r
+                  + (av.charHeight + sy) + "\""\r
+                  + " onMouseOver=\"toolTip('"\r
+                  + alIndex + " " + triplet );\r
+              }\r
 \r
-              String triplet = obj.toString();\r
+              if(groups[g].getStartRes()<res && groups[g].getEndRes()>res)\r
+                text.append("<br><em>" + groups[g].getName() + "</em>");\r
+            }\r
 \r
-              out.println(\r
-                  "<area shape=\"rect\" coords=\""\r
+            if (features != null)\r
+            {\r
+              if(text.length()<1)\r
+              {\r
+                text.append("<area shape=\"rect\" coords=\""\r
                   + (idWidth + res * av.charWidth) + ","\r
                   + sy + ","\r
                   + (idWidth + (res + 1) * av.charWidth) + ","\r
                   + (av.charHeight + sy) + "\""\r
                   + " onMouseOver=\"toolTip('"\r
-                  + alIndex + " " + triplet +\r
-                  "<br><em>" + groups[i].getName() +\r
-                  "</em>')\"; onMouseOut=\"toolTip()\"; "\r
-                  + " href=\"#\">");\r
+                  + alIndex + " " + triplet );\r
+              }\r
+                fSize = features.size();\r
+                for (f = 0; f < fSize; f++)\r
+                {\r
+                  SequenceFeature sf = (SequenceFeature) features.elementAt(f);\r
+\r
+                  if ( (sf.getBegin() <= seq.findPosition(res)) &&\r
+                      (sf.getEnd() >= seq.findPosition(res)))\r
+                  {\r
+                    if (sf.getType().equals("disulfide bond"))\r
+                    {\r
+                      if (sf.getBegin() == seq.findPosition(res)\r
+                          || sf.getEnd() == seq.findPosition(res))\r
+                      {\r
+                        text.append("<br>disulfide bond " + sf.getBegin() + ":" +\r
+                                       sf.getEnd());\r
+                      }\r
+                    }\r
+                    else\r
+                    {\r
+                      text.append("<br>");\r
+                      text.append(sf.getType());\r
+                      if (sf.getDescription() != null && !sf.getType().equals(sf.getDescription()))\r
+                        text.append(" " + sf.getDescription());\r
+\r
+                      if (sf.getStatus() != null && sf.getStatus().length()>0)\r
+                      {\r
+                        text.append(" (" + sf.getStatus() + ")");\r
+                      }\r
+                    }\r
+                  }\r
+\r
+                }\r
+              }\r
+              if(text.length()>1)\r
+              {\r
+                text.append("')\"; onMouseOut=\"toolTip()\";  href=\"#\">");\r
+                out.println(text.toString());\r
+              }\r
             }\r
           }\r
-        }\r
-\r
         out.println("</map></body></html>");\r
         out.close();\r
 \r