import jalview.io.DataSourceType;
import jalview.io.FileFormat;
import jalview.io.FileFormatI;
+import jalview.io.FileFormats;
import jalview.io.FileLoader;
import jalview.io.FormatAdapter;
import jalview.io.HtmlSvgOutput;
import java.awt.print.PrinterJob;
import java.beans.PropertyChangeEvent;
import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
showReverse.setVisible(nucleotide);
showReverseComplement.setVisible(nucleotide);
conservationMenuItem.setEnabled(!nucleotide);
- modifyConservation.setEnabled(!nucleotide);
+ modifyConservation.setEnabled(!nucleotide
+ && conservationMenuItem.isSelected());
showGroupConservation.setEnabled(!nucleotide);
showComplementMenuItem.setText(nucleotide ? MessageManager
padGapsMenuitem.setSelected(av.isPadGaps());
colourTextMenuItem.setSelected(av.isShowColourText());
abovePIDThreshold.setSelected(av.getAbovePIDThreshold());
+ modifyPID.setEnabled(abovePIDThreshold.isSelected());
conservationMenuItem.setSelected(av.getConservationSelected());
+ modifyConservation.setEnabled(conservationMenuItem.isSelected());
seqLimits.setSelected(av.getShowJVSuffix());
idRightAlign.setSelected(av.isRightAlignIds());
centreColumnLabelsMenuItem.setState(av.isCentreColumnLabels());
public void saveAs_actionPerformed(ActionEvent e)
{
String format = currentFileFormat == null ? null : currentFileFormat
- .toString();
+ .getName();
JalviewFileChooser chooser = JalviewFileChooser.forWrite(
Cache.getProperty("LAST_DIRECTORY"), format);
fileName = chooser.getSelectedFile().getPath();
- Cache.setProperty("DEFAULT_FILE_FORMAT",
- currentFileFormat.toString());
+ Cache.setProperty("DEFAULT_FILE_FORMAT", currentFileFormat.getName());
Cache.setProperty("LAST_DIRECTORY", fileName);
saveAlignment(fileName, currentFileFormat);
}
else
{
- // if (!jalview.io.AppletFormatAdapter.isValidFormat(format, true))
- // {
- // warningMessage("Cannot save file " + fileName + " using format "
- // + format, "Alignment output format not supported");
- // if (!Jalview.isHeadlessMode())
- // {
- // saveAs_actionPerformed(null);
- // }
- // return false;
- // }
-
AlignmentExportData exportData = getAlignmentForExport(format,
viewport, null);
if (exportData.getSettings().isCancelled())
{
try
{
- java.io.PrintWriter out = new java.io.PrintWriter(
- new java.io.FileWriter(file));
+ PrintWriter out = new PrintWriter(new FileWriter(file));
out.print(output);
out.close();
this.setTitle(file);
statusBar.setText(MessageManager.formatMessage(
"label.successfully_saved_to_file_in_format",
- new Object[] { fileName, format }));
+ new Object[] { fileName, format.getName() }));
} catch (Exception ex)
{
success = false;
@Override
protected void outputText_actionPerformed(ActionEvent e)
{
-
- FileFormatI fileFormat = FileFormat.forName(e.getActionCommand());
+ FileFormatI fileFormat = FileFormats.getInstance().forName(
+ e.getActionCommand());
AlignmentExportData exportData = getAlignmentForExport(fileFormat,
viewport, null);
if (exportData.getSettings().isCancelled())
{
FileFormatI format = fileFormat;
cap.setText(new FormatAdapter(alignPanel, exportData.getSettings())
- .formatSequences(format,
- exportData.getAlignment(),
+ .formatSequences(format, exportData.getAlignment(),
exportData.getOmitHidden(),
exportData.getStartEndPostions(),
viewport.getColumnSelection()));
}
String output = new FormatAdapter().formatSequences(FileFormat.Fasta,
- seqs,
- omitHidden, null);
+ seqs, omitHidden, null);
StringSelection ss = new StringSelection(output);
* colour scheme to all groups. If unchecked, groups may have their own
* independent colour schemes.
*
+ * @param selected
*/
@Override
- protected void applyToAllGroups_actionPerformed()
+ public void applyToAllGroups_actionPerformed(boolean selected)
{
- viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
+ viewport.setColourAppliesToAllGroups(selected);
}
/**
if (cs != null)
{
ColourMenuHelper.setColourSelected(colourMenu, cs.getSchemeName());
- // Make sure viewport is up to date w.r.t. any sliders
- if (viewport.getAbovePIDThreshold())
- {
- int threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
- "Background");
- viewport.setThreshold(threshold);
- }
-
- if (viewport.getConservationSelected())
- {
- cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel,
- cs, "Background"));
- }
}
viewport.setGlobalColourScheme(cs);
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Show the PID threshold slider panel
*/
@Override
protected void modifyPID_actionPerformed()
{
- if (viewport.getAbovePIDThreshold()
- && viewport.getGlobalColourScheme() != null)
- {
- SliderPanel.setPIDSliderSource(alignPanel,
- viewport.getGlobalColourScheme(), "Background");
- SliderPanel.showPIDSlider();
- }
+ SliderPanel.setPIDSliderSource(alignPanel,
+ viewport.getViewportColourScheme(), alignPanel.getViewName());
+ SliderPanel.showPIDSlider();
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Show the Conservation slider panel
*/
@Override
protected void modifyConservation_actionPerformed()
{
- if (viewport.getConservationSelected()
- && viewport.getGlobalColourScheme() != null)
- {
- SliderPanel.setConservationSlider(alignPanel,
- viewport.getGlobalColourScheme(), "Background");
- SliderPanel.showConservationSlider();
- }
+ SliderPanel.setConservationSlider(alignPanel,
+ viewport.getViewportColourScheme(), alignPanel.getViewName());
+ SliderPanel.showConservationSlider();
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Action on selecting or deselecting (Colour) By Conservation
*/
@Override
- protected void conservationMenuItem_actionPerformed()
+ public void conservationMenuItem_actionPerformed(boolean selected)
{
- viewport.setConservationSelected(conservationMenuItem.isSelected());
-
- viewport.setAbovePIDThreshold(false);
- abovePIDThreshold.setSelected(false);
+ modifyConservation.setEnabled(selected);
+ viewport.setConservationSelected(selected);
+ viewport.getViewportColourScheme().setConservationApplied(selected);
changeColour(viewport.getGlobalColourScheme());
-
- modifyConservation_actionPerformed();
+ if (selected)
+ {
+ modifyConservation_actionPerformed();
+ }
+ else
+ {
+ SliderPanel.hideConservationSlider();
+ }
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Action on selecting or deselecting (Colour) Above PID Threshold
*/
@Override
- public void abovePIDThreshold_actionPerformed()
+ public void abovePIDThreshold_actionPerformed(boolean selected)
{
- viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());
-
- conservationMenuItem.setSelected(false);
- viewport.setConservationSelected(false);
+ modifyPID.setEnabled(selected);
+ viewport.setAbovePIDThreshold(selected);
+ if (!selected)
+ {
+ viewport.getViewportColourScheme().setThreshold(0,
+ viewport.isIgnoreGapsConsensus());
+ }
changeColour(viewport.getGlobalColourScheme());
-
- modifyPID_actionPerformed();
+ if (selected)
+ {
+ modifyPID_actionPerformed();
+ }
+ else
+ {
+ SliderPanel.hidePIDSlider();
+ }
}
/**
}
if (FileFormat.Jnet.equals(format))
{
- JPredFile predictions = new JPredFile(
- file, sourceType);
+ JPredFile predictions = new JPredFile(file, sourceType);
new JnetAnnotationMaker();
JnetAnnotationMaker.add_annotation(predictions,
viewport.getAlignment(), 0, false);
}
/*
+ * 'focus' any colour slider that is open to the selected viewport
+ */
+ if (viewport.getConservationSelected())
+ {
+ SliderPanel.setConservationSlider(alignPanel,
+ viewport.getViewportColourScheme(), alignPanel.getViewName());
+ }
+ else
+ {
+ SliderPanel.hideConservationSlider();
+ }
+ if (viewport.getAbovePIDThreshold())
+ {
+ SliderPanel.setPIDSliderSource(alignPanel,
+ viewport.getViewportColourScheme(), alignPanel.getViewName());
+ }
+ else
+ {
+ SliderPanel.hidePIDSlider();
+ }
+
+ /*
* If there is a frame linked to this one in a SplitPane, switch it to the
* same view tab index. No infinite recursion of calls should happen, since
* tabSelectionChanged() should not get invoked on setting the selected
colourMenu.add(textColour);
colourMenu.addSeparator();
- ColourMenuHelper
- .addMenuItems(colourMenu, this, viewport.getAlignment());
+ ColourMenuHelper.addMenuItems(colourMenu, this,
+ viewport.getAlignment(), false);
colourMenu.addSeparator();
colourMenu.add(conservationMenuItem);
colourMenu.add(modifyPID);
colourMenu.add(annotationColour);
- /*
- * select the default colour for the alignment (this may be
- * overridden later)
- */
- boolean nucleotide = viewport.getAlignment().isNucleotide();
- String defaultColourScheme = Cache.getDefault(
- nucleotide ? Preferences.DEFAULT_COLOUR_NUC
- : Preferences.DEFAULT_COLOUR_PROT,
- ResidueColourScheme.NONE);
+ ColourSchemeI colourScheme = viewport.getGlobalColourScheme();
+ String schemeName = colourScheme == null ? null : colourScheme
+ .getSchemeName();
- ColourMenuHelper.setColourSelected(colourMenu, defaultColourScheme);
+ ColourMenuHelper.setColourSelected(colourMenu, schemeName);
}
}