From 0615edf610baff76b1675e2f174f22d855fd3fe4 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 27 Apr 2018 15:24:21 +0100 Subject: [PATCH] JAL-2963 correctly dim PCA points with negative z-coordinates --- src/jalview/appletgui/RotatableCanvas.java | 30 ++++++++---------------- src/jalview/gui/RotatableCanvas.java | 34 +++++++++++++--------------- 2 files changed, 26 insertions(+), 38 deletions(-) diff --git a/src/jalview/appletgui/RotatableCanvas.java b/src/jalview/appletgui/RotatableCanvas.java index 179a91d..3000363 100755 --- a/src/jalview/appletgui/RotatableCanvas.java +++ b/src/jalview/appletgui/RotatableCanvas.java @@ -344,29 +344,13 @@ public class RotatableCanvas extends Panel implements MouseListener, public void drawScene(Graphics g) { - // boolean darker = false; - - int halfwidth = getSize().width / 2; - int halfheight = getSize().height / 2; - for (int i = 0; i < npoint; i++) { SequencePoint sp = points.elementAt(i); - int x = (int) ((sp.coord.x - centre.x) * scale) + halfwidth; - int y = (int) ((sp.coord.y - centre.y) * scale) - + halfheight; - float z = sp.coord.y - centre.z; - SequenceI sequence = sp.getSequence(); - if (av.getSequenceColour(sequence) == Color.black) - { - g.setColor(Color.white); - } - else - { - g.setColor(av.getSequenceColour(sequence)); - } - + Color sequenceColour = av.getSequenceColour(sequence); + g.setColor( + sequenceColour == Color.black ? Color.white : sequenceColour); if (av.getSelectionGroup() != null) { if (av.getSelectionGroup().getSequences(null) @@ -375,12 +359,18 @@ public class RotatableCanvas extends Panel implements MouseListener, g.setColor(Color.gray); } } - if (z < 0) + + if (sp.coord.z < centre.z) { g.setColor(g.getColor().darker()); } + int halfwidth = getSize().width / 2; + int halfheight = getSize().height / 2; + int x = (int) ((sp.coord.x - centre.x) * scale) + halfwidth; + int y = (int) ((sp.coord.y - centre.y) * scale) + halfheight; g.fillRect(x - 3, y - 3, 6, 6); + if (showLabels) { g.setColor(Color.red); diff --git a/src/jalview/gui/RotatableCanvas.java b/src/jalview/gui/RotatableCanvas.java index 617180f..6fabd95 100755 --- a/src/jalview/gui/RotatableCanvas.java +++ b/src/jalview/gui/RotatableCanvas.java @@ -427,27 +427,17 @@ public class RotatableCanvas extends JPanel implements MouseListener, g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - int halfwidth = getWidth() / 2; - int halfheight = getHeight() / 2; - for (int i = 0; i < npoint; i++) { + /* + * sequence point colour as sequence id, but + * gray if sequence is currently selected + */ SequencePoint sp = points.elementAt(i); - int x = (int) ((sp.coord.x - centre.x) * scale) + halfwidth; - int y = (int) ((sp.coord.y - centre.y) * scale) - + halfheight; - float z = sp.coord.y - centre.z; // todo sp.coord.z JAL-2963 - SequenceI sequence = sp.getSequence(); - if (av.getSequenceColour(sequence) == Color.black) - { - g.setColor(Color.white); - } - else - { - g.setColor(av.getSequenceColour(sequence)); - } - + Color sequenceColour = av.getSequenceColour(sequence); + g.setColor( + sequenceColour == Color.black ? Color.white : sequenceColour); if (av.getSelectionGroup() != null) { if (av.getSelectionGroup().getSequences(null) @@ -457,12 +447,20 @@ public class RotatableCanvas extends JPanel implements MouseListener, } } - if (z < 0) + /* + * dim sequence points 'at the back' + */ + if (sp.coord.z < centre.z) { g.setColor(g.getColor().darker()); } + int halfwidth = getWidth() / 2; + int halfheight = getHeight() / 2; + int x = (int) ((sp.coord.x - centre.x) * scale) + halfwidth; + int y = (int) ((sp.coord.y - centre.y) * scale) + halfheight; g.fillRect(x - 3, y - 3, 6, 6); + if (showLabels) { g.setColor(Color.red); -- 1.7.10.2