* transparency, this class provides a dummy 'offscreen' graphics context
* where multiple feature colours can be overlaid and the combined colour read
* back.
+ * <p>
+ * This method is not thread-safe when transparency is applied, since a shared
+ * BufferedImage would be used by all threads to hold the composite colour at
+ * a position. Each thread should use a separate instance of this class.
*
* @param defaultColour
* @param seq
public Color findFeatureColour(Color defaultColour, SequenceI seq,
int column)
{
- if (!((FeatureRendererModel) featureRenderer).hasRenderOrder())
+ if (noFeaturesDisplayed())
{
return defaultColour;
}
- FeaturesDisplayedI displayed = featureRenderer.getFeaturesDisplayed();
- if (displayed == null || displayed.getVisibleFeatureCount() == 0)
- {
- return defaultColour; // nothing to see here folks
- }
-
Graphics g = null;
/*
}
return c;
}
+
+ /**
+ * Answers true if feature display is turned off, or there are no features
+ * configured to be visible
+ *
+ * @return
+ */
+ boolean noFeaturesDisplayed()
+ {
+ if (!featureRenderer.getViewport().isShowSequenceFeatures())
+ {
+ return true;
+ }
+
+ if (!((FeatureRendererModel) featureRenderer).hasRenderOrder())
+ {
+ return true;
+ }
+
+ FeaturesDisplayedI displayed = featureRenderer.getFeaturesDisplayed();
+ if (displayed == null || displayed.getVisibleFeatureCount() == 0)
+ {
+ return true;
+ }
+
+ return false;
+ }
}
package jalview.renderer.seqfeatures;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
import jalview.api.FeatureColourI;
import jalview.datamodel.SequenceFeature;
c = finder.findFeatureColour(Color.pink, seq, 10);
assertEquals(c, new Color(102, 223, 70));
}
+
+ @Test(groups = "Functional")
+ public void testNoFeaturesDisplayed()
+ {
+ /*
+ * no features on alignment to render
+ */
+ assertTrue(finder.noFeaturesDisplayed());
+
+ /*
+ * add a feature
+ * it will be automatically set visible but the viewport
+ * is still configured not to show features
+ */
+ seq.addSequenceFeature(new SequenceFeature("Metal", "Metal", 2, 12,
+ Float.NaN, "MetalGroup"));
+ FeatureColour red = new FeatureColour(Color.red);
+ fr.setColour("Metal", red);
+ fr.featuresAdded();
+ assertTrue(finder.noFeaturesDisplayed());
+
+ /*
+ * turn on feature display
+ */
+ av.setShowSequenceFeatures(true);
+ assertFalse(finder.noFeaturesDisplayed());
+
+ /*
+ * turn off display of Metal
+ */
+ Object[][] data = new Object[1][];
+ data[0] = new Object[] { "Metal", red, false };
+ fr.setFeaturePriority(data);
+ assertTrue(finder.noFeaturesDisplayed());
+
+ /*
+ * turn display of Metal back on
+ */
+ fr.setVisible("Metal");
+ assertFalse(finder.noFeaturesDisplayed());
+
+ /*
+ * turn off MetalGroup - has no effect here since the group of a
+ * sequence feature instance is independent of its type
+ */
+ fr.setGroupVisibility("MetalGroup", false);
+ assertFalse(finder.noFeaturesDisplayed());
+ }
}