}
/**
- * 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.
+ * 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. NOT IMPLEMENTED FOR APPLET
*
* @param featureSettings
*/
// TODO implement for applet
}
+ /**
+ * Merges the supplied feature settings descriptor with existing feature styles.
+ * 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. NOT IMPLEMENTED FOR APPLET
+ *
+ * @param featureSettings
+ */
+ @Override
+ public void mergeFeaturesStyle(FeatureSettingsModelI featureSettings)
+ {
+ // TODO Auto-generated method stub
+
+ }
}
import jalview.structure.SelectionSource;
import jalview.structure.StructureSelectionManager;
import jalview.structure.VamsasSource;
+import jalview.util.ColorUtils;
import jalview.util.MessageManager;
import jalview.viewmodel.AlignmentViewport;
import jalview.ws.params.AutoCalcSetting;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Rectangle;
+import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
@Override
public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
{
+ transferFeaturesStyles(featureSettings, false);
+ }
+
+ /**
+ * 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 mergeFeaturesStyle(FeatureSettingsModelI featureSettings)
+ {
+ transferFeaturesStyles(featureSettings, true);
+ }
+
+ /**
+ * when mergeOnly is set, then group and feature visibility or feature colours
+ * are not modified for features and groups already known to the feature
+ * renderer. Feature ordering is always adjusted, and transparency is always set
+ * regardless.
+ *
+ * @param featureSettings
+ * @param mergeOnly
+ */
+ private void transferFeaturesStyles(FeatureSettingsModelI featureSettings,
+ boolean mergeOnly)
+ {
if (featureSettings == null)
{
return;
}
-
+
FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
.getFeatureRenderer();
+ List<String> origRenderOrder = new ArrayList(),
+ origGroups = new ArrayList();
+ // preserve original render order - allows differentiation between user configured colours and autogenerated ones
+ origRenderOrder.addAll(fr.getRenderOrder());
+ origGroups.addAll(fr.getFeatureGroups());
+
fr.findAllFeatures(true);
List<String> renderOrder = fr.getRenderOrder();
FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
- displayed.clear();
+ if (!mergeOnly)
+ {
+ // only clear displayed features if we are mergeing
+ displayed.clear();
+ }
// TODO this clears displayed.featuresRegistered - do we care?
-
+ //
+ // JAL-3330 - JBP - yes we do - calling applyFeatureStyle to a view where
+ // feature visibility has already been configured is not very friendly
/*
* set feature colour if specified by feature settings
* set visibility of all features
{
FeatureColourI preferredColour = featureSettings
.getFeatureColour(type);
- if (preferredColour != null)
- {
- fr.setColour(type, preferredColour);
- }
- if (featureSettings.isFeatureDisplayed(type))
+ FeatureColourI origColour = fr.getFeatureStyle(type);
+ if (!mergeOnly || (!origRenderOrder.contains(type)
+ || origColour == null
+ || (!origColour.isGraduatedColour()
+ && origColour.getColour() != null
+ && origColour.getColour().equals(
+ ColorUtils.createColourFromName(type)))))
{
- displayed.setVisible(type);
+ // if we are merging, only update if there wasn't already a colour defined for
+ // this type
+ if (preferredColour != null)
+ {
+ fr.setColour(type, preferredColour);
+ }
+ if (featureSettings.isFeatureDisplayed(type))
+ {
+ displayed.setVisible(type);
+ }
}
}
*/
for (String group : fr.getFeatureGroups())
{
- fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
+ if (!mergeOnly || !origGroups.contains(group))
+ {
+ // when merging, display groups only if the aren't already marked as not visible
+ fr.setGroupVisibility(group,
+ featureSettings.isGroupDisplayed(group));
+ }
}
/*