import java.awt.BorderLayout;
import java.awt.Component;
-import java.awt.GridLayout;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.util.Set;
import java.util.Vector;
-import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JEditorPane;
import javax.swing.JInternalFrame;
-import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JProgressBar;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.AlignmentView;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenSequences;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SeqCigar;
import jalview.datamodel.Sequence;
*/
void init()
{
+ progressBar = new ProgressBar(this.statusPanel, this.statusBar);
+
avc = new jalview.controller.AlignViewController(this, viewport,
alignPanel);
if (viewport.getAlignmentConservationAnnotation() == null)
updateEditMenuBar();
}
- // methods for implementing IProgressIndicator
- // need to refactor to a reusable stub class
- Hashtable progressBars, progressBarHandlers;
+ private IProgressIndicator progressBar;
/*
* (non-Javadoc)
@Override
public void setProgressBar(String message, long id)
{
- if (progressBars == null)
- {
- progressBars = new Hashtable();
- progressBarHandlers = new Hashtable();
- }
-
- JPanel progressPanel;
- Long lId = new Long(id);
- GridLayout layout = (GridLayout) statusPanel.getLayout();
- if (progressBars.get(lId) != null)
- {
- progressPanel = (JPanel) progressBars.get(new Long(id));
- statusPanel.remove(progressPanel);
- progressBars.remove(lId);
- progressPanel = null;
- if (message != null)
- {
- statusBar.setText(message);
- }
- if (progressBarHandlers.contains(lId))
- {
- progressBarHandlers.remove(lId);
- }
- layout.setRows(layout.getRows() - 1);
- }
- else
- {
- progressPanel = new JPanel(new BorderLayout(10, 5));
-
- JProgressBar progressBar = new JProgressBar();
- progressBar.setIndeterminate(true);
-
- progressPanel.add(new JLabel(message), BorderLayout.WEST);
- progressPanel.add(progressBar, BorderLayout.CENTER);
-
- layout.setRows(layout.getRows() + 1);
- statusPanel.add(progressPanel);
-
- progressBars.put(lId, progressPanel);
- }
- // update GUI
- // setMenusForViewport();
- validate();
+ progressBar.setProgressBar(message, id);
}
@Override
public void registerHandler(final long id,
final IProgressIndicatorHandler handler)
{
- if (progressBarHandlers == null || !progressBars.contains(new Long(id)))
- {
- throw new Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler"));
- }
- progressBarHandlers.put(new Long(id), handler);
- final JPanel progressPanel = (JPanel) progressBars.get(new Long(id));
- if (handler.canCancel())
- {
- JButton cancel = new JButton(
- MessageManager.getString("action.cancel"));
- final IProgressIndicator us = this;
- cancel.addActionListener(new ActionListener()
- {
-
- @Override
- public void actionPerformed(ActionEvent e)
- {
- handler.cancelActivity(id);
- us.setProgressBar(MessageManager.formatMessage("label.cancelled_params", new Object[]{((JLabel) progressPanel.getComponent(0)).getText()}), id);
- }
- });
- progressPanel.add(cancel, BorderLayout.EAST);
- }
+ progressBar.registerHandler(id, handler);
}
/**
@Override
public boolean operationInProgress()
{
- if (progressBars != null && progressBars.size() > 0)
- {
- return true;
- }
- return false;
+ return progressBar.operationInProgress();
}
@Override
public void setStatus(String text)
{
statusBar.setText(text);
- };
+ }
/*
* Added so Castor Mapping file can obtain Jalview Version
.lastIndexOf(java.io.File.separatorChar) + 1);
}
- /*
- * First save any linked Chimera session.
- */
- Desktop.instance.saveChimeraSessions(file);
-
success = new Jalview2XML().saveAlignment(this, file, shortName);
statusBar.setText(MessageManager.formatMessage(
return false;
}
- String[] omitHidden = null;
-
- if (viewport.hasHiddenColumns())
- {
- int reply = JOptionPane
- .showInternalConfirmDialog(
- Desktop.desktop,
- MessageManager
- .getString("label.alignment_contains_hidden_columns"),
- MessageManager
- .getString("action.save_omit_hidden_columns"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
-
- if (reply == JOptionPane.YES_OPTION)
- {
- omitHidden = viewport.getViewAsString(false);
- }
- }
- FormatAdapter f = new FormatAdapter();
+ ExportData exportData = getAlignmentForExport();
+ FormatAdapter f = new FormatAdapter(viewport);
String output = f.formatSequences(format,
- viewport.getAlignment(), // class cast exceptions will
+ exportData.getAlignment(), // class cast exceptions will
// occur in the distant future
- omitHidden, f.getCacheSuffixDefault(format),
+ exportData.getOmitHidden(), f.getCacheSuffixDefault(format),
viewport.getColumnSelection());
if (output == null)
return success;
}
+
private void warningMessage(String warning, String title)
{
if (new jalview.util.Platform().isHeadless())
@Override
protected void outputText_actionPerformed(ActionEvent e)
{
- String[] omitHidden = null;
- if (viewport.hasHiddenColumns())
+ ExportData exportData = getAlignmentForExport();
+ CutAndPasteTransfer cap = new CutAndPasteTransfer();
+ cap.setForInput(null);
+
+ try
+ {
+ cap.setText(new FormatAdapter(viewport).formatSequences(
+ e.getActionCommand(),
+ exportData.getAlignment(),
+ exportData.getOmitHidden(),
+ viewport.getColumnSelection()));
+ Desktop.addInternalFrame(cap, MessageManager.formatMessage(
+ "label.alignment_output_command", new Object[]
+ { e.getActionCommand() }), 600, 500);
+ } catch (OutOfMemoryError oom)
+ {
+ new OOMWarning("Outputting alignment as " + e.getActionCommand(), oom);
+ cap.dispose();
+ }
+
+ }
+
+ public ExportData getAlignmentForExport()
+ {
+ AlignmentI alignmentToExport = null;
+ String[] omitHidden = null;
+ FeatureRenderer fr = new FeatureRenderer(this.alignPanel);
+ viewport.setFeatureRenderer(fr);
+ HiddenSequences hiddenSeqs = viewport.getAlignment()
+ .getHiddenSequences();
+ if (viewport.hasHiddenColumns() || hiddenSeqs.getSize() > 0)
{
int reply = JOptionPane
.showInternalConfirmDialog(
{
omitHidden = viewport.getViewAsString(false);
}
+ else
+ {
+ alignmentToExport = viewport.getAlignment().getHiddenSequences()
+ .getFullAlignment();
+ }
}
-
- CutAndPasteTransfer cap = new CutAndPasteTransfer();
- cap.setForInput(null);
-
- try
+ if (alignmentToExport == null)
{
- Desktop.setCurrentAlignFrame(this);
- cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
- viewport.getAlignment(), omitHidden,
- viewport.getColumnSelection()));
- Desktop.addInternalFrame(cap, MessageManager.formatMessage(
- "label.alignment_output_command", new Object[]
- { e.getActionCommand() }), 600, 500);
- } catch (OutOfMemoryError oom)
- {
- new OOMWarning("Outputting alignment as " + e.getActionCommand(), oom);
- cap.dispose();
+ alignmentToExport = viewport.getAlignment();
}
-
+ return new ExportData(alignmentToExport, omitHidden);
}
/**
@Override
public void bioJSMenuItem_actionPerformed(ActionEvent e)
{
- new BioJsHTMLOutput(alignPanel,
+ BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel,
alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer());
+ bjs.exportJalviewAlignmentAsBioJsHtmlFile();
}
public void createImageMap(File file, String image)
{
for (AlignmentAnnotation aa : alignPanel.getAlignment()
.getAlignmentAnnotation())
{
+ /*
+ * don't display non-positional annotations on an alignment
+ */
+ if (aa.annotations == null)
+ {
+ continue;
+ }
boolean apply = (aa.sequenceRef == null && forAlignment)
|| (aa.sequenceRef != null && forSequences);
if (apply)
sf.setComplementVisible(this, show);
}
}
+
+ public class ExportData
+ {
+ private AlignmentI alignment;
+
+ private String[] omitHidden;
+
+ public ExportData(AlignmentI align, String[] ommit)
+ {
+ this.alignment = align;
+ this.omitHidden = ommit;
+ System.out.println();
+ }
+
+ public AlignmentI getAlignment()
+ {
+ return alignment;
+ }
+
+ public void setAlignment(AlignmentI alignment)
+ {
+ this.alignment = alignment;
+ }
+
+ public String[] getOmitHidden()
+ {
+ return omitHidden;
+ }
+
+ public void setOmitHidden(String[] omitHidden)
+ {
+ this.omitHidden = omitHidden;
+ }
+ }
+
+ @Override
+ public void hideColumns(List<int[]> colsToHide)
+ {
+ for (int[] colRange : colsToHide)
+ {
+ viewport.hideColumns(colRange[0], colRange[1]);
+ }
+
+ }
+
+ @Override
+ public void syncHiddenSequences()
+ {
+ AlignmentI al = viewport.getAlignment();
+ HiddenSequences hiddenSeqs = al.getHiddenSequences();
+ for (SequenceI seq : al.getSequencesArray())
+ {
+ if (seq.isHidden())
+ {
+ hiddenSeqs.hideSequence(seq);
+ }
+ }
+ }
}
class PrintThread extends Thread