Merge branch 'develop' into patch/JAL-4281_idwidthandannotHeight_in_project
authorJames Procter <j.procter@dundee.ac.uk>
Wed, 1 Nov 2023 19:08:58 +0000 (19:08 +0000)
committerJames Procter <j.procter@dundee.ac.uk>
Wed, 1 Nov 2023 19:08:58 +0000 (19:08 +0000)
 Conflicts:
src/jalview/gui/AlignmentPanel.java
and regenerated schema binding

35 files changed:
schemas/jalview.xsd
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/IdCanvas.java
src/jalview/gui/IdwidthAdjuster.java
src/jalview/project/Jalview2XML.java
src/jalview/xml/binding/jalview/AlcodonFrame.java
src/jalview/xml/binding/jalview/Annotation.java
src/jalview/xml/binding/jalview/AnnotationColourScheme.java
src/jalview/xml/binding/jalview/AnnotationElement.java
src/jalview/xml/binding/jalview/DoubleMatrix.java
src/jalview/xml/binding/jalview/DoubleVector.java
src/jalview/xml/binding/jalview/Feature.java
src/jalview/xml/binding/jalview/FeatureMatcher.java
src/jalview/xml/binding/jalview/FeatureMatcherSet.java
src/jalview/xml/binding/jalview/FilterBy.java
src/jalview/xml/binding/jalview/JalviewModel.java
src/jalview/xml/binding/jalview/JalviewUserColours.java
src/jalview/xml/binding/jalview/MapListType.java
src/jalview/xml/binding/jalview/MapOnAMatrixType.java
src/jalview/xml/binding/jalview/Mapping.java
src/jalview/xml/binding/jalview/MatrixType.java
src/jalview/xml/binding/jalview/NoValueColour.java
src/jalview/xml/binding/jalview/ObjectFactory.java
src/jalview/xml/binding/jalview/PcaDataType.java
src/jalview/xml/binding/jalview/Pdbentry.java
src/jalview/xml/binding/jalview/Property.java
src/jalview/xml/binding/jalview/Sequence.java
src/jalview/xml/binding/jalview/SequenceSet.java
src/jalview/xml/binding/jalview/SequenceType.java
src/jalview/xml/binding/jalview/ThresholdType.java
src/jalview/xml/binding/jalview/VAMSAS.java
src/jalview/xml/binding/jalview/WebServiceParameterSet.java
src/jalview/xml/binding/jalview/package-info.java
test/jalview/gui/AlignmentPanelTest.java
test/jalview/project/Jalview2xmlTests.java

index adaa3ee..c5d35fb 100755 (executable)
                                                <xs:attribute name="fontName" type="xs:string" />
                                                <xs:attribute name="fontSize" type="xs:int" />
                                                <xs:attribute name="fontStyle" type="xs:int" />
+                                               <xs:attribute name="idWidth" type="xs:int" />
+                                               <xs:attribute name="idWidthManuallyAdjusted" type="xs:boolean" />
                                                <xs:attribute name="scaleProteinAsCdna" type="xs:boolean" use="optional" default="true" />
                                                <xs:attribute name="viewName" type="xs:string" />
                                                <xs:attribute name="sequenceSetId" type="xs:string" />
index 3127731..fe6477e 100644 (file)
@@ -256,8 +256,10 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
   /**
    * Calculates the width of the alignment labels based on the displayed names
-   * and any bounds on label width set in preferences. The calculated width is
-   * also set as a property of the viewport.
+   * and any bounds on label width set in preferences.
+   * 
+   * The calculated width is set as a property of the viewport and the layout is
+   * updated.
    * 
    * @return Dimension giving the maximum width of the alignment label panel
    *         that should be used.
@@ -294,10 +296,19 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
   public Dimension calculateDefaultAlignmentIdWidth()
   {
+    return calculateIdWidth(-1, false, false);
+  }
+  /**
+   * pre 2.11.3 Id width calculation - used when importing old projects only
+   * @return
+   */
+  public int getLegacyIdWidth()
+  {
     int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300);
     int idWidth = Math.min(afwidth - 200, 2 * afwidth / 3);
     int maxwidth = Math.max(IdwidthAdjuster.MIN_ID_WIDTH, idWidth);
-    return calculateIdWidth(-1, false, false);
+    Dimension w = calculateIdWidthOrLegacy(true, maxwidth, false, false);
+    return w.width;
   }
 
   /**
@@ -324,13 +335,27 @@ public class AlignmentPanel extends GAlignmentPanel implements
    * @param maxwidth
    *          -1 or maximum width allowed for IdWidth
    * @param includeAnnotations - when true includes width of any additional marks in annotation id panel 
-   * @param visibleOnly -  
+   * @param visibleOnly - when true, ignore label widths for hidden annotation rows 
    * @return Dimension giving the maximum width of the alignment label panel
    *         that should be used.
    */
   public Dimension calculateIdWidth(int maxwidth,
           boolean includeAnnotations, boolean visibleOnly)
   {
+    return calculateIdWidthOrLegacy(false, maxwidth, includeAnnotations, visibleOnly);
+  }
+  
+  /**
+   * legacy mode or post 2.11.3 ID width calculation
+   * @param legacy - uses annotation labels, not rendered label width (excludes additional decorators)
+   * @param maxwidth
+   * @param includeAnnotations
+   * @param visibleOnly
+   * @return
+   */
+  private Dimension calculateIdWidthOrLegacy(boolean legacy, int maxwidth,
+          boolean includeAnnotations, boolean visibleOnly)
+  {
     Container c = new Container();
 
     FontMetrics fm = c.getFontMetrics(
@@ -352,10 +377,29 @@ public class AlignmentPanel extends GAlignmentPanel implements
     // Also check annotation label widths
     if (includeAnnotations && al.getAlignmentAnnotation() != null)
     {
-      AnnotationLabels aal = getAlabels();
-      int stringWidth = aal.drawLabels(null, false, idWidth, false, false,
-              fm, !visibleOnly);
-      idWidth = Math.max(idWidth, stringWidth);
+      fm = c.getFontMetrics(getAlabels().getFont());
+
+      if (!legacy || Jalview.isHeadlessMode())
+      {
+        AnnotationLabels aal = getAlabels();
+        int stringWidth = aal.drawLabels(null, false, idWidth, false, false,
+                fm, !visibleOnly);
+        idWidth = Math.max(idWidth, stringWidth);
+      }
+      else
+      {
+        for (i = 0; i < al.getAlignmentAnnotation().length; i++)
+        {
+          AlignmentAnnotation aa = al.getAlignmentAnnotation()[i];
+          if (visibleOnly && !aa.visible)
+          {
+            continue;
+          }
+          String label = aa.label;
+          int stringWidth = fm.stringWidth(label);
+          idWidth = Math.max(idWidth, stringWidth);
+        }
+      }
     }
 
     int w = maxwidth < 0 ? idWidth : Math.min(maxwidth, idWidth);
@@ -562,7 +606,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     // this is called after loading new annotation onto alignment
     if (alignFrame.getHeight() == 0)
     {
-      jalview.bin.Console.outPrintln("NEEDS FIXING");
+      jalview.bin.Console.error("adjustAnnotationHeight called with zero height alignment window");
     }
     validateAnnotationDimensions(true);
     addNotify();
@@ -595,7 +639,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     Dimension e = idPanel.getSize();
     int idWidth = e.width;
     boolean manuallyAdjusted = this.getIdPanel().getIdCanvas()
-            .manuallyAdjusted();
+            .isManuallyAdjusted();
     annotationScroller.setPreferredSize(new Dimension(
             manuallyAdjusted ? idWidth : annotationScroller.getWidth(),
             annotationHeight));
@@ -1229,7 +1273,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     }
 
     int w = getIdPanel().getWidth();
-    w = this.calculateIdWidth(-1, true, true).width;
+    w = calculateIdWidth(-1, true, true).width;
     return (w > 0 ? w : calculateIdWidth().width);
   }
 
@@ -1857,5 +1901,4 @@ public class AlignmentPanel extends GAlignmentPanel implements
       overviewPanel = null;
     }
   }
-
 }
index 0dde9b5..dbffc72 100755 (executable)
@@ -455,7 +455,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI
         int getWidth = getWidth();
         int thisIdWidth = getWidth;
         g.translate(0, ypos + (alheight * charHeight));
-        if (!manuallyAdjusted())
+        if (!isManuallyAdjusted())
         {
           int getAnnotationsIdWidth = labels.drawLabels(g, false, -1, false,forGUI,
                   null, false);
@@ -627,7 +627,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI
 
   private boolean manuallyAdjusted = false;
 
-  public boolean manuallyAdjusted()
+  public boolean isManuallyAdjusted()
   {
     return manuallyAdjusted;
   }
index 762612e..f1c4c83 100755 (executable)
@@ -179,7 +179,7 @@ public class IdwidthAdjuster extends JPanel
   public void setWidth(int newWidth)
   {
     if (newWidth < MIN_ID_WIDTH
-            || ap.getIdPanel().getIdCanvas().manuallyAdjusted())
+            || ap.getIdPanel().getIdCanvas().isManuallyAdjusted())
     {
       return;
     }
@@ -190,7 +190,7 @@ public class IdwidthAdjuster extends JPanel
 
   public boolean manuallyAdjusted()
   {
-    return ap.getIdPanel().getIdCanvas().manuallyAdjusted();
+    return ap.getIdPanel().getIdCanvas().isManuallyAdjusted();
   }
 
   @Override
index ecb24b4..d5b3808 100644 (file)
@@ -1646,6 +1646,9 @@ public class Jalview2XML
       view.setShowColourText(av.getColourText());
       view.setShowFullId(av.getShowJVSuffix());
       view.setRightAlignIds(av.isRightAlignIds());
+      view.setIdWidth(av.getIdWidth());
+      view.setIdWidthManuallyAdjusted(ap.getIdPanel().getIdCanvas().isManuallyAdjusted());
+      
       view.setShowSequenceFeatures(av.isShowSequenceFeatures());
       view.setShowText(av.getShowText());
       view.setShowUnconserved(av.getShowUnconserved());
@@ -5241,6 +5244,21 @@ public class Jalview2XML
     }
     af.setBounds(safeInt(view.getXpos()), safeInt(view.getYpos()),
             safeInt(view.getWidth()), safeInt(view.getHeight()));
+    
+    af.alignPanel.fontChanged(); // make sure font is updated *before* we set ID width
+    if (view.getIdWidth()==null)
+    {
+      if (!isVersionStringLaterThan("2.11.3", jm.getVersion())) {
+        // Pre 2.11.3 jalview projects do not store the id width
+        // idWidth was also calculated in a different way.
+        viewport.setIdWidth(af.alignPanel.getLegacyIdWidth());
+        af.alignPanel.getIdPanel().getIdCanvas().setManuallyAdjusted(true);
+      }
+    } else {
+      viewport.setIdWidth(view.getIdWidth());
+      af.alignPanel.getIdPanel().getIdCanvas().setManuallyAdjusted(view.isIdWidthManuallyAdjusted());
+    }
+    
     // startSeq set in af.alignPanel.updateLayout below
     af.alignPanel.updateLayout();
     ColourSchemeI cs = null;
index c241422..c412c36 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index bb20751..261e0ed 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 5f2f7d0..f7e974b 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index eaddc5a..a57101a 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index f2d3fe2..4ef5abc 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index b7d7d87..19a0d24 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 7b25d44..97bedae 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index d83131c..9913337 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index f182816..a51e7d5 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 2db2173..5723e3d 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 4e0857d..360c074 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
@@ -215,6 +215,8 @@ import javax.xml.datatype.XMLGregorianCalendar;
  *                   &amp;lt;attribute name="fontName" type="{http://www.w3.org/2001/XMLSchema}string" /&amp;gt;
  *                   &amp;lt;attribute name="fontSize" type="{http://www.w3.org/2001/XMLSchema}int" /&amp;gt;
  *                   &amp;lt;attribute name="fontStyle" type="{http://www.w3.org/2001/XMLSchema}int" /&amp;gt;
+ *                   &amp;lt;attribute name="idWidth" type="{http://www.w3.org/2001/XMLSchema}int" /&amp;gt;
+ *                   &amp;lt;attribute name="idWidthManuallyAdjusted" type="{http://www.w3.org/2001/XMLSchema}boolean" /&amp;gt;
  *                   &amp;lt;attribute name="scaleProteinAsCdna" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" /&amp;gt;
  *                   &amp;lt;attribute name="viewName" type="{http://www.w3.org/2001/XMLSchema}string" /&amp;gt;
  *                   &amp;lt;attribute name="sequenceSetId" type="{http://www.w3.org/2001/XMLSchema}string" /&amp;gt;
@@ -4893,6 +4895,8 @@ public class JalviewModel {
      *       &amp;lt;attribute name="fontName" type="{http://www.w3.org/2001/XMLSchema}string" /&amp;gt;
      *       &amp;lt;attribute name="fontSize" type="{http://www.w3.org/2001/XMLSchema}int" /&amp;gt;
      *       &amp;lt;attribute name="fontStyle" type="{http://www.w3.org/2001/XMLSchema}int" /&amp;gt;
+     *       &amp;lt;attribute name="idWidth" type="{http://www.w3.org/2001/XMLSchema}int" /&amp;gt;
+     *       &amp;lt;attribute name="idWidthManuallyAdjusted" type="{http://www.w3.org/2001/XMLSchema}boolean" /&amp;gt;
      *       &amp;lt;attribute name="scaleProteinAsCdna" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" /&amp;gt;
      *       &amp;lt;attribute name="viewName" type="{http://www.w3.org/2001/XMLSchema}string" /&amp;gt;
      *       &amp;lt;attribute name="sequenceSetId" type="{http://www.w3.org/2001/XMLSchema}string" /&amp;gt;
@@ -4996,6 +5000,10 @@ public class JalviewModel {
         protected Integer fontSize;
         @XmlAttribute(name = "fontStyle")
         protected Integer fontStyle;
+        @XmlAttribute(name = "idWidth")
+        protected Integer idWidth;
+        @XmlAttribute(name = "idWidthManuallyAdjusted")
+        protected Boolean idWidthManuallyAdjusted;
         @XmlAttribute(name = "scaleProteinAsCdna")
         protected Boolean scaleProteinAsCdna;
         @XmlAttribute(name = "viewName")
@@ -5993,6 +6001,54 @@ public class JalviewModel {
         }
 
         /**
+         * Gets the value of the idWidth property.
+         * 
+         * @return
+         *     possible object is
+         *     {@link Integer }
+         *     
+         */
+        public Integer getIdWidth() {
+            return idWidth;
+        }
+
+        /**
+         * Sets the value of the idWidth property.
+         * 
+         * @param value
+         *     allowed object is
+         *     {@link Integer }
+         *     
+         */
+        public void setIdWidth(Integer value) {
+            this.idWidth = value;
+        }
+
+        /**
+         * Gets the value of the idWidthManuallyAdjusted property.
+         * 
+         * @return
+         *     possible object is
+         *     {@link Boolean }
+         *     
+         */
+        public Boolean isIdWidthManuallyAdjusted() {
+            return idWidthManuallyAdjusted;
+        }
+
+        /**
+         * Sets the value of the idWidthManuallyAdjusted property.
+         * 
+         * @param value
+         *     allowed object is
+         *     {@link Boolean }
+         *     
+         */
+        public void setIdWidthManuallyAdjusted(Boolean value) {
+            this.idWidthManuallyAdjusted = value;
+        }
+
+        /**
          * Gets the value of the scaleProteinAsCdna property.
          * 
          * @return
index 1c0af33..592ef1b 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 2bac782..d5cd7a8 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 47460a3..d48a315 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index f32c611..9c98af8 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 01629b0..34d1158 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 5b329a9..8d22ad8 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 26269ec..90ce3fa 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index a4b2dbe..aa418e5 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 6fabea0..144076b 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 4c85bc3..5fc6047 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 76b4f1a..af05181 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index ce80b9c..751f6ca 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index dbcefe8..429061b 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index a467506..f6570a2 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index f1eab2b..6c5240f 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 577c9a4..181d9e1 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 
index 21a46db..bb3301a 100644 (file)
@@ -2,7 +2,7 @@
 // This file was generated by the Eclipse Implementation of JAXB, v2.3.3 
 // See https://eclipse-ee4j.github.io/jaxb-ri 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2023.09.01 at 02:16:11 PM BST 
+// Generated on: 2023.11.01 at 07:03:09 PM GMT 
 //
 
 @javax.xml.bind.annotation.XmlSchema(namespace = "www.vamsas.ac.uk/jalview/version2", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
index 892cdef..a39257c 100644 (file)
@@ -23,6 +23,7 @@ package jalview.gui;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotEquals;
 import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
 
 import java.awt.Container;
 import java.awt.Dimension;
@@ -299,7 +300,30 @@ public class AlignmentPanelTest
     Cache.setProperty("FIGURE_AUTOIDWIDTH", Boolean.TRUE.toString());
     assertEquals(115, af.alignPanel.getVisibleIdWidth(false));
   }
+  @Test(groups = { "Functional", "Not-bamboo" })
+  public void testresetIdWidth()
+  {
+    /*
+     * width for onscreen rendering is IDPanel width
+     */
+    int w = af.alignPanel.getVisibleIdWidth(true);
+    assertEquals(w, af.alignPanel.getIdPanel().getWidth());
+    assertEquals(w, 115);
+
+    // manually adjust 
+    af.viewport.setIdWidth(200);
+    w = af.alignPanel.calculateIdWidth().width;
+    assertTrue(af.alignPanel.getIdPanel().getIdCanvas().isManuallyAdjusted());
+    assertEquals(w, af.alignPanel.getIdPanel().getWidth());
 
+    af.viewport.setIdWidth(-1);
+    af.alignPanel.getIdPanel().getIdCanvas().setManuallyAdjusted(false);
+    w = af.alignPanel.calculateIdWidth().width;
+    
+    assertEquals(w, af.alignPanel.getIdPanel().getWidth());
+
+    assertNotEquals(w,115);
+  }
   @Test(groups = "Functional")
   public void testSetOverviewTitle()
   {
index 9c1b32f..76c5266 100644 (file)
@@ -1738,4 +1738,67 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     
   }
 
+  @Test(groups = "Functional")
+  public void testStoreAndRestoreIDwidthAndAnnotationHeight() throws IOException
+  {
+    Desktop.instance.closeAll_actionPerformed(null);
+    final String SECONDVIEW = "With Diffferent IDwidth";
+    // create a new tempfile
+    File tempfile = File.createTempFile("jvIdWidthStoreRestore", "jvp");
+
+
+    AlignFrame af = new FileLoader().LoadFileWaitTillLoaded("examples/exampleFile.jvp",
+              DataSourceType.FILE);
+      assertNotNull(af, "Didn't read in the example file correctly.");
+      assertEquals(af.alignPanel.getAlignViewport().getIdWidth(), 144,
+              "Legacy project import should have fixed ID width");
+      assertTrue(af.alignPanel.getIdPanel().getIdCanvas().isManuallyAdjusted());
+      
+      
+      af.alignPanel.getAlignViewport().setIdWidth(100);
+      af.alignPanel.updateLayout();
+      assertTrue(af.alignPanel.getIdPanel().getIdCanvas().isManuallyAdjusted());
+      
+      Jalview2XML jv2xml = new jalview.project.Jalview2XML(false);
+      tempfile.delete();
+      jv2xml.saveState(tempfile);
+      assertTrue(jv2xml.errorMessage == null,
+              "Failed to save dummy project with PCA: test broken");
+      af = null;
+      // load again.
+      Desktop.instance.closeAll_actionPerformed(null);
+      af = new FileLoader().LoadFileWaitTillLoaded(
+              tempfile.getCanonicalPath(), DataSourceType.FILE);
+      assertTrue(af.alignPanel.getIdPanel().getIdCanvas()
+              .isManuallyAdjusted());
+      assertEquals(af.alignPanel.getAlignViewport().getIdWidth(), 100,
+              "New project exported and import should have adjusted ID width");
+
+      af.alignPanel.getAlignViewport().setIdWidth(100);
+      af.alignPanel.updateLayout();
+      assertTrue(af.alignPanel.getIdPanel().getIdCanvas().isManuallyAdjusted());
+      
+      // now make it autoadjusted
+      af.alignPanel.getAlignViewport().setIdWidth(-1);
+      af.alignPanel.getIdPanel().getIdCanvas().setManuallyAdjusted(false);
+      af.alignPanel.updateLayout();
+      assertFalse(af.alignPanel.getIdPanel().getIdCanvas().isManuallyAdjusted());
+      assertTrue(af.alignPanel.getAlignViewport().getIdWidth()>-1,
+              "New project exported and import should have adjusted ID width");
+      
+      jv2xml = new jalview.project.Jalview2XML(false);
+      tempfile.delete();
+      jv2xml.saveState(tempfile);
+      assertTrue(jv2xml.errorMessage == null,
+              "Failed to save dummy project with PCA: test broken");
+      af = null;
+      // load again.
+      Desktop.instance.closeAll_actionPerformed(null);
+      af = new FileLoader().LoadFileWaitTillLoaded(
+              tempfile.getCanonicalPath(), DataSourceType.FILE);
+      assertFalse(af.alignPanel.getIdPanel().getIdCanvas().isManuallyAdjusted());
+      assertTrue(af.alignPanel.getAlignViewport().getIdWidth()>-1,
+              "New project exported and import should have adjusted ID width");
+  }
+
 }