import jalview.analysis.AlignmentUtils;
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
-import jalview.analysis.TreeModel;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureColourI;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.HiddenColumns;
-import jalview.datamodel.PDBEntry;
import jalview.datamodel.SearchResults;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceGroup;
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.Rectangle;
import java.util.ArrayList;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
import javax.swing.JInternalFrame;
boolean antiAlias = false;
- private Rectangle explodedGeometry;
+ private Rectangle explodedGeometry = null;
- String viewName;
+ private String viewName = null;
/*
* Flag set true on the view that should 'gather' multiple views of the same
*/
private void applyViewProperties()
{
- antiAlias = Cache.getDefault("ANTI_ALIAS", false);
+ antiAlias = Cache.getDefault("ANTI_ALIAS", true);
viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
ResidueColourScheme.NONE);
}
ColourSchemeI colourScheme = ColourSchemeProperty
- .getColourScheme(alignment, schemeName);
+ .getColourScheme(this, alignment, schemeName);
residueShading = new ResidueShader(colourScheme);
if (colourScheme instanceof UserColourScheme)
{
residueShading.setConsensus(hconsensus);
}
+ setColourAppliesToAllGroups(true);
}
boolean validCharWidth;
* area
* @return
*/
- public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
+ public Iterator<int[]> getViewAsVisibleContigs(boolean selectedRegionOnly)
{
- int[] viscontigs = null;
- int start = 0, end = 0;
+ int start = 0;
+ int end = 0;
if (selectedRegionOnly && selectionGroup != null)
{
start = selectionGroup.getStartRes();
{
end = alignment.getWidth();
}
- viscontigs = alignment.getHiddenColumns().getVisibleContigs(start, end);
- return viscontigs;
+ return (alignment.getHiddenColumns().getVisContigsIterator(start, end,
+ false));
}
/**
.getStructureSelectionManager(Desktop.instance);
}
- /**
- *
- * @param pdbEntries
- * @return an array of SequenceI arrays, one for each PDBEntry, listing which
- * sequences in the alignment hold a reference to it
- */
- public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
- {
- List<SequenceI[]> seqvectors = new ArrayList<SequenceI[]>();
- for (PDBEntry pdb : pdbEntries)
- {
- List<SequenceI> choosenSeqs = new ArrayList<SequenceI>();
- for (SequenceI sq : alignment.getSequences())
- {
- Vector<PDBEntry> pdbRefEntries = sq.getDatasetSequence()
- .getAllPDBEntries();
- if (pdbRefEntries == null)
- {
- continue;
- }
- for (PDBEntry pdbRefEntry : pdbRefEntries)
- {
- if (pdbRefEntry.getId().equals(pdb.getId()))
- {
- if (pdbRefEntry.getChainCode() != null
- && pdb.getChainCode() != null)
- {
- if (pdbRefEntry.getChainCode().equalsIgnoreCase(
- pdb.getChainCode()) && !choosenSeqs.contains(sq))
- {
- choosenSeqs.add(sq);
- continue;
- }
- }
- else
- {
- if (!choosenSeqs.contains(sq))
- {
- choosenSeqs.add(sq);
- continue;
- }
- }
-
- }
- }
- }
- seqvectors
- .add(choosenSeqs.toArray(new SequenceI[choosenSeqs.size()]));
- }
- return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
- }
-
@Override
public boolean isNormaliseSequenceLogo()
{
return validCharWidth;
}
- private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
+ private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<>();
public AutoCalcSetting getCalcIdSettingsFor(String calcId)
{
AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
newAlignFrame.setTitle(title);
- newAlignFrame.statusBar.setText(MessageManager
+ newAlignFrame.setStatus(MessageManager
.formatMessage("label.successfully_loaded_file", new Object[]
{ title }));
@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));
+ }
}
/*
}
fr.setTransparency(featureSettings.getTransparency());
}
+
+ public String getViewName()
+ {
+ return viewName;
+ }
+
+ public void setViewName(String viewName)
+ {
+ this.viewName = viewName;
+ }
}