@Test(groups = { "Functional", "Not-bamboo" })
public void testGetVisibleWidth()
{
+ double scaling = jalview.gui.JvSwingUtilsTest.getScaling(af.alignPanel);
/*
* width for onscreen rendering is IDPanel width
*/
int w = af.alignPanel.getVisibleIdWidth(true);
assertEquals(w, af.alignPanel.getIdPanel().getWidth());
- assertEquals(w, 115);
+
+ // different scaling (1.0, 2.0) gives different results
+ assertEquals(w, scaling == 1.0 ? 112 : 107);
/*
* width for offscreen rendering is the same
* preference for auto id width overrides fixed width
*/
Cache.setProperty("FIGURE_AUTOIDWIDTH", Boolean.TRUE.toString());
- assertEquals(115, af.alignPanel.getVisibleIdWidth(false));
+ w = af.alignPanel.getVisibleIdWidth(false);
+ // allow some leeway for different OS renderings
+ assertTrue(w > 105 && w < 120);
+ // different scaling (1.0, 2.0) gives different results
+ assertEquals(w, scaling == 1.0 ? 112 : 107);
}
@Test(groups = { "Functional", "Not-bamboo" })
public void testresetIdWidth()
{
+ double scaling = jalview.gui.JvSwingUtilsTest.getScaling(af.alignPanel);
/*
* width for onscreen rendering is IDPanel width
*/
assertEquals(w, actual);
// allow some leeway for different OS renderings
assertTrue(w > 105 && w < 120);
+ // different scaling (1.0, 2.0) gives different results
+ assertEquals(w, scaling == 1.0 ? 112 : 107);
// manually adjust
af.viewport.setIdWidth(200);
// to optimal id width
// allow some leeway for different OS renderings
assertTrue(w > 105 && w < 120);
+ // different scaling (1.0, 2.0) gives different results
+ assertEquals(w, scaling == 1.0 ? 112 : 107);
}
@Test(groups = "Functional")
public class AnnotationLabelsTest2
{
+ private static double scaling;
+
@BeforeClass(alwaysRun = true)
public static void setUpBeforeClass() throws Exception
{
*/
Cache.loadProperties("test/jalview/io/testProps.jvprops");
Jalview.main(new String[] { "--nonews", "--nosplash", });
+
+ scaling = JvSwingUtilsTest.getScaling(Desktop.instance);
}
@AfterMethod(alwaysRun = true)
{
AlignFrame af = new FileLoader()
.LoadFileWaitTillLoaded(alignmentFilename, DataSourceType.FILE);
+
try
{
Thread.sleep(200); // to allow alignment annotations to open
// idWidth = ap.getIdPanel().getWidth();
idWidth = av.getIdWidth();
- assertTrue(idWidth > idWidth2min,
+ assertTrue(idWidth >= idWidth2min,
"idWidth (" + idWidth + ") is not greater than " + idWidth2min);
- assertTrue(idWidth < idWidth2max,
+ assertTrue(idWidth <= idWidth2max,
"idWidth (" + idWidth + ") is not narrower than" + idWidth2max);
}
AlignViewport av = af.getCurrentView();
int idWidth = 0;
-
idWidth = av.getIdWidth();
assertTrue(idWidth > idWidth1min,
"idWidth (" + idWidth + ") is not greater than " + idWidth1min);
int idWidth2min,
int idWidth2max,
*/
+ int idWidth2min = scaling == 1.0 ? 114 : 108;
+ int idWidth2max = scaling == 1.0 ? 114 : 114; // was 130
+
return new Object[][] {
//
/*
100,
"./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb",
"./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json",
- true, TFType.PLDDT, null, 115, 130 },
+ true, TFType.PLDDT, null, idWidth2min, idWidth2max },
{ "./test/files/annotation_label_width/sample.a2m", true, 50, 70,
100,
"./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb",
"./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json",
- true, TFType.PLDDT, null, 115, 130 },
+ true, TFType.PLDDT, null, idWidth2min, idWidth2max },
/*
*/
};
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
+import java.awt.Component;
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+
import javax.swing.JScrollBar;
import org.testng.annotations.BeforeClass;
JvSwingUtils.wrapTooltip(true, tip));
assertEquals(expected, JvSwingUtils.wrapTooltip(false, tip));
}
+
+ public static double getScaling(Component c)
+ {
+ Graphics2D g = (Graphics2D) c.getGraphics();
+ if (g == null)
+ {
+ return 0.0;
+ }
+ AffineTransform t = g.getTransform();
+ double scaling = t.getScaleX(); // Assuming square pixels :P
+ return scaling;
+ }
+
}
*/
package jalview.gui;
-import java.awt.Font;
-import java.awt.FontMetrics;
-
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
+import java.awt.Font;
+import java.awt.FontMetrics;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SearchResults;
import jalview.datamodel.SearchResultsI;
import jalview.io.DataSourceType;
-import jalview.io.DataSourceType;
import jalview.io.FileLoader;
-
import junit.extensions.PA;
public class SeqCanvasTest
av.setScaleRightWrapped(true);
FontMetrics fm = testee.getFontMetrics(av.getFont());
int labelWidth = fm.stringWidth("000") + charWidth;
- assertEquals(labelWidth, 39); // 3 x 9 + charWidth
+ // some leeway for different OS rendering of text
+ assertTrue(labelWidth >= 36 && labelWidth <= 39);
/*
* width 400 pixels leaves (400 - 2*labelWidth) for residue columns
av.setScaleLeftWrapped(false);
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth,
canvasHeight);
- assertEquals(wrappedWidth, 23);
+ // some leeway for different OS rendering of text
+ assertTrue(wrappedWidth >= 22 && wrappedWidth <= 23);
+ int difference = wrappedWidth - 23;
/*
* add 10 pixels to width to fit in another whole residue column
canvasWidth += 1;
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth,
canvasHeight);
- assertEquals(wrappedWidth, 24);
+ assertEquals(wrappedWidth, 24 + difference);
/*
* turn off East scale to gain 39 more pixels (3 columns remainder 3)
av.setScaleRightWrapped(false);
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth,
canvasHeight);
- assertEquals(wrappedWidth, 27);
+ assertEquals(wrappedWidth, 27 + difference);
/*
* add 9 pixels to width to gain a residue column
canvasWidth += 1;
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth,
canvasHeight);
- assertEquals(wrappedWidth, 28); // 9px is enough
+ assertEquals(wrappedWidth, 28 + difference); // 9px is enough
/*
* now West but not East scale - lose 39 pixels or 4 columns
canvasWidth += 1;
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth,
canvasHeight);
- assertEquals(wrappedWidth, 25); // 3px is enough
+ assertEquals(wrappedWidth, 25 + difference); // 3px is enough
/*
* turn off scales left and right, make width exactly 157 columns
av.setScaleRightWrapped(true);
FontMetrics fm = testee.getFontMetrics(av.getFont());
int labelWidth = fm.stringWidth("000") + charWidth;
- assertEquals(labelWidth, 39); // 3 x 9 + charWidth
+ // some leeway for different OS rendering of text
+ assertTrue(labelWidth >= 36 && labelWidth <= 39);
int annotationHeight = testee.getAnnotationHeight();
/*
assertEquals(charHeight, 17);
assertEquals(charWidth, 12);
+ double scaling = JvSwingUtilsTest.getScaling(alignFrame.alignPanel);
+
FontMetrics fm = testee.getFontMetrics(av.getFont());
int labelWidth = fm.stringWidth("00000") + charWidth;
- assertEquals(labelWidth, 57); // 5 x 9 + charWidth
+ // some leeway for different OS rendering of text
+ assertTrue(labelWidth >= 52 && labelWidth <= 57);
assertEquals(testee.seqCanvas.getLabelWidthWest(), labelWidth);
int x = 0;
import java.awt.Rectangle;
import java.io.File;
import java.io.IOException;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashMap;
boolean diffseqcols = false, diffgseqcols = false;
SequenceI[] sqs = af.getViewport().getAlignment().getSequencesArray();
- for (int p = 0, pSize = af.getViewport().getAlignment()
- .getWidth(); p < pSize && (!diffseqcols || !diffgseqcols); p++)
+ for (int p = 0,
+ pSize = af.getViewport().getAlignment().getWidth(); p < pSize
+ && (!diffseqcols || !diffgseqcols); p++)
{
if (_rcs.findColour(sqs[0].getCharAt(p), p, sqs[0], null, 0f) != _rcs
.findColour(sqs[5].getCharAt(p), p, sqs[5], null, 0f))
assertTrue(__rcs.isSeqAssociated(),
"Group Annotation colourscheme wasn't sequence associated");
- for (int p = 0, pSize = af.getViewport().getAlignment()
- .getWidth(); p < pSize && (!diffseqcols || !diffgseqcols); p++)
+ for (int p = 0,
+ pSize = af.getViewport().getAlignment().getWidth(); p < pSize
+ && (!diffseqcols || !diffgseqcols); p++)
{
if (_rgcs.findColour(sqs[1].getCharAt(p), p, sqs[1], null,
0f) != _rgcs.findColour(sqs[2].getCharAt(p), p, sqs[2], null,
assertEquals(ov1.getCanvas().getResidueColour(), Color.white);
assertEquals(ov1.getCanvas().getHiddenColour(), Color.yellow);
assertEquals(ov1.getTitle(), "Overview examples/uniref50.fa Original");
- assertEquals(ov1.getFrameBounds(), new Rectangle(20, 30, 200, 400));
+
+ double scaling = jalview.gui.JvSwingUtilsTest.getScaling(ov1);
+ int width = scaling == 1.0 ? 225 : 200;
+ Rectangle ov1Rectangle = ov1.getFrameBounds();
+ assertEquals(ov1Rectangle, new Rectangle(20, 30, width, 400));
assertTrue(ov1.isShowHiddenRegions());
}
assertNotNull(af, "Didn't read in the example file correctly.");
// FIXME JAL-4281 test made platform dependent to pass, but probably
// shouldn't be platform dependent
- assertEquals(af.alignPanel.getAlignViewport().getIdWidth(),
- Platform.isAMacAndNotJS() ? 144 : 138,
+ int idWidth = af.alignPanel.getAlignViewport().getIdWidth();
+ double scaling = jalview.gui.JvSwingUtilsTest.getScaling(af.alignPanel);
+ int expectedWidth = Platform.isMac() ? 144
+ : Platform.isLinux() ? scaling == 1.0 ? 131 : 128 : 138;
+ System.err.println("##### scaling=" + scaling + ", idWidth=" + idWidth
+ + ", expectedWidth=" + expectedWidth);
+ assertEquals(idWidth, expectedWidth,
"Legacy project import should have fixed ID width");
assertTrue(
af.alignPanel.getIdPanel().getIdCanvas().isManuallyAdjusted());