From ede65e4bb4c184f93f794c1d3aa05521355e4bb9 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 20 Aug 2019 10:07:26 +0100 Subject: [PATCH] JAL-3364 tweaks to override of FIGURE_FIXEDIDWIDTH for split frame image --- src/jalview/gui/AlignmentPanel.java | 41 ++++++++++++++++++++--------------- src/jalview/gui/SeqCanvas.java | 1 - 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 716c237..c1d4249 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -1081,8 +1081,9 @@ public class AlignmentPanel extends GAlignmentPanel implements public int printWrappedAlignment(int pageWidth, int pageHeight, int pageNumber, Graphics g, boolean clipToPage) { - getSeqPanel().seqCanvas.calculateWrappedGeometry(getWidth(), - getHeight()); + final SeqCanvas seqCanvas = getSeqPanel().seqCanvas; + seqCanvas.calculateWrappedGeometry(seqCanvas.getWidth(), + seqCanvas.getHeight()); int annotationHeight = 0; if (av.isShowAnnotation()) { @@ -1102,7 +1103,7 @@ public class AlignmentPanel extends GAlignmentPanel implements int maxwidth = av.getAlignment().getVisibleWidth(); - int resWidth = getSeqPanel().seqCanvas + int resWidth = seqCanvas .getWrappedCanvasWidth(pageWidth - idWidth); av.getRanges().setViewportStartAndWidth(0, resWidth); @@ -1133,7 +1134,7 @@ public class AlignmentPanel extends GAlignmentPanel implements idCanvas.drawIdsWrapped((Graphics2D) g, av, 0, totalHeight); g.translate(idWidth, 0); - getSeqPanel().seqCanvas.drawWrappedPanelForPrinting(g, pageWidth - idWidth, + seqCanvas.drawWrappedPanelForPrinting(g, pageWidth - idWidth, totalHeight, 0); g.translate(-idWidth, 0); @@ -1225,27 +1226,31 @@ public class AlignmentPanel extends GAlignmentPanel implements * if exporting a split frame image, the graphics object has * width: maximum of the top and bottom image widths * height: sum of the top and bottom image heights - * if 'protein scaled to codons' and 'auto id width', fudge - * to a fixed width (and restore preferences afterwards) + * Any preferences for auto or fixed id width are overridden here + * with the actual id widths, and restored after export */ AlignmentPanel complement = null; - AlignmentDimension dim1 = getAlignmentDimension(); - AlignmentDimension dim2 = new AlignmentDimension(0, 0); + final int idWidth = getIdPanel().getWidth(); + int complementIdWidth = 0; if (forSplitFrame) { complement = ((AlignViewport) av.getCodingComplement()) .getAlignPanel(); + Cache.setProperty("FIGURE_AUTOIDWIDTH", Boolean.FALSE.toString()); + Cache.setProperty("FIGURE_FIXEDIDWIDTH", String.valueOf(idWidth)); + } + AlignmentDimension dim1 = getAlignmentDimension(); + AlignmentDimension dim2 = new AlignmentDimension(0, 0); + + if (forSplitFrame) + { + complementIdWidth = complement.getIdPanel().getWidth(); + Cache.setProperty("FIGURE_FIXEDIDWIDTH", String.valueOf(complementIdWidth)); dim2 = complement.getAlignmentDimension(); - if (Boolean.valueOf(autoIdWidth) && av.isScaleProteinAsCdna()) - { - int w1 = this.getVisibleIdWidth(false); - int w2 = complement.getVisibleIdWidth(false); - Cache.setProperty("FIGURE_AUTOIDWIDTH", Boolean.FALSE.toString()); - Cache.setProperty("FIGURE_FIXEDIDWIDTH", - String.valueOf(Math.max(w1, w2))); - } + Cache.setProperty("FIGURE_FIXEDIDWIDTH", String.valueOf(idWidth)); } + final int graphicsHeight = dim1.height + dim2.height + borderBottomOffset; final int graphicsWidth = Math.max(dim1.width, dim2.width); @@ -1281,6 +1286,8 @@ public class AlignmentPanel extends GAlignmentPanel implements */ // to debug location of next write to Graphics: // graphics.drawString("Hello world", 0, 0); + Cache.setProperty("FIGURE_FIXEDIDWIDTH", + String.valueOf(complementIdWidth)); if (av.getCodingComplement().getWrapAlignment()) { complement.printWrappedAlignment(dim2.width, @@ -1307,7 +1314,7 @@ public class AlignmentPanel extends GAlignmentPanel implements } finally { /* - * restore preference settings in case they were fudged + * restore preference settings in case they were overridden */ if (autoIdWidth == null) { diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 5f67cb5..70afc5a 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -561,7 +561,6 @@ public class SeqCanvas extends JComponent implements ViewportListenerI { int wrappedWidthInResidues = calculateWrappedGeometry(canvasWidth, canvasHeight); - av.setWrappedWidth(wrappedWidthInResidues); ViewportRanges ranges = av.getRanges(); -- 1.7.10.2