+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GPCAPanel#outputPoints_actionPerformed(java.awt.event.ActionEvent
+ * )
+ */
+ @Override
+ protected void outputPoints_actionPerformed()
+ {
+ CutAndPasteTransfer cap = new CutAndPasteTransfer();
+ try
+ {
+ cap.setText(getPcaModel().getPointsasCsv(false,
+ xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(),
+ zCombobox.getSelectedIndex()));
+ Desktop.addInternalFrame(cap, MessageManager
+ .formatMessage("label.points_for_params", new String[]
+ { this.getTitle() }), 500, 500);
+ } catch (OutOfMemoryError oom)
+ {
+ new OOMWarning("exporting PCA points", oom);
+ cap.dispose();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GPCAPanel#outputProjPoints_actionPerformed(java.awt.event
+ * .ActionEvent)
+ */
+ @Override
+ protected void outputProjPoints_actionPerformed()
+ {
+ CutAndPasteTransfer cap = new CutAndPasteTransfer();
+ try
+ {
+ cap.setText(getPcaModel().getPointsasCsv(true,
+ xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(),
+ zCombobox.getSelectedIndex()));
+ Desktop.addInternalFrame(cap, MessageManager.formatMessage(
+ "label.transformed_points_for_params", new String[]
+ { this.getTitle() }), 500, 500);
+ } catch (OutOfMemoryError oom)
+ {
+ new OOMWarning("exporting transformed PCA points", oom);
+ cap.dispose();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
+ */
+ @Override
+ public void setProgressBar(String message, long id)
+ {
+ progressBar.setProgressBar(message, id);
+ // if (progressBars == null)
+ // {
+ // progressBars = new Hashtable();
+ // progressBarHandlers = new Hashtable();
+ // }
+ //
+ // JPanel progressPanel;
+ // Long lId = Long.valueOf(id);
+ // GridLayout layout = (GridLayout) statusPanel.getLayout();
+ // if (progressBars.get(lId) != null)
+ // {
+ // progressPanel = (JPanel) progressBars.get(Long.valueOf(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();
+ }
+
+ @Override
+ public void registerHandler(final long id,
+ final IProgressIndicatorHandler handler)
+ {
+ progressBar.registerHandler(id, handler);
+ // if (progressBarHandlers == null || !progressBars.contains(Long.valueOf(id)))
+ // {
+ // throw new
+ // Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler"));
+ // }
+ // progressBarHandlers.put(Long.valueOf(id), handler);
+ // final JPanel progressPanel = (JPanel) progressBars.get(Long.valueOf(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 String[]{((JLabel) progressPanel.getComponent(0)).getText()}), id);
+ // }
+ // });
+ // progressPanel.add(cancel, BorderLayout.EAST);
+ // }
+ }
+
+ /**
+ *
+ * @return true if any progress bars are still active
+ */
+ @Override
+ public boolean operationInProgress()
+ {
+ return progressBar.operationInProgress();
+ }
+
+ @Override
+ protected void resetButton_actionPerformed()
+ {
+ int t = getTop();
+ setTop(0); // ugly - prevents dimensionChanged events from being processed
+ xCombobox.setSelectedIndex(0);
+ yCombobox.setSelectedIndex(1);
+ setTop(t);
+ zCombobox.setSelectedIndex(2);
+ }
+
+ /**
+ * Answers true if PCA calculation is in progress, else false
+ *
+ * @return
+ */
+ public boolean isWorking()
+ {
+ return working;
+ }
+
+ /**
+ * Answers the selected checkbox item index for PCA dimension for the X, Y or
+ * Z axis of the display
+ *
+ * @param axis
+ * @return
+ */
+ public int getSelectedDimensionIndex(Axis axis)
+ {
+ switch (axis)
+ {
+ case X:
+ return xCombobox.getSelectedIndex();
+ case Y:
+ return yCombobox.getSelectedIndex();
+ default:
+ return zCombobox.getSelectedIndex();
+ }
+ }
+
+ public void setShowLabels(boolean show)
+ {
+ showLabels.setSelected(show);
+ }
+
+ /**
+ * Sets the input data used to calculate the PCA. This is provided for
+ * 'restore from project', which does not currently support this (AL-2647), so
+ * sets the value to null, and hides the menu option for "Input Data...". J
+ *
+ * @param data
+ */
+ public void setInputData(AlignmentView data)
+ {
+ getPcaModel().setInputData(data);
+ originalSeqData.setVisible(data != null);
+ }
+
+ public AlignViewportI getAlignViewport()
+ {
+ return av;
+ }
+
+ public PCAModel getPcaModel()
+ {
+ return pcaModel;
+ }
+
+ public void setPcaModel(PCAModel pcaModel)
+ {
+ this.pcaModel = pcaModel;
+ }
+
+ public RotatableCanvas getRotatableCanvas()
+ {
+ return rc;
+ }
+
+ public void setRotatableCanvas(RotatableCanvas rc)
+ {
+ this.rc = rc;
+ }
+
+ public int getTop()
+ {
+ return top;
+ }
+
+ public void setTop(int top)
+ {
+ this.top = top;
+ }
+
+ /**
+ * set the associated view for this PCA.
+ *
+ * @param panel
+ */
+ public void selectAssociatedView(AlignmentPanel panel)
+ {
+ getRotatableCanvas().setApplyToAllViews(false);
+
+ ap = panel;
+ av = panel.av;
+
+ getRotatableCanvas().av = panel.av;
+ getRotatableCanvas().ap = panel;
+ PaintRefresher.Register(PCAPanel.this, panel.av.getSequenceSetId());
+ }