+
+ /**
+ * If this viewport has a (Protein/cDNA) complement, then scroll the
+ * complementary alignment to match this one.
+ */
+ public void scrollComplementaryAlignment()
+ {
+ /*
+ * Populate a SearchResults object with the mapped location to scroll to. If
+ * there is no complement, or it is not following highlights, or no mapping
+ * is found, the result will be empty.
+ */
+ SearchResultsI sr = new SearchResults();
+ int verticalOffset = findComplementScrollTarget(sr);
+ if (!sr.isEmpty())
+ {
+ // TODO would like next line without cast but needs more refactoring...
+ final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
+ .getAlignPanel();
+ complementPanel.setDontScrollComplement(true);
+ complementPanel.scrollToCentre(sr, verticalOffset);
+ }
+ }
+
+ /**
+ * Answers true if no alignment holds a reference to the given mapping
+ *
+ * @param acf
+ * @return
+ */
+ protected boolean noReferencesTo(AlignedCodonFrame acf)
+ {
+ AlignFrame[] frames = Desktop.getAlignFrames();
+ if (frames == null)
+ {
+ return true;
+ }
+ for (AlignFrame af : frames)
+ {
+ if (!af.isClosed())
+ {
+ for (AlignmentViewPanel ap : af.getAlignPanels())
+ {
+ AlignmentI al = ap.getAlignment();
+ if (al != null && al.getCodonFrames().contains(acf))
+ {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Applies the supplied feature settings descriptor to currently known
+ * features. This supports an 'initial configuration' of feature colouring
+ * based on a preset or user favourite. This may then be modified in the usual
+ * way using the Feature Settings dialogue.
+ *
+ * @param featureSettings
+ */
+ @Override
+ public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
+ {
+ if (featureSettings == null)
+ {
+ return;
+ }
+
+ FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
+ .getFeatureRenderer();
+ fr.findAllFeatures(true);
+ List<String> renderOrder = fr.getRenderOrder();
+ FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
+ displayed.clear();
+ // TODO this clears displayed.featuresRegistered - do we care?
+
+ /*
+ * set feature colour if specified by feature settings
+ * set visibility of all features
+ */
+ for (String type : renderOrder)
+ {
+ FeatureColourI preferredColour = featureSettings
+ .getFeatureColour(type);
+ if (preferredColour != null)
+ {
+ fr.setColour(type, preferredColour);
+ }
+ if (featureSettings.isFeatureDisplayed(type))
+ {
+ displayed.setVisible(type);
+ }
+ }
+
+ /*
+ * set visibility of feature groups
+ */
+ for (String group : fr.getFeatureGroups())
+ {
+ fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
+ }
+
+ /*
+ * order the features
+ */
+ if (featureSettings.optimiseOrder())
+ {
+ // TODO not supported (yet?)
+ }
+ else
+ {
+ fr.orderFeatures(featureSettings);
+ }
+ fr.setTransparency(featureSettings.getTransparency());
+ }
+