From 772387bbccde43cd52ccfadb854d45b1c27f3324 Mon Sep 17 00:00:00 2001 From: James Procter Date: Thu, 7 Sep 2023 10:45:43 +0100 Subject: [PATCH] JAL-4273 release notes for visible adjuster marks, and patch so they are not rendered during figure export --- help/markdown/releases/release-2_11_3_0.md | 1 + src/jalview/gui/AlignmentPanel.java | 8 ++++---- src/jalview/gui/AnnotationLabels.java | 25 ++++++++++++++++--------- src/jalview/gui/IdCanvas.java | 28 +++++++++++++++++++++------- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/help/markdown/releases/release-2_11_3_0.md b/help/markdown/releases/release-2_11_3_0.md index 2b649f4..fdfa3a5 100644 --- a/help/markdown/releases/release-2_11_3_0.md +++ b/help/markdown/releases/release-2_11_3_0.md @@ -21,6 +21,7 @@ channel: "release" - Highlight aligned positions on all associated structures when mousing over a column - sequence descriptions are updated from database reference sources if not already defined +- Visible adjuster marks to grab and adjust annotation panel height and id width ### Improved support for working with computationally determined models diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 27397e2..ce87c01 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -341,7 +341,7 @@ public class AlignmentPanel extends GAlignmentPanel implements if (Jalview.isHeadlessMode()) { AnnotationLabels aal = getAlabels(); - int stringWidth = aal.drawLabels(null, false, idWidth, false, fm); + int stringWidth = aal.drawLabels(null, false, idWidth, false, false, fm); idWidth = Math.max(idWidth, stringWidth); } else @@ -1064,7 +1064,7 @@ public class AlignmentPanel extends GAlignmentPanel implements List selection = av.getSelectionGroup() == null ? null : av.getSelectionGroup().getSequences(null); idCanvas.drawIds((Graphics2D) idGraphics, av, startSeq, endSeq - 1, - selection); + selection, false); idGraphics.setFont(av.getFont()); idGraphics.translate(0, -scaleHeight); @@ -1088,7 +1088,7 @@ public class AlignmentPanel extends GAlignmentPanel implements int offset = getAlabels().getScrollOffset(); idGraphics.translate(0, -offset); idGraphics.translate(0, alignmentDrawnHeight); - getAlabels().drawComponent(idGraphics, idWidth); + getAlabels().drawComponentNotGUI(idGraphics, idWidth); idGraphics.translate(0, -alignmentDrawnHeight); /* @@ -1169,7 +1169,7 @@ public class AlignmentPanel extends GAlignmentPanel implements * draw sequence ids and annotation labels (if shown) */ IdCanvas idCanvas = getIdPanel().getIdCanvas(); - idCanvas.drawIdsWrapped((Graphics2D) g, av, 0, totalHeight); + idCanvas.drawIdsWrappedNoGUI((Graphics2D) g, av, 0, totalHeight); g.translate(idWidth, 0); diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 20e1b1b..d9d6b9f 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -1168,7 +1168,7 @@ public class AnnotationLabels extends JPanel RenderingHints.VALUE_ANTIALIAS_ON); } - drawComponent(g2, true, width); + drawComponent(g2, true, width, true); } /** @@ -1183,7 +1183,7 @@ public class AnnotationLabels extends JPanel */ public void drawComponent(Graphics g, int width) { - drawComponent(g, false, width); + drawComponent(g, false, width, true); } /** @@ -1198,7 +1198,7 @@ public class AnnotationLabels extends JPanel * @param width * Width for scaling labels */ - public void drawComponent(Graphics g, boolean clip, int givenWidth) + public void drawComponent(Graphics g, boolean clip, int givenWidth, boolean forGUI) { int width = givenWidth; IdwidthAdjuster iwa = null; @@ -1210,7 +1210,7 @@ public class AnnotationLabels extends JPanel { Graphics2D g2d = (Graphics2D) g; Graphics dummy = g2d.create(); - int newAnnotationIdWidth = drawLabels(dummy, clip, width, false, + int newAnnotationIdWidth = drawLabels(dummy, clip, width, false, forGUI, null); dummy.dispose(); Dimension d = ap.calculateDefaultAlignmentIdWidth(); @@ -1245,10 +1245,10 @@ public class AnnotationLabels extends JPanel } else { - int newAnnotationIdWidth = drawLabels(g, clip, width, false, null); + int newAnnotationIdWidth = drawLabels(g, clip, width, false, forGUI, null); width = Math.max(newAnnotationIdWidth, givenWidth); } - drawLabels(g, clip, width, true, null); + drawLabels(g, clip, width, true, forGUI, null); } /** @@ -1260,17 +1260,19 @@ public class AnnotationLabels extends JPanel * Returns the width of the annotation labels. * * @param g - * Graphics2D instance (needed for font scaling) + * Graphics2D instance (used for rendering and font scaling if no fmetrics supplied) * @param clip * - true indicates that only current visible area needs to be * rendered * @param width * Width for scaling labels + * @param actuallyDraw - when false, no graphics are rendered to g0 + * @param forGUI - when false, GUI relevant marks like indicators for dragging annotation panel height are not rendered * @param fmetrics * FontMetrics if Graphics object g is null */ public int drawLabels(Graphics g0, boolean clip, int width, - boolean actuallyDraw, FontMetrics fmetrics) + boolean actuallyDraw, boolean forGUI, FontMetrics fmetrics) { if (clip) { @@ -1312,7 +1314,7 @@ public class AnnotationLabels extends JPanel g.fillRect(0, 0, getWidth(), getHeight()); if (!Cache.getDefault(RESIZE_MARGINS_MARK_PREF, false) - && !av.getWrapAlignment()) + && !av.getWrapAlignment() && forGUI) { g.setColor(Color.LIGHT_GRAY); g.drawLine(0, HEIGHT_ADJUSTER_HEIGHT / 4, HEIGHT_ADJUSTER_WIDTH / 4, @@ -1587,4 +1589,9 @@ public class AnnotationLabels extends JPanel public void mouseEntered(MouseEvent e) { } + + public void drawComponentNotGUI(Graphics idGraphics, int idWidth) + { + drawComponent(idGraphics, false, idWidth, false); + } } diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index eb0715a..aaded9e 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -199,7 +199,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI gg.translate(0, transY); - drawIds(gg, av, ss, es, searchResults); + drawIds(gg, av, ss, es, searchResults,true); gg.translate(0, -transY); @@ -256,7 +256,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI gg.fillRect(0, 0, getWidth(), imgHeight); drawIds(gg, av, av.getRanges().getStartSeq(), - av.getRanges().getEndSeq(), searchResults); + av.getRanges().getEndSeq(), searchResults,true); gg.dispose(); @@ -276,7 +276,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI * @param selection */ void drawIds(Graphics2D g, AlignViewport alignViewport, - final int startSeq, final int endSeq, List selection) + final int startSeq, final int endSeq, List selection, boolean forGUI) { Font font = alignViewport.getFont(); if (alignViewport.isSeqNameItalics()) @@ -383,11 +383,24 @@ public class IdCanvas extends JPanel implements ViewportListenerI void drawIdsWrapped(Graphics2D g, AlignViewport alignViewport, int startSeq, int pageHeight) { - drawIdsWrapped(g, alignViewport, startSeq, pageHeight, -1); + drawIdsWrapped(g, alignViewport, startSeq, pageHeight, -1, true); + } + + /** + * render sequence IDs and annotation labels when wrapped - without GUI junk + * @param g + * @param av2 + * @param i + * @param totalHeight + */ + public void drawIdsWrappedNoGUI(Graphics2D g, AlignViewport av2, int i, + int totalHeight) + { + drawIdsWrapped(g, av2, totalHeight, totalHeight, i,false); } void drawIdsWrapped(Graphics2D g, AlignViewport alignViewport, - int startSeq, int pageHeight, int idWidth) + int startSeq, int pageHeight, int idWidth, boolean forGUI) { int alignmentWidth = alignViewport.getAlignment().getWidth(); final int alheight = alignViewport.getAlignment().getHeight(); @@ -440,7 +453,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI g.translate(0, ypos + (alheight * charHeight)); if (!manuallyAdjusted()) { - int getAnnotationsIdWidth = labels.drawLabels(g, false, -1, false, + int getAnnotationsIdWidth = labels.drawLabels(g, false, -1, false,forGUI, null); thisIdWidth = idWidth < 0 ? getAnnotationsIdWidth : idWidth; if (thisIdWidth > getWidth) @@ -451,7 +464,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI alignViewport.setIdWidth(thisIdWidth); } } - labels.drawComponent(g, false, thisIdWidth); + labels.drawComponent(g, false, thisIdWidth, forGUI); g.translate(0, -ypos - (alheight * charHeight)); } @@ -619,4 +632,5 @@ public class IdCanvas extends JPanel implements ViewportListenerI { manuallyAdjusted = b; } + } -- 1.7.10.2