+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showDbRefs_actionPerformed(java.awt.event.ActionEvent
+ * )
+ */
+ protected void showDbRefs_actionPerformed(ActionEvent e)
+ {
+ viewport.setShowDbRefs(showDbRefsMenuitem.isSelected());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seejalview.jbgui.GAlignFrame#showNpFeats_actionPerformed(java.awt.event.
+ * ActionEvent)
+ */
+ protected void showNpFeats_actionPerformed(ActionEvent e)
+ {
+ viewport.setShowNpFeats(showNpFeatsMenuitem.isSelected());
+ }
+
+ /**
+ * find the viewport amongst the tabs in this alignment frame and close that
+ * tab
+ *
+ * @param av
+ */
+ public boolean closeView(AlignViewport av)
+ {
+ if (viewport == av)
+ {
+ this.closeMenuItem_actionPerformed(false);
+ return true;
+ }
+ Component[] comp = tabbedPane.getComponents();
+ for (int i = 0; comp != null && i < comp.length; i++)
+ {
+ if (comp[i] instanceof AlignmentPanel)
+ {
+ if (((AlignmentPanel) comp[i]).av == av)
+ {
+ // close the view.
+ closeView((AlignmentPanel) comp[i]);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ protected void build_fetchdbmenu(JMenu webService)
+ {
+ // Temporary hack - DBRef Fetcher always top level ws entry.
+ // TODO We probably want to store a sequence database checklist in
+ // preferences and have checkboxes.. rather than individual sources selected
+ // here
+ final JMenu rfetch = new JMenu("Fetch DB References");
+ rfetch.setToolTipText("Retrieve and parse sequence database records for the alignment or the currently selected sequences");
+ webService.add(rfetch);
+
+ JMenuItem fetchr = new JMenuItem("Standard Databases");
+ fetchr.setToolTipText("Fetch from EMBL/EMBLCDS or Uniprot/PDB and any selected DAS sources");
+ fetchr.addActionListener(new ActionListener()
+ {
+
+ public void actionPerformed(ActionEvent e)
+ {
+ new Thread(new Runnable()
+ {
+
+ public void run()
+ {
+ new jalview.ws.DBRefFetcher(alignPanel.av
+ .getSequenceSelection(), alignPanel.alignFrame)
+ .fetchDBRefs(false);
+ }
+ }).start();
+
+ }
+
+ });
+ rfetch.add(fetchr);
+ final AlignFrame me = this;
+ new Thread(new Runnable()
+ {
+ public void run()
+ {
+ final jalview.ws.SequenceFetcher sf = SequenceFetcher
+ .getSequenceFetcherSingleton(me);
+ final String[] otherdb = sf.getOrderedSupportedSources();
+ // sf.getDbInstances(jalview.ws.dbsources.DasSequenceSource.class);
+ // jalview.util.QuickSort.sort(otherdb, otherdb);
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+
+ JMenu dfetch = new JMenu();
+ JMenuItem fetchr;
+ rfetch.add(dfetch);
+ int comp = 0, mcomp = 15;
+ String mname = null;
+ if (otherdb != null && otherdb.length > 0)
+ {
+ for (int i = 0; i < otherdb.length; i++)
+ {
+ String dbname = sf.getSourceProxy(otherdb[i]).getDbName();
+ if (mname == null)
+ {
+ mname = "from '" + dbname + "'";
+ }
+ fetchr = new JMenuItem(otherdb[i]);
+ final String[] dassource = new String[]
+ { otherdb[i] };
+ fetchr.addActionListener(new ActionListener()
+ {
+
+ public void actionPerformed(ActionEvent e)
+ {
+ new Thread(new Runnable()
+ {
+
+ public void run()
+ {
+ new jalview.ws.DBRefFetcher(alignPanel.av
+ .getSequenceSelection(),
+ alignPanel.alignFrame, dassource)
+ .fetchDBRefs(false);
+ }
+ }).start();
+ }
+
+ });
+ fetchr.setToolTipText("Retrieve from " + dbname);
+ dfetch.add(fetchr);
+ if (comp++ == mcomp || i == (otherdb.length - 1))
+ {
+ dfetch.setText(mname + " to '" + dbname + "'");
+ rfetch.add(dfetch);
+ dfetch = new JMenu();
+ mname = null;
+ comp = 0;
+ }
+ }
+ }
+ }
+ });
+ }
+ }).start();
+
+ }
+
+ /**
+ * Left justify the whole alignment.
+ */
+ protected void justifyLeftMenuItem_actionPerformed(ActionEvent e)
+ {
+ AlignmentI al = viewport.getAlignment();
+ al.justify(false);
+ viewport.firePropertyChange("alignment", null, al);
+ }
+
+ /**
+ * Right justify the whole alignment.
+ */
+ protected void justifyRightMenuItem_actionPerformed(ActionEvent e)
+ {
+ AlignmentI al = viewport.getAlignment();
+ al.justify(true);
+ viewport.firePropertyChange("alignment", null, al);
+ }
+
+ public void setShowSeqFeatures(boolean b)
+ {
+ showSeqFeatures.setSelected(true);
+ viewport.setShowSequenceFeatures(true);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showUnconservedMenuItem_actionPerformed(java.
+ * awt.event.ActionEvent)
+ */
+ protected void showUnconservedMenuItem_actionPerformed(ActionEvent e)
+ {
+ viewport.setShowUnconserved(showNonconservedMenuItem.getState());
+ alignPanel.paintAlignment(true);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showGroupConsensus_actionPerformed(java.awt.event
+ * .ActionEvent)
+ */
+ protected void showGroupConsensus_actionPerformed(ActionEvent e)
+ {
+ viewport.setShowGroupConsensus(showGroupConsensus.getState());
+ alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showGroupConservation_actionPerformed(java.awt
+ * .event.ActionEvent)
+ */
+ protected void showGroupConservation_actionPerformed(ActionEvent e)
+ {
+ viewport.setShowGroupConservation(showGroupConservation.getState());
+ alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
+ * .event.ActionEvent)
+ */
+ protected void showConsensusHistogram_actionPerformed(ActionEvent e)
+ {
+ viewport.setShowConsensusHistogram(showConsensusHistogram.getState());
+ alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
+ * .event.ActionEvent)
+ */
+ protected void showSequenceLogo_actionPerformed(ActionEvent e)
+ {
+ viewport.setShowSequenceLogo(showSequenceLogo.getState());
+ alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+ }
+
+ protected void applyAutoAnnotationSettings_actionPerformed(ActionEvent e)
+ {
+ alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#makeGrpsFromSelection_actionPerformed(java.awt
+ * .event.ActionEvent)
+ */
+ protected void makeGrpsFromSelection_actionPerformed(ActionEvent e)
+ {
+ if (viewport.getSelectionGroup() != null)
+ {
+ SequenceGroup[] gps = jalview.analysis.Grouping.makeGroupsFrom(
+ viewport.getSequenceSelection(),
+ viewport.getAlignmentView(true).getSequenceStrings(
+ viewport.getGapCharacter()),
+ viewport.alignment.getGroups());
+ viewport.alignment.deleteAllGroups();
+ viewport.sequenceColours = null;
+ viewport.setSelectionGroup(null);
+ // set view properties for each group
+ for (int g = 0; g < gps.length; g++)
+ {
+ gps[g].setShowNonconserved(viewport.getShowUnconserved());
+ gps[g].setshowSequenceLogo(viewport.isShowSequenceLogo());
+ viewport.alignment.addGroup(gps[g]);
+ Color col = new Color((int) (Math.random() * 255),
+ (int) (Math.random() * 255), (int) (Math.random() * 255));
+ col = col.brighter();
+ for (Enumeration sq = gps[g].getSequences(null).elements(); sq
+ .hasMoreElements(); viewport.setSequenceColour(
+ (SequenceI) sq.nextElement(), col))
+ ;
+ }
+ PaintRefresher.Refresh(this, viewport.getSequenceSetId());
+ alignPanel.updateAnnotation();
+ alignPanel.paintAlignment(true);
+ }
+ }
+
+ /**
+ * make the given alignmentPanel the currently selected tab
+ *
+ * @param alignmentPanel
+ */
+ public void setDisplayedView(AlignmentPanel alignmentPanel)
+ {
+ if (!viewport.getSequenceSetId().equals(
+ alignmentPanel.av.getSequenceSetId()))
+ {
+ throw new Error(
+ "Implementation error: cannot show a view from another alignment in an AlignFrame.");
+ }
+ if (tabbedPane != null
+ & alignPanels.indexOf(alignmentPanel) != tabbedPane.getSelectedIndex())
+ {
+ tabbedPane.setSelectedIndex(alignPanels.indexOf(alignmentPanel));
+ }
+ }