right align ids
authoramwaterhouse <Andrew Waterhouse>
Wed, 15 Nov 2006 15:46:15 +0000 (15:46 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 15 Nov 2006 15:46:15 +0000 (15:46 +0000)
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/IdCanvas.java
src/jalview/gui/Jalview2XML.java

index 46bbc1b..18ebf0e 100755 (executable)
@@ -374,6 +374,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
 
     alignPanels.addElement(ap);
 
+    PaintRefresher.Register(ap, ap.av.getSequenceSetId());
+
     int aSize = alignPanels.size();
 
     tabbedPane.setVisible(aSize>1 || ap.av.viewName!=null);
@@ -466,10 +468,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
    */
   void setMenusFromViewport(AlignViewport av)
   {
+    padGapsMenuitem.setSelected(av.padGaps);
     colourTextMenuItem.setSelected(av.showColourText);
     abovePIDThreshold.setSelected(av.getAbovePIDThreshold());
     conservationMenuItem.setSelected(av.getConservationSelected());
     seqLimits.setSelected(av.getShowJVSuffix());
+    idRightAlign.setSelected(av.idsAlignRight);
     renderGapsMenuItem.setSelected(av.renderGaps);
     wrapMenuItem.setSelected(av.wrapAlignment);
     annotationPanelMenuItem.setState(av.showAnnotation);
@@ -957,10 +961,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
     viewport.redoList.push(command);
     command.undoCommand();
 
+
     viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
     updateEditMenuBar();
-    viewport.firePropertyChange("alignment", null,
-                                viewport.getAlignment().getSequences());
+    viewport.firePropertyChange("alignment", null,null);
   }
 
   /**
@@ -976,7 +980,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
     viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null;
 
     updateEditMenuBar();
-    viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
+    viewport.firePropertyChange("alignment", null, null);
   }
 
 
@@ -1729,6 +1733,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
     alignPanel.repaint();
   }
 
+  public void idRightAlign_actionPerformed(ActionEvent e)
+  {
+    viewport.idsAlignRight = idRightAlign.isSelected();
+    alignPanel.repaint();
+  }
+
+
 
   /**
    * DOCUMENT ME!
index ec52ee3..b609417 100755 (executable)
@@ -118,6 +118,8 @@ public class AlignViewport
     Color textColour = Color.black;
     Color textColour2 = Color.white;
 
+    boolean idsAlignRight = false;
+
 
     /**
      * Creates a new AlignViewport object.
index c9ed305..7b4d4ee 100755 (executable)
@@ -43,6 +43,7 @@ public class IdCanvas extends JPanel
     int imgHeight = 0;\r
     boolean fastPaint = false;\r
     java.util.Vector searchResults;\r
+    FontMetrics fm;\r
 \r
     /**\r
      * Creates a new IdCanvas object.\r
@@ -67,6 +68,8 @@ public class IdCanvas extends JPanel
      */\r
     public void drawIdString(Graphics2D gg, SequenceI s, int i, int starty, int ypos)\r
     {\r
+        int xPos = 0;\r
+        int panelWidth = getWidth();\r
         int charHeight = av.charHeight;\r
 \r
         if ((searchResults != null) && searchResults.contains(s))\r
@@ -92,9 +95,15 @@ public class IdCanvas extends JPanel
             gg.setColor(Color.black);\r
         }\r
 \r
+        if (av.idsAlignRight)\r
+        {\r
+          xPos = panelWidth - fm.stringWidth(\r
+              s.getDisplayId(av.getShowJVSuffix())\r
+              ) - 4;\r
+        }\r
 \r
         gg.drawString( s.getDisplayId(av.getShowJVSuffix()),\r
-                      0, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5));\r
+                    xPos, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5));\r
 \r
         if (av.hasHiddenRows && av.showHiddenMarkers)\r
           drawMarker(i, starty, ypos);\r
@@ -190,6 +199,7 @@ public class IdCanvas extends JPanel
         }\r
 \r
         gg = (Graphics2D) image.getGraphics();\r
+\r
         //Fill in the background\r
         gg.setColor(Color.white);\r
         gg.fillRect(0, 0, getWidth(), imgHeight);\r
@@ -211,6 +221,7 @@ public class IdCanvas extends JPanel
                              av.getFont().getSize());\r
 \r
       gg.setFont(italic);\r
+      fm = gg.getFontMetrics();\r
 \r
       if (av.antiAlias)\r
         gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
@@ -279,6 +290,8 @@ public class IdCanvas extends JPanel
         else\r
         {\r
           //Now draw the id strings\r
+          int panelWidth = getWidth();\r
+          int xPos = 0;\r
 \r
             SequenceI sequence;\r
             //Now draw the id strings\r
@@ -323,7 +336,13 @@ public class IdCanvas extends JPanel
 \r
                 String string = sequence.getDisplayId( av.getShowJVSuffix());\r
 \r
-                gg.drawString(string, 0,\r
+\r
+                if(av.idsAlignRight)\r
+                {\r
+                  xPos = panelWidth - fm.stringWidth(string) - 4;\r
+                }\r
+\r
+                gg.drawString(string, xPos,\r
                     (((i - starty) * av.charHeight) + av.charHeight) -\r
                     (av.charHeight / 5));\r
 \r
index 0f08896..6e3bffe 100755 (executable)
@@ -669,6 +669,7 @@ public class Jalview2XML
         view.setShowBoxes(av.getShowBoxes());
         view.setShowColourText(av.getColourText());
         view.setShowFullId(av.getShowJVSuffix());
+        view.setRightAlignIds(av.idsAlignRight);
         view.setShowSequenceFeatures(av.showSequenceFeatures);
         view.setShowText(av.getShowText());
         view.setWrapAlignment(av.getWrapAlignment());
@@ -1414,6 +1415,7 @@ public class Jalview2XML
 
         af.viewport.setConservationSelected(view.getConservationSelected());
         af.viewport.setShowJVSuffix(view.getShowFullId());
+        af.viewport.idsAlignRight=view.getRightAlignIds();
         af.viewport.setFont(new java.awt.Font(view.getFontName(),
                 view.getFontStyle(), view.getFontSize()));
         af.alignPanel.fontChanged();