From 685909b39c1c85ff304ecea9763925de75b2cf77 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 19 Jun 2015 16:14:39 +0100 Subject: [PATCH] JAL-653 JAL-1780 minimise call rate now av.hasHiddenRows is dynamic --- src/jalview/appletgui/IdCanvas.java | 18 +++++++++++------- src/jalview/appletgui/OverviewPanel.java | 6 ++++-- src/jalview/gui/IdCanvas.java | 18 ++++++++++++------ src/jalview/gui/OverviewPanel.java | 6 ++++-- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/jalview/appletgui/IdCanvas.java b/src/jalview/appletgui/IdCanvas.java index 7f9eba9..5204094 100755 --- a/src/jalview/appletgui/IdCanvas.java +++ b/src/jalview/appletgui/IdCanvas.java @@ -56,7 +56,8 @@ public class IdCanvas extends Panel PaintRefresher.Register(this, av.getSequenceSetId()); } - public void drawIdString(Graphics gg, SequenceI s, int i, int starty, + public void drawIdString(Graphics gg, boolean hiddenRows, SequenceI s, + int i, int starty, int ypos) { int charHeight = av.getCharHeight(); @@ -88,7 +89,7 @@ public class IdCanvas extends Panel ((i - starty) * charHeight) + ypos + charHeight - (charHeight / 5)); - if (av.hasHiddenRows() && av.getShowHiddenMarkers()) + if (hiddenRows) { drawMarker(i, starty, ypos); } @@ -199,6 +200,10 @@ public class IdCanvas extends Panel Color currentColor = Color.white; Color currentTextColor = Color.black; + final boolean doHiddenCheck = av.isDisplayReferenceSeq() + || av.hasHiddenRows(), hiddenRows = av.hasHiddenRows() + && av.getShowHiddenMarkers(); + if (av.getWrapAlignment()) { int maxwidth = av.getAlignment().getWidth(); @@ -227,7 +232,6 @@ public class IdCanvas extends Panel int cHeight = alheight * avcharHeight + hgap + annotationHeight; int rowSize = av.getEndRes() - av.getStartRes(); - // Draw the rest of the panels for (int ypos = hgap, row = av.startRes; (ypos <= getSize().height) && (row < maxwidth); ypos += cHeight, row += rowSize) @@ -237,11 +241,11 @@ public class IdCanvas extends Panel SequenceI s = av.getAlignment().getSequenceAt(i); gg.setFont(italic); - if (av.isDisplayReferenceSeq() || av.hasHiddenRows()) + if (doHiddenCheck) { setHiddenFont(s); } - drawIdString(gg, s, i, 0, ypos); + drawIdString(gg, hiddenRows, s, i, 0, ypos); } if (labels != null) @@ -267,7 +271,7 @@ public class IdCanvas extends Panel } gg.setFont(italic); // boolean isrep=false; - if (av.isDisplayReferenceSeq() || av.hasHiddenRows()) + if (doHiddenCheck) { // isrep = setHiddenFont(seq); @@ -302,7 +306,7 @@ public class IdCanvas extends Panel (((i - starty) * avcharHeight) + avcharHeight) - (avcharHeight / 5)); - if (av.hasHiddenRows() && av.getShowHiddenMarkers()) + if (hiddenRows) { drawMarker(i, starty, 0); } diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 1749e23..f09bda5 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -298,6 +298,8 @@ public class OverviewPanel extends Panel implements Runnable, Color color = Color.yellow; int row, col, sameRow = 0, sameCol = 0; jalview.datamodel.SequenceI seq; + final boolean hasHiddenRows = av.hasHiddenRows(), hasHiddenCols = av + .hasHiddenColumns(); boolean hiddenRow = false; AlignmentI alignment = av.getAlignment(); for (row = 0; row <= sequencesHeight; row++) @@ -309,7 +311,7 @@ public class OverviewPanel extends Panel implements Runnable, } hiddenRow = false; - if (av.hasHiddenRows()) + if (hasHiddenRows) { seq = alignment.getHiddenSequences().getHiddenSequence(lastrow); if (seq == null) @@ -355,7 +357,7 @@ public class OverviewPanel extends Panel implements Runnable, } if (hiddenRow - || (av.hasHiddenColumns() && !av.getColumnSelection() + || (hasHiddenCols && !av.getColumnSelection() .isVisible(lastcol))) { color = color.darker().darker(); diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index a7a4e34..fe42e1e 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -86,6 +86,8 @@ public class IdCanvas extends JPanel * * @param gg * DOCUMENT ME! + * @param hiddenRows + * true - check and display hidden row marker if need be * @param s * DOCUMENT ME! * @param i @@ -95,7 +97,8 @@ public class IdCanvas extends JPanel * @param ypos * DOCUMENT ME! */ - public void drawIdString(Graphics2D gg, SequenceI s, int i, int starty, + public void drawIdString(Graphics2D gg, boolean hiddenRows, SequenceI s, + int i, int starty, int ypos) { int xPos = 0; @@ -134,7 +137,7 @@ public class IdCanvas extends JPanel gg.drawString(s.getDisplayId(av.getShowJVSuffix()), xPos, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5)); - if (av.hasHiddenRows() && av.getShowHiddenMarkers()) + if (hiddenRows) { drawMarker(i, starty, ypos); } @@ -274,6 +277,9 @@ public class IdCanvas extends JPanel Color currentColor = Color.white; Color currentTextColor = Color.black; + final boolean doHiddenCheck = av.isDisplayReferenceSeq() + || av.hasHiddenRows(), hiddenRows = av.hasHiddenRows(); + if (av.getWrapAlignment()) { int maxwidth = av.getAlignment().getWidth(); @@ -317,7 +323,7 @@ public class IdCanvas extends JPanel for (int i = starty; i < alheight; i++) { SequenceI s = av.getAlignment().getSequenceAt(i); - if (av.isDisplayReferenceSeq() || av.hasHiddenRows()) + if (doHiddenCheck) { setHiddenFont(s); } @@ -326,7 +332,7 @@ public class IdCanvas extends JPanel gg.setFont(getIdfont()); } - drawIdString(gg, s, i, 0, ypos); + drawIdString(gg, hiddenRows, s, i, 0, ypos); } if (labels != null && av.isShowAnnotation()) @@ -357,7 +363,7 @@ public class IdCanvas extends JPanel continue; } - if (av.isDisplayReferenceSeq() || av.hasHiddenRows()) + if (doHiddenCheck) { setHiddenFont(sequence); } @@ -399,7 +405,7 @@ public class IdCanvas extends JPanel (((i - starty) * av.getCharHeight()) + av.getCharHeight()) - (av.getCharHeight() / 5)); - if (av.hasHiddenRows() && av.getShowHiddenMarkers()) + if (hiddenRows) { drawMarker(i, starty, 0); } diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 39a232a..609e010 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -292,6 +292,8 @@ public class OverviewPanel extends JPanel implements Runnable int color = Color.white.getRGB(); int row, col; jalview.datamodel.SequenceI seq; + final boolean hasHiddenRows = av.hasHiddenRows(), hasHiddenCols = av + .hasHiddenColumns(); boolean hiddenRow = false; for (row = 0; row < sequencesHeight; row++) { @@ -309,7 +311,7 @@ public class OverviewPanel extends JPanel implements Runnable lastrow = (int) (row * sampleRow); hiddenRow = false; - if (av.hasHiddenRows()) + if (hasHiddenRows) { seq = av.getAlignment().getHiddenSequences() .getHiddenSequence(lastrow); @@ -362,7 +364,7 @@ public class OverviewPanel extends JPanel implements Runnable } if (hiddenRow - || (av.hasHiddenColumns() && !av.getColumnSelection() + || (hasHiddenCols && !av.getColumnSelection() .isVisible(lastcol))) { color = new Color(color).darker().darker().getRGB(); -- 1.7.10.2