From: amwaterhouse Date: Wed, 15 Nov 2006 15:46:15 +0000 (+0000) Subject: right align ids X-Git-Tag: Release_2_2~112 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e5f2de91dc41062d8cee8a2a900710f63cf5ae42;p=jalview.git right align ids --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 46bbc1b..18ebf0e 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -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! diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index ec52ee3..b609417 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -118,6 +118,8 @@ public class AlignViewport Color textColour = Color.black; Color textColour2 = Color.white; + boolean idsAlignRight = false; + /** * Creates a new AlignViewport object. diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index c9ed305..7b4d4ee 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -43,6 +43,7 @@ public class IdCanvas extends JPanel int imgHeight = 0; boolean fastPaint = false; java.util.Vector searchResults; + FontMetrics fm; /** * Creates a new IdCanvas object. @@ -67,6 +68,8 @@ public class IdCanvas extends JPanel */ public void drawIdString(Graphics2D gg, SequenceI s, int i, int starty, int ypos) { + int xPos = 0; + int panelWidth = getWidth(); int charHeight = av.charHeight; if ((searchResults != null) && searchResults.contains(s)) @@ -92,9 +95,15 @@ public class IdCanvas extends JPanel gg.setColor(Color.black); } + if (av.idsAlignRight) + { + xPos = panelWidth - fm.stringWidth( + s.getDisplayId(av.getShowJVSuffix()) + ) - 4; + } gg.drawString( s.getDisplayId(av.getShowJVSuffix()), - 0, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5)); + xPos, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5)); if (av.hasHiddenRows && av.showHiddenMarkers) drawMarker(i, starty, ypos); @@ -190,6 +199,7 @@ public class IdCanvas extends JPanel } gg = (Graphics2D) image.getGraphics(); + //Fill in the background gg.setColor(Color.white); gg.fillRect(0, 0, getWidth(), imgHeight); @@ -211,6 +221,7 @@ public class IdCanvas extends JPanel av.getFont().getSize()); gg.setFont(italic); + fm = gg.getFontMetrics(); if (av.antiAlias) gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, @@ -279,6 +290,8 @@ public class IdCanvas extends JPanel else { //Now draw the id strings + int panelWidth = getWidth(); + int xPos = 0; SequenceI sequence; //Now draw the id strings @@ -323,7 +336,13 @@ public class IdCanvas extends JPanel String string = sequence.getDisplayId( av.getShowJVSuffix()); - gg.drawString(string, 0, + + if(av.idsAlignRight) + { + xPos = panelWidth - fm.stringWidth(string) - 4; + } + + gg.drawString(string, xPos, (((i - starty) * av.charHeight) + av.charHeight) - (av.charHeight / 5)); diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 0f08896..6e3bffe 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -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();