From ed1529065c002bb837ea2572b00d1dfdceaa6050 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 5 Mar 2019 10:26:53 +0000 Subject: [PATCH] JAL-3049 redo (part of) commit 92bc328 --- src/jalview/gui/FeatureSettings.java | 14 ++++++++++---- test/jalview/gui/FeatureSettingsTest.java | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index da4de25..390427a 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -219,7 +219,7 @@ public class FeatureSettings extends JPanel case COLOUR_COLUMN: FeatureColourI colour = (FeatureColourI) table.getValueAt(row, column); - tip = getColorTooltip(colour); + tip = getColorTooltip(colour, true); break; case FILTER_COLUMN: FeatureMatcherSet o = (FeatureMatcherSet) table.getValueAt(row, @@ -1311,9 +1311,12 @@ public class FeatureSettings extends JPanel * Answers a suitable tooltip to show on the colour cell of the table * * @param fcol + * @param withHint + * if true include 'click to edit' and similar text * @return */ - public static String getColorTooltip(FeatureColourI fcol) + public static String getColorTooltip(FeatureColourI fcol, + boolean withHint) { if (fcol == null) { @@ -1321,13 +1324,16 @@ public class FeatureSettings extends JPanel } if (fcol.isSimpleColour()) { - return BASE_TOOLTIP; + return withHint ? BASE_TOOLTIP : null; } String description = fcol.getDescription(); description = description.replaceAll("<", "<"); description = description.replaceAll(">", ">"); StringBuilder tt = new StringBuilder(description); - tt.append("
").append(BASE_TOOLTIP).append("
"); + if (withHint) + { + tt.append("
").append(BASE_TOOLTIP).append("
"); + } return JvSwingUtils.wrapTooltip(true, tt.toString()); } diff --git a/test/jalview/gui/FeatureSettingsTest.java b/test/jalview/gui/FeatureSettingsTest.java index 5219bda..6d8a47e 100644 --- a/test/jalview/gui/FeatureSettingsTest.java +++ b/test/jalview/gui/FeatureSettingsTest.java @@ -197,20 +197,23 @@ public class FeatureSettingsTest @Test(groups = "Functional") public void testGetColorTooltip() throws IOException { - assertNull(FeatureSettings.getColorTooltip(null)); + assertNull(FeatureSettings.getColorTooltip(null, false)); /* * simple colour */ FeatureColourI fc = new FeatureColour(Color.black); String simpleTooltip = "Click to edit, right-click for menu"; - assertEquals(FeatureSettings.getColorTooltip(fc), simpleTooltip); + assertEquals(FeatureSettings.getColorTooltip(fc, true), simpleTooltip); + assertNull(FeatureSettings.getColorTooltip(fc, false)); /* * graduated colour tooltip includes description of colour */ fc.setColourByLabel(true); - assertEquals(FeatureSettings.getColorTooltip(fc), + assertEquals(FeatureSettings.getColorTooltip(fc, false), + "By Label"); + assertEquals(FeatureSettings.getColorTooltip(fc, true), "By Label
" + simpleTooltip + "
"); /* @@ -219,11 +222,16 @@ public class FeatureSettingsTest fc = new FeatureColour(null, Color.red, Color.blue, null, 2f, 10f); fc.setBelowThreshold(true); fc.setThreshold(4f); - assertEquals(FeatureSettings.getColorTooltip(fc), + assertEquals(FeatureSettings.getColorTooltip(fc, false), + "By Score (< 4.0)"); + assertEquals(FeatureSettings.getColorTooltip(fc, true), "By Score (< 4.0)
" + simpleTooltip + "
"); + fc.setAboveThreshold(true); - assertEquals(FeatureSettings.getColorTooltip(fc), + assertEquals(FeatureSettings.getColorTooltip(fc, false), + "By Score (> 4.0)"); + assertEquals(FeatureSettings.getColorTooltip(fc, true), "By Score (> 4.0)
" + simpleTooltip + "
"); } -- 1.7.10.2