*
* @param maxwidth
* -1 or maximum width allowed for IdWidth
- * @param includeAnnotations - when true, annotation label widths are also accounted for
+ * @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.
*/
// 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);
++ 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);
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);
+ null, false);
thisIdWidth = idWidth < 0 ? getAnnotationsIdWidth : idWidth;
if (thisIdWidth > getWidth)
{
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
--- /dev/null
+ //
+ // 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
+ //
+
+
+ package jalview.xml.binding.jalview;
+
+ import java.util.ArrayList;
+ import java.util.List;
+ import javax.xml.bind.annotation.XmlAccessType;
+ import javax.xml.bind.annotation.XmlAccessorType;
+ import javax.xml.bind.annotation.XmlAttribute;
+ import javax.xml.bind.annotation.XmlType;
+
+
+ /**
+ * Defines a mapping from the local frame to a matrix
+ * and its associated data specified by MatrixType
+ *
+ *
+ * <p>Java class for MapOnAMatrixType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="MapOnAMatrixType"&gt;
+ * &lt;complexContent&gt;
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
+ * &lt;sequence&gt;
+ * &lt;element name="property" type="{www.vamsas.ac.uk/jalview/version2}property" maxOccurs="unbounded" minOccurs="0"/&gt;
+ * &lt;element name="mapping" type="{www.vamsas.ac.uk/jalview/version2}mapListType" minOccurs="0"/&gt;
+ * &lt;/sequence&gt;
+ * &lt;attribute name="matrix" use="required" type="{http://www.w3.org/2001/XMLSchema}string" /&gt;
+ * &lt;attribute name="id" type="{http://www.w3.org/2001/XMLSchema}string" /&gt;
+ * &lt;/restriction&gt;
+ * &lt;/complexContent&gt;
+ * &lt;/complexType&gt;
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "MapOnAMatrixType", propOrder = {
+ "property",
+ "mapping"
+ })
+ public class MapOnAMatrixType {
+
+ protected List<Property> property;
+ protected MapListType mapping;
+ @XmlAttribute(name = "matrix", required = true)
+ protected String matrix;
+ @XmlAttribute(name = "id")
+ protected String id;
+
+ /**
+ * Gets the value of the property property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the property property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getProperty().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Property }
+ *
+ *
+ */
+ public List<Property> getProperty() {
+ if (property == null) {
+ property = new ArrayList<Property>();
+ }
+ return this.property;
+ }
+
+ /**
+ * Gets the value of the mapping property.
+ *
+ * @return
+ * possible object is
+ * {@link MapListType }
+ *
+ */
+ public MapListType getMapping() {
+ return mapping;
+ }
+
+ /**
+ * Sets the value of the mapping property.
+ *
+ * @param value
+ * allowed object is
+ * {@link MapListType }
+ *
+ */
+ public void setMapping(MapListType value) {
+ this.mapping = value;
+ }
+
+ /**
+ * Gets the value of the matrix property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMatrix() {
+ return matrix;
+ }
+
+ /**
+ * Sets the value of the matrix property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMatrix(String value) {
+ this.matrix = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+ }
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// Generated on: 2023.09.01 at 02:16:11 PM BST
++// Generated on: 2023.11.01 at 07:03:09 PM GMT
//
// 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.08 at 03:55:49 PM BST
-// 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)
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;
import java.awt.Font;
import java.awt.FontMetrics;
Assert.assertEquals(restoredMat.getGroups(), dummyMat.getGroups());
Assert.assertEquals(restoredMat.hasTree(), dummyMat.hasTree());
Assert.assertEquals(restoredMat.getNewick(), dummyMat.getNewick());
+
+ // verify no duplicate PAE matrix data when new view created and saved
+
+ // add reference annotations to view first, then copy
+ AlignmentUtils.addReferenceAnnotationTo(newAl, newAl.getSequenceAt(0), newSeq.getAnnotation()[0],null);
+
+ AlignmentViewPanel newview = af.newView("copy of PAE", true);
+
+ // redundant asserts here check all is good with the new view firest...
+ AlignmentI newviewAl = newview.getAlignment();
+ SequenceI newviewSeq = newviewAl.getSequenceAt(0);
+ // check annotation of the expected type exists
+ Assert.assertEquals(newviewSeq.getAnnotation().length, 1);
+ Assert.assertEquals(newviewSeq.getAnnotation()[0].graph, paeCm.graph);
+ // check we have just one contact matrix mapping
+ Assert.assertEquals(newviewSeq.getContactMaps().size(), 1);
+
+ // and can be found for the annotation on the sequence
+ ContactMatrixI newviewMat = newviewSeq
+ .getContactMatrixFor(newviewSeq.getAnnotation()[0]);
+ Assert.assertNotNull(newviewMat);
+
+ Assert.assertTrue(newviewMat == restoredMat);
+
+ // save the two views and restore. Now look at visible annotation to check all views have shared refs.
+
+ tfile = File.createTempFile("testStoreAndRecoverPAEmatrixTwoViews",
+ ".jvp");
+ new Jalview2XML(false).saveState(tfile);
+ Desktop.instance.closeAll_actionPerformed(null);
+
+ af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
+ DataSourceType.FILE);
+ newAl = af.getAlignPanels().get(0).getAlignment();
+ AlignmentAnnotation view1aa = newAl.getSequenceAt(0).getAnnotation()[0];
+
+ newviewAl = af.getAlignPanels().get(1).getAlignment();
+ AlignmentAnnotation view2aa = newviewAl.getSequenceAt(0).getAnnotation()[0];
+
+ // annotations are shared across alignment views - so should still have an identical pair of annotations.
+ Assert.assertTrue(view1aa==view2aa);
+ // identical annotations means identical contact matrix mappings
+ Assert.assertEquals(newAl.getDataset().getSequenceAt(0).getContactMaps().size(), 1);
+
+ // TODO Verify when distinct mappable PAEs are created, only one PAE dataset is actually held.
+ // Assert.assertTrue(view1aa!=view2aa);
+ // restoredMat = newAl.getContactMatrixFor(view1aa);
+ // newviewMat = newviewAl.getContactMatrixFor(view2aa);
+ // Assert.assertTrue(restoredMat!=newviewMat);
+
}
+ @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");
+ }
+
}