From: gmungoc Date: Fri, 27 Apr 2018 14:24:21 +0000 (+0100) Subject: JAL-2963 correctly dim PCA points with negative z-coordinates X-Git-Tag: Release_2_11_1_0~78^2~9^2~13 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0615edf610baff76b1675e2f174f22d855fd3fe4;p=jalview.git JAL-2963 correctly dim PCA points with negative z-coordinates --- 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);