From 8b5ae15a094b5a90238bfe39ce10310ed92184d1 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Fri, 2 Feb 2024 01:11:32 +0000 Subject: [PATCH] JAL-4375 Single width pixel artifacts appearing for PAE annotation now fixed for drawLine method. AnnotationRowRendererI adjusted to pass isVectorRendering boolean to ensure correct method to draw the matrix blocks in vector graphic export. --- src/jalview/renderer/AnnotationRenderer.java | 2 +- src/jalview/renderer/ContactMapRenderer.java | 19 +++++++++++++++---- .../renderer/api/AnnotationRowRendererI.java | 7 ++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/jalview/renderer/AnnotationRenderer.java b/src/jalview/renderer/AnnotationRenderer.java index f733875..0fbfb02 100644 --- a/src/jalview/renderer/AnnotationRenderer.java +++ b/src/jalview/renderer/AnnotationRenderer.java @@ -1142,7 +1142,7 @@ public class AnnotationRenderer renderer.renderRow(g, charWidth, charHeight, hasHiddenColumns, av, hiddenColumns, columnSelection, row, row_annotations, startRes, endRes, row.graphMin, - row.graphMax, y); + row.graphMax, y, isVectorRendering()); } if (debugRedraw) { diff --git a/src/jalview/renderer/ContactMapRenderer.java b/src/jalview/renderer/ContactMapRenderer.java index 9f0cc35..9a295f9 100644 --- a/src/jalview/renderer/ContactMapRenderer.java +++ b/src/jalview/renderer/ContactMapRenderer.java @@ -20,8 +20,12 @@ */ package jalview.renderer; +import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.Stroke; import jalview.api.AlignViewportI; import jalview.datamodel.AlignmentAnnotation; @@ -134,7 +138,7 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI boolean hasHiddenColumns, AlignViewportI viewport, HiddenColumns hiddenColumns, ColumnSelection columnSelection, AlignmentAnnotation _aa, Annotation[] aa_annotations, int sRes, - int eRes, float min, float max, int y) + int eRes, float min, float max, int y, boolean isVectorRendering) { if (sRes > aa_annotations.length) { @@ -157,6 +161,10 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI { return; } + Graphics2D g2d = (Graphics2D) g; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_OFF); + g2d.setStroke(thinRectangularLineStroke); while (x < eRes - sRes) { column = sRes + x; @@ -251,14 +259,14 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI (int) ((col.getBlue() + gpcol.getBlue()) / 2f)); } g.setColor(col); - if (cgeom.pixels_step > 1) + if (isVectorRendering || cgeom.pixels_step > 1) { - g.fillRect(x * charWidth, botY + ht, charWidth, + g2d.fillRect(x * charWidth, botY + ht, charWidth, cgeom.pixels_step); } else { - g.drawLine(x * charWidth, botY + ht, (x + 1) * charWidth, + g2d.drawLine(x * charWidth, botY + ht, (x + 1) * charWidth - 1, botY + ht); } } @@ -267,6 +275,9 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI } + private static Stroke thinRectangularLineStroke = new BasicStroke(1, + BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL); + Color shadeFor(float min, float max, float value) { return jalview.util.ColorUtils.getGraduatedColour(value, 0, diff --git a/src/jalview/renderer/api/AnnotationRowRendererI.java b/src/jalview/renderer/api/AnnotationRowRendererI.java index d4f80a6..2b88cee 100644 --- a/src/jalview/renderer/api/AnnotationRowRendererI.java +++ b/src/jalview/renderer/api/AnnotationRowRendererI.java @@ -20,14 +20,14 @@ */ package jalview.renderer.api; +import java.awt.Graphics; + import jalview.api.AlignViewportI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.Annotation; import jalview.datamodel.ColumnSelection; import jalview.datamodel.HiddenColumns; -import java.awt.Graphics; - public interface AnnotationRowRendererI { @@ -35,6 +35,7 @@ public interface AnnotationRowRendererI boolean hasHiddenColumns, AlignViewportI av, HiddenColumns hiddenColumns, ColumnSelection columnSelection, AlignmentAnnotation row, Annotation[] row_annotations, - int startRes, int endRes, float graphMin, float graphMax, int y); + int startRes, int endRes, float graphMin, float graphMax, int y, + boolean isVectorRendering); } -- 1.7.10.2