Merge remote-tracking branch 'origin/releases/Release_2_10_2b1_Branch'
[jalview.git] / src / jalview / gui / AlignmentPanel.java
index c4eb26a..7cd8b50 100644 (file)
@@ -70,8 +70,7 @@ import javax.swing.SwingUtilities;
  * @version $Revision: 1.161 $
  */
 public class AlignmentPanel extends GAlignmentPanel implements
-        AdjustmentListener, Printable, AlignmentViewPanel,
-        ViewportListenerI
+        AdjustmentListener, Printable, AlignmentViewPanel, ViewportListenerI
 {
   public AlignViewport av;
 
@@ -157,8 +156,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
         // is initialised
         if (av.getWrapAlignment())
         {
-          int widthInRes = getSeqPanel().seqCanvas
-                  .getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
+          int widthInRes = getSeqPanel().seqCanvas.getWrappedCanvasWidth(
+                  getSeqPanel().seqCanvas.getWidth());
           vpRanges.setViewportWidth(widthInRes);
         }
         else
@@ -167,7 +166,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
                   / av.getCharWidth();
           int heightInSeq = getSeqPanel().seqCanvas.getHeight()
                   / av.getCharHeight();
-          
+
           vpRanges.setViewportWidth(widthInRes);
           vpRanges.setViewportHeight(heightInSeq);
         }
@@ -226,10 +225,10 @@ public class AlignmentPanel extends GAlignmentPanel implements
     // to prevent drawing old image
     FontMetrics fm = getFontMetrics(av.getFont());
 
-    scalePanelHolder.setPreferredSize(new Dimension(10, av.getCharHeight()
-            + fm.getDescent()));
-    idSpaceFillerPanel1.setPreferredSize(new Dimension(10, av
-            .getCharHeight() + fm.getDescent()));
+    scalePanelHolder.setPreferredSize(
+            new Dimension(10, av.getCharHeight() + fm.getDescent()));
+    idSpaceFillerPanel1.setPreferredSize(
+            new Dimension(10, av.getCharHeight() + fm.getDescent()));
 
     getIdPanel().getIdCanvas().gg = null;
     getSeqPanel().seqCanvas.img = null;
@@ -289,8 +288,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
   {
     Container c = new Container();
 
-    FontMetrics fm = c.getFontMetrics(new Font(av.font.getName(),
-            Font.ITALIC, av.font.getSize()));
+    FontMetrics fm = c.getFontMetrics(
+            new Font(av.font.getName(), Font.ITALIC, av.font.getSize()));
 
     AlignmentI al = av.getAlignment();
     int i = 0;
@@ -331,8 +330,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
       }
     }
 
-    return new Dimension(maxwidth < 0 ? idWidth : Math.min(maxwidth,
-            idWidth), 12);
+    return new Dimension(
+            maxwidth < 0 ? idWidth : Math.min(maxwidth, idWidth), 12);
   }
 
   /**
@@ -477,8 +476,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
           /*
            * Scroll down to make end of search results visible
            */
-          setScrollValues(vpRanges.getStartRes(), starts + seqIndex - ends
-                  + 1);
+          setScrollValues(vpRanges.getStartRes(),
+                  starts + seqIndex - ends + 1);
         }
         /*
          * Else results are already visible - no need to scroll
@@ -579,8 +578,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
        */
       if (annotationHeight + alignmentHeight > availableHeight)
       {
-        annotationHeight = Math.min(annotationHeight, availableHeight - 2
-                * rowHeight);
+        annotationHeight = Math.min(annotationHeight,
+                availableHeight - 2 * rowHeight);
       }
     }
     else
@@ -590,8 +589,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
     }
     hscroll.addNotify();
 
-    annotationScroller.setPreferredSize(new Dimension(annotationScroller
-            .getWidth(), annotationHeight));
+    annotationScroller.setPreferredSize(
+            new Dimension(annotationScroller.getWidth(), annotationHeight));
 
     Dimension e = idPanel.getSize();
     alabels.setSize(new Dimension(e.width, annotationHeight));
@@ -641,8 +640,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
       else
       {
         int widthInRes = (canvasWidth / av.getCharWidth()) - 1;
-        int heightInSeq = (getSeqPanel().seqCanvas.getHeight() / av
-                .getCharHeight()) - 1;
+        int heightInSeq = (getSeqPanel().seqCanvas.getHeight()
+                / av.getCharHeight()) - 1;
 
         vpRanges.setViewportWidth(widthInRes);
         vpRanges.setViewportHeight(heightInSeq);
@@ -654,7 +653,6 @@ public class AlignmentPanel extends GAlignmentPanel implements
     repaint();
   }
 
-
   /**
    * Adjust row/column scrollers to show a visible position in the alignment.
    * 
@@ -686,7 +684,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
       if (av.hasHiddenColumns())
       {
         // reset the width to exclude hidden columns
-        width = av.getAlignment().getHiddenColumns().findColumnPosition(width);
+        width = av.getAlignment().getHiddenColumns()
+                .findColumnPosition(width);
       }
 
       hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
@@ -828,13 +827,13 @@ public class AlignmentPanel extends GAlignmentPanel implements
       {
         @Override
         public void run()
-      {
+        {
           // When updating scrolling to use ViewportChange events, this code
           // could not be validated and it is not clear if it is now being
           // called. Log warning here in case it is called and unforeseen
           // problems occur
-          Cache.log
-                  .warn("Unexpected path through code: Wrapped jar file opened with wrap alignment set in preferences");
+          Cache.log.warn(
+                  "Unexpected path through code: Wrapped jar file opened with wrap alignment set in preferences");
 
           // scroll to start of panel
           vpRanges.setStartRes(0);
@@ -989,7 +988,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
      * Get the horizontal offset to where we draw the sequences.
      * This is idWidth if using a single Graphics context, else zero.
      */
-    final int alignmentGraphicsOffset = idGraphics != alignmentGraphics ? 0 : idWidth;
+    final int alignmentGraphicsOffset = idGraphics != alignmentGraphics ? 0
+            : idWidth;
 
     FontMetrics fm = getFontMetrics(av.getFont());
     int charHeight = av.getCharHeight();
@@ -1026,8 +1026,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
       endSeq = alignmentHeight;
     }
 
-    int pagesHigh = ((alignmentHeight / totalSeq) + 1)
-            * pageHeight;
+    int pagesHigh = ((alignmentHeight / totalSeq) + 1) * pageHeight;
 
     if (av.isShowAnnotation())
     {
@@ -1040,8 +1039,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     {
       return Printable.NO_SUCH_PAGE;
     }
-    final int alignmentDrawnHeight = (endSeq - startSeq) * charHeight
-            + 3;
+    final int alignmentDrawnHeight = (endSeq - startSeq) * charHeight + 3;
 
     /*
      * draw the Scale at horizontal offset, then reset to top left (0, 0)
@@ -1090,9 +1088,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
       if (av.isRightAlignIds())
       {
         fm = idGraphics.getFontMetrics();
-        xPos = idWidth
-                - fm.stringWidth(displayId)
-                - 4;
+        xPos = idWidth - fm.stringWidth(displayId) - 4;
       }
 
       idGraphics.drawString(displayId, xPos,
@@ -1128,7 +1124,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
        * draw the annotations starting at 
        * (idOffset, alignmentHeight) from (0, scaleHeight)
        */
-      alignmentGraphics.translate(alignmentGraphicsOffset, alignmentDrawnHeight);
+      alignmentGraphics.translate(alignmentGraphicsOffset,
+              alignmentDrawnHeight);
       getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av,
               alignmentGraphics, -1, startRes, endRes + 1);
     }
@@ -1182,8 +1179,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
               .findColumnPosition(maxwidth) - 1;
     }
 
-    int resWidth = getSeqPanel().seqCanvas.getWrappedCanvasWidth(pwidth
-            - idWidth);
+    int resWidth = getSeqPanel().seqCanvas
+            .getWrappedCanvasWidth(pwidth - idWidth);
 
     int totalHeight = cHeight * (maxwidth / resWidth + 1);
 
@@ -1220,16 +1217,13 @@ public class AlignmentPanel extends GAlignmentPanel implements
       }
       if (labels != null)
       {
-        pg.translate(-3,
-                ypos + (av.getAlignment().getHeight() * av.getCharHeight()));
+        pg.translate(-3, ypos
+                + (av.getAlignment().getHeight() * av.getCharHeight()));
 
         pg.setFont(av.getFont());
         labels.drawComponent(pg, idWidth);
-        pg.translate(
-                +3,
-                -ypos
-                        - (av.getAlignment().getHeight() * av
-                                .getCharHeight()));
+        pg.translate(+3, -ypos
+                - (av.getAlignment().getHeight() * av.getCharHeight()));
       }
 
       ypos += cHeight;
@@ -1279,8 +1273,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
       return calculateIdWidth(-1).width + 4;
     }
     Integer idwidth = null;
-    if (onscreen
-            || (idwidth = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH")) == null)
+    if (onscreen || (idwidth = Cache
+            .getIntegerProperty("FIGURE_FIXEDIDWIDTH")) == null)
     {
       int w = getIdPanel().getWidth();
       return (w > 0 ? w : calculateIdWidth().width + 4);
@@ -1292,15 +1286,15 @@ public class AlignmentPanel extends GAlignmentPanel implements
   {
     int boarderBottomOffset = 5;
     long pSessionId = System.currentTimeMillis();
-    headless = (System.getProperty("java.awt.headless") != null && System
-            .getProperty("java.awt.headless").equals("true"));
+    headless = (System.getProperty("java.awt.headless") != null
+            && System.getProperty("java.awt.headless").equals("true"));
     if (alignFrame != null && !headless)
     {
       if (file != null)
       {
-        alignFrame.setProgressBar(MessageManager.formatMessage(
-                "status.saving_file", new Object[] { type.getLabel() }),
-                pSessionId);
+        alignFrame.setProgressBar(MessageManager
+                .formatMessage("status.saving_file", new Object[]
+                { type.getLabel() }), pSessionId);
       }
     }
     try
@@ -1327,9 +1321,9 @@ public class AlignmentPanel extends GAlignmentPanel implements
         }
 
         im = new jalview.util.ImageMaker(this, type, imageAction,
-                aDimension.getWidth(), aDimension.getHeight()
-                        + boarderBottomOffset, file, imageTitle,
-                alignFrame, pSessionId, headless);
+                aDimension.getWidth(),
+                aDimension.getHeight() + boarderBottomOffset, file,
+                imageTitle, alignFrame, pSessionId, headless);
         Graphics graphics = im.getGraphics();
         if (av.getWrapAlignment())
         {
@@ -1345,8 +1339,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
         {
           if (graphics != null)
           {
-            printUnwrapped(aDimension.getWidth(), aDimension.getHeight(),
-                    0, graphics, graphics);
+            printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
+                    graphics, graphics);
             im.writeImage();
           }
         }
@@ -1391,9 +1385,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
         // this duplicates the calculation in getWrappedHeight but adjusts for
         // offscreen idWith
         width = alignFrame.getWidth() - vscroll.getPreferredSize().width
-                - alignFrame.getInsets().left
-                - alignFrame.getInsets().right - getVisibleIdWidth()
-                + getVisibleIdWidth(false);
+                - alignFrame.getInsets().left - alignFrame.getInsets().right
+                - getVisibleIdWidth() + getVisibleIdWidth(false);
       }
       else
       {
@@ -1444,8 +1437,9 @@ public class AlignmentPanel extends GAlignmentPanel implements
     {
       try
       {
-        int s, sSize = av.getAlignment().getHeight(), res, alwidth = av
-                .getAlignment().getWidth(), g, gSize, f, fSize, sy;
+        int s, sSize = av.getAlignment().getHeight(), res,
+                alwidth = av.getAlignment().getWidth(), g, gSize, f, fSize,
+                sy;
         PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));
         out.println(jalview.io.HTMLOutput.getImageMapHTML());
         out.println("<img src=\"" + imageName
@@ -1465,13 +1459,13 @@ public class AlignmentPanel extends GAlignmentPanel implements
             String triplet = null;
             if (av.getAlignment().isNucleotide())
             {
-              triplet = ResidueProperties.nucleotideName.get(seq
-                      .getCharAt(res) + "");
+              triplet = ResidueProperties.nucleotideName
+                      .get(seq.getCharAt(res) + "");
             }
             else
             {
-              triplet = ResidueProperties.aa2Triplet.get(seq.getCharAt(res)
-                      + "");
+              triplet = ResidueProperties.aa2Triplet
+                      .get(seq.getCharAt(res) + "");
             }
 
             if (triplet == null)
@@ -1536,16 +1530,16 @@ public class AlignmentPanel extends GAlignmentPanel implements
                   {
                     text.append("<br>");
                     text.append(features[f].getType());
-                    if (features[f].getDescription() != null
-                            && !features[f].getType().equals(
-                                    features[f].getDescription()))
+                    if (features[f].getDescription() != null && !features[f]
+                            .getType().equals(features[f].getDescription()))
                     {
                       text.append(" ").append(features[f].getDescription());
                     }
 
                     if (features[f].getValue("status") != null)
                     {
-                      text.append(" (").append(features[f].getValue("status"))
+                      text.append(" (")
+                              .append(features[f].getValue("status"))
                               .append(")");
                     }
                   }
@@ -1903,7 +1897,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
   @Override
   /**
-   * Property change event fired when a change is made to the viewport ranges 
+   * Property change event fired when a change is made to the viewport ranges
    * object associated with this alignment panel's viewport
    */
   public void propertyChange(PropertyChangeEvent evt)